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 prefix

  • image_num (str) – File number identified

  • config_filepath (str) – Path to the .mask config file

  • output_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
_set_image_coordinates()[source]

Set Image Coordinates.

Compute the image coordinates for matching with the star catalogue and star mask.

make_mask()[source]

Make Mask.

Main function to create the 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

dict

Raises

ValueError – For invalid configuration options

mask_border(width=100, flag_value=4)[source]

Create Mask Border.

Mask width pixels around the image.

Parameters
  • width (int) – Width of the mask mask border

  • flag_value (int) – Value of the flag for the border (power of 2)

Returns

Array containing the mask

Return type

numpy.ndarray

Raises

ValueError – If width is None

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
  • cat_path (str) – Path to the deep-sky catalogue

  • size_plus (float) – Increase the size of the mask by this factor (e.g. 0.1 means 10%)

  • flag_value (int) – Value of the flag, some power of 2

  • obj_type ({'Messier', 'NGO'}, optional) – Object type

Returns

If no deep-sky objects are found in the field return None and the flag map

Return type

numpy.ndarray or None

Raises
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
Returns

The distance in degrees.

Return type

float

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

float

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.

Parameters

CDSclient_output (str) – Output of findgsc2.2

Returns

Star dictionary containing all information

Return type

dict

_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 or SPIKE

  • 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 or ALL

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
  • path_mask1 (str) – Path to a mask (FITS format)

  • path_mask2 (str, optional) – Path to a mask (FITS format)

  • masks_internal (dict, optional) – Internally created masks

  • path_external_flag (str, optional) – Path to an external flag file

Returns

Array containing the final mask

Return type

numpy.ndarray

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
_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

str

Raises

ValueError – If temp_dir_path is of type None