Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wave rms refactor #1672

Merged
merged 16 commits into from
Oct 1, 2023
8 changes: 4 additions & 4 deletions pypeit/core/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def fit2darc_global_qa(pypeitFit, nspec, outfile=None):

# Finish
if outfile is not None:
plt.savefig(outfile, dpi=800)
plt.savefig(outfile, dpi=300)
plt.close()
else:
plt.show()
Expand Down Expand Up @@ -291,9 +291,9 @@ def fit2darc_orders_qa(pypeitFit, nspec, outfile=None):

ax1.set_ylabel(r'Res. [pix]')

ax0.text(0.1, 0.9, r'RMS={0:.3f} Pixel'.format(rms_order / np.abs(dwl)), ha="left", va="top",
ax0.text(0.1, 0.8, r'RMS={0:.3f} Pixel'.format(rms_order / np.abs(dwl)), ha="left", va="top",
transform=ax0.transAxes)
ax0.text(0.1, 0.8, r'$\Delta\lambda$={0:.3f} Pixel/$\AA$'.format(np.abs(dwl)), ha="left", va="top",
ax0.text(0.1, 0.9, r'$\Delta\lambda$={0:.3f} $\AA$/Pixel'.format(np.abs(dwl)), ha="left", va="top",
transform=ax0.transAxes)
ax0.get_yaxis().set_label_coords(-0.15, 0.5)

Expand All @@ -311,7 +311,7 @@ def fit2darc_orders_qa(pypeitFit, nspec, outfile=None):

# Finish
if outfile is not None:
plt.savefig(outfile, dpi=800)
plt.savefig(outfile, dpi=200)
plt.close()
else:
plt.show()
Expand Down
552 changes: 309 additions & 243 deletions pypeit/core/wavecal/autoid.py

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions pypeit/par/pypeitpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2507,7 +2507,7 @@ class WavelengthSolutionPar(ParSet):
def __init__(self, reference=None, method=None, echelle=None, ech_nspec_coeff=None, ech_norder_coeff=None, ech_sigrej=None, lamps=None,
sigdetect=None, fwhm=None, fwhm_fromlines=None, fwhm_spat_order=None, fwhm_spec_order=None,
reid_arxiv=None, nreid_min=None, cc_thresh=None, cc_local_thresh=None, nlocal_cc=None,
rms_threshold=None, match_toler=None, func=None, n_first=None, n_final=None,
rms_thresh_frac_fwhm=None, match_toler=None, func=None, n_first=None, n_final=None,
sigrej_first=None, sigrej_final=None, numsearch=None,
nfitpix=None, refframe=None,
nsnippet=None, use_instr_flag=None, wvrng_arxiv=None,
Expand Down Expand Up @@ -2626,12 +2626,13 @@ def __init__(self, reference=None, method=None, echelle=None, ech_nspec_coeff=No
descr['fwhm'] = 'Spectral sampling of the arc lines. This is the FWHM of an arcline in ' \
'binned pixels of the input arc image'

defaults['fwhm_fromlines'] = False
defaults['fwhm_fromlines'] = True
dtypes['fwhm_fromlines'] = bool
descr['fwhm_fromlines'] = 'Estimate spectral resolution in each slit using the arc lines. '\
'If True, the estimated FWHM will override ``fwhm`` only in '\
'the determination of the wavelength solution (`i.e.`, not in '\
'WaveTilts).'
'the determination of the wavelength solution (including the ' \
'calculation of the threshold for the solution RMS, see ' \
'``rms_thresh_frac_fwhm``), but not for the wave tilts calibration.' \

defaults['fwhm_spat_order'] = 0
dtypes['fwhm_spat_order'] = int
Expand Down Expand Up @@ -2698,12 +2699,15 @@ def __init__(self, reference=None, method=None, echelle=None, ech_nspec_coeff=No
'be added to it to make it odd.'

# These are the parameters used for the iterative fitting of the arc lines
defaults['rms_threshold'] = 0.15
dtypes['rms_threshold'] = float
descr['rms_threshold'] = 'Maximum RMS (in binned pixels) for keeping a slit/order solution. ' \
'Used for echelle spectrographs, the \'reidentify\' method, and when re-analyzing a slit with the redo_slits parameter.' \
'In a future PR, we will refactor the code to always scale this threshold off the measured FWHM of the arc lines.'

defaults['rms_thresh_frac_fwhm'] = 0.15
dtypes['rms_thresh_frac_fwhm'] = float
descr['rms_thresh_frac_fwhm'] = 'Maximum RMS (expressed as fraction of the FWHM) for keeping ' \
'a slit/order solution. If ``fwhm_fromlines`` is True, ' \
'FWHM will be computed from the arc lines in each slits ' \
'(the median value among all the slits is used), otherwise ``fwhm`` ' \
'will be used. This parameter is used for the \'holy-grail\', ' \
'\'reidentify\', and \'echelle\' methods and when re-analyzing ' \
'a slit using the ``redo_slits`` parameter. '

defaults['match_toler'] = 2.0
dtypes['match_toler'] = float
Expand Down Expand Up @@ -2785,7 +2789,7 @@ def from_dict(cls, cfg):
'ech_norder_coeff', 'ech_sigrej', 'ech_separate_2d', 'lamps', 'sigdetect',
'fwhm', 'fwhm_fromlines', 'fwhm_spat_order', 'fwhm_spec_order',
'reid_arxiv', 'nreid_min', 'cc_thresh', 'cc_local_thresh',
'nlocal_cc', 'rms_threshold', 'match_toler', 'func', 'n_first','n_final',
'nlocal_cc', 'rms_thresh_frac_fwhm', 'match_toler', 'func', 'n_first','n_final',
'sigrej_first', 'sigrej_final', 'numsearch', 'nfitpix',
'refframe', 'nsnippet', 'use_instr_flag', 'wvrng_arxiv',
'redo_slits', 'qa_log']
Expand Down
4 changes: 2 additions & 2 deletions pypeit/spectrographs/bok_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ def default_pypeit_par(cls):
par['calibrations']['wavelengths']['lamps'] = ['NeI', 'ArI', 'ArII', 'HeI']
# Wavelengths
# 1D wavelength solution
par['calibrations']['wavelengths']['rms_threshold'] = 0.5
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.19
par['calibrations']['wavelengths']['sigdetect'] = 5.
par['calibrations']['wavelengths']['fwhm']= 5.0
par['calibrations']['wavelengths']['fwhm']= 2.6

#par['calibrations']['wavelengths']['n_first'] = 3
#par['calibrations']['wavelengths']['n_final'] = 5
Expand Down
8 changes: 4 additions & 4 deletions pypeit/spectrographs/gemini_flamingos.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ def default_pypeit_par(cls):

# Wavelengths
# 1D wavelength solution with arc lines
par['calibrations']['wavelengths']['rms_threshold'] = 0.5
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.1
par['calibrations']['wavelengths']['sigdetect']=5
par['calibrations']['wavelengths']['fwhm'] = 5
par['calibrations']['wavelengths']['fwhm'] = 5.
par['calibrations']['wavelengths']['n_first']=2
par['calibrations']['wavelengths']['n_final']=4
par['calibrations']['wavelengths']['lamps'] = ['OH_NIRES']
Expand Down Expand Up @@ -276,9 +276,9 @@ def default_pypeit_par(cls):

# Wavelengths
# 1D wavelength solution with arc lines
par['calibrations']['wavelengths']['rms_threshold'] = 1.0
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.05 # this needs to be updated
par['calibrations']['wavelengths']['sigdetect']=3
par['calibrations']['wavelengths']['fwhm'] = 20
par['calibrations']['wavelengths']['fwhm'] = 20 # we don't know this value, no dataset in the repo
par['calibrations']['wavelengths']['n_first']=2
par['calibrations']['wavelengths']['n_final']=4
par['calibrations']['wavelengths']['lamps'] = ['ArI', 'ArII', 'ThAr', 'NeI']
Expand Down
4 changes: 2 additions & 2 deletions pypeit/spectrographs/gemini_gmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ def default_pypeit_par(cls):
par['calibrations']['slitedges']['fit_order'] = 3

# 1D wavelength solution
par['calibrations']['wavelengths']['rms_threshold'] = 0.40 # Might be grating dependent..
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.08 # Might be grating dependent..
par['calibrations']['wavelengths']['fwhm'] = 5.
par['calibrations']['wavelengths']['sigdetect'] = 5. # Doesn't work for reddest chip
par['calibrations']['wavelengths']['lamps'] = ['CuI', 'ArI', 'ArII']
par['calibrations']['wavelengths']['method'] = 'full_template'
Expand Down Expand Up @@ -325,7 +326,6 @@ def config_specific_par(self, scifile, inp_par=None):

# Allow for various binning
binning = parse.parse_binning(self.get_meta_value(headarr, 'binning'))
par['calibrations']['wavelengths']['fwhm_fromlines'] = True

return par

Expand Down
6 changes: 3 additions & 3 deletions pypeit/spectrographs/gemini_gnirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ def config_specific_par(self, scifile, inp_par=None):
par['calibrations']['slitedges']['fit_min_spec_length'] = 0.5

# Wavelengths
par['calibrations']['wavelengths']['rms_threshold'] = 1.0 # Might be grating dependent..
par['calibrations']['wavelengths']['sigdetect'] = 5.0
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.4
par['calibrations']['wavelengths']['sigdetect'] = 10.0
par['calibrations']['wavelengths']['lamps'] = ['OH_GNIRS']
# par['calibrations']['wavelengths']['nonlinear_counts'] = self.detector[0]['nonlinear'] * self.detector[0]['saturation']
par['calibrations']['wavelengths']['n_first'] = 2
Expand Down Expand Up @@ -354,7 +354,7 @@ def config_specific_par(self, scifile, inp_par=None):
par['calibrations']['slitedges']['sync_predict'] = 'nearest'

# Wavelengths
par['calibrations']['wavelengths']['rms_threshold'] = 1.0 # Might be grating dependent..
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.05
par['calibrations']['wavelengths']['sigdetect'] = 5.0
par['calibrations']['wavelengths']['lamps'] = ['Ar_IR_GNIRS']
# par['calibrations']['wavelengths']['nonlinear_counts'] = self.detector[0]['nonlinear'] * self.detector[0]['saturation']
Expand Down
1 change: 0 additions & 1 deletion pypeit/spectrographs/keck_deimos.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ def config_specific_par(self, scifile, inp_par=None):
# Wavelength FWHM
binning = parse.parse_binning(self.get_meta_value(headarr, 'binning'))
par['calibrations']['wavelengths']['fwhm'] = 6.0 / binning[1]
par['calibrations']['wavelengths']['fwhm_fromlines'] = True

# Objects FWHM
# Find objects
Expand Down
3 changes: 1 addition & 2 deletions pypeit/spectrographs/keck_esi.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ def default_pypeit_par(cls):
# Wavelengths
# 1D wavelength solution
# This is for 1x1
par['calibrations']['wavelengths']['rms_threshold'] = 0.30
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.103
par['calibrations']['wavelengths']['fwhm'] = 2.9
par['calibrations']['wavelengths']['fwhm_fromlines'] = True
#
par['calibrations']['wavelengths']['sigdetect'] = 5.0
par['calibrations']['wavelengths']['lamps'] = ['CuI', 'ArI', 'NeI', 'HgI', 'XeI', 'ArII']
Expand Down
2 changes: 1 addition & 1 deletion pypeit/spectrographs/keck_hires.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def default_pypeit_par(cls):
# 1D wavelength solution
par['calibrations']['wavelengths']['lamps'] = ['ThAr']
# This is for 1x1 binning. TODO GET BINNING SORTED OUT!!
par['calibrations']['wavelengths']['rms_threshold'] = 0.50
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.1
par['calibrations']['wavelengths']['sigdetect'] = 5.0
par['calibrations']['wavelengths']['n_final'] = 4 #[3] + 13 * [4] + [3]
# This is for 1x1 binning. Needs to be divided by binning for binned data!!
Expand Down
5 changes: 2 additions & 3 deletions pypeit/spectrographs/keck_lris.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def default_pypeit_par(cls):
# Remove slits that are too short
par['calibrations']['slitedges']['minimum_slit_length'] = 3.
# 1D wavelengths
par['calibrations']['wavelengths']['rms_threshold'] = 0.20 # Might be grism dependent
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.05 # Might be grism dependent
# Set the default exposure time ranges for the frame typing
par['calibrations']['biasframe']['exprng'] = [None, 0.001]
par['calibrations']['darkframe']['exprng'] = [999999, None] # No dark frames
Expand Down Expand Up @@ -136,7 +136,6 @@ def config_specific_par(self, scifile, inp_par=None):
# Wave FWHM
binning = parse.parse_binning(self.get_meta_value(scifile, 'binning'))
par['calibrations']['wavelengths']['fwhm'] = 8.0 / binning[0]
par['calibrations']['wavelengths']['fwhm_fromlines'] = True
# Arc lamps list from header
par['calibrations']['wavelengths']['lamps'] = ['use_header']

Expand Down Expand Up @@ -843,7 +842,7 @@ def default_pypeit_par(cls):
par['calibrations']['slitedges']['fit_min_spec_length'] = 0.2

# 1D wavelength solution -- Additional parameters are grism dependent
par['calibrations']['wavelengths']['rms_threshold'] = 0.20 # Might be grism dependent..
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.06 # Might be grism dependent..
par['calibrations']['wavelengths']['sigdetect'] = 10.0

#par['calibrations']['wavelengths']['nonlinear_counts'] = self.detector[0]['nonlinear'] * self.detector[0]['saturation']
Expand Down
4 changes: 1 addition & 3 deletions pypeit/spectrographs/keck_mosfire.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def default_pypeit_par(cls):

# Wavelengths
# 1D wavelength solution
par['calibrations']['wavelengths']['rms_threshold'] = 0.30 #0.20 # Might be grating dependent..
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.11 #0.20 # Might be grating dependent..
par['calibrations']['wavelengths']['sigdetect']=5.0
par['calibrations']['wavelengths']['fwhm']= 5.0
par['calibrations']['wavelengths']['n_final']= 4
Expand Down Expand Up @@ -210,7 +210,6 @@ def config_specific_par(self, scifile, inp_par=None):
# using OH lines
if 'long2pos_specphot' not in decker and filter in supported_filters:
par['calibrations']['wavelengths']['method'] = 'full_template'
par['calibrations']['wavelengths']['fwhm_fromlines'] = True
par['calibrations']['wavelengths']['sigdetect'] = 10.
# templates
if filter == 'Y':
Expand All @@ -233,7 +232,6 @@ def config_specific_par(self, scifile, inp_par=None):
elif 'long2pos_specphot' in decker and filter in supported_filters:
par['calibrations']['wavelengths']['lamps'] = ['Ar_IR_MOSFIRE', 'Ne_IR_MOSFIRE']
par['calibrations']['wavelengths']['method'] = 'full_template'
par['calibrations']['wavelengths']['fwhm_fromlines'] = True
# templates
if filter == 'Y':
par['calibrations']['wavelengths']['reid_arxiv'] = 'keck_mosfire_arcs_Y.fits'
Expand Down
3 changes: 1 addition & 2 deletions pypeit/spectrographs/keck_nires.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ def default_pypeit_par(cls):

# Wavelengths
# 1D wavelength solution
par['calibrations']['wavelengths']['rms_threshold'] = 0.30
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.136
par['calibrations']['wavelengths']['sigdetect']=5.0
par['calibrations']['wavelengths']['fwhm']= 2.2 # Measured
par['calibrations']['wavelengths']['fwhm_fromlines'] = True
par['calibrations']['wavelengths']['n_final']= [3,4,4,4,4]
par['calibrations']['wavelengths']['lamps'] = ['OH_NIRES']
#par['calibrations']['wavelengths']['nonlinear_counts'] = self.detector[0]['nonlinear'] * self.detector[0]['saturation']
Expand Down
4 changes: 2 additions & 2 deletions pypeit/spectrographs/keck_nirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def default_pypeit_par(cls):

# Wavelengths
# 1D wavelength solution
par['calibrations']['wavelengths']['rms_threshold'] = 0.20 #0.20 # Might be grating dependent..
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.06 #0.20 # Might be grating dependent..
par['calibrations']['wavelengths']['sigdetect']=5.0
par['calibrations']['wavelengths']['fwhm']= 5.0
par['calibrations']['wavelengths']['fwhm']= 3.5
par['calibrations']['wavelengths']['n_final']= 4
par['calibrations']['wavelengths']['lamps'] = ['OH_NIRES']
#par['calibrations']['wavelengths']['nonlinear_counts'] = self.detector[0]['nonlinear'] * self.detector[0]['saturation']
Expand Down
8 changes: 3 additions & 5 deletions pypeit/spectrographs/lbt_luci.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,9 @@ def default_pypeit_par(cls):

# Wavelengths
# 1D wavelength solution
par['calibrations']['wavelengths'][
'rms_threshold'] = 0.20 # 0.20 # Might be grating dependent..
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.05 # 0.20 # Might be grating dependent..
par['calibrations']['wavelengths']['sigdetect'] = 5.0
par['calibrations']['wavelengths']['fwhm'] = 5.0
par['calibrations']['wavelengths']['fwhm'] = 4.5
par['calibrations']['wavelengths']['n_final'] = 4
par['calibrations']['wavelengths']['lamps'] = ['OH_NIRES']
#par['calibrations']['wavelengths']['nonlinear_counts'] = \
Expand Down Expand Up @@ -444,8 +443,7 @@ def default_pypeit_par(cls):

# Wavelengths
# 1D wavelength solution
par['calibrations']['wavelengths'][
'rms_threshold'] = 0.20 # 0.20 # Might be grating dependent..
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.04 # 0.20 # Might be grating dependent..
par['calibrations']['wavelengths']['sigdetect'] = 5.0
par['calibrations']['wavelengths']['fwhm'] = 5.0
par['calibrations']['wavelengths']['n_final'] = 4
Expand Down
8 changes: 4 additions & 4 deletions pypeit/spectrographs/lbt_mods.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def default_pypeit_par(cls):

# 1D wavelength solution
par['calibrations']['wavelengths']['sigdetect'] = 5.
par['calibrations']['wavelengths']['rms_threshold'] = 0.4
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.09
par['calibrations']['wavelengths']['fwhm'] = 10.
#par['calibrations']['wavelengths']['lamps'] = ['XeI','ArII','ArI','NeI','KrI']]
par['calibrations']['wavelengths']['lamps'] = ['ArI','NeI','KrI','XeI']
Expand Down Expand Up @@ -488,7 +488,7 @@ def default_pypeit_par(cls):

# 1D wavelength solution
par['calibrations']['wavelengths']['sigdetect'] = 10.
par['calibrations']['wavelengths']['rms_threshold'] = 0.4
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.09
par['calibrations']['wavelengths']['lamps'] = ['XeI','KrI','ArI','HgI']

# slit
Expand Down Expand Up @@ -645,7 +645,7 @@ def default_pypeit_par(cls):

# 1D wavelength solution
par['calibrations']['wavelengths']['sigdetect'] = 5.
par['calibrations']['wavelengths']['rms_threshold'] = 1.0
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.22
par['calibrations']['wavelengths']['fwhm'] = 10.
#par['calibrations']['wavelengths']['lamps'] = ['XeI','ArII','ArI','NeI','KrI']]
par['calibrations']['wavelengths']['lamps'] = ['ArI','NeI','KrI','XeI']
Expand Down Expand Up @@ -807,7 +807,7 @@ def default_pypeit_par(cls):

# 1D wavelength solution
par['calibrations']['wavelengths']['sigdetect'] = 10.
par['calibrations']['wavelengths']['rms_threshold'] = 0.4
par['calibrations']['wavelengths']['rms_thresh_frac_fwhm'] = 0.09
par['calibrations']['wavelengths']['lamps'] = ['XeI','KrI','ArI','HgI']

# slit
Expand Down
Loading