libpyhat.utils package

Submodules

libpyhat.utils.folds module

libpyhat.utils.folds.random(df, col, nfolds=5, seed=10, meta_label='meta')[source]
libpyhat.utils.folds.stratified_folds(df, nfolds=5, sortby=None, tiebreaker=None, meta_label='meta')[source]

libpyhat.utils.lookup module

libpyhat.utils.lookup.lookup(df, lookupfile=None, lookupdf=None, sep=',', skiprows=0, left_on='sclock', right_on='Spacecraft Clock', meta_label='meta')[source]

libpyhat.utils.outlier_identify module

libpyhat.utils.outlier_identify.outlier_identify(df, col, method, params, meta_label='meta')[source]

libpyhat.utils.paths module

libpyhat.utils.paths.get_path(dataset_name)[source]

Get the path of the example file

Parameters

dataset_namestr

The name of the example file to return the absolute path

libpyhat.utils.utils module

libpyhat.utils.utils.checkbandnumbers(bands, checkbands)[source]

Given a list of input bands, check that the passed tuple contains those bands.

In case of THEMIS, we check for band 9 as band 9 is the temperature band required to derive thermal temperature. We also check for band 10 which is required for TES atmosphere calculations.

Parameters

bandstuple

of bands in the input image

checkbandslist

of bands to check against

Returns

: bool

True if the bands are present, else False

libpyhat.utils.utils.checkdeplaid(incidence)[source]

Given an incidence angle, select the appropriate deplaid method.

Parameters

incidencefloat

incidence angle extracted from the campt results.

libpyhat.utils.utils.checkmonotonic(iterable, piecewise=False)[source]

Check if a given iterable is monotonically increasing.

Parameters

iterableiterable

Any Python iterable object

piecewiseboolean

If false, return a boolean for the entire iterable, else return a list with elementwise monotinicy checks

Returns

monotonicbool/list

A boolean list of all True if monotonic, or including an inflection point

libpyhat.utils.utils.col_within_range(self, rangevals, col, meta_label='meta')[source]
libpyhat.utils.utils.crossform(a)[source]

Return the cross form, e.g. a in the cross product of a b. Parameters ———- a : ndarray

(3,) vector

Returns

andarray

(3,3)

libpyhat.utils.utils.enumerate_duplicates(df, col, meta_label='meta')[source]
libpyhat.utils.utils.find_in_dict(obj, key)[source]

Recursively find an entry in a dictionary

Parameters

objdict

The dictionary to search

keystr

The key to find in the dictionary

Returns

itemobj

The value from the dictionary

libpyhat.utils.utils.find_nested_in_dict(data, key_list)[source]

Traverse a list of keys into a dict.

Parameters

datadict

The dictionary to be traversed

key_list: list

The list of keys to be travered. Keys are traversed in the order they are entered in the list

Returns

valueobject

The value in the dict

libpyhat.utils.utils.getnearest(iterable, value)[source]

Given an iterable, get the index nearest to the input value

Parameters

iterableiterable

An iterable to search

valueint, float

The value to search for

Returns

: int

The index into the list

libpyhat.utils.utils.identify_rows(df, colname, operator, value, spect_label='wvl')[source]
libpyhat.utils.utils.make_homogeneous(points)[source]
Convert a set of points (n x dim array) to

homogeneous coordinates.

Parameters

pointsndarray

n x m array of points, where n is the number of points.

Returns

: ndarray

n x m + 1 array of homogeneous points

libpyhat.utils.utils.normalize_vector(line)[source]

Normalize a standard form line

Parameters

linendarray

Standard form of a line (Ax + By + C = 0)

Returns

linendarray

The normalized line

Examples

>>> x = np.random.random((3,3))
>>> normalize_vector(x)
array([[ 0.88280225,  0.4697448 ,  0.11460811],
   [ 0.26090555,  0.96536433,  0.91648305],
   [ 0.58271501,  0.81267657,  0.30796395]])
libpyhat.utils.utils.ratio(df, range1, range2, rationame='', spect_label='wvl')[source]
libpyhat.utils.utils.remove_field_name(a, name)[source]

Given a numpy structured array, remove a column and return a copy of the remainder of the array

Parameters

andarray

Numpy structured array

namestr

of the index (column) to be removed

Returns

bndarray

Numpy structured array with the ‘name’ column removed

libpyhat.utils.utils.remove_rows(df, matching_values, spect_label='wvl')[source]
libpyhat.utils.utils.rows_match(df, column_name, isin_array, invert=False)[source]

Module contents