MarsImage subclasses#
Base class for MarsImage data.
- class marsimage.imagebase.MarsImageBase(filename)[source]#
Base class for MarsImage data.
- property img#
The image array of the image.
PDR loads the image array lazily, so this poperty is used to prevent preemtive loading. The image is loaded and converted to the appropriate dtype on first access.
- property mask#
The mask array of the image.
Lazy loading of mask image, if not found, a blank mask is returned.
- process(undebayer=False, uncrop=False, crop=False)[source]#
Calibrates the image according to the calibration settings specified in the kwargs.
This modifies the image in place.
- Parameters:
undebayer (bool) – If True, and the image is color, it will be undebayered using the CFA pattern specified in the instrument_defs.
- Return type:
None
- crop(rect)[source]#
Crop the image and mask to the specified rectangle.
This modifies the image and mask in place. TODO update camera model!
- crop_active_area()[source]#
Crop the image and mask to the max active area.
TODO update camera model!
- uncrop()[source]#
Revert image to the full sensor size.
This modifies the image and mask in place, padding them with zeros to the full sensor size.
TODO update camera model!
- to_subframe(subframe)[source]#
Crop/pad the image and mask to the specified subframe.
This modifies the image and mask in place.
- save(save_path, *args, **kwargs)[source]#
Save the image to the specified path, with optional arguments for metadata etc.
The file format is determined by the file extension of the save_path. Currently supported formats are TIFF and DNG.
- Parameters:
save_path (str) – The path to save the image to. The file extension determines the file format.
See also
marsimage.save.save_tiffSave the image as a TIFF file.
marsimage.dng.save_dngSave the image as a DNG file.
- rawtherapee_convert(save_path, apply_mask=True, remove_dng=True)[source]#
Convert the image to a TIFF file using RawTherapee and save it to the specified path.
- property xmp#
Generates an XMP object from the image metadata.
- Returns:
XMP
- Return type:
The XMP object.
See also
XMPThe XMP class.
- metafind(keys, fallback=<object object>)[source]#
Find a value from the metadata object using a list of possible keys.
Nested keys can be accessed by passing a tuple of keys. If the key is not found, return a default value, else raise a KeyError.
- Parameters:
- Raises:
KeyError – If the key is not found in the metadata and no fallback value was provided.
- property mission_id#
The mission ID of the image. e.g. ‘MSL’ or ‘M20’.
- property mission_name#
The mission name of the image. e.g. ‘MARS SCIENCE LABORATORY’.
- property instrument_id#
The instrument ID of the image. e.g. ‘MAHLI’ or ‘MARDI’.
- property instrument_name#
The instrument name of the image. e.g. ‘MARS HAND LENS IMAGER CAMERA’.
- property rationale#
The rationale for the image acquisition.
- property start_time#
The start time of the image acquisition as a time.struct_time object.
- property mean_solar_time#
The mean solar time of the image acquisition as a string.
- property sol#
The sol of the image acquisition.
- property sclk#
The spacecraft clock counter (sclk) of the image acquisition.
- property width#
The width of the image array.
- property height#
The height of the image array.
- property subframe#
The subframe of the image.
- property subframe_rect#
The subframe of the image as a rectangle.
- property pixel_averaging#
The downsample factor of an image.
- property active_area#
Returns the active area of the image.
The active area in the image coordinates [x1, y1, x2, y2] and start at [0,0] of the image.
- property localization#
Get the localization object containing the rover position and orientation.
- Returns:
An instance of OrbitalCoordinateFrame representing the rover position and orientation.
- Return type:
- property cahvore#
CAHVORE camera model object for the image.
- Returns:
A CAHVORE camera model object created from the image metadata.
- Return type:
- property cm#
Generate a CameraModel object for the image in the rover frame.
- Returns:
The camera model object for the image.
- Return type:
Notes
The CameraModel is created using the CAHVORE model parameters, image width, image height, and pixel size adjusted by pixel averaging.
See also
CameraModel.from_cahvoreMethod to create a CameraModel from CAHVORE parameters.
- property cm_global#
Camera model object for the image in the global frame.
- Returns:
The camera model object for the image in the global frame.
- Return type:
- property solar_elevation#
The solar elevation angle at image acquisition.
- property solar_azimuth#
The solar azimuth angle at image acquisition.
- property target#
The specified target from the label.
- property zenith_scaling#
The zenith scaling factor for the image.
Note
The zenith scaling factor is currently only calculated based on the solar elevation angle and ignores the atmospheric optical depth.
- property baseline_exposure_factor#
Calculate the baseline exposure factor based on solar elevation.
The baseline exposure factor is only calculated if the solar elevation is above 5 degrees. At night, the image would get too dark, so a default value of 1.0 is returned.
- Returns:
The calculated baseline exposure factor if solar elevation is above 5 degrees, otherwise 1.0.
- Return type:
- property baseline_exposure_stops#
The baseline exposure factor in EV stops.
See also
baseline_exposure_factorThe baseline exposure factor.
- property whitelevel#
The white level of the image.
The white level is initialized with the maximum valid value from the image label. If the value is not found in the label, the maximum value for the image array’s data type is used.
- Returns:
The white level value for the image.
- Return type:
- property radiance_scaling_factor#
Retrieve the radiance scaling factor from the metadata.
This method searches for the radiance scaling factor in the metadata using different possible keys. The keys are specific to different missions and instruments.
- property radiance_offset#
Float value of the radiance offset of the image.
- class marsimage.msl.MAHLIZstackImage(filename)[source]#
Mahli image class to handle non standard MAHLI images.
- find_source_image_from_zstack_rationale()[source]#
Find a source image of the MAHLI zstack.
MAHLI Z-STACK images labels contain the rover state during stack generation, so we need to find the source images to get valid metadata. Currently this method only tries to load the middle image of the sequence.