pypeit.core.wavecal.templates module

Module to generate templates for the PypeIt full_template wavelength calibration routine

pypeit.core.wavecal.templates.build_template(in_files, slits, wv_cuts, binspec, outroot, outdir=None, normalize=False, subtract_conti=False, wvspec=None, lowredux=False, ifiles=None, det_cut=None, chk=False, miny=None, overwrite=True, ascii_tbl=False, in_vac=True, shift_wave=False, binning=None, micron=False)[source]

Generate a full_template for a given instrument

Parameters:
  • in_files (list or str) – Wavelength solution files, XIDL or PypeIt If PypeIt, they can be a mix of WaveCalib JSON and FITS files

  • slits (list) – Slits in the archive files to use

  • wv_cuts (list) – Wavelengths to cut each slit at. The elements of the list correspond to the wavelengths where two spectra are stitched together.

  • binspec (int) – Spectral binning of the archived spectrum

  • outroot (str) – Name of output archive

  • outdir (str) – Name of output directory

  • lowredux (bool, optional) – If true, in_files are from LowRedux

  • wvspec (ndarray, optional) – Manually input the wavelength values

  • ifiles (list, optional) – Ordering of the in_files. Default is np.arange(len(in_files))

  • det_cut (dict, optional) – Cut the detector into pieces. Important for long detectors with wavelengths on one side

  • chk (bool, optional) – Show a plot or two

  • miny (float) – Impose a minimum value

  • normalize (bool, optional) – If provided multiple in_files, normalize each snippet to have the same maximum amplitude.

  • subtract_conti (bool, optional) – Subtract the continuum for the final archive

  • ascii_tbl (bool, optional) – Table is a simple ASCII 2 column wave,flux table

  • in_vac (bool, optional) – True if input wavelengths are in vacuum

  • shift_wave (bool, optional) – Shift wavelengths when splicing to sync up precisely (Recommended) Requires PypeIt file (old JSON works for now)

  • binning (list, optional) – Allows for multiple binnings for input files

  • micron (bool, optional) – If True, assume the in_files archive has a solution in microns, so convert this to Angstroms which is the PypeIt convention. Default=False

pypeit.core.wavecal.templates.cheby_val(coeff, x, nrm, order)[source]
pypeit.core.wavecal.templates.fcheby(xnrm, order)[source]
pypeit.core.wavecal.templates.grab_wvlim(kk, wv_cuts, nslits)[source]

Set the wavelength range to cut on

Parameters:
  • kk (int) –

  • wv_cuts (list) –

  • nslits (int) –

Returns:

wv_min, wv_max (float, float)

Return type:

tuple

pypeit.core.wavecal.templates.main(flg)[source]
pypeit.core.wavecal.templates.poly_val(coeff, x, nrm)[source]

IDL style function for polynomial

Parameters:
Returns:

Same shape as x

Return type:

numpy.ndarray

pypeit.core.wavecal.templates.pypeit_arcspec(in_file, slit, binspec, binning=None)[source]

Load up the arc spectrum from an input JSON file

Parameters:
  • in_file (str or pathlib.Path) – File containing the arc spectrum and or fit

  • slit (int) – slit index

Returns:

numpy.ndarray, numpy.ndarray, PypeItFit: wave, flux, pypeitFitting

Return type:

tuple

pypeit.core.wavecal.templates.pypeit_identify_record(iwv_calib, binspec, specname, gratname, dispangl, outdir=None)[source]

From within PypeIt, generate a template file if the user manually identifies an arc spectrum

Parameters:
  • iwv_calib (dict) – Wavelength calibration returned by final_fit

  • binspec (int) – Spectral binning

  • specname (str) – Name of instrument

  • gratname (str) – Name of grating

  • dispangl (str) – Dispersion angle

  • outdir (str, None) – Output directory

pypeit.core.wavecal.templates.read_ascii(tbl_file, in_vac=True)[source]

The columns need to be wave, flux And the data should be monoonically increasing in wavelength

Parameters:
  • tbl_file (str) – file of the table

  • in_vac (bool, optional) – If True, wavelenghts are already in vacuum

Returns:

np.ndarray, np.ndarray of wavelength, flux

Return type:

tuple

pypeit.core.wavecal.templates.xidl_arcspec(xidl_file, slit)[source]

Read an XIDL format solution for a Longslit

Note: These are in air

Parameters:
  • xidl_file (str) – XIDL file

  • slit (int) – The slit in question.

Returns:

  • wave (np.ndarray) – Wavelengths in vacuum for that slit

  • spec (np.ndarray) – Arc spectrum for that slit

pypeit.core.wavecal.templates.xidl_esihires(xidl_file, specbin=1, order_vec=None, log10=True)[source]

Read an XIDL format solution for Keck/HIRES or Keck/ESI

Note: They used air

Parameters:

xidl_file (str) – Keck/HIRES save file

Returns:

np.ndarray, np.ndarray, np.ndarray of orders, wavelength, flux

Return type:

tuple