crikit.data package

Submodules

crikit.data.factorized module

Factored data class

Created on Fri Apr 22 23:42:40 2016

@author: chc

class crikit.data.factorized.FactorizedHsi[source]

Bases: crikit.data.hsi.Hsi, crikit.data.factorized._Factorized

Factorized Hsi Class

Notes

  • TODO: deside on

class crikit.data.factorized.FactorizedSpectra[source]

Bases: crikit.data.spectra.Spectra, crikit.data.factorized._Factorized

Factorized Spectra Class

Notes

  • TODO: deside on

crikit.data.frequency module

“Frequency” [,wavelength, and wavenumber] class and function.

class crikit.data.frequency.Frequency(data=None, calib=None, calib_orig=None, calib_fcn=None, units=None)[source]

Bases: object

Frequency [,wavelength, and wavenumber] class

data

Frequency vector

Type

1D ndarray, optional (see note)

calib

Calibration object that is passed to calib_fcn

Type

object, optional (see note)

calib_orig

Calibration object (‘original’). Set during initial setting of calib. Useful for backing-up calibration)

Type

object, optional (see note)

calib_fcn

Function that accepts a calibration object and returns data and units

Type

fcn, optional (see note)

units

Units of data (the default is ‘Frequency’). Over-written by return from calib_fcn

Type

str, optional

op_list_pix

Range of pixels to perform operations over. Must be even lengthed.

Type

list or tuple or 1D ndarray

op_list_freq

Range of frequencies (or wavelength, or wavenumber) to perform operations over. Must be even lengthed.

Type

list or tuple or 1D ndarray

plot_list_pix

Range of pixels to plot. Must be even lengthed.

Type

list or tuple or 1D ndarray

plot_list_freq

Range of frequencies (or wavelength, or wavenumber) to plot. Must be even lengthed.

Type

list or tuple or 1D ndarray

size

Length of data

Type

int, read-only

pix_vec

Pixel vector (0-indexed)

Type

1D ndarray, read-only

op_range_freq

Range of operarational frequencies

Type

1D ndarray, read-only

plot_range_freq

Range of printing frequencies (not implemented)

Type

1D ndarray, read-only

update()[source]

Updates data based on contents of calib (or calib_orig) and calib_fcn

get_index_of_closest_freq()[source]

Find the closest frequency in freq to a given freq value and RETURN the pixel value.

get_closest_freq()[source]

Find the closest frequency in freq to a given freq value.

Notes

Currently, this implementation does not check whether the attributes/parameters are contradictory: - calib - calib_orig - data

  • The purpose of _list_ is to limit the range over which operation or plotting is performed. In some instances, for example, one may collect a larger set of frequencies that of interest or there may be blank (i.e., no signal) regions. Limiting these regions enables faster computation, may minimize “edge effects”, and may allow for zoomed-in plotting when there are items of interest or a large dynamic range across a spectrum.

  • For functions, methods, etc. that take into account _list_ parameters, they should default to op_list_* if plot_list_* are set to None.

property calib
property calib_fcn
property calib_orig
property data
get_closest_freq(in_freqs)[source]

Return frequency(-ies) in freq closest to in_freqs

get_index_of_closest_freq(in_freqs)[source]

Return index(-es) of frequency(-ies) in freq closest to in_freqs

property op_list_freq
property op_list_pix
property op_range_freq
property op_range_pix
property op_size
property pix_vec
property plot_list_freq
property plot_list_pix
property size
property units
update()[source]

Update data with calib and calib_fcn.

crikit.data.frequency.calib_pix_wl(calib_obj)[source]

Return a wavelength (wl) vector based on calibration (calib) object

Parameters
  • calib_obj (list or 1D ndarray) – Calibration object (see below).

  • calib_obj – Calibration dict with 5 key-value pairs (see Notes)

  • calib_obj – Calibration array [‘n_pix’, ‘ctr_wl’, ‘ctr_wl0’, ‘units’, ‘a_0’, ‘a_1’, …, ‘a_n’]

Returns

  • wl_vec (1D ndarray) – Wavelength vector

  • units (str) – Units string ‘Wavelength (‘ + calib_obj[‘units’] + ‘)’

Notes

calib_obj dict key-value pairs:
  • n_pix : int, number of pixels (0-index)

  • ctr_wl : float, center wavelength

  • ctr_wl0 : float, center calibration wavelength

  • units : str, wavelength units, optional (default is ‘nm’)

  • a_vec : list or 1D ndarray, polynomial coefficients, [a_n, a_n-1,…, a_1, a_0]. a_2…a_n, optional.

calibration model:
\[wl\_{vec} = a_n*(n\_{pix})^n + a_{n-1}*(n\_{pix})^{n-1} + ~...~ + n\_{pix}*a_1 + a_0 + ctr\_{wl} - ctr\_{wl0}\]
crikit.data.frequency.calib_pix_wn(calib_obj)[source]

