pypeit.outputfiles module
Module for constructing output file names and paths for PypeIt reductions.
- pypeit.outputfiles.construct_basename(filename, target, camera, mjd, allowed_extensions)[source]
Construct the root name primarily for PypeIt file output.
- Parameters:
filename (str, Path) – The name of the raw file. The extension is stripped based on
allowed_extensionsbefore constructing the basename. If no extension inallowed_extensionsmatches, a warning is issued and the full input name is used unmodified.target (str) – The name of the target/object observed.
mjd (float) – The MJD of the observation.
allowed_extensions (list) – List of recognized raw-file extensions for the relevant spectrograph, used to correctly strip the extension from
filename; seeallowed_extensions.
- Returns:
The root name for file output.
- Return type:
- pypeit.outputfiles.existing_spec2d_files(pypeit_file, target, science_dir, spectrograph)[source]
Find the current reduced spec2d products expected for a target.
- Parameters:
pypeit_file (
PypeItFile) – The parsed PypeIt reduction file.target (
str) – Target name to match; seetarget_matches().science_dir (
str, Path) – Directory to search for reduced spec2d files.spectrograph (
Spectrograph) – Spectrograph instance, passed through tofind_reduced_spec2d().
- Returns:
files (
list) – Paths to the reduced spec2d files found for the target, one per combination group.missing (
list) – Raw-file stems (seegroup_science_rows()) for combination groups whose spec2d product has not yet been reduced.target_name (
str) – The literal target name as recorded in the PypeIt file’s data block.
- pypeit.outputfiles.find_reduced_spec2d(science_dir, row, spectrograph)[source]
Find the existing spec2d product for a science-frame row.
Tries an exact match first, reconstructing the spec2d basename from the row’s own metadata via
construct_basename(); a hit is target-correct by construction, since the row’s own target was used to build the name, so no header read is needed. Falls back to matching by raw-file stem and verifying the target recorded in each candidate’s header, for cases where the exact name can’t be reconstructed (e.g. nomjdcolumn, or a corrupt/missingmjdvalue) or doesn’t match an existing file (e.g. an older.pypeitfile, or different metadata precision).- Parameters:
science_dir (
str, Path) – Directory to search for spec2d files.row (astropy.table.Row) – Data-table row for the raw science frame whose reduced spec2d product is sought, e.g. the first row of a group from
group_science_rows(). Must havefilename,target, andmjdcolumns.spectrograph (
Spectrograph) – Spectrograph instance, used forcameraandallowed_extensions.
- Returns:
Path to the matching spec2d file. If more than one candidate matches in the fallback search, the first (alphabetically sorted) is used and a warning is logged. Returns None if no candidate matches.
- Return type:
- pypeit.outputfiles.get_std_outfile(fitstbl, par, standard_frames)[source]
Return the spec1d file name for a reduced standard to use as a tracing crutch.
The file is either constructed using the provided standard frame indices or it is directly pulled from the
FindObjParparameters inpar. The latter takes precedence. If more than one row is provided bystandard_frames, the first index is used.- Parameters:
fitstbl (
pypeit.metadata.PypeItMetaData) – The metadata table for the current reduction.par (
pypeit.par.pypeitpar.PypeItPar) – The parameter set for the current reduction.standard_frames (
list) – List of frame indices infitstblcorresponding to standard star frames.
- Returns:
Full path to the standard spec1d output file to use.
- Return type:
- pypeit.outputfiles.intermediate_filename(itype, basename, det_name, inter_path='Intermediate')[source]
Construct the intermediate file name for a given type and detector
- Parameters:
- Returns:
The full path to the intermediate file
- Return type:
- pypeit.outputfiles.science_path(par)[source]
Constructs the path to the science directory based on the provided parameters.
- Parameters:
par (
PypeItPar) – The parameter set for the reduction, including slitmask and object finding parameters.- Returns:
The full path to the science directory as a Path object.
- Return type:
Path
- pypeit.outputfiles.spec2d_target(spec2d_file)[source]
Read the target name from a spec2d primary header.
- pypeit.outputfiles.spec_output_file(fitstbl, par, frame, twod=False, ext='.fits', sci_path=None)[source]
Return the path to the spectral output data file.
- Parameters:
fitstbl (
pypeit.metadata.PypeItMetaData) – The metadata table for the current reduction.par (
pypeit.par.pypeitpar.PypeItPar) – The parameter set for the current reduction.frame (
int) – Frame index fromfitstbl.twod (
bool) – Name for the 2D output file; 1D file otherwise.ext (
str, optional) – Extension for the output file. Default is ‘.fits’.
- Returns:
The path for the output file
- Return type:
- pypeit.outputfiles.strip_raw_extension(filename, allowed_extensions)[source]
Strip the raw-file extension from a filename.
- Parameters:
filename (str,
Path) – The name of the raw file. Only the file name is used; seePath.name.allowed_extensions (list) – List of recognized raw-file extensions for the relevant spectrograph, used to correctly strip the extension from
filename; seeallowed_extensions.
- Returns:
The file name with the extension removed. If no extension in
allowed_extensionsmatches, a warning is issued and the full input name is returned unmodified.- Return type: