Skip to content

Quicklook viewer#2090

Draft
MNBrod wants to merge 104 commits intopypeit:developfrom
MNBrod:quicklook_viewer
Draft

Quicklook viewer#2090
MNBrod wants to merge 104 commits intopypeit:developfrom
MNBrod:quicklook_viewer

Conversation

@MNBrod
Copy link
Copy Markdown
Collaborator

@MNBrod MNBrod commented Mar 14, 2026

Adds a Quicklook GUI to PypeIt.

The changes are mostly isolated to /pypeit/display/ with a few exceptions:

pypeit/logger was changed to fix a bug where repeated invocations of pypeit's logger from the same process would not carry through a user's requested log file. This was a simple "move that block of code up a but" fix.

pypeit/scripts/ql.py was changed to accept manual extraction info as a command line argument, and pass that along appropriately.

pyproject.toml was changed to add the HTTP packages needed to handle a remote backend as optional dependencies (i.e. they are not installed by default).

The overall architecture of the plugin is described in the docstrings of qlview.py and at the bottom of the readthedocs page. Quick overview:

  • ui.py has all the widget stuff
  • state.py has a small struct-like class for keeping GUI state neat
  • file_browser.py has the logic for file sorting/display
  • slit_overlay.py draws slits over raw images and helps with clicking callbacks and the like. It's mostly stolen from show2dspec, but adapted to use Ginga slightly differently.
  • backend.py provides an "abstract" interface for talking to a filesystem and pypeit. There are currently two implementation, a local backend that passes through to whatever machine Ginga is running on, and an HTTP backend that allows PypeIt and the science files to be running on another machine on the network (which will be what Keck uses operationally, eventually). I have not tested the HTTP server much at all, that's on the to-do list.
  • servers has the HTTP server itself in it. This isn't really related to "display" per se, but there's no where else that it seemed to fit in PypeIt.
  • qlview.py has the meat of the plugin
  • display.py was updated to add this plugin. I went for Eric's show1dspec implementation approach

A readthedocs page has been started at pypeit/doc/quicklook_viewer.rst, I will be adding to it over the next few days (filling out sections and providing screenshots). This page was added to the end of the "Reference" section for now, it can be moved somewhere more fitting if someone has a better idea. I tried to be thorough with docstrings, many are Claude generated, but most are mine (Claude's are probably better...).

Items on my to-do list:

I am still making changes to this, but the core of the plugin is basically done and I can get feedback while adding more instruments/fixing minor stuff.

  • Finish the sphinx page
  • Thoroughly test each instrument. So far, I have only extensively used the GUI with longslit and multislit MOSFIRE data, and some DEIMOS. The code for HIRES, NIRES, LRIS R/B, and NIRSPEC is totally AI generated and I have not reviewed it.
  • Remove the Keck specific stuff. All I know about so far is using a "INSTRUME" FITS header to identify what instrument a file came from, that should be an easy enough fix
  • Figure out what tests look like for this. There are no pytest tests at the moment, nor am I sure what the right way to handle that is (especially for testing things like the HTTP server - I can write tests for that easily, but it shouldn't be part of the dev suite, right?)
  • Test the HTTP backend
  • Improve dithering support, right now it handles AB (in a clunky way) and can do a 2dcoadd of two science files, but you can't do more than 2, and it takes forever (fixing that is a bigger pypeit task, but there's some low hanging parallelization stuff there).
  • Better feedback on what's happening behind the scenes. Either a subwindow that lets you tail the log, or watching the log for more keywords and bodging a progress bar out of that.
  • I have some calibration scripts I can add to pypeit, they take the default ql.py and inst ql params and parallelizes it out from there (runs all setups at the same time, and all detectors/mosaics at the same time).

What Feedback I Need:

Generally, if people who are already familiar with PypeIt would be most helpful right now (so that I don't have to disentangle "I wish pypeit did ____" from "I wish the GUI did ____" myself) could play around with the GUI and report bugs/wanted features, that would be great. I would use a multislit dataset from DEIMOS for now - it has the highest density of slits (i.e. most places for it to go wrong) and also yields cleaner outputs than a single IR AB pair will. MOSFIRE is also a reasonable choice.

I have been using this GUI with Keck SAs and observers for a while, so the general shape of things seems OK at the moment.

There was a substantial refactor in February '26, so the commit history beyond that is a bit cluttered, apologies.

Copy link
Copy Markdown
Collaborator

@profxj profxj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks max!

I think my comments/requests are pretty bening
so holler if you think otherwise.

Comment thread doc/quicklook_viewer.rst
#. The Plugin is launched on the right-hand side of the screen. Select your
instrument from the dropdown at the top.
#. In the "Raw Data" table, navigate to where the raw science files are stored.
#. In the "Reduced Calibrations" table, navigate to where the pre-processed
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, this needs some massaging. Or, I should say, the code doesn't work if the user chooses Calibrations directly.

Comment thread doc/quicklook_viewer.rst
#. Pick your calibrations. If PypeIt was able to detect a matching configuration
amongst the calibrations in the directory you selected, it will pre-select it for
you. Then, press "Render Slits" to draw the slits on top of the raw image. Press
"Show Wavelengths" to display wavelength information on top of the raw image (as
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This never enabled for me

Comment thread doc/quicklook_viewer.rst
you hover over the image, the wavelength will be shown in the lower left of the
screen).
#. Select the slit you would like to process either by clicking directly on it,
or selecting it from the drop-down menu next to "Reduce Slit."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on what one should see. I saw one orange trace. It then turned cyan

Comment thread doc/quicklook_viewer.rst
[DEFAULT]
redux_path = /data/redux
raw_path = /data/raw
reduced_path = /data/reduced
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized (late in the game) to set this manually.

If that is the standard move, add that to the HOWTO steps above.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related: should the path be exposed in the
"Reduction Control" section?

Comment thread doc/quicklook_viewer.rst
==================

[PIC HERE: Annotated screenshot labelling the four main UI sections:
instrument selector, Raw Data frame, Reduced Calibrations frame, and
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the fonts for each section be Bold or a different color or something to distinguish them as Section headings?

class LRISBlue(Instrument):
"""Keck LRIS Blue channel — multi-slit, 2-detector mosaic.

Untested!
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not reviewed! :)

@@ -0,0 +1,2608 @@
"""
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I scanned through the entire module but didn't comment; largely because I'm not Ginga plug-in savvy

I will make one plea - in any try/except clause, try to make sure to log the failure in some depth. I'll also note my logging didn't seem to work (it generated 0kb file). But I'm rather sure that was user error

@@ -0,0 +1,303 @@
from __future__ import annotations
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment on what this module is for

-------
None
"""
top = Widgets.VBox()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly sprinkle in a number of Inline comments
thanks!

Comment thread pyproject.toml
"scikit-learn>=1.2",
"IPython>=8.0.0",
"ginga>=5.5.1",
"ginga==5.5.1",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the only ginga allowed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants