Skip to content

Commit

Permalink
Update the DV5 reid_arxiv template for LDT/DeVeny
Browse files Browse the repository at this point in the history
Add function in the template-maker file for DV5.

(Update things to pathlib.Path... needed to add a force-str in one of
the other functions.)

	modified:   pypeit/core/wavecal/spectrographs/templ_ldt_deveny.py
	modified:   pypeit/core/wavecal/templates.py
	modified:   pypeit/data/arc_lines/reid_arxiv/ldt_deveny_500_HgCdAr.fits
  • Loading branch information
tbowers7 committed Oct 25, 2023
1 parent 37a8d28 commit 8d9f56a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 15 deletions.
60 changes: 47 additions & 13 deletions pypeit/core/wavecal/spectrographs/templ_ldt_deveny.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
""" Generate the wavelength templates for LDT/DeVeny"""
import os

from pypeit.core.wavecal import templates


# LDT/DeVeny Wavelength Templates stitched together from multiple grating angles
def ldt_deveny_150(overwrite=False):
"""ldt_deveny_150 Template from the DV1 grating (150 g/mm)
"""Template from the DV1 grating (150 g/mm)
Args:
overwrite: bool, optional
Expand All @@ -17,10 +16,10 @@ def ldt_deveny_150(overwrite=False):
outroot = 'ldt_deveny_150_HgCdAr.fits'

# PypeIt fits
wpath = os.path.join(templates.template_path, 'LDT_DeVeny', '150')
wpath = templates.template_path / 'LDT_DeVeny' / '150'

basefiles = ['MasterWaveCalib_A_DV1_7200.fits']
wfiles = [os.path.join(wpath, basefile) for basefile in basefiles]
wfiles = [wpath / basefile for basefile in basefiles]

# Snippets
ifiles = [0]
Expand All @@ -38,7 +37,7 @@ def ldt_deveny_150(overwrite=False):


def ldt_deveny_300(overwrite=False):
"""ldt_deveny_300 Template from the DV2 & DV3 gratings (300 g/mm)
"""Template from the DV2 & DV3 gratings (300 g/mm)
Args:
overwrite: bool, optional
Expand All @@ -49,12 +48,12 @@ def ldt_deveny_300(overwrite=False):
outroot = 'ldt_deveny_300_HgCdAr.fits'

# PypeIt fits
wpath = os.path.join(templates.template_path, 'LDT_DeVeny', '300')
wpath = templates.template_path / 'LDT_DeVeny' / '300'

basefiles = ['MasterWaveCalib_A_DV2_5200.fits',
'MasterWaveCalib_B_DV3_8000.fits',
'MasterWaveCalib_C_DV3_9000.fits']
wfiles = [os.path.join(wpath, basefile) for basefile in basefiles]
wfiles = [wpath / basefile for basefile in basefiles]

# Snippets
ifiles = [0, 1, 2]
Expand All @@ -71,8 +70,42 @@ def ldt_deveny_300(overwrite=False):
shift_wave=True)


def ldt_deveny_500(overwrite=False):
"""Template from the DV5 grating (500 g/mm)
Args:
overwrite: bool, optional
Overwrite the existing file? [Default: False]
"""

binspec = 1
outroot = 'ldt_deveny_500_HgCdAr.fits'
# PypeIt fits
wpath = templates.template_path / 'LDT_DeVeny' / '500'

basefiles = ['WaveCalib_A_DV5_5000.fits',
'WaveCalib_B_DV5_6000.fits',
'WaveCalib_C_DV5_6600.fits',
'WaveCalib_D_DV5_7200.fits']
wfiles = [wpath / basefile for basefile in basefiles]

# Snippets
ifiles = [0, 1, 2, 3]
slits = [120, 241, 241, 241]
wv_cuts = [5900., 6500., 7200.]
assert len(wv_cuts) == len(slits)-1
# det_dict
det_cut = None
#
templates.build_template(wfiles, slits, wv_cuts, binspec, outroot,
ifiles=ifiles, det_cut=det_cut, chk=True,
normalize=True, lowredux=False,
subtract_conti=True, overwrite=overwrite,
shift_wave=True)


