Skip to content

Commit

Permalink
Merge branch 'develop' into nirspec
Browse files Browse the repository at this point in the history
  • Loading branch information
kbwestfall committed Jun 3, 2024
2 parents d3b7929 + d1d9630 commit 57d66fd
Show file tree
Hide file tree
Showing 18 changed files with 830 additions and 625 deletions.
2 changes: 1 addition & 1 deletion doc/help/run_pypeit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
usage: run_pypeit [-h] [-v VERBOSITY] [-r REDUX_PATH] [-m] [-s] [-o] [-c]
pypeit_file
## [1;37;42mPypeIt : The Python Spectroscopic Data Reduction Pipeline v1.15.1.dev151+g015ee23ce.d20240423[0m
## [1;37;42mPypeIt : The Python Spectroscopic Data Reduction Pipeline v1.15.1.dev192+gf7d381a4b.d20240516[0m
##
## Available spectrographs include:
## bok_bc, gemini_flamingos1, gemini_flamingos2, gemini_gmos_north_e2v,
Expand Down
236 changes: 118 additions & 118 deletions doc/include/calspec_table.rst

Large diffs are not rendered by default.

78 changes: 39 additions & 39 deletions doc/pypeit_par.rst

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pypeit/core/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def fit2darc(all_wv,all_pix,all_orders,nspec, nspec_coeff=4,norder_coeff=4,sigre
utils.pyplot_rcparams()
plt.figure(figsize=(7,5))
msgs.info("Plot identified lines")
cm = plt.cm.get_cmap('RdYlBu_r')
cm = plt.get_cmap('RdYlBu_r')
sc = plt.scatter(all_orders, all_pix,c=all_wv/10000., cmap=cm)
cbar = plt.colorbar(sc)
cbar.set_label(r'Wavelength [$\mu$m]', rotation=270,
Expand Down
4 changes: 2 additions & 2 deletions pypeit/core/tracewave.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
from scipy import interpolate, ndimage
from matplotlib import pyplot as plt
from matplotlib import cm, lines
from matplotlib import lines, colormaps

from IPython import embed

Expand Down Expand Up @@ -1061,7 +1061,7 @@ def arc_tilts_spat_qa(tilts_dspat, tilts, tilts_model, tilts_spec_fit, tot_mask,
# Show the fit residuals as a function of spatial position
line_indx = np.outer(np.ones(nspat), np.arange(nuse))
lines_spec = tilts_spec_fit[0, :]
cmap = cm.get_cmap('coolwarm', nuse)
cmap = colormaps['coolwarm'].resampled(nuse)

fig, ax = plt.subplots(figsize=(14, 12))
# dummy mappable shows the spectral pixel
Expand Down
6 changes: 6 additions & 0 deletions pypeit/core/wavecal/wvutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ def get_wave_grid(waves=None, gpms=None, wave_method='linear', iref=0, wave_grid
elif wave_method == 'iref': # Use the iref index wavelength array
wave_tmp = waves[iref]
wave_grid = wave_tmp[wave_tmp > 1.0]
if spec_samp_fact != 1: # adjust sampling via internal interpolation
nwave = len(wave_grid)
indx = np.arange(nwave)
indx_new = np.linspace(0,nwave-1,int(nwave/spec_samp_fact))
wave_tmp = np.interp(indx_new,indx,wave_grid)
wave_grid = wave_tmp

else:
msgs.error("Bad method for wavelength grid: {:s}".format(wave_method))
Expand Down
234 changes: 118 additions & 116 deletions pypeit/data/standards/calspec/calspec_info.txt

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions pypeit/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _vet_instrument(self, meta_tbl):
msgs.warn(f'More than one instrument in your dataset! {instr_names} \n'
'Proceed with great caution...')
# Check the name
if instr_names[0] != self.spectrograph.header_name:
if not instr_names[0].startswith(self.spectrograph.header_name):
msgs.warn('The instrument name in the headers of the raw files does not match the '
f'expected one! Found {instr_names[0]}, expected {self.spectrograph.header_name}. '
'You may have chosen the wrong PypeIt spectrograph name!')
Expand Down Expand Up @@ -857,7 +857,7 @@ def set_configurations(self, configs=None, force=False, fill=None):
mod_cfg = self.spectrograph.modify_config(self.table[i], cfg)
this_cfg = self.get_configuration(i, modified=True)
if self.spectrograph.same_configuration([this_cfg, mod_cfg], check_keys=False):
if d in self.table['setup'][i]:
if d in self.table['setup'][i].split(','):
continue
elif self.table['setup'][i] == 'None':
self.table['setup'][i] = d
Expand All @@ -882,7 +882,7 @@ def set_configurations(self, configs=None, force=False, fill=None):
# For each configuration, determine if any of the frames with
# the ignored frame types should be assigned to it:
for cfg_key in _configs.keys():
in_cfg = np.array([cfg_key in _setup for _setup in self.table['setup']])
in_cfg = np.array([cfg_key in _setup.split(',') for _setup in self.table['setup']])
for ftype, metakey in ignore_frames.items():

# TODO: For now, use this assert to check that the
Expand Down Expand Up @@ -937,7 +937,7 @@ def set_configurations(self, configs=None, force=False, fill=None):
# assign
new_cfg_key = np.full(len(self.table['setup'][indx]), 'None', dtype=object)
for c in range(len(self.table['setup'][indx])):
if cfg_key in self.table['setup'][indx][c]:
if cfg_key in self.table['setup'][indx][c].split(','):
new_cfg_key[c] = self.table['setup'][indx][c]
elif self.table['setup'][indx][c] == 'None':
new_cfg_key[c] = cfg_key
Expand Down Expand Up @@ -1168,7 +1168,7 @@ def set_calibration_groups(self, global_frames=None, default=False, force=False)
# any changes to the strings will be truncated at 4 characters.
self.table['calib'] = np.full(len(self), 'None', dtype=object)
for i in range(n_cfg):
in_cfg = np.array([configs[i] in _set for _set in self.table['setup']]) # & (self['framebit'] > 0)
in_cfg = np.array([configs[i] in _set.split(',') for _set in self.table['setup']]) # & (self['framebit'] > 0)
if not any(in_cfg):
continue
icalibs = np.full(len(self['calib'][in_cfg]), 'None', dtype=object)
Expand Down Expand Up @@ -1638,7 +1638,7 @@ def write_sorted(self, ofile, overwrite=True, ignore=None,
ff = open(_ofile, 'w')
for setup in cfgs.keys():
# Get the subtable of frames taken in this configuration
indx = np.array([setup in _set for _set in self['setup']])
indx = np.array([setup in _set.split(',') for _set in self['setup']])
if not np.any(indx):
continue
subtbl = self.table[output_cols][indx]
Expand Down Expand Up @@ -1772,7 +1772,7 @@ def write_pypeit(self, output_path=None, cfg_lines=None,
setup_dict[f'Setup {setup}'][key] = cfg[setup][key]

# Get the paths
in_cfg = np.array([setup in _set for _set in self.table['setup']])
in_cfg = np.array([setup in _set.split(',') for _set in self.table['setup']])
if not np.any(in_cfg):
continue
paths = np.unique(self['directory'][in_cfg]).tolist()
Expand Down
42 changes: 26 additions & 16 deletions pypeit/scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,35 @@ def main(args):
msgs.set_logfile_and_verbosity('setup', args.verbosity)

if args.spectrograph is None:
raise IOError('spectrograph is a required argument. Use the -s, --spectrograph '
'command-line option.')

# Check that input spectrograph is supported
if args.spectrograph not in available_spectrographs:
raise ValueError(f'Instrument "{args.spectrograph}" unknown to PypeIt.\n'
f'\tOptions are: {", ".join(available_spectrographs)}\n'
'\tSelect an available instrument or consult the documentation '
'on how to add a new instrument.')
if args.gui is False:
raise IOError('spectrograph is a required argument. Use the -s, --spectrograph '
'command-line option.')
else:
# Check that input spectrograph is supported
if args.spectrograph not in available_spectrographs:
raise ValueError(f'Instrument "{args.spectrograph}" unknown to PypeIt.\n'
f'\tOptions are: {", ".join(available_spectrographs)}\n'
'\tSelect an available instrument or consult the documentation '
'on how to add a new instrument.')

if args.gui:
from pypeit.scripts.setup_gui import SetupGUI
if isinstance(args.root,list):
root_args = args.root
else:
# If the root argument is a single string, convert it to a lsit.
# This can happen when the default for --root is used
root_args = [args.root]
gui_args = SetupGUI.parse_args(["-s", args.spectrograph, "-e", args.extension, "-r", *root_args])
# Build up arguments to the GUI
setup_gui_argv = ["-e", args.extension]
if args.spectrograph is not None:
setup_gui_argv += ["-s", args.spectrograph]

# Pass root but only if there's a spectrograph, because
# root has a default value but can't be acted upon by the GUI
# without a spectrograph.
if isinstance(args.root,list):
root_args = args.root
else:
# If the root argument is a single string, convert it to a list.
# This can happen when the default for --root is used
root_args = [args.root]
setup_gui_argv += ["-r"] + root_args
gui_args = SetupGUI.parse_args(setup_gui_argv)
SetupGUI.main(gui_args)

# Initialize PypeItSetup based on the arguments
Expand Down
8 changes: 2 additions & 6 deletions pypeit/scripts/setup_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

from pypeit.scripts import scriptbase
from pypeit.setup_gui.controller import SetupGUIController
from pypeit.setup_gui import model

from pypeit.spectrographs import available_spectrographs
class SetupGUI(scriptbase.ScriptBase):

@classmethod
Expand All @@ -21,7 +20,7 @@ def get_parser(cls, width=None):
width=width)
parser.add_argument('-s', '--spectrograph', default=None, type=str,
help='A valid spectrograph identifier: {0}'.format(
', '.join(model.available_spectrographs())))
', '.join(available_spectrographs)))
parser.add_argument('-r', '--root', default=[], type=str,nargs='+',
help='Root to search for data files. You can provide the top-level '
'directory (e.g., /data/Kast) or the search string up through '
Expand Down Expand Up @@ -54,6 +53,3 @@ def main(combined_args):
app = QApplication(qt_args)
controller = SetupGUIController(args)
controller.start(app)

if __name__ == '__main__':
SetupGUI.entry_point()
Loading

0 comments on commit 57d66fd

Please sign in to comment.