Note
Go to the end to download the full example code or to run this example in your browser via Binder.
Plotting PUNCH data#
How to plot PUNCH data using built-in plotting tools
So you’ve downloaded a PUNCH FITS file, and you want to display it in Python in a simple way. We’ve encapsulated a flexible plotting function within the punchbowl repository that users can use and build on.
First we’ll load a set of libraries. This is minimal, but will provide a sample file to use for plotting, and the plotting function itself.
from punchbowl.data.sample import PUNCH_CAM
from punchbowl.data.visualize import plot_punch
Files Downloaded: 0%| | 0/1 [00:00<?, ?file/s]
PUNCH_L3_CAM_20251022223629_v0h.fits: 0%| | 0.00/18.2M [00:00<?, ?B/s]
PUNCH_L3_CAM_20251022223629_v0h.fits: 0%| | 40.9k/18.2M [00:00<00:49, 370kB/s]
PUNCH_L3_CAM_20251022223629_v0h.fits: 4%|▍ | 768k/18.2M [00:00<00:04, 4.07MB/s]
PUNCH_L3_CAM_20251022223629_v0h.fits: 23%|██▎ | 4.11M/18.2M [00:00<00:00, 16.2MB/s]
PUNCH_L3_CAM_20251022223629_v0h.fits: 51%|█████ | 9.29M/18.2M [00:00<00:00, 29.5MB/s]
PUNCH_L3_CAM_20251022223629_v0h.fits: 80%|████████ | 14.6M/18.2M [00:00<00:00, 37.7MB/s]
Files Downloaded: 100%|██████████| 1/1 [00:00<00:00, 1.13file/s]
Files Downloaded: 100%|██████████| 1/1 [00:00<00:00, 1.13file/s]
Next we’ll plot the data. Note that you can provide as input either a path to a FITS file directly, or alternatively a loaded NDCube object.
plt, ax = plot_punch(PUNCH_CAM)

This is using the default parameters, but the function is flexible to plot in a few different ways. For example, let’s say we want a minimal plot of just the data, but still with some annotation.
plt, ax = plot_punch(PUNCH_CAM, axes_off=True)

For a more complex example let’s bring down the vmax value a bit, relabel the axes, and turn off the colorbar.
plt, ax = plot_punch(PUNCH_CAM, vmax=5e-13, axes_labels=(r'$X_{im}$', r'$Y_{im}$'), colorbar=False)

A variety of other plotting elements and options can be controlled - for full details see the function docstring or ask the SOC.
Total running time of the script: (0 minutes 7.837 seconds)