Skip to content

script plots#1018

Merged
astrofle merged 8 commits intorelease-1.1from
blocking-plots
Mar 19, 2026
Merged

script plots#1018
astrofle merged 8 commits intorelease-1.1from
blocking-plots

Conversation

@astrofle
Copy link
Copy Markdown
Collaborator

Enable halting a script to bring up a plotter

@astrofle astrofle requested review from etsmit and teuben February 19, 2026 17:58
@astrofle astrofle marked this pull request as ready for review February 19, 2026 17:59
@teuben
Copy link
Copy Markdown
Collaborator

teuben commented Feb 20, 2026

Definitely working better. I have a good test script that emulates the EDGE HI pipeline graphics, but it has a few failing options. Will report back after I confirm if it's a pilot error.

One thing that it still reports:

Not running on IPython and trying to use the ShellGUI may result in unexpected behavior.

@astrofle
Copy link
Copy Markdown
Collaborator Author

Definitely working better. I have a good test script that emulates the EDGE HI pipeline graphics, but it has a few failing options. Will report back after I confirm if it's a pilot error.

One thing that it still reports:

Not running on IPython and trying to use the ShellGUI may result in unexpected behavior.

That is a reminder to you that we don't support Spyder ;)

@teuben
Copy link
Copy Markdown
Collaborator

teuben commented Feb 23, 2026

Definitely working better. I have a good test script that emulates the EDGE HI pipeline graphics, but it has a few failing options. Will report back after I confirm if it's a pilot error.
One thing that it still reports:
Not running on IPython and trying to use the ShellGUI may result in unexpected behavior.

That is a reminder to you that we don't support Spyder ;)

I know, and my complaint about that IPython message was from a script, not via ipython.

On a more "serious" note. We don't have an example script that makes an example of scripting. I do have the edge pipeline script, and I've created a "10 liner" out of this, which will run through this. The features I would recommend we have in such an example pipeline script are:

  • should do dysh and optional matplotlib plotting
  • should run in batch mode (presumably where one creates png's) as well as interactive mode
  • keeps all plots on the screen. so far I had some case where if I killed a window, it would kill others. This was not the case in the plotting infrastructure we had before and I wonder if that's a new feature of the new blocking script.

Should we add such a script to notebooks/developer, or is there another better location?

@teuben
Copy link
Copy Markdown
Collaborator

teuben commented Feb 26, 2026

As i'm using the p.show(block=True) i realized for plt.show() the default is block=True. Is there a reason why you wanted block=False to be the default?

@etsmit
Copy link
Copy Markdown
Collaborator

etsmit commented Mar 4, 2026

I'm not able to use the callbacks in this mode, for example get_selected_regions(). For example, in the use case of

  1. cycle through 10 spectra
  2. for each, plot the spectrum, interactively select good regions, then
  3. auto-take out a 1st order baseline and maybe add it to a buffer for averaging or write it back to disk

This fails because the script gets paused on the plot, where I can select the regions, but in order to get to the next step in the script (ps.baseline(..., include=ps.get_selected_regions())), there is no more ps._plotter to reference.

p.s. I'm putting this down because it's a likely use case for whenever I get around to making a receiver checkout script.

@etsmit
Copy link
Copy Markdown
Collaborator

etsmit commented Mar 4, 2026

See PR 1034 for a potential fix idea.

@astrofle
Copy link
Copy Markdown
Collaborator Author

astrofle commented Mar 4, 2026

As i'm using the p.show(block=True) i realized for plt.show() the default is block=True. Is there a reason why you wanted block=False to be the default?

I was thinking that maybe matplotlib users will be used to calling show, even in the dysh shell, and wanted to avoid blocking unless explicitly requested. We can change it if you think it makes more sense to be 1-to-1 with matplotlib.

@teuben
Copy link
Copy Markdown
Collaborator

teuben commented Mar 5, 2026

I wrote a simple script, mimicking what the edge pipeline does: bring up two dysh plots, and bring up 2 mpl plots. They all 4 stay up, for simple interactions (pan & zoom, measure etc.) and can be killed one by one. It has the --batch option where png's are created and the script should be able run headless.

It works with the current blocking-plots branch.

Since this was a non-trivial thing, I think we should also "advertise" this approach.

You can my final drafted script in https://github.com/teuben/dyshp/blob/main/scripts/fake_plot.py but I have a few simpler versions for mpl and dysh only in that same directory.

Copy link
Copy Markdown
Collaborator

@teuben teuben left a comment

Choose a reason for hiding this comment

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

I think it would still be nice to have block=True the default, as it is in matplotlib.

There are some strange blocking behaviors with mpl i the same script, as I've shown in my fake_plot.py script, but that may also be the peculiar way how I've written the interaction. See comments in that script, it's now a show stopper, more a feature?

etsmit and others added 6 commits March 13, 2026 22:39
@astrofle astrofle changed the base branch from main to release-1.1 March 19, 2026 04:57
@astrofle astrofle merged commit 4fd6f73 into release-1.1 Mar 19, 2026
16 of 18 checks passed
@astrofle astrofle deleted the blocking-plots branch March 19, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants