pypeit.inputfiles module
Class for I/O of PypeIt input files
- class pypeit.inputfiles.Coadd1DFile(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
InputFile
Child class for coaddition in 1D
- data_block = 'coadd1d'
- datablock_required = True
- flavor = 'Coadd1D'
- property objids
- required_columns = ['filename', 'obj_id']
- property sensfiles
Generate a list of the sensitivity files with the full path. The files must exist and be within one of the paths (or the current folder with not other paths specified) for this to succeed.
- Returns:
List of full path to each data file or None if filename is not part of the data table or there is no data table!
- Return type:
- property setup_id
- setup_required = False
- class pypeit.inputfiles.Coadd2DFile(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
InputFile
Child class for coaddition in 2D
- data_block = 'spec2d'
- datablock_required = True
- flavor = 'Coadd2D'
- required_columns = ['filename']
- setup_required = False
- class pypeit.inputfiles.Coadd3DFile(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
InputFile
Child class for coadding spec2d files into datacubes
- data_block = 'spec2d'
- datablock_required = True
- flavor = 'Coadd3d'
- property options
Parse the options associated with a cube block. Here is a description of the available options:
scale_corr
: The name of an alternative spec2d file that is used for the relative spectral scale correction. This parameter can also be set for all frames with the default command:[reduce] [[cube]] scale_corr = spec2d_alternative.fits
skysub_frame
: The name of an alternative spec2d file that is used for the sky subtraction. This parameter can also be set for all frames with the default command:[reduce] [[cube]] skysub_frame = spec2d_alternative.fits
- Returns:
opts – Dictionary containing cube options.
- Return type:
- required_columns = ['filename']
- setup_required = False
- class pypeit.inputfiles.Collate1DFile(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
InputFile
Child class for collate 1D script
- data_block = 'spec1d'
- datablock_required = True
- property filenames
List of path + filename’s
Allows for wildcads
- Returns:
List of the full paths to each data file or None if filename is not part of the data table or there is no data table!
- Return type:
list or None
- flavor = 'Collate1D'
- required_columns = ['filename']
- setup_required = False
- class pypeit.inputfiles.FlexureFile(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
InputFile
Child class for flexure corrections
- data_block = 'flexure'
- datablock_required = True
- flavor = 'Flexure'
- required_columns = ['filename']
- setup_required = False
- class pypeit.inputfiles.FluxFile(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
InputFile
Child class for the Fluxing input file
- data_block = 'flux'
- datablock_required = True
- flavor = 'Flux'
- required_columns = ['filename']
- property sensfiles
Generate a list of the sensitivity files with the full path. The files must exist and be within one of the paths (or the current folder with not other paths specified) for this to succeed.
- Returns:
List of full path to each data file or None if filename is not part of the data table or there is no data table!
- Return type:
- setup_required = False
- class pypeit.inputfiles.InputFile(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
object
Generic class to load, process, and write PypeIt input files
In practice, we use one of the children of this class, e.g. PypeItFile
This class has limited support for preserving comments in the input files. We currently support comments in the configuration section, and commented out data lines in the data sections. Other comments are not preserved.
- Parameters:
config (
dict
orlist
) – Configuration dict or list of config lines Converted to a ConfigObjfile_paths (list) – List of file paths for the data files
data_table (astropy.table.Table) – Data block
setup (
dict
) – dict defining the Setup The first key contains the namevet (bool,Optional) – Whether or not to vet the file after iniitialization. Defaults to True. The vet() method can be called after initialization if needed.
preserve_comments (bool, Optional) – Whether or not to preserve comments in the input file
- static _parse_setup_lines(lines)[source]
Return a list of the setup names and corresponding Setup dict
- Parameters:
lines (numpy.ndarray) – Setup lines as an array
- Returns:
list, dict. List of setup name, setup dict
- Return type:
- static _read_data_file_table(lines, preserve_comments)[source]
Read the file table format.
Because we allow (even encourage!) the users to modify entries by hand, we have a custom way to parse what is largely a standard fixed_width ASCII table
- Parameters:
- Returns:
A
list
with the paths provided (can be empty) and an astropy.table.Table with the data provided in the input file.- Return type:
- property cfg_lines
- Return a list containing the configuration lines
If no configuration is available (
config
is None), None is returned.
- Returns:
List of the configuration lines prepared for writing to a file (and other usages).
- Return type:
- data_block = None
- datablock_required = False
- property filenames
List of path + filename’s Wrapper to
path_and_files()
. See that function for a full description.- Returns:
List of the full paths to each data file or None if filename is not part of the data table or there is no data table!
- Return type:
list or None
- static find_block(lines, block)[source]
Find a specific block of lines
These must be wrapped within
block read
andblock end
, e.g.:setup read Setup A: ... setup end
- flavor = 'Generic'
- classmethod from_file(input_file: str, vet: bool = True, preserve_comments: bool = False)[source]
Parse the user-provided input file.
- Parameters:
input_file (
str
) – Name of input filevet (bool,Optional) – Whether or not to vet the file after iniitialization. Defaults to True. The vet() method can be called after initialization if needed.
preserve_comments (bool,Optional) – Whether or not to preserve comments and blank lines in the congiguration section and the data table. Defaults to False.
- Returns:
An instance of the InputFile class
- Return type:
- get_pypeitpar(config_specific_file=None)[source]
Use the configuration lines and a configuration-specific example file to build the full parameter set.
- Parameters:
config_specific_file (
str
, Path, optional) – The file to use to generate the default, configuration-specific parameters. If None and instance contains filenames, use the first file. If None and instance provides no filenames, configuration-specific parameters are not set.- Returns:
A tuple with the spectrograph instance, the parameters, and the file name used to generate the configuration-specific parameters. That latter will be None if the no example file was available.
- Return type:
- get_spectrograph()[source]
Use the configuration lines to instantiate the relevant
Spectrograph
subclass.- Returns:
Spectrograph subclass instance using the relevant configuration parameter.
- Return type:
- Raises:
PypeItError – Raised if the relevant configuration parameter is not available.
- path_and_files(key: str, skip_blank=False, include_commented_out=False, check_exists=True)[source]
Generate a list of the filenames with the full path from the column of the data astropy.table.Table specified by key. The files must exist and be within one of the paths for this to succeed.
- Parameters:
key (str) – Column of self.data with the filenames of interest
skip_blank (bool, optional) – If True, ignore any entry that is ‘’, ‘none’ or ‘None’. Defaults to False.
check_exists (bool, optional) – If False, PypeIt will not check if ‘key’ exists as a file. Defaults to True.
include_commented_out (bool,Optional) – If False, commented out files will not be included. If True, they are included, without the “#” character.
- Returns:
List of the full paths to each data file or None if filename is not part of the data table or there is no data table!
- Return type:
- Raises:
PypeItError – Raised if the path+file does not exist
- static readlines(ifile: str)[source]
General parser for a PypeIt input file. Used for many of our input files, including the main PypeIt file.
Checks that the file exists.
Reads all the lines in the file
Replaces special characters.
Applies to settings, setup, and user-level reduction files.
- Parameters:
ifile (str) – Name of the file to parse.
- Returns:
Returns a list of the valid lines in the files.
- Return type:
- required_columns = []
- property setup_name
Return the setup name
- Returns:
Setup name. Usually a single, capitalized Letter
- Return type:
- setup_required = False
- vet()[source]
Check for required bits and pieces of the Input file besides the input objects themselves
- class pypeit.inputfiles.PypeItFile(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
InputFile
Child class for the PypeIt file
- data_block = 'data'
- datablock_required = True
- flavor = 'PypeIt'
- property frametypes
Return a dict of the frametypes with key, item the filename, frametype
- Return type:
- get_pypeitpar()[source]
Override the base class function to use files with specific frametypes for the config-specific parameters.
- Returns:
A tuple with the spectrograph instance, the parameters, and the file name used to generate the configuration-specific parameters. That latter will be None if the no example file was available.
- Return type:
- required_columns = ['filename', 'frametype']
- setup_required = True
- class pypeit.inputfiles.RawFiles(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
InputFile
Child class for a list of raw files
- data_block = 'raw'
- datablock_required = True
- flavor = 'Raw'
- required_columns = ['filename']
- setup_required = False
- class pypeit.inputfiles.SensFile(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
InputFile
Child class for the Sensitivity input file
- data_block = 'sens'
- datablock_required = False
- flavor = 'Sens'
- setup_required = False
- class pypeit.inputfiles.TelluricFile(config=None, file_paths: list = None, data_table: Table = None, setup: dict = None, vet: bool = True, preserve_comments: bool = False)[source]
Bases:
InputFile
Child class for telluric corrections
- data_block = None
- datablock_required = False
- flavor = 'Telluric'
- setup_required = False
- pypeit.inputfiles.grab_rawfiles(file_of_files: str = None, list_of_files: list = None, raw_paths: list = None, extension: str = '.fits')[source]
Parse a set of raw files from the input.
Although all arguments are optional, one of
file_of_files
,list_of_files
, orraw_paths
must be true. Precedence is given in that order; i.e., iffile_of_files
is provided, all other arguments are ignored.- Parameters:
file_of_files (str, optional) – File with list of raw files. Format must follow the Data Block of a PypeIt file, and the only required column is the filename.
list_of_files (list, optional) – List of raw files (str). Ignored if
file_of_files
is provided. Ifraw_paths
is None, the path is assumed to be the current working directory.raw_paths (list, optional) – One or more paths with the raw files. Ignored if
file_of_files
is provided. Iflist_of_files
is None, all files with the provided extension are assumed to be raw files.extension (str, optional) – File extension to search on. Ignored if
file_of_files
orlist_of_files
is provided.
- Returns:
List of raw data filenames with full path
- Return type: