libpyhat.derived package

Subpackages

Submodules

libpyhat.derived.utils module

libpyhat.derived.utils.band_area(spectrum, low_wvl=None, high_wvl=None, mask_threshold=1.0)[source]

Compute the area under the spectrum. The user can specify a subsection or ‘band’ of the spectra on which to compute the integral.

Parameters

spectrum : single spectrum represented as a Pandas series, with indices corresponding to wavelength values.

low_wvl (optional)float

The low wavelength (in units of the actual wavelength not the index value)

high_wvl (optional)float

The high wavelength (in units of the actual wavelength not the index value)

mask (optional): float Spectrum values above this threshold will be set to 0 before integration. Useful for excluding bands with bad data.

Returns

(no var)float

The area under the curve

libpyhat.derived.utils.band_asymmetry(spectrum, low_wvl=None, high_wvl=None, degree=3)[source]

Compute the asymmetry of an absorption feature as (left_area - right_area) / total_area

Parameters

spectrum : single spectrum represented as a Pandas series, with indices corresponding to wavelength values.

low_wvl (optional)float

The low wavelength (in units of the actual wavelength not the index value)

high_wvl (optional)float

The high wavelength (in units of the actual wavelength not the index value)

degree (optional)int

The degree of the polynomial

Returns

asymmetryfloat

value indicating how asymmetrical the two halves of the band are, where 1.0 is completely asymmetrical and 0.0 is completely symmetrical

asymmetry = abs((area_left - area_right) / (area_left + area_right))

libpyhat.derived.utils.band_center(spectrum, low_wvl=None, high_wvl=None, degree=3)[source]

Given a spectrum, fit a polynomial to it. User can specify a subdomain of the spectrum to fit and the polynomial degree through optional kwargs. Be aware that high-degree polynomials may complicate the computation of the band center, and it is always important to plot the results to visualize the fit.

Parameters

spectrum : single spectrum represented as a Pandas series, with indices corresponding to wavelength values.

low_wvl (optional)float

The low wavelength (in units of the actual wavelength not the index value)

high_wvl (optional)float

The high wavelength (in units of the actual wavelength not the index value)

degree (optional)int

The degree of the polynomial

Returns

centerwvlfloat

The wavelength where the center of the polynomial lies

centervalfloat

The spectrum value where the center of the polynomial lies

center_fitPandas Series object

Contains the fit values and wavelength information

libpyhat.derived.utils.band_minimum(spectrum, low_wvl=None, high_wvl=None)[source]

Given a 1-D spectrum, find the minimum intensity value and the location of the minimum in wavelength space. A subset of the spectra can also be selected with optional kwargs.

Parameters

spectrum : single spectrum represented as a Pandas series, with indices corresponding to wavelength values.

low_wvl (optional)float

The low wavelength (in units of the actual wavelength not the index value)

high_wvl (optional)float

The high wavelength (in units of the actual wavelength not the index value)

Returns

min_wvlint

The wavelength of the minimum value

min_valuefloat

The observed minimal value

libpyhat.derived.utils.clip_multiband(multiband_image, n)[source]

Clips the values of each band of a multi-band image to +/- n stdevs

Parameters

multiband_image: An array representing a multiband image with dimensions [x,y,bands] n: the number of stdevs to use when scaling

Returns

multiband_image: the image with each band mean centered and values clipped so that the range of values goes

from -n*stdev to +n*stdev

libpyhat.derived.utils.compute_b_a(wavelengths)[source]

Given a set of three wavelengths compute their b and a values as per the Viviano Beck CRISM Derived Products paper (Revised CRISM spectral parameters and summary products based on the currently detected mineral diversity on Mars)

Parameters

wavelengthsiterable

A list of three wavelength values

Returns

bfloat

b value from the paper

afloat

a value from the paper

libpyhat.derived.utils.compute_slope(x1, x2, y1, y2)[source]

Computes slope given two points on a line

Parameters

x1float

First points x value

x2float

Second points x value

y1float

First points y value

y2float

Second points y value

Returns

: float

Slope between the two points

libpyhat.derived.utils.continuum_reflectance(data, central_wvl, left_wvl, right_wvl)[source]
libpyhat.derived.utils.get_roi(data, roi_x, roi_y, meta_label='meta')[source]

Extract an ROI from a Spectra Data object

Parameters

data: PyHAT Spectral Data object roi_x: min and max x values for the ROI [x_min,x_max] roi_y: min and max y values for the ROI [y_min,y_max]

Returns

data_roi : Spectral data object for the spectra within an ROI. (Note: Extracting an ROI strips any geodata that was associated with the original Spectral Data object, and x and y values are reset to begin at 0,0 within the ROI)

libpyhat.derived.utils.get_roi_avg(data, roi_x, roi_y)[source]

Calculate the average spectrum within a specified ROI

Parameters

data: PyHAT Spectral Data object roi_x: min and max x values for the ROI [x_min,x_max] roi_y: min and max y values for the ROI [y_min,y_max]

Returns

roi_avg : The average spectrum of the ROI

libpyhat.derived.utils.get_sub_spectrum(spectrum, low_wvl=None, high_wvl=None)[source]

Grab a subdomain of spectrum according to starting and ending wavelength values. Endpoints will be included.

Parameters

spectrum : single spectrum represented as a Pandas series, with indices corresponding to wavelength values.

low_wvl (optional)float

The low wavelength (in units of the actual wavelength not the index value)

high_wvl (optional)float

The high wavelength (in units of the actual wavelength not the index value)

Returns

sub_spectrumlibpyhat Spectrum object

This contains spectral information and corresponding wavelength values. See the Spectrum object documentation.

libpyhat.derived.utils.line_fit(slope, x, b)[source]

Finds the y value for a given x using a given slope and y intercept

Parameters

slopefloat

Slope of a line

xfloat

Point along the x axis of a line

bfloat

Y intercept of a line

Returns

: float

Y coordinate corresponding to the given x

libpyhat.derived.utils.median_kernel(data, center_wvl, kernel_width)[source]

Calculate the median of spectrum given a center wavelength and a kernel width.

libpyhat.derived.utils.reflectance(data, central_wvl, kernel=5)[source]

Module contents