pwspy.dataTypes.ExtraReflectionCube¶
- class pwspy.dataTypes.ExtraReflectionCube(data, wavelengths, metadata)[source]¶
Bases:
pwspy.dataTypes._data.ICBase
This class is meant to be constructed from an ExtraReflectanceCube along with additional reference measurement information. Rather than being in units of reflectance (between 0 and 1) it is in the same units as the reference measurement that is provided with, usually counts/ms or just counts.
- Parameters
data (
ndarray
) – The 3D array of the extra reflection in the system. In units of counts/ms or just countswavelengths (
Tuple
[float
,...
]) – The wavelengths associated with each 2D slice along the 3rd axis of the data array.metadata (
ERMetaData
) – Metadata
- classmethod create(reflectance, theoryR, reference)[source]¶
Construct and ExtraReflectionCube from an ExtraReflectanceCube and a reference measurement. The resulting ExtraReflectionCube will be in the same units as reference. theoryR should be a spectrum describing the theoretically expected reflectance of the reference data cube. Both theoryR and reflectance should be in units of reflectance (between 0 and 1).
- Parameters
reflectance (
ExtraReflectanceCube
) – The ExtraReflectanceCube to construct an ExtraReflectionCube from.theoryR (
Series
) – The theoretically predicted reflectance of material imaged in reference.reference (
PwsCube
) – A PWS image of a blank glass-{material} interface, usually water.
- Return type
- Returns
A new instance of ExtraReflectionCube.
- classmethod decodeHdf(d)¶
Load a new instance of ICBase from an h5py.Dataset
- Parameters
d (
Dataset
) – The dataset that the ICBase has been saved to- Returns
(data: The 3D array of data, index: A tuple containing the index)
- Return type
A tuple containing
- filterDust(sigma, pixelSize)¶
Blurs the data cube in the X and Y dimensions. Often used to remove the effects of dust on a normalization.
- Parameters
sigma (
float
) – This specifies the radius of the gaussian filter used for blurring. The units of the value are determined by pixelSizepixelSize (
float
) – The pixel size in microns. Settings this to 1 will effectively causes sigma to be in units of pixels rather than microns.
- getMeanSpectra(mask=None)¶
Calculate the average spectra within a region of the data.
- Parameters
mask (
Union
[Roi
,ndarray
,None
]) – An optional other.Roi or boolean numpy array used to select pixels from the X and Y dimensions of the data array. If left as None then the full data array will be used as the region.- Return type
Tuple
[ndarray
,ndarray
]- Returns
The average spectra within the region, the standard deviation of the spectra within the region
- plotMean()¶
- Return type
Tuple
[Figure
,Axes
]- Returns
- A figure and attached axes plotting the mean of the data along the index axis.
corresponds to the mean reflectance in most cases.
- selIndex(start, stop)¶
- Parameters
start (
Optional
[float
]) – The beginning value of the index in the new object. Pass None to include everything.stop (
Optional
[float
]) – The ending value of the index in the new object. Pass None to include everything.
- Return type
Tuple
[ndarray
,Sequence
]- Returns
A new instance of ICBase with only data from start to stop in the index.
- selectLassoROI(displayIndex=None, clim=None)¶
Allow the user to draw a freehand ROI on an image of the acquisition.
- Parameters
displayIndex (
Optional
[int
]) – Display a particular z-slice of the array for mask drawing. If None then the mean along Z is displayed.- Return type
- Returns
An array of vertices of the polygon drawn.
- selectRectangleROI(displayIndex=None)¶
Allow the user to draw a rectangular ROI on an image of the acquisition.
- Parameters
displayIndex (int) – is used to display a particular z-slice for mask drawing. If None then the mean along Z is displayed. Returns an array of vertices of the rectangle.
- Returns
An array of the 4 XY vertices of the rectangle.
- Return type
np.ndarray
- toHdfDataset(g, name, fixedPointCompression=True, compression=None)¶
Save the data of this class to a new HDF dataset.
- Parameters
g (h5py.Group) – the parent HDF Group of the new dataset.
name (str) – the name of the new HDF dataset in group g.
fixedPointCompression (bool) – if True then save the data in a special 16bit fixed-point format. Testing has shown that this has a maximum conversion error of 1.4e-3 percent. Saving is ~10% faster but requires only 50% the hard drive space.
compression (
Optional
[str
]) – The value of this argument will be passed to h5py.create_dataset for numpy arrays. See h5py documentation for available options.
- Returns
This is the the same h5py.Group that was passed in a g. It should now have a new dataset by the name of ‘name’
- Return type
h5py.Group
- property index: Tuple[float, ...]¶
Returns: The values of the datacube’s index
- Return type
Tuple
[float
,...
]