Note
Go to the end to download the full example code.
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-05 13:50:10 - spiceypy.utils.libspicehelper - INFO: Using fallback library next to module: /home/runner/work/hermpy/hermpy/.venv/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)
['/home/runner/.hermpy/cache/download/url/5934f7bc99d7a04b729faaa448a2941b/contents', '/home/runner/.hermpy/cache/download/url/fa5c95d6b67b4c89a85a7f058da42b64/contents']
Total running time of the script: (0 minutes 5.632 seconds)