Maskο
- class Mask[source]ο
Class representing a mask image for astronomical data processing.
Inherits from DummyImage and provides methods for creating, combining, and managing various types of masks including source masks, bad pixel masks, and cosmic ray masks.
- Parameters:
path (str or Path) β Path to the mask FITS image.
masktype (str, optional) β Type of mask (βnoneβ, βinvalidβ, βsourceβ, βbadpixelβ, βcosmicrayβ, βsubtractionβ).
status (Status, optional) β Initial status object. If not provided, status is loaded from file or initialized.
load (bool, optional) β Whether to load status and header upon initialization.
Methodsο
- combine_mask(self, new_mask, operation='or')ο
Combine the current mask with a new mask.
- Parameters:
new_mask (str or Path or np.ndarray) β Path to the new mask FITS image or numpy array.
operation (str, optional) β Operation to combine the current mask with the new mask.
- show(self, cmap='gray', scale='zscale', downsample=4, figsize=(8, 6), title=None, save_path=False, close_fig=False)ο
Visualize the FITS image using slicing-based downsampling and scaling.
- Parameters:
cmap (str, optional) β Matplotlib colormap. Default is βgrayβ.
scale (str, optional) β Scaling method. Default is βzscaleβ.
downsample (int, optional) β Step size for downsampling via slicing. Default is 4.
figsize (tuple, optional) β Matplotlib figure size. Default is (8, 6).
title (str, optional) β Plot title. Default is None.
save_path (str, optional) β Path to save the figure. Default is None.
close_fig (bool, optional) β If True, close the figure after saving. Default is False.
- run_ds9(self)ο
Open the image with SAOImage DS9.
- Parameters:
None
- Return type:
None
- load(self)ο
Load both image data and header from disk.
- Parameters:
None
- Return type:
None
- write(self, compress=False, verbose=True)ο
Write MaskImage data to savepath.
- Parameters:
None
- Return type:
None
- remove(self, remove_main=True, remove_connected_files=True, skip_patterns=[], verbose=True)ο
- Return type:
dict
- copy(self)ο
Return an in-memory deep copy of this Mask instance,
- Parameters:
None
- Returns:
copied_image β A deep copy of the Mask instance.
- Return type:
- rename(self, new_name, verbose=True)ο
Rename the image file and update the internal path.
- Parameters:
new_name (str) β New name of the image file.
- Return type:
None
- clear(self, clear_data=True, clear_header=False, verbose=True)ο
Clear the image data and/or header from memory.
- Parameters:
clear_data (bool, optional) β If True, clear the image data. Default is True.
clear_header (bool, optional) β If True, clear the image header. Default is False.
Additional Methodsο
- update_header(self, **kwargs)ο
Update FITS header values using known key variants.
- Parameters:
kwargs (dict) β Keyword arguments to update the FITS header.
- Return type:
None
- load_status(self)ο
Load processing status from a JSON file.
- Parameters:
None
- Returns:
status β Status object loaded from the JSON file.
- Return type:
Status
- save_status(self)ο
Save processing status to a JSON file.
- Parameters:
None
- Return type:
None
- add_status(self, event_name, **event_details)ο
Add a status event to the mask.
- Parameters:
event_name (str) β Name of the event to add.
event_details (dict) β Details of the event to add.
- save_info(self)ο
Save processing info to JSON file.
- Parameters:
None
- Return type:
None
Propertiesο
Key Properties
Property |
Description |
|---|---|
|
Return a list of available telescope keys. |
|
Center pixel (0-based) and its world coordinates (RA, Dec). |
|
Return all associated files that would be deleted in remove() if remove_connected_files=True, |
|
Image data array. |
|
Electron gain of the image. |
|
Exposure time of the image. |
|
Field of view along the first axis. |
|
Field of view along the second axis. |
|
FITS header object. |
|
Information instance of the mask. Info is defined in Info class. |
|
Check if the image data is loaded. |
|
Check if the image file exists. |
|
Check if the image header is loaded. |
|
Check if the image has been saved |
|
Number of pixels along the first axis. |
|
Number of pixels along the second axis. |
|
Pixel scale of the image. |
|
Return the directory where this image and associated files will be saved. |
|
Dynamically builds save paths based on current header info |
|
Target image of the mask. If not exists, return None. |
|
WCS information of the image. |