Fluxing

Overview

Fluxing is done after the main run of PypeIt using a separate input file modeled after the PypeIt file. This file sets the main parameters of the run and guides the process. See Example File for a complete example file.

The top of the file sets fluxing parameters. The spectrograph must always be set:

[rdx]
  spectrograph = vlt_fors2

See the FluxCalib ParSet documentation for other parameters that guide generation of the sensitivity function or the fluxing operation.

WARNING: The code only allows for a select set of Standard Stars.

Sensitivity Function

If you wish to generate a sensitivity function from an input standard star file, then you need to set std_file and sensfunc:

[fluxcalib]
   std_file = spec1d_STD_vlt_fors2_2018Dec04T004939.578.fits
   sensfunc = bpm16274_fors2.fits

The former specifies the spec1d spectrum file produced by PypeIt for the standard star. The latter specifies the output file name, which will be overwritten if need be.

Fluxing

To flux one or more spec1d files, generate a flux read, e.g.:

flux read
  spec1d_UnknownFRBHostY_vlt_fors2_2018Dec05T020241.687.fits FRB181112_fors2_1.fits
  spec1d_UnknownFRBHostY_vlt_fors2_2018Dec05T021815.356.fits FRB181112_fors2_2.fits
  spec1d_UnknownFRBHostY_vlt_fors2_2018Dec05T023349.816.fits FRB181112_fors2_3.fits
flux end

The first entry of each row is the spec1d file to be fluxed and the second provides the output filename. One separates the two entries by a single space!

Flux Spec Script

It may be preferential to flux the spectra after the main reduction (i.e. run_pypeit). PypeIt provides a script to guide the process. Here is the usage:

pypeit_flux_spec FRB181112.flux -h
usage: pypeit_flux_spec [-h] [--debug] [--plot] [--par_outfile] flux_file

Parse

positional arguments:
  flux_file      File to guide fluxing process

optional arguments:
  -h, --help     show this help message and exit
  --debug        show debug plots?
  --plot         Show the sensitivity function?
  --par_outfile  Output to save the parameters

The parameters used to guide the process are written to par_outfile (default = fluxing.par) and –plot will generate a simple plot of the sensitivity function.

FluxSpec Class

The guts of the flux algorithms are guided by the FluxSpec class. See the FluxSpec.ipynb Notebook on GitHub (in doc/nb) for some usage examples, although we recommend that most users use the Flux Spec Script.

Example File

Here is a complete example file:

# User-defined fluxing parameters
[rdx]
   spectrograph = vlt_fors2
[fluxcalib]
   balm_mask_wid = 12.
   #std_file = spec1d_STD_vlt_fors2_2018Dec04T004939.578.fits
   sensfunc = bpm16274_fors2.fits

flux read
  spec1d_UnknownFRBHostY_vlt_fors2_2018Dec05T020241.687.fits FRB181112_fors2_1.fits
  spec1d_UnknownFRBHostY_vlt_fors2_2018Dec05T021815.356.fits FRB181112_fors2_2.fits
  spec1d_UnknownFRBHostY_vlt_fors2_2018Dec05T023349.816.fits FRB181112_fors2_3.fits
flux end

Note the std_file is commented out to avoid remaking the sensitivity function.

Sensitivity Function

PypeIt uses the CALSPEC calibration database, which can be found at http://stsci.edu/hst/observatory/crds/calspec.html for flux calibrations, specifically, generating the sensitivity function (see also Standard Stars).

The sensitivity function is generated by dividing the standard star’s flux, which is loaded in by PypeIt from CALSPEC, by the standard star’s counts per second. This is then multiplied to the science object’s counts per second to yield a fluxed science spectrum.

The sensitivity function is written to disk as a YAML file in the MasterFrames folder with prefix MasterSensFunc. There is only one file per setup (not per detector). If one has a previous file, this can be placed in the MasterFrames folder to be loaded (one must turn on MasterFrame usage, e.g. with the -m flag on run_pypeit).

Fluxing Output

Science

The resulting fluxed science spectrum, \(\rm f_\lambda\), is given in units of \(10^{-17}\,\rm ergs/s/cm^2/Angstrom\) and is stored in the ‘box_flam’ extension of the extracted 1D spectrum. If an optimal extraction was successful, there also exists an ‘opt_flam’ extension in the 1D spectrum.

Standard

The 1D extracted standard spectrum is also saved as an output of the fluxing routine. The counts and fluxed standard spectrum are available in the ‘box_counts’ and ‘box_flam’ extensions, respectively. The fluxed spectrum saved here is the fluxed standard, using the sensitivity function generated from itself (rather than the archived fluxed standard star loaded from CALSPEC), and can be examined and compared to the expected \(\rm f_\lambda\) as a sanity check.

Troubleshooting

Problem with bspline knot

Things sometimes go wrong the fluxing and it commonly has to do with the bspline algorithm. If you reach a stop in the code with a message that says “Problem with bspline knot” there are a couple things to check:

  • There are instances where there isn’t data between the knots. You can change the knot spacing by including the following in your .pypeit file under the Reduce block:

    reduce skysub bspline everyn NUM
    

    where you adjust NUM.

  • If your observation of the standard star is taken with a setup that goes beyond the wavelength range of the version in data/standards/calspec.

  • If the wavelength solution is really bad it can manifest as problem in bspline knot. If the issue isn’t the spacing or wavelength coverage check the QA files to see if there is an issue in the wavelength solution. If this is the case, check the Wavelength Calibration page for Troubleshooting or open an issue on the GitHub repo.