Downloading data with hermpy#

A minimal example of how hermpy’s network clients can be used to download and load data

from sunpy.time import TimeRange

from hermpy.net import ClientMESSENGER
2026-06-08 20:49:41 - spiceypy.utils.libspicehelper - INFO: Using fallback library next to module: /home/docs/checkouts/readthedocs.org/user_builds/hermpy/envs/stable/lib/python3.14/site-packages/spiceypy/utils/libcspice.so

We initialise a client for the MESSENGER mission. The PDS sources are set by defaults in hermpy.net.client_messenger.py, but can be changed in the class constructor (not recommended unless you have good knowledge of these data).

The available intruments in the client are stored for reference in the .instruments attribute:

client = ClientMESSENGER()
print(client.instruments)
['MAG', 'MAG 1s', 'MAG 5s', 'MAG 10s', 'MAG 60s', 'MAG RTN 60s', 'FIPS']

A query can be made for any range of time using Sunpy’s TimeRange as an input. The instrument (‘MAG’ in this example) must also be passed to the client. The instrument must exist in the client source.

The client returns a list of urls, which can be checked before downloading. These are automatically added to the query buffer (ClientMESSENGER._query_buffer: list[str]). These calls extend a list of queries, and so multiple queries can be made before downloading. This is useful for accessing multiple instruments, or non-continous timespans.

query = client.query(TimeRange("2011-06-01", "2011-06-02"), "MAG")
print(query)
['https://pds-ppi.igpp.ucla.edu/data/mess-mag-calibrated/data/mso/2011/152_181_JUN/MAGMSOSCI11152_V08.TAB', 'https://pds-ppi.igpp.ucla.edu/data/mess-mag-calibrated/data/mso/2011/152_181_JUN/MAGMSOSCI11153_V08.TAB']

We can access files added to the query buffer with this function. They will be downloaded if not already in cache, and their path returned. The query buffer is automatically flushed after this call. Redownloads can be forced with check_for_updates=True

local_paths = client.fetch()
print(local_paths)
Files Downloaded:   0%|          | 0/2 [00:00<?, ?file/s]


MAGMSOSCI11153_V08.TAB:   0%|          | 0.00/34.3M [00:00<?, ?B/s]

MAGMSOSCI11152_V08.TAB:   0%|          | 0.00/33.6M [00:00<?, ?B/s]


MAGMSOSCI11153_V08.TAB:   0%|          | 1.02k/34.3M [00:00<1:10:51, 8.08kB/s]


MAGMSOSCI11153_V08.TAB:   0%|          | 98.9k/34.3M [00:00<01:10, 486kB/s]

MAGMSOSCI11152_V08.TAB:   0%|          | 1.02k/33.6M [00:00<2:01:25, 4.62kB/s]


MAGMSOSCI11153_V08.TAB:   1%|▏         | 457k/34.3M [00:00<00:20, 1.69MB/s]

MAGMSOSCI11152_V08.TAB:   1%|          | 196k/33.6M [00:00<00:46, 722kB/s]


MAGMSOSCI11153_V08.TAB:   5%|▌         | 1.82M/34.3M [00:00<00:05, 5.88MB/s]

MAGMSOSCI11152_V08.TAB:   3%|▎         | 1.01M/33.6M [00:00<00:10, 3.13MB/s]




MAGMSOSCI11152_V08.TAB:  10%|█         | 3.49M/33.6M [00:00<00:03, 9.57MB/s]

MAGMSOSCI11152_V08.TAB:  30%|██▉       | 10.0M/33.6M [00:00<00:00, 26.2MB/s]

MAGMSOSCI11152_V08.TAB:  52%|█████▏    | 17.5M/33.6M [00:00<00:00, 40.8MB/s]



2/0 files failed to download. Please check `.errors` for details

