pypeit.masterframe module

Implements the master frame base class.

class pypeit.masterframe.MasterFrame(master_type, master_dir=None, master_key=None, file_format='fits', reuse_masters=False)[source]

Bases: object

Base class for all PypeIt calibration master frames.

Main methods of the class are to implement the default paths for the master frames and their I/O methods.

Parameters:
  • master_type (str) – Master frame type, used when constructing the output file name. See file_name.
  • master_dir (str or None) – Name of the MasterFrame folder. If None, set to current working directory.
  • master_key (str or None) – Root of the MasterFrame names, e.g. ‘A_1_01’. If None, set to ‘master’
  • file_format (str, optional) – File format for the master frame. Typically ‘fits’ or ‘json’.
  • reuse_masters (bool, optional) – Reuse already created master files from disk.
master_type

See initialization arguments.

Type:str
master_dir

See initialization arguments.

Type:str
master_key

See initialization arguments.

Type:str
file_format

See initialization arguments.

Type:str
reuse_masters

See initialization arguments.

Type:bool
static construct_file_name(master_type, master_key, file_format='fits')[source]

Name of the MasterFrame file.

file_name

Name of the MasterFrame file.

file_path

Full path to MasterFrame file.

initialize_header(hdr=None)[source]

Initialize the master frame header.

The function writes information generic to all PypeIt master frame headers with basic information.

Parameters:hdr (astropy.io.fits.Header, optional) – Header object to update with basic summary information. The object is modified in-place and also returned. If None, an empty header is instantiated, edited, and returned.
Returns:The initialized (or edited) fits header.
Return type:astropy.io.fits.Header
load(ext, ifile=None, return_header=False)[source]

Generic master file reader.

This generic reader assumes the file is in fits format.

Parameters:
  • ext (str, int, list) – One or more file extensions with data to return. The extension can be designated by its 0-indexed integer number or its name.
  • ifile (str, optional) – Name of the master frame file. Defaults to file_path.
  • return_header (bool, optional) – Return the header
Returns:

Returns the image data from each provided extension. If return_header is true, the primary header is also returned. If nothing is loaded, either because reuse_masters is False or the file does not exist, everything is returned as None (one per expected extension and one if the header is requested).

Return type:

tuple

static load_from_file(filename, ext, return_header=False)[source]

Generic static method to read a master file.

Parameters:
  • filename (str) – Name of the master frame file.
  • ext (str, int, list) – One or more file extensions with data to return. The extension can be designated by its 0-indexed integer number or its name.
  • return_header (bool, optional) – Return the header.
Returns:

Returns the image data from each provided extension. If return_header is true, the primary header is also returned.

Return type:

tuple

save(data, extnames, outfile=None, overwrite=True, raw_files=None, steps=None, checksum=True)[source]

Base interface for saving master frame image data to a fits file.

Data is always placed in extensions, with the PRIMARY extension only containing the header data. More complicated master frame data models should overload this function.

Parameters:
  • data (list, numpy.ndarray) – One or more data arrays to save.
  • extnames (list, str) – The names for the data extensions.
  • outfile (str, optional) – Name for the output file. Defaults to file_path.
  • overwrite (bool, optional) – Overwrite any existing file.
  • raw_files (list, optional) – List of processed raw files used to construct the master frame.
  • steps (list, optional) – The list of steps executed by the derived class to construct the master frame.
  • checksum (bool, optional) – Passed to astropy.io.fits.HDUList.writeto to add the DATASUM and CHECKSUM keywords fits header(s).