Preprocessing¶
irisreader.preprocessing.image_cropper¶
-
class
irisreader.preprocessing.
image_cropper
(offset=0, check_coverage=True)[source]¶ Implements a transformer that cuts out only the non-null regions of an IRIS image (be it SJI or spectra). Null pixels of the image are encoded as -200.
The bounds are found by moving in lines from all sides towards the center until the number of nonzero pixels stops increasing. To make sure everything worked well, the cropped image is checked for negative pixels at the end, throwing an error if more than 5% of the image border pixels or the whole image are negative. In this way, bounds for the image are determined with the fit method while the transform method returns a the cropped image.
- Parameters
offset (integer) – Number of pixels that are removed as a safety border from all sides after the cropping.
check_coverage (boolean) – Whether to check the coverage of the cropped image. It can happen that there are patches of negative values in images, either due to loss of data during transmission (typically a band or a large rectangular patch of negative data) or due to overall low data counts (missing data is no data). image_cropper labels an image as corrupt if >5% of its pixels are still negative after cropping. This might be problematic for lines with low data counts (and therefore many missing pixels) and the user is advised to disable the coverage check for such lines. A method that is able to distinguish missing data arising from transmission errors from missing data due to low data counts could be helpful here.
-
fit
(X, y=None)[source]¶ Determines bounds for the supplied image with the sliding lines approach mentioned in the class description.
- Parameters
X (numpy.ndarray) – 2D image data that is to be cropped, format [y,x]
- Returns
Returns this object with fitted variables.
- Return type
irisreader.preprocessing.image_cube_cropper¶
-
class
irisreader.preprocessing.
image_cube_cropper
(offset=0, check_coverage=True)[source]¶ Implements a transformer that can crop all images of an observed line (be it SJI or spectra) by applying image_cropper to every individual image and identifying corrupt images and outliers.
Corrupt images can either be identified directly when
image_cropper
throws an error because more than 5% of the pixels of the border or the overall image are negative or, however, they can appear as outliers in the bound data returned byimage_cropper
: sometimes whole stripes of data are corrupt, resulting in a rectangular image with for example half the width and the height of the valid image. We thus look for outliers in the data returned byimage_cropper
and degrade them to corrupt images. Outliers are defined here as values that deviate more than 1.5% from the median bound (15 pixels on 1000 pixels).- Parameters
offset (integer) – Number of pixels that are removed as a safety border from all sides after the cropping.
check_coverage (boolean) – Whether to check the coverage of the cropped image. It can happen that there are patches of negative values in images, either due to loss of data during transmission (typically a band or a large rectangular patch of negative data) or due to overall low data counts (missing data is no data). image_cropper labels an image as corrupt if >5% of its pixels are still negative after cropping. This might be problematic for lines with low data counts (and therefore many missing pixels) and the user is advised to disable the coverage check for such lines. A method that is able to distinguish missing data arising from transmission errors from missing data due to low data counts could be helpful here.
-
fit
(X, y=None)[source]¶ Determines the overall cropping bounds and the corrupt images for the supplied data cube.
- Parameters
X (irisreader.iris_data_cube (irisreader.sji_cube / irisreader.raster_cube)) – Data cube object that has to be cropped.
- Returns
This object with fitted variables.
- Return type
-
get_bounds
()[source]¶ Gets the overall bounds recovered by image_cube_cropper.
- Returns
List [ xmin, xmax, ymin, ymax ] for the given data cube.
- Return type
int
irisreader.preprocessing.spectrum_interpolator¶
-
class
irisreader.preprocessing.
spectrum_interpolator
(lambda_min, lambda_max, steps)[source]¶ Interpolates supplied spectra to a certain range and size using cubic splines.
- Parameters
lambda_min (float) – Minimum wavelength.
lambda_max (float) – Maximum wavelength.
steps (integer) – Number of interpolation steps.
-
fit
(X, y)[source]¶ Creates a cubic spline function fitting the supplied spectrum data.
- Parameters
X (numpy.ndarray) – Array of spectra to interpolate (rows are different spectra and columns are wavelength bins)
y (float) – List of wavelength units.
- Returns
This object with fitted variables.
- Return type