Animating PUNCH data#

How to animate PUNCH data using built-in plotting tools

First we’ll load a set of libraries. This is minimal, but will give us the tools to query a sample of data to download and animate. Note that for animation, you’ll need a local copy of ffmpeg, which can be installed through tools such as homebrew or conda. Depending on your environment you may also need to install a corresponding python package with a command such as pip install ffmpeg-python. Also note that punchbowl is in active development at the moment. To install the bleeding-edge version, use a command such as pip install git+https://github.com/punch-mission/punchbowl@main.

from sunpy.net import Fido
from sunpy.net import attrs as a

import punchbowl  # Note that this import is needed to register PUNCH fido tools
from punchbowl.data.visualize import animate_punch

Next we’ll query a sample of data to animate. Note that you can modify the time range, the product code, and the data version code. Two useful datasets to visualize are CAM and PAM - level 3 clear and polarized low-noise mosaics.

result = Fido.search(a.Time('2025/10/14 14:30:00', '2025/10/14 17:00:00'),
                     a.punch.ProductCode.ca, # (ca for clear low-noise), or pa for polarized low-noise, etc.
                     a.Instrument.m, # (m for mosaic), or a.Instrument.nfi_4, etc for earlier levels.
                     a.Level.three,
                     a.punch.DataVersion.newest, # or a.punch.DataVersion.zero_j, etc.
                     a.punch.FileType.fits) # or a.punch.FileType.jp2

result
Results from 1 Provider:

5 Results from the PUNCHClient:
QueryResponse length=5
Start TimeEnd TimeLevelProductCodeInstrumentDataVersionSourceProviderFileType
TimeTimestr1str2str1str2str5str4str4
2025-10-14 14:40:00.0002025-10-14 14:40:00.9993CAM0jPUNCHSwRIfits
2025-10-14 15:12:00.0002025-10-14 15:12:00.9993CAM0jPUNCHSwRIfits
2025-10-14 15:44:00.0002025-10-14 15:44:00.9993CAM0jPUNCHSwRIfits
2025-10-14 16:16:00.0002025-10-14 16:16:00.9993CAM0jPUNCHSwRIfits
2025-10-14 16:48:00.0002025-10-14 16:48:00.9993CAM0jPUNCHSwRIfits



The resulting files can then be downloaded. Note that occasionally data access through these tools can be down for maintenance or other issues. To instead query a list of local files you may have on hand, import the glob package into python, and then use a command such as files = glob.glob("path/to/files/*.fits") followed by files.sort().

files = Fido.fetch(result)
Files Downloaded:   0%|          | 0/5 [00:00<?, ?file/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:   0%|          | 0.00/22.7M [00:00<?, ?B/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:   0%|          | 0.00/22.7M [00:00<?, ?B/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:   0%|          | 0.00/22.7M [00:00<?, ?B/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:   2%|▏         | 457k/22.7M [00:00<00:05, 4.43MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:   0%|          | 0.00/22.7M [00:00<?, ?B/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  29%|██▉       | 6.60M/22.7M [00:00<00:00, 37.6MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:   0%|          | 1.02k/22.7M [00:00<1:40:00, 3.78kB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  71%|███████   | 16.1M/22.7M [00:00<00:00, 63.4MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:   0%|          | 1.02k/22.7M [00:00<1:56:26, 3.25kB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:   5%|▍         | 1.03M/22.7M [00:00<00:06, 3.48MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:   6%|▌         | 1.41M/22.7M [00:00<00:04, 4.36MB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  99%|█████████▉| 22.4M/22.7M [00:00<00:00, 52.0MB/s]


Files Downloaded:  20%|██        | 1/5 [00:00<00:02,  1.90file/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  22%|██▏       | 4.90M/22.7M [00:00<00:01, 14.7MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  24%|██▍       | 5.50M/22.7M [00:00<00:01, 15.5MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  40%|████      | 9.09M/22.7M [00:00<00:00, 22.6MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  56%|█████▌    | 12.7M/22.7M [00:00<00:00, 32.6MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  88%|████████▊ | 20.0M/22.7M [00:00<00:00, 44.9MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:   0%|          | 1.02k/22.7M [00:00<3:29:14, 1.81kB/s]





Files Downloaded:  40%|████      | 2/5 [00:00<00:01,  2.47file/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  52%|█████▏    | 11.8M/22.7M [00:00<00:00, 18.1MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:   6%|▌         | 1.34M/22.7M [00:00<00:07, 2.69MB/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:   0%|          | 0.00/22.7M [00:00<?, ?B/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  67%|██████▋   | 15.3M/22.7M [00:00<00:00, 21.9MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  32%|███▏      | 7.24M/22.7M [00:00<00:01, 15.3MB/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:   0%|          | 80.7k/22.7M [00:00<00:31, 708kB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  79%|███████▊  | 17.9M/22.7M [00:01<00:00, 22.6MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  63%|██████▎   | 14.2M/22.7M [00:00<00:00, 28.3MB/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:   4%|▎         | 833k/22.7M [00:00<00:05, 4.27MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  99%|█████████▉| 22.5M/22.7M [00:00<00:00, 42.5MB/s]




Files Downloaded:  60%|██████    | 3/5 [00:01<00:00,  2.55file/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:  15%|█▌        | 3.43M/22.7M [00:00<00:01, 13.6MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  90%|████████▉ | 20.4M/22.7M [00:01<00:00, 17.6MB/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:  46%|████▌     | 10.4M/22.7M [00:00<00:00, 34.8MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits: 100%|█████████▉| 22.6M/22.7M [00:01<00:00, 18.5MB/s]






Files Downloaded:  80%|████████  | 4/5 [00:01<00:00,  3.21file/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:  90%|████████▉ | 20.4M/22.7M [00:00<00:00, 57.7MB/s]



Files Downloaded: 100%|██████████| 5/5 [00:01<00:00,  3.39file/s]

That file list is then passed into the animator function, along with an output filename.

animate_punch(files, output_path="PUNCH_CAM.mp4", axes_off=True, trim_edge=(0.13, 0.68))
  0%|          | 0/5 [00:00<?, ?it/s]
 20%|██        | 1/5 [00:04<00:17,  4.31s/it]
 40%|████      | 2/5 [00:04<00:05,  1.88s/it]
 60%|██████    | 3/5 [00:07<00:04,  2.45s/it]
 80%|████████  | 4/5 [00:07<00:01,  1.57s/it]
100%|██████████| 5/5 [00:10<00:00,  1.98s/it]
100%|██████████| 5/5 [00:10<00:00,  2.11s/it]

Total running time of the script: (0 minutes 14.551 seconds)

Gallery generated by Sphinx-Gallery