Skip to content

Commit

Permalink
Merge pull request #1632 from pypeit/hotfix_arxiv_soln
Browse files Browse the repository at this point in the history
Hotfix - arxiv soln
  • Loading branch information
rcooke-ast authored Jul 17, 2023
2 parents 2045e8b + 36af1e6 commit 670eacb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Instrumental FWHM map is calculated and output in ``Calibrations`` and ``spec1d`` files.
- Adds Keck/ESI to PypeIt
- Add MDM/Modspec spectrograph
- Store user-generated wavelength solution in pypeit cache

1.13.0 (2 June 2023)
--------------------
Expand Down
19 changes: 2 additions & 17 deletions pypeit/core/gui/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from pypeit.par import pypeitpar
from pypeit.core.wavecal import wv_fitting, waveio, wvutils
from pypeit import data, msgs
from pypeit import msgs
from astropy.io import ascii as ascii_io
from astropy.table import Table

Expand Down Expand Up @@ -763,22 +763,7 @@ def store_solution(self, final_fit, binspec, rmstol=0.15,
# Instead of a generic name, save the wvarxiv with a unique identifier
date_str = datetime.now().strftime("%Y%m%dT%H%M")
wvarxiv_name = f"wvarxiv_{self.specname}_{date_str}.fits"
wvutils.write_template(wavelengths, self.specdata, binspec,
'./', wvarxiv_name)

# Also copy the file to the cache for direct use
data.write_file_to_cache(wvarxiv_name,
wvarxiv_name,
"arc_lines/reid_arxiv")

msgs.info(f"Your arxiv solution has been written to ./{wvarxiv_name}\n")
msgs.info(f"Your arxiv solution has also been cached.{msgs.newline()}"
f"To utilize this wavelength solution, insert the{msgs.newline()}"
f"following block in your PypeIt Reduction File:{msgs.newline()}"
f" [calibrations]{msgs.newline()}"
f" [[wavelengths]]{msgs.newline()}"
f" reid_arxiv = {wvarxiv_name}{msgs.newline()}"
f" method = full_template\n")
wvutils.write_template(wavelengths, self.specdata, binspec, './', wvarxiv_name, cache=True)

# Write the WVCalib file
outfname = "wvcalib.fits"
Expand Down
23 changes: 20 additions & 3 deletions pypeit/core/wavecal/wvutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from astropy import constants

from pypeit import msgs
from pypeit import utils
from pypeit import utils, data
from pypeit.core import arc
from pypeit.pypmsgs import PypeItError

Expand Down Expand Up @@ -771,7 +771,7 @@ def wavegrid(wave_min, wave_max, dwave, spec_samp_fact=1.0, log10=False):


def write_template(nwwv, nwspec, binspec, outpath, outroot, det_cut=None,
order=None, overwrite=True):
order=None, overwrite=True, cache=False):
"""
Write the template spectrum into a binary FITS table
Expand All @@ -783,14 +783,18 @@ def write_template(nwwv, nwspec, binspec, outpath, outroot, det_cut=None,
binspec (int):
Binning of the template
outpath (str):
Directory to store the wavelength template file
outroot (str):
Filename to use for the template
det_cut (bool, optional):
Cuts in wavelength for detector snippets
Used primarily for DEIMOS
order (`numpy.ndarray`_, optional):
Echelle order numbers
overwrite (bool, optional):
If True, overwrite any existing file
cache (bool, optional):
Store the wavelength solution in the pypeit cache?
"""
tbl = Table()
tbl['wave'] = nwwv
Expand All @@ -809,4 +813,17 @@ def write_template(nwwv, nwspec, binspec, outpath, outroot, det_cut=None,
# Write
outfile = os.path.join(outpath, outroot)
tbl.write(outfile, overwrite=overwrite)
print("Wrote: {}".format(outfile))
msgs.info(f"Your arxiv solution has been written to {outfile}\n")
if cache:
# Also copy the file to the cache for direct use
data.write_file_to_cache(outroot, outroot, "arc_lines/reid_arxiv")

msgs.info(f"Your arxiv solution has also been cached.{msgs.newline()}"
f"To utilize this wavelength solution, insert the{msgs.newline()}"
f"following block in your PypeIt Reduction File:{msgs.newline()}"
f" [calibrations]{msgs.newline()}"
f" [[wavelengths]]{msgs.newline()}"
f" reid_arxiv = {outroot}{msgs.newline()}"
f" method = full_template\n")
print("") # Empty line for clarity
msgs.info("Please consider sharing your solution with the PypeIt Developers.")
10 changes: 1 addition & 9 deletions pypeit/scripts/arxiv_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,4 @@ def main(args):
wave = wv_calib['wv_fits'][args.slit]['wave_soln'].flatten()
spec = wv_calib['wv_fits'][args.slit]['spec'].flatten()
outname = args.file.replace(".fits", "_arXiv.fits")
wvutils.write_template(wave, spec, args.binning, './', outname)
print("") # Empty line for clarity
msgs.info("To include the newly generated solution in the PypeIt archive," + msgs.newline() +
"move (and appropriately rename) the following file: " + msgs.newline() +
outname + msgs.newline() +
"to the following directory:" + msgs.newline() +
"pypeit/data/arc_lines/reid_arxiv/")
print("") # Empty line for clarity
msgs.info("Please also consider sharing your solution with the PypeIt Developers.")
wvutils.write_template(wave, spec, args.binning, './', outname, cache=True)

0 comments on commit 670eacb

Please sign in to comment.