image
This module contains the class that is used to store images.
Module Contents
Classes
The class used to store raw image data. Internally, this data is stored as a numpy array. |
Functions
add transmission correction if transmission data available |
|
add count time correction if count_time available |
|
Data
API
- image.logger = 'getLogger(...)'
- image.get_coordchange_matrix(oop)
- image.correct_transmission(transmission_array, data_array, index)
add transmission correction if transmission data available
- image.correct_counttime(count_time_array, data_array, index)
add count time correction if count_time available
- image.get_norm_value(values, index)
- image.do_mask_eiger(data_arr)
- image.do_edfmask(edfmask, data_arr)
- image.do_mask_pixels(mask_pixels, data_arr)
- image.do_mask_regions(mask_regions, data_arr)
- image.norm_kout_array(k_out_array, i, j)
- class image.Image(metadata: fast_rsm.rsm_metadata.RSMMetadata, index: int, load_image=True, pyfai_calculation=False)
The class used to store raw image data. Internally, this data is stored as a numpy array.
- Attrs:
- data:
A numpy array storing the image data. This is a property.
- metadata:
An instance of RSMMetadata containing the scan’s metadata.
- diffractometer:
A reference to the RSMMetadata’s diffractometer.
- index:
The index of the image in the scan.
- load_image:
Should we actually load the image? It can be useful to access an Image object without incurring the latency of an image load to e.g. quickly calculate a few q_vectors.
Initialization
- _correct_img_axes()
Correct the image axes so that the image is the right way around, taking transposes if necessary. This method can use the metadata to work out where the data came from so that different transposes/inversions can be carried out depending on where the data was acquired. Information should be scraped from self.metadata to work out if any corrections are necessary at this point.
- get_detector_values(frame)
- get_vert_hor_values(frame)
- apply_corrections(frame, lorentz_correction, pol_correction, incident_beam_arr, k_out_array)
- generate_mask(min_intensity: Union[float, int]) numpy.ndarray
Generates a mask from every pixel whose intensity is below a certain value. This mask uses the intensities recorded in the _raw_data, not the corrected data returned by the Image.data property. While this might seem a bit dodgy, it does mean that the mask is consistent with what a user would see as a raw detector output.
- Note that the condition is written as
self._raw_data >= min_intensity
- not
self._raw_data > min_intensity
- Args:
- min_intensity:
If the raw intensity value of a pixel is below this cutoff, that pixel will be masked.
- Returns:
A numpy array of ones and zeroes, where a zeroes represent masked pixels. The dtype of the array is dtype(‘bool’), but under the hood it’s just ones and zeros.
- add_processing_step(function) None
Adds the processing step to the processing pipeline.
- Args:
- function:
A function that takes a numpy array as an argument, and returns a numpy array.
- property data
Returns the normalized, processed data. If you want to apply some pre-processing to the data before mapping (e.g. by applying some thresholding, masking, clustering, or any arbitrary algorithm) then use the add_processing_step method.
- q_vectors(frame: diffraction_utils.Frame, spherical_bragg_vec: numpy.array, oop='y', indices: tuple = None, lorentz_correction: bool = False, pol_correction: bool = True) numpy.ndarray
Calculates the wavevector through which light had to scatter to reach every pixel on the detector in a given frame of reference.
First, we calculate the wavevector of the outgoing light at each pixel. This is done using basic vector algebra.
- Args:
- frame:
The frame of reference in which we want to calculate the q_vectors.
- spherical_bragg_vec:
XYZ vector for shifting centre of volume when interested in plotting spherical polar plots. defaults to [0,0,0] when unspecified.
- indices:
The indices that we want to carry out the map for. Defaults to None, in which case the entire image is mapped. E.g. passing indices=(-1, -1) will only calculate the scattering vector for the bottom right pixel.
- Returns:
If your image has a shape of (a, b), the output of q_vectors has shape (a, b, 3), i.e. you get one q_vector for each pixel. If you specify an index, then your output will have shape (1, 1, 3). Probably.
- q_vector_array(frame: diffraction_utils.Frame, spherical_bragg_vec: numpy.array, oop='y', lorentz_correction: bool = False, pol_correction: bool = True) numpy.ndarray
Returns a numpy array of q_vectors whose shape is (N,3).