Files Downloaded:   0%|          | 0/2 [00:01<?, ?file/s]2026-06-08 20:49:43 - parfive - INFO: https://pds-ppi.igpp.ucla.edu/data/mess-mag-calibrated/data/mso/2011/152_181_JUN/MAGMSOSCI11152_V08.TAB failed to download with exception
Response payload is not completed: <ContentLengthError: 400, message='Not enough data to satisfy content length header (received 2956029 of 6728582 bytes).'>
2026-06-08 20:49:43 - parfive - INFO: https://pds-ppi.igpp.ucla.edu/data/mess-mag-calibrated/data/mso/2011/152_181_JUN/MAGMSOSCI11153_V08.TAB failed to download with exception
Response payload is not completed: <ContentLengthError: 400, message='Not enough data to satisfy content length header (received 3362925 of 6866237 bytes).'>

Files Downloaded:   0%|          | 0/2 [00:01<?, ?file/s]
Failed to download all files. Retrying (1/3).

Files Downloaded:   0%|          | 0/2 [00:00<?, ?file/s]

MAGMSOSCI11152_V08.TAB:   0%|          | 0.00/33.6M [00:00<?, ?B/s]

MAGMSOSCI11152_V08.TAB:   0%|          | 1.02k/33.6M [00:00<1:05:12, 8.60kB/s]

MAGMSOSCI11152_V08.TAB:   0%|          | 98.9k/33.6M [00:00<01:08, 493kB/s]

MAGMSOSCI11152_V08.TAB:   1%|▏         | 443k/33.6M [00:00<00:20, 1.61MB/s]

MAGMSOSCI11152_V08.TAB:   5%|▌         | 1.84M/33.6M [00:00<00:05, 5.69MB/s]

MAGMSOSCI11152_V08.TAB:  17%|█▋        | 5.87M/33.6M [00:00<00:01, 15.9MB/s]

MAGMSOSCI11152_V08.TAB:  37%|███▋      | 12.4M/33.6M [00:00<00:00, 29.2MB/s]

MAGMSOSCI11152_V08.TAB:  55%|█████▍    | 18.4M/33.6M [00:00<00:00, 38.3MB/s]

MAGMSOSCI11152_V08.TAB:  66%|██████▋   | 22.4M/33.6M [00:00<00:00, 35.1MB/s]

MAGMSOSCI11152_V08.TAB:  79%|███████▉  | 26.5M/33.6M [00:01<00:00, 37.0MB/s]

MAGMSOSCI11152_V08.TAB:  90%|█████████ | 30.3M/33.6M [00:01<00:00, 35.8MB/s]


Files Downloaded:  50%|█████     | 1/2 [00:01<00:01,  1.50s/file]

MAGMSOSCI11153_V08.TAB:   0%|          | 0.00/34.3M [00:00<?, ?B/s]

MAGMSOSCI11153_V08.TAB:   6%|▌         | 1.95M/34.3M [00:00<00:02, 16.2MB/s]

MAGMSOSCI11153_V08.TAB:  18%|█▊        | 6.13M/34.3M [00:00<00:01, 27.6MB/s]

MAGMSOSCI11153_V08.TAB:  30%|███       | 10.3M/34.3M [00:00<00:00, 31.5MB/s]

MAGMSOSCI11153_V08.TAB:  42%|████▏     | 14.6M/34.3M [00:00<00:00, 33.3MB/s]

MAGMSOSCI11153_V08.TAB:  55%|█████▍    | 18.8M/34.3M [00:00<00:00, 34.6MB/s]

MAGMSOSCI11153_V08.TAB:  67%|██████▋   | 23.1M/34.3M [00:00<00:00, 35.3MB/s]

MAGMSOSCI11153_V08.TAB:  80%|███████▉  | 27.4M/34.3M [00:00<00:00, 35.9MB/s]

MAGMSOSCI11153_V08.TAB:  93%|█████████▎| 31.8M/34.3M [00:00<00:00, 36.4MB/s]


Files Downloaded: 100%|██████████| 2/2 [00:02<00:00,  1.25s/file]
Files Downloaded: 100%|██████████| 2/2 [00:02<00:00,  1.29s/file]
['/home/docs/.hermpy/MAGMSOSCI11152_V08.TAB', '/home/docs/.hermpy/MAGMSOSCI11153_V08.TAB']

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

Gallery generated by Sphinx-Gallery