Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions storm_analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,39 @@
"""
import os
import matplotlib

#
# Headless operation.
#
# Setting STORM_ANALYSIS_HEADLESS in the environment selects a
# non-interactive matplotlib backend, which makes every pyplot.show() in
# the package a no-op. Nothing can then open a window and block, which is
# what you want when running the diagnostics, or anything else, without
# someone sitting there to close the windows.
#
# This has to happen before pyplot is imported, hence its position here.
# Saving figures is not affected, savefig() works the same under Agg.
#
if os.environ.get("STORM_ANALYSIS_HEADLESS"):
matplotlib.use("Agg")

import matplotlib.pyplot as pyplot


class SAException(Exception):
pass


def isHeadless():
"""
Return True if we were asked not to open any plot windows.

Note that this reports the request, not the outcome. matplotlib will
also fall back to a non-interactive backend on its own when there is
no display available.
"""
return bool(os.environ.get("STORM_ANALYSIS_HEADLESS"))

__version__ = "2026.08.30"

# Maybe there is a builtin function that does this??
Expand Down
15 changes: 15 additions & 0 deletions storm_analysis/diagnostics/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ changing (1) and (3) as needed, to test analysis performance with different type
simulated data.


Running without a display:

Some of the analysis these call will open a plot window and wait for you to close
it, which is not what you want when running several diagnostics in a row. Setting

STORM_ANALYSIS_HEADLESS=1

in the environment selects a non-interactive matplotlib backend, so pyplot.show()
does nothing anywhere in the package. Figures that are written to disk, such as the
mapping images from the multicolor diagnostic, are still written.

Note that multiplane/configure.py needs --psf-model, one of psf_fft, pupilfn or
spline. The rest take no arguments.


(Linux) C profiling tools:
1. http://valgrind.org/docs/manual/cl-manual.html
2. http://kcachegrind.sourceforge.net/html/Home.html
Expand Down
4 changes: 3 additions & 1 deletion storm_analysis/diagnostics/frc/analyze_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ def analyzeData():
frc_text = os.path.join(a_dir, "frc.txt")

# Run FRC analysis.
frcCalc2d.frcCalc2d(hdf5, frc_text)
# show_plot defaults to True, and this loops over every test
# directory, so without this it stops on a window each time.
frcCalc2d.frcCalc2d(hdf5, frc_text, show_plot = False)

print()

Expand Down