def ldt_deveny_600(overwrite=False):
"""ldt_deveny_600 Template from the DV6 & DV7 gratings (600 g/mm)
"""Template from the DV6 & DV7 gratings (600 g/mm)
Args:
overwrite: bool, optional
Expand All @@ -82,13 +115,13 @@ def ldt_deveny_600(overwrite=False):
binspec = 1
outroot = 'ldt_deveny_600_HgCdAr.fits'
# PypeIt fits
wpath = os.path.join(templates.template_path, 'LDT_DeVeny', '600')
wpath = templates.template_path / 'LDT_DeVeny' / '600'

basefiles = ['MasterWaveCalib_D_DV6_4000.fits',
'MasterWaveCalib_E_DV6_5200.fits',
'MasterWaveCalib_F_DV7_7000.fits',
'MasterWaveCalib_G_DV7_8500.fits']
wfiles = [os.path.join(wpath, basefile) for basefile in basefiles]
wfiles = [wpath / basefile for basefile in basefiles]

# Snippets
ifiles = [0, 1, 2, 3]
Expand All @@ -106,7 +139,7 @@ def ldt_deveny_600(overwrite=False):


def ldt_deveny_1200(overwrite=False):
"""ldt_deveny_1200 Template from the DV9 grating (1200 g/mm)
"""Template from the DV9 grating (1200 g/mm)
Args:
overwrite: bool, optional
Expand All @@ -116,13 +149,13 @@ def ldt_deveny_1200(overwrite=False):
binspec = 1
outroot = 'ldt_deveny_1200_HgCdAr.fits'
# PypeIt fits
wpath = os.path.join(templates.template_path, 'LDT_DeVeny', '1200')
wpath = templates.template_path / 'LDT_DeVeny' / '1200'

basefiles = ['MasterWaveCalib_H_DV9_3800.fits',
'MasterWaveCalib_I_DV9_4800.fits',
'MasterWaveCalib_J_DV9_5800.fits',
'MasterWaveCalib_K_DV9_6800.fits']
wfiles = [os.path.join(wpath, basefile) for basefile in basefiles]
wfiles = [wpath / basefile for basefile in basefiles]

# Snippets
ifiles = [0, 1, 2, 3]
Expand All @@ -142,5 +175,6 @@ def ldt_deveny_1200(overwrite=False):
if __name__ == '__main__':
ldt_deveny_150(overwrite=True)
ldt_deveny_300(overwrite=True)
ldt_deveny_500(overwrite=True)
ldt_deveny_600(overwrite=True)
ldt_deveny_1200(overwrite=True)
7 changes: 5 additions & 2 deletions pypeit/core/wavecal/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def pypeit_arcspec(in_file, slit, binspec, binning=None):
Load up the arc spectrum from an input JSON file
Args:
in_file (str):
in_file (str or :obj:`pathlib.Path`):
File containing the arc spectrum and or fit
slit (int):
slit index
Expand All @@ -245,9 +245,12 @@ def pypeit_arcspec(in_file, slit, binspec, binning=None):
tuple: `numpy.ndarray`_, `numpy.ndarray`_, PypeItFit: wave, flux, pypeitFitting
"""
# Enforce `str` type for input file name
in_file = str(in_file)

if '.json' in in_file:
# Force any possible pathlib.Path object to string before `loadjson`
wv_dict = linetools.utils.loadjson(str(in_file))
wv_dict = linetools.utils.loadjson(in_file)
iwv_calib = wv_dict[str(slit)]
pypeitFitting = fitting.PypeItFit(fitc=np.array(iwv_calib['fitc']),
func=iwv_calib['function'],
Expand Down
Binary file modified pypeit/data/arc_lines/reid_arxiv/ldt_deveny_500_HgCdAr.fits
Binary file not shown.

0 comments on commit 8d9f56a

Please sign in to comment.