Skip to content

Commit

Permalink
Merge pull request #1806 from pypeit/setup_gui_v1_01
Browse files Browse the repository at this point in the history
Bug fixes to Setup Gui
  • Loading branch information
badpandabear authored Jun 3, 2024
2 parents f838186 + 53d9586 commit d1d9630
Show file tree
Hide file tree
Showing 11 changed files with 511 additions and 350 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.dev62+g88b471fa0[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
62 changes: 31 additions & 31 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
42 changes: 26 additions & 16 deletions pypeit/scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,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 d1d9630

Please sign in to comment.