1. Getting Started: Main Program

1.1. make_hst_spec_previews

exception make_hst_spec_previews.HSTSpecPrevError(value)

This class defines a generic Exception to use for errors raised in MAKE_HST_SPEC_PREVIEWS. It simply prints the given string when raising the exception. e.g.,

raise HSTSpecPrevError("Print this string")
HSTSpecPrevError: *** MAKE_HST_SPEC_PREVIEWS ERROR: 'Print this string'
make_hst_spec_previews.check_input_options(args)

Check that input arguments satisfy some minimum requirements.

Parameters:

args (argparse.Namespace object.) – Stores arguments and options.

Raises:

HSTSpecPrevError, ValueError

make_hst_spec_previews.get_instrument_name(input_file)

Determines whether the input file is for HASP (Hubbble Advanced Spectral Product).

Parameters:

input_file (str) – Name of input FITS file.

Returns:

str – The name of the instrument based on the FITS header keyword, in uppercase with leading/trailing whitespace removed.

Raises:

KeyError, HSTSpecPrevError

make_hst_spec_previews.is_hasp_product(input_file)

Retrieves the instrument name from a FITS file primary header.

Parameters:

input_file (str) – Name of input FITS file.

Returns:

bool – Returns True if the filename ends in _cspec.fits.

make_hst_spec_previews.make_hst_spec_previews(input_file, flux_scale_factor=10.0, fluxerr_scale_factor=5.0, n_consecutive=20, output_path='', output_type=['png'], dpi_val=96.0, debug=False, full_ylabels=False, optimize=True, verbose=False)

Main function in the module.

Parameters:
  • input_file (str) – The full path and name of the FITS file to create a preview for.

  • flux_scale_factor (float) – The ratio between the flux and the median flux that defines the pass/fail criterion within the edge trim test.

  • fluxerr_scale_factor (float) – The ratio between the flux uncertainty and the median flux uncertainty that defines the pass/fail criterion within the edge trim test.

  • n_consecutive (int) – The number of consecutive data points that must pass the edge trim test to define the start and end of the spectrum for plotting purposes.

  • output_path (str) – Full path to output plot files. Do not include the output file name in this path. If not supplied, plots will be created in the same directory as the input file.

  • output_type (list) – The file type(s) of the plots to make.

  • dpi_val (float) – The DPI value of your device’s monitor, which will affect the size of the output plots.

  • debug (bool) – If True, turns on debug mode, which will plot to the screen and color-code fluxes based on different rejection criteria.

  • full_ylabels (bool) – If True, label the y-axis with full values, including powers of ten in scientific notation.

  • optimize (bool) – If set to True, will use a slightly optimized version of determining the plot covering fraction.

  • verbose (bool) – Turn on verbose messages/logging?

Raises:

HSTSpecPrevError

make_hst_spec_previews.setup_args()

Set up command-line arguments and options.

Returns:

ArgumentParser – Stores arguments and options.

1.2. make_jwst_spec_previews

exception make_jwst_spec_previews.JWSTSpecPrevError(value)

This class defines a generic Exception to use for errors raised in MAKE_JWST_SPEC_PREVIEWS. It simply prints the given string when raising the exception. e.g.,

raise JWSTSpecPrevError("Print a string")
JWSTSpecPrevError: *** MAKE_JWST_SPEC_PREVIEWS ERROR: 'Print a string'
make_jwst_spec_previews.check_input_options(args)

Check that input arguments satisfy some minimum requirements.

Parameters:

args (argparse.Namespace object.) – Stores arguments and options.

Raises:

JWSTSpecPrevError, ValueError

make_jwst_spec_previews.get_instrument_name(input_file)

Retrieves the instrument name from a FITS file primary header.

Parameters:

input_file (str) – Name of input FITS file.

Returns:

str – The name of the instrument based on the FITS header keyword, in uppercase with leading/trailing whitespace removed.

Raises:

KeyError, JWSTSpecPrevError

make_jwst_spec_previews.make_jwst_spec_previews(input_file, flux_scale_factor=10.0, fluxerr_scale_factor=5.0, n_consecutive=20, output_path='', output_type=['png'], dpi_val=96.0, debug=False, full_ylabels=False, optimize=True, verbose=False)

Main function in the module.

Parameters:
  • input_file (str) – The full path and name of the FITS file to create a preview for.

  • flux_scale_factor (float) – The ratio between the flux and the median flux that defines the pass/fail criterion within the edge trim test.

  • fluxerr_scale_factor (float) – The ratio between the flux uncertainty and the median flux uncertainty that defines the pass/fail criterion within the edge trim test.

  • n_consecutive (int) – The number of consecutive data points that must pass the edge trim test to define the start and end of the spectrum for plotting purposes.

  • output_path (str) – Full path to output plot files. Do not include the output file name in this path. If not supplied, plots will be created in the same directory as the input file.

  • output_type (list) – The file type(s) of the plots to make.

  • dpi_val (float) – The DPI value of your device’s monitor, which will affect the size of the output plots.

  • debug (bool) – If True, turns on debug mode, which will plot to the screen and color-code fluxes based on different rejection criteria.

  • full_ylabels (bool) – If True, label the y-axis with full values, including powers of ten in scientific notation.

  • optimize (bool) – If set to True, will use a slightly optimized version of determining the plot covering fraction.

  • verbose (bool) – Turn on verbose messages/logging?

Raises:

JWSTSpecPrevError

make_jwst_spec_previews.setup_args()

Set up command-line arguments and options.

Returns:

ArgumentParser – Stores arguments and options.