shapepipe.modules.mask_package.mask
shapepipe.modules.mask_package.mask¶
MASK.
This module contains a class to create star mask for an image.
- Authors
Axel Guinot, Martin Kilbinger
- class Mask(image_path, weight_path, image_prefix, image_num, config_filepath, output_dir, w_log, path_external_flag=None, outname_base='flag', star_cat_path=None, hdu=0)[source]¶
Bases:
object
Mask.
Class to create mask based on a star catalogue.
- Parameters
image_path (str) – Path to image (FITS format)
weight_path (str) – Path to the weight image (FITS format)
image_prefix (str) – Prefix to input image name, specify as
'none'
for no prefiximage_num (str) – File number identified
config_filepath (str) – Path to the
.mask
config fileoutput_dir (str) – Path to the output directory
w_log (logging.Logger) – Log file
path_external_flag (str, optional) – Path to external flag file, default is
None
(not used)outname_base (str, optional) – Output file name base, default is
flag
star_cat_path (str, optional) – Path to external star catalogue, default is
None
(not used; instead the star catalogue is produced on the fly at run time)hdu (int, optional) – HDU number, default is
0
- _get_config()[source]¶
Get Config.
Read the config file and set parameters.
- Raises
ValueError – If config file name is
None
IOError – If config file not found
- _set_image_coordinates()[source]¶
Set Image Coordinates.
Compute the image coordinates for matching with the star catalogue and star mask.
- find_stars(position, radius)[source]¶
Find Stars.
Return GSC (Guide Star Catalog) objects for a field with center (RA, Dec) and radius \(r\).
- Parameters
position (numpy.ndarray) – Position of the center of the field
radius (float) – Radius in which the query is done (in arcmin)
- Returns
Star dicotionnary for GSC objects in the field
- Return type
- Raises
ValueError – For invalid configuration options
- mask_border(width=100, flag_value=4)[source]¶
Create Mask Border.
Mask
width
pixels around the image.- Parameters
- Returns
Array containing the mask
- Return type
- Raises
ValueError – If
width
isNone
- mask_dso(cat_path, size_plus=0.1, flag_value=8, obj_type='Messier')[source]¶
Mask DSO.
Create a circular patch for deep-sky objects (DSOs), e.g. Messier or NGC objects.
- Parameters
- Returns
If no deep-sky objects are found in the field return
None
and the flag map- Return type
numpy.ndarray or
None
- Raises
ValueError – If
size_plus
is negativeValueError – If
cat_path
isNone
- missing_data()[source]¶
Find Missing Data.
Look for zero-valued pixels in image. Flag if their relative number is larger than a threshold.
- sphere_dist(position1, position2)[source]¶
Compute Spherical Distance.
Compute spherical distance between 2 points.
- Parameters
position1 (numpy.ndarray) – [x,y] first point (in pixels)
position2 (numpy.ndarray) – [x,y] second point (in pixels)
- Returns
The distance in degrees.
- Return type
- Raises
ValueError – If input positions are not Numpy arrays
- _get_image_radius(center=None)[source]¶
Get Image Radius.
Compute the diagonal distance of the image in arcmin.
- Parameters
center (numpy.ndarray, optional) – Coordinates of the center of the image (in pixels)
- Returns
The diagonal distance of the image in arcmin
- Return type
- Raises
TypeError – If centre is not a Numpy array
- _make_star_cat(CDSclient_output)[source]¶
Make Star Catalogue.
Make a dictionary from findgsc2.2 output.
- _create_mask(stars, types='HALO', mag_limit=18.0, mag_pivot=13.8, scale_factor=0.3)[source]¶
Create Mask.
Apply mask from model to stars and save into DS9 region file.
- Parameters
stars (dict) – Stars dictionary (output of
find_stars
)types ({'HALO', 'SPIKE'}, optional) – Type of mask, options are
HALO
orSPIKE
mag_limit (float, optional) – Faint magnitude limit for mask, default is
18.0
mag_pivot (float, optional) – Pivot magnitude for the model, default is
13.8
scale_factor (float, optional) – Scaling for the model, default is
0.3
- Raises
ValueError – If no star catalogue is provided
ValueError – If an invalid option is provided for type
- _exec_WW(types='HALO')[source]¶
Execute WeightWatcher.
Execute WeightWatcher to transform
.reg
to.fits
flag map.- Parameters
types ({'HALO', 'SPIKE', 'ALL'}, optional) – Type of WeightWatcher execution, options are
HALO
,SPIKE
orALL
- Raises
BaseCatalogue.CatalogFileNotFound – If catalogue file not found
- _build_final_mask(path_mask1, path_mask2=None, masks_internal=None, path_external_flag=None)[source]¶
Create Final Mask.
Create the final mask by combining the individual masks.
- Parameters
- Returns
Array containing the final mask
- Return type
- Raises
ValueError – If all masks are of type
None
TypeError – If border is not a Numpy array
TypeError – If Messier mask is not a Numpy array
- _mask_to_file(input_mask, output_fullpath)[source]¶
Mask to File.
Save the mask to a fits file.
- Parameters
input_mask (numpy.ndarray) – Mask to save
output_fullpath (str) – Path of the output file
- Raises
ValueError – If input_mask is type
None
ValueError – If output_fullpath is type
None
- _get_temp_dir_path(temp_dir_path)[source]¶
Get Temporary Directory Path.
Create the path and the directory for temporary files.
- Parameters
temp_dir_path (str) – Path to the temporary directory, a value of
OUTPUT
will include the temporary files in the run directory- Returns
Path to the temporary directory
- Return type
- Raises
ValueError – If
temp_dir_path
is of typeNone