Return a wavenumber (wn) vector based on calibration (calib) object

Parameters
  • calib_obj (list or 1D ndarray) – Calibration object (see below).

  • calib_obj – Calibration dict with 6 key-value pairs (see Notes)

  • calib_obj – Calibration array [‘n_pix’, ‘ctr_wl’, ‘ctr_wl0’, ‘probe’, ‘units’, ‘a_0’, ‘a_1’, …, ‘a_n’]

Returns

  • wn_vec (1D ndarray) – Wavenumber vector

  • units (str) – Wavenumber units. Always ‘cm$^-1$’

Notes

calib_obj dict key-value pairs:
  • n_pix : int, number of pixels (0-index)

  • ctr_wl : float, center wavelength

  • ctr_wl0 : float, center calibration wavelength

  • probe : float, center wavelength of probe source (in units)

  • units : {‘nm’, ‘um’}, wavelength units, optional (default is ‘nm’)

  • a_vec : list or 1D ndarray, polynomial coefficients, [a_n, a_n-1,…, a_1, a_0]. a_2…a_n, optional.

calibration model :
Wavelength vector:
\[wl\_{vec} = a_n*(n\_{pix})^n + a_{n-1}*(n\_{pix})^{n-1} + ~...~ + n\_{pix}*a_1 + a_0 + ctr\_{wl} - ctr\_{wl0}\]
Wavenumber vector:
\[wl\_{vec} = a_n*(n\_{pix})^n + a_{n-1}*(n\_{pix})^{n-1} + ~...~ + n\_{pix}*a_1 + a_0 + ctr\_{wl} - ctr\_{wl0}\]

crikit.data.hsi module

Hyperspectral imagery (hsi) class

Created on Tue Apr 12 13:06:30 2016

@author: chc

class crikit.data.hsi.Hsi(data=None, freq=None, x=None, y=None, x_rep=None, y_rep=None, label=None, units=None, meta=None)[source]

Bases: crikit.data.spectrum.Spectrum

Hyperspectral imagery class

Parameters
  • data (3D ndarray [y_pix, x_pix, f_pix]) – HSI image

  • mask (3D ndarray (int) [y_pix, x_pix, f_pix]) – 0,1 mask with 1 is a usable pixel and 0 is not

  • freq (crikit.data.frequency.Frequency instance) – Frequency [wavelength, wavenumber] object (i.e., the independent variable)

  • label (str) – Image label (i.e., a string describing what the image is)

  • units (str) – Units of image (e.g., intensity)

  • x_rep (crikit.data.replicate.Replicate instance, Not implemented yet) – x-axis spatial object

  • y_rep (crikit.data.replicate.Replicate instance, Not implemented yet) – x-axis spatial object

  • x (1D ndarray) – x-axis spatial vector

  • y (1D ndarray) – y-axis spatial vector

  • meta (dict) – Meta-data dictionary

shape

Shape of data

Type

tuple, read-only

size

Size of data (i.e., total number of entries)

Type

int, read-only

mean : 1D ndarray

Mean spectrum. If extent [a,b] is provided, calculate mean over that inclusive region.

std : 1D ndarray

Standard deviation of spectrum. If extent [a,b] is provided, calculate standard deviation over that inclusive region.

subtract : 3D ndarray or None

Subtract spectrum or object

Notes

  • freq object contains some useful parameters such as op_range_* and plot_range_*, which define spectral regions-of-interest. (It’s debatable as to whether those parameters should be in Frequency or Spectrum classes)

check()[source]

Check x, y, and freq to make sure the dimensions agree with data

config = {'nd_axis': -1}
property data
get_rand_spectra(num, pt_sz=1, quads=False, full=False)[source]
property mask
subtract(spectra, overwrite=True)[source]

Subtract spectrum from data

property x
property x_rep
property y
property y_rep

crikit.data.mosaic module

class crikit.data.mosaic.Mosaic[source]

Bases: object

Mosaic Class

Notes

  • input objects mts be ndarray

  • input objects must be 2D/3D # ! Higher-D?

  • For 3D objects, assumed to be Y, X, Color

append(obj)[source]

Append new object to data. Check dimensions

attr_dict(prefix='Mosaic.')[source]
property dtype

Return the highest dtype

property is2d
property is3d
property issamedim
mosaic2d(shape=None, idx=None, out=None)[source]

Return 2D mosaic image

mosaic_mask(shape=None, out=None)[source]

Returns a 2D mosaic image with integer values for which img is where

mosaic_shape(shape=None, idx=None)[source]

Return the shape of a would-be mosaic

mosaicfull(shape=None, out=None)[source]

Return full mosaic

property shape
property size
property unitshape
property unitshape_orig

crikit.data.replicate module

Replicate class used for things such as repetitive measurements or even spatial vectors (e.g., x and y)

