shapepipe.modules.setools_package.setools

shapepipe.modules.setools_package.setools

SETOOLS.

This module contains a class to handle operations on SExtractor output catalogues.

Authors

Axel Guinot

class SETools(cat, output_dir, file_number_string, config_filepath, cat_file=True)[source]

Bases: object

The SETools Class.

Tools to analyse SExtractor catalogues.

Parameters
  • cat (str, numpy.ndarray) – Path to SExtractor catalogue (FITS_LDAC format) or numpy.ndarray (structured array)

  • output_dir (str) – Path to pipeline result directory

  • file_number_string (str) – input catalogue number/specifier

  • config_filepath (str) – Path to config.setools file

  • cat_file (bool, optional) – True if cat is a path to a file, False otherwise

process(w_log)[source]

Process.

Main function called to process a SExtractor catalogue.

Parameters

w_log (logging.Logger) – Logging instance

read()[source]

Read the Configuration File.

This function read the config file and creates a dictionary for every task.

Raises
_clean_line(line)[source]

Clean Lines.

This function is called during the reading process to clean lines from spaces, empty lines and ignore comments.

Parameters

line (str) – Input line

Returns

If the line is not empty or a comment return the contents and None otherwise

Return type

str

save_mask(mask, output_path, ext_name='LDAC_OBJECTS')[source]

Save Mask.

This function will apply a mask to the data and save them into a new SExtractor-like FITS file.

Parameters
  • mask (numpy.ndarray) – Numpy array of boolean containing

  • output_path (str) – Path to the general output directory

  • ext_name (str, optional) – Name of the HDU containing masked data; default is LDAC_OBJECTS SExtractor name

Raises
save_new_cat(new_cat, output_path, ext_name='LDAC_OBJECTS')[source]

Save New Catalogue.

This function creates a new catalogue with a specific format (FITS bin table, SExtractor-like FITS catalogue or ASCII).

Parameters
  • new_cat (dict) – Dictionary containing the data and OUTPUT_FORMAT

  • output_path (str) – Path of the output

  • ext_name (str) – Name of the extension for FITS bin table output

Raises
save_rand_split(rand_split, output_path, file_number, ext_name='LDAC_OBJECTS')[source]

Save Random Split Catalogues.

Save two catalogues following the random split specified.

Parameters
  • rand_split (dict) – Dictionary containing the indices for the split and mask to apply

  • output_path (str) – Path of the output dir

  • file_number (str) – Numbering of the pipeline

  • ext_name (str, optional) – Name of the extension where data are stored

Raises
save_stat(stat, output_path)[source]

Save Statistics.

Save the statistics in ASCII format.

Parameters
  • stat (dict) – Dictionary containing the statistics

  • output_path (str) – Path of the output dir

Raises
_make_mask()[source]

Make Mask.

This function transforms the constraints from the config file to conditions.

Raises

RuntimeError – If value not found in mask

_make_plot()[source]

Make Plot.

This function interpret the different parameters for the plot.

Raises
  • ValueError – If plot option keyword or value is not in the correct format

  • ValueError – If plot keyword not in the correct format

_make_new_cat()[source]

Make New Catalogue.

This function interprets the contents for each column of the new catalogue.

Raises

ValueError – For invalid output format

_make_rand_split()[source]

Make Random Split.

This function creates mask with random indices corresponding to the specfied ratio.

Raises
_make_stat()[source]

Make Statistics.

This function interprets the different statistics required.

Raises

ValueError – For invalid statistics format

class SEPlot(plot_dict, catalogue, output_path, mask_dict=None)[source]

Bases: object

The SEPlot Class.

Tools to create plots.

Parameters
  • plot_dict (dict) – Dictionary containing the parameters for the plot

  • catalogue (numpy.recarray or astropy.fits.fitsrec) – Array containing the full data

  • output_path (str) – Path for the output

  • mask_dict (dict, optional) – Dictionary containing masks to apply

Raises

Notes

Types of plots available : plot, scatter, hist.

_check_key_for_plot(key_list)[source]

Check Key for Plot.

Raise exception if keys not found in plot description.

Parameters

key_list (list) – List of keys

Raises

ValueError – If key not provided for plot type

_make_plot()[source]

Make Plot.

This function calls matplotlib.pyplot.plot.

Raises
  • ValueError – If X not provided for each value of Y

  • ValueError – If plot keyword not in the correct format

_make_scatter()[source]

Make Scatter.

This function calls matplotlib.pyplot.scatter.

Raises
  • ValueError – If X not provided for every SCATTER

  • ValueError – If Y not provided for every SCATTER

_make_hist()[source]

Make Hist.

This function calls matplotlib.pyplot.hist.