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_20251014151200_v0j.fits:   0%|          | 0.00/22.7M [00:00<?, ?B/s]



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

PUNCH_L3_CAM_20251014144000_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_20251014161600_v0j.fits:   0%|          | 0.00/22.7M [00:00<?, ?B/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:   0%|          | 1.02k/22.7M [00:01<8:51:20, 712B/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:   2%|▏         | 433k/22.7M [00:01<00:57, 390kB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:   0%|          | 1.02k/22.7M [00:01<9:45:18, 646B/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:  12%|█▏        | 2.70M/22.7M [00:01<00:06, 2.93MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:   4%|▍         | 952k/22.7M [00:01<00:27, 787kB/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:  25%|██▌       | 5.72M/22.7M [00:01<00:02, 6.72MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  12%|█▏        | 2.78M/22.7M [00:01<00:07, 2.63MB/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:  45%|████▍     | 10.1M/22.7M [00:01<00:00, 12.9MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  20%|██        | 4.62M/22.7M [00:01<00:03, 4.69MB/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:  58%|█████▊    | 13.2M/22.7M [00:01<00:00, 16.2MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  34%|███▍      | 7.67M/22.7M [00:01<00:01, 8.73MB/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:  71%|███████   | 16.2M/22.7M [00:02<00:00, 19.1MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  44%|████▍     | 10.1M/22.7M [00:02<00:01, 11.6MB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:   0%|          | 1.02k/22.7M [00:02<12:39:03, 498B/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:   0%|          | 1.02k/22.7M [00:02<12:43:03, 496B/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  55%|█████▍    | 12.4M/22.7M [00:02<00:00, 13.9MB/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:  84%|████████▍ | 19.1M/22.7M [00:02<00:00, 18.6MB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:   2%|▏         | 440k/22.7M [00:02<01:17, 286kB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:   1%|          | 257k/22.7M [00:02<02:15, 166kB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  64%|██████▍   | 14.6M/22.7M [00:02<00:00, 15.7MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:   0%|          | 1.02k/22.7M [00:02<13:38:14, 463B/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:   7%|▋         | 1.60M/22.7M [00:02<00:16, 1.25MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:   4%|▍         | 872k/22.7M [00:02<00:33, 661kB/s]


PUNCH_L3_CAM_20251014151200_v0j.fits:  95%|█████████▌| 21.6M/22.7M [00:02<00:00, 16.4MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  74%|███████▍  | 16.7M/22.7M [00:02<00:00, 15.9MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:   1%|          | 233k/22.7M [00:02<02:40, 140kB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  16%|█▋        | 3.70M/22.7M [00:02<00:05, 3.38MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:   9%|▉         | 2.08M/22.7M [00:02<00:11, 1.87MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:   6%|▌         | 1.26M/22.7M [00:02<00:22, 944kB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  27%|██▋       | 6.13M/22.7M [00:02<00:02, 6.17MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  83%|████████▎ | 18.7M/22.7M [00:02<00:00, 15.3MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  14%|█▍        | 3.18M/22.7M [00:02<00:06, 3.07MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  14%|█▎        | 3.10M/22.7M [00:02<00:07, 2.70MB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  37%|███▋      | 8.34M/22.7M [00:02<00:01, 8.73MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  18%|█▊        | 4.16M/22.7M [00:02<00:04, 4.12MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  23%|██▎       | 5.30M/22.7M [00:02<00:03, 5.12MB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  45%|████▌     | 10.3M/22.7M [00:02<00:01, 10.5MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  24%|██▎       | 5.35M/22.7M [00:02<00:03, 5.55MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  91%|█████████ | 20.6M/22.7M [00:02<00:00, 11.3MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  36%|███▌      | 8.18M/22.7M [00:02<00:01, 8.65MB/s]




PUNCH_L3_CAM_20251014144000_v0j.fits:  53%|█████▎    | 12.1M/22.7M [00:02<00:00, 12.1MB/s]
Files Downloaded:  20%|██        | 1/5 [00:04<00:16,  4.09s/file]





PUNCH_L3_CAM_20251014164800_v0j.fits:  28%|██▊       | 6.36M/22.7M [00:02<00:02, 6.48MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  47%|████▋     | 10.7M/22.7M [00:02<00:01, 11.5MB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  62%|██████▏   | 14.0M/22.7M [00:02<00:00, 13.5MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  32%|███▏      | 7.38M/22.7M [00:02<00:02, 7.21MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  63%|██████▎   | 14.2M/22.7M [00:02<00:00, 16.3MB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  70%|███████   | 16.0M/22.7M [00:02<00:00, 14.9MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  38%|███▊      | 8.62M/22.7M [00:03<00:01, 8.48MB/s]



PUNCH_L3_CAM_20251014154400_v0j.fits:  97%|█████████▋| 22.0M/22.7M [00:03<00:00, 8.65MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  74%|███████▍  | 16.8M/22.7M [00:03<00:00, 18.4MB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  78%|███████▊  | 17.8M/22.7M [00:03<00:00, 14.7MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  45%|████▍     | 10.2M/22.7M [00:03<00:01, 10.3MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  85%|████████▌ | 19.4M/22.7M [00:03<00:00, 18.4MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  53%|█████▎    | 12.0M/22.7M [00:03<00:00, 12.2MB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  86%|████████▌ | 19.5M/22.7M [00:03<00:00, 13.8MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  60%|██████    | 13.6M/22.7M [00:03<00:00, 13.5MB/s]




Files Downloaded:  40%|████      | 2/5 [00:04<00:06,  2.02s/file]





PUNCH_L3_CAM_20251014164800_v0j.fits:  67%|██████▋   | 15.1M/22.7M [00:03<00:00, 14.0MB/s]

PUNCH_L3_CAM_20251014144000_v0j.fits:  93%|█████████▎| 21.1M/22.7M [00:03<00:00, 11.8MB/s]




PUNCH_L3_CAM_20251014161600_v0j.fits:  95%|█████████▌| 21.7M/22.7M [00:03<00:00, 14.0MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  73%|███████▎  | 16.6M/22.7M [00:03<00:00, 13.9MB/s]





Files Downloaded:  60%|██████    | 3/5 [00:04<00:02,  1.22s/file]





PUNCH_L3_CAM_20251014164800_v0j.fits:  80%|███████▉  | 18.1M/22.7M [00:03<00:00, 12.7MB/s]

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





PUNCH_L3_CAM_20251014164800_v0j.fits:  85%|████████▌ | 19.4M/22.7M [00:03<00:00, 12.2MB/s]


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





PUNCH_L3_CAM_20251014164800_v0j.fits:  91%|█████████ | 20.7M/22.7M [00:03<00:00, 10.1MB/s]





PUNCH_L3_CAM_20251014164800_v0j.fits:  96%|█████████▌| 21.8M/22.7M [00:04<00:00, 9.14MB/s]






Files Downloaded: 100%|██████████| 5/5 [00:05<00:00,  1.41file/s]
Files Downloaded: 100%|██████████| 5/5 [00:05<00:00,  1.13s/file]

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:08<00:33,  8.44s/it]
 40%|████      | 2/5 [00:08<00:10,  3.58s/it]
 60%|██████    | 3/5 [00:15<00:10,  5.16s/it]
 80%|████████  | 4/5 [00:16<00:03,  3.30s/it]
100%|██████████| 5/5 [00:19<00:00,  3.29s/it]
100%|██████████| 5/5 [00:19<00:00,  3.88s/it]

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

Gallery generated by Sphinx-Gallery