Created on Tue Apr 12 11:42:56 2016

@author: chc

class crikit.data.replicate.Replicate(data=None, calib=None, units=None, label=None)[source]

Bases: object

Replicate class

data

Replicate data

Type

1D ndarray [size]

calib

Calibration descriptor. See Note.

Type

list [(start), stop, (step size)]

units

Units of replicate data

Type

str

size
Type

int, read-only

update_calib_from_data()[source]

Calculate and set calib parameter from data

update_data_from_calib()[source]

Calculate and set data from calib parameter

calib_data_agree()[source]

Return bool as to whether data and that derived from calib agree

Notes

  • input to calib can be a list or tuple or 1D ndarray or int or float

Setting calib can take up to 3 entries :
  • 1 entry: stop = entry; start = 0, step size = 1

  • 2 entries: start = entry[0], stop = entry[1], step size = 1

  • 3 entries: [start, stop, step size]

property calib
calib_data_agree()[source]
property data
property label
property size
property units
update_calib_from_data()[source]

Calculate and set calib parameter from data. Note: assumes uniform spacing of data.

update_data_from_calib()[source]

Calculate and set data from calib parameter

crikit.data.spectra module

Spectra class and function (very similar to Spetcrum except this deals with multiple entries)

class crikit.data.spectra.Spectra(data=None, freq=None, label=None, units=None, meta=None)[source]

Bases: crikit.data.spectrum.Spectrum

Spectra class

data

Spectra. Note: input can be a ndarray of any dimension: it will be CONVERTED to [n_pix, f_pix] shape, assuming that shape[-1] is the f_pix long.

Type

2D ndarray [n_pix, f_pix]

freq

Frequency [wavelength, wavenumber] object (i.e., the independent variable)

Type

crikit.data.frequency.Frequency instance

label

Spectrum label (i.e., a string describing what the spectrum is)

Type

str

units

Units of spectrum

Type

str

reps

Object describing the meaning of multiple spectra (i.e., the physical meaning of n_pix).

Type

crikit.data.replicate.Replicate instance, Not implemented yet

meta

Meta-data dictionary

Type

dict

shape

Shape of data

Type

tuple, read-only

n_pix

Size of data’s replicate/spectral number axis.

Type

int, read-only

mean : 1D ndarray

Mean spectrum. If extent [a,b] is provided, calculate mean over that inclusive region.

std : 1D ndarray

Standard deviation of spectrum. If extent [a,b] is provided, calculate standard deviation over that inclusive region.

subtract : 2D ndarray or None

Subtract spectrum or object

Notes

  • freq object contains some useful parameters such as op_range* and plot_range*, which define spectral regions-of-interest. (It’s debatable as to whether those parameters should be in Frequency or Spectrum classes)

config = {'nd_axis': -1}
property data
property n_pix
property reps
subtract(spectra, overwrite=True)[source]

Subtract spectrum from data

crikit.data.spectrum module

Spectrum class and function

class crikit.data.spectrum.Spectrum(data=None, freq=None, label=None, units=None, meta=None)[source]

Bases: object

Spectrum class

data

Spectrum

Type

1D ndarray [f_pix]

freq

Frequency [wavelength, wavenumber] object (i.e., the independent variable)

Type

crikit.data.Frequency instance

label

Spectrum label (i.e., a string describing what the spectrum is)

Type

str

units

Units of spectrum

Type

str

meta

Meta-data dictionary

Type

dict

f_pix

Size of data. Note: this matches the size of data and does NOT check the size of freq.freq_vec.

Type

int, read-only

ndim

Number of data dimensions

Type

int, read-only

shape

Shape of data

Type

tuple, read-only

size

Size of data (i.e., total number of entries)

Type

int, read-only

mean : int

Mean value. If extent [a,b] is provided, calculate mean over that inclusive region.

std : int

Standard deviation. If extent [a,b] is provided, calculate standard deviation over that inclusive region.

subtract : 1D ndarray or None

Subtract spectrum or object

Notes

  • freq object contains some useful parameters such as op_range* and plot_range*, which define spectral regions-of-interest. (It’s debatable as to whether those parameters should be in Frequency or Spectrum classes)

config = {'nd_axis': -1, 'nd_fcn': <function mean>}
property data
property f

return frequency vector within operating (op) range

Type

Convenience attribute

property f_full

return full frequency vector

Type

Convenience attribute

property f_pix
property freq
property label
mean(extent=None, over_space=True)[source]

Return mean spectrum (or mean over extent [list with 2 elements]). If over_space is False, returns reps-number of mean spectra

property meta
property ndim
property shape
property size
std(extent=None, over_space=True)[source]

Return standard deviation (std) spectrum (or std over extent [list with 2 elements]). If over_space is False, reps (or reps x reps) number of std’s.

subtract(spectrum, overwrite=True)[source]

Subtract spectrum from data

property units

Module contents