.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated_examples/download_data.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_generated_examples_download_data.py: Downloading data with hermpy ============================ A minimal example of how ``hermpy``'s network clients can be used to download and load data .. GENERATED FROM PYTHON SOURCE LINES 6-11 .. code-block:: Python from sunpy.time import TimeRange from hermpy.net import ClientMESSENGER .. rst-class:: sphx-glr-script-out .. code-block:: none 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 .. GENERATED FROM PYTHON SOURCE LINES 12-19 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: .. GENERATED FROM PYTHON SOURCE LINES 19-22 .. code-block:: Python client = ClientMESSENGER() print(client.instruments) .. rst-class:: sphx-glr-script-out .. code-block:: none ['MAG', 'MAG 1s', 'MAG 5s', 'MAG 10s', 'MAG 60s', 'MAG RTN 60s', 'FIPS'] .. GENERATED FROM PYTHON SOURCE LINES 23-32 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. .. GENERATED FROM PYTHON SOURCE LINES 32-35 .. code-block:: Python query = client.query(TimeRange("2011-06-01", "2011-06-02"), "MAG") print(query) .. rst-class:: sphx-glr-script-out .. code-block:: none ['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'] .. GENERATED FROM PYTHON SOURCE LINES 36-40 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 .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: Python local_paths = client.fetch() print(local_paths) .. rst-class:: sphx-glr-script-out .. code-block:: none Files Downloaded: 0%| | 0/2 [00:00 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: Files Downloaded: 0%| | 0/2 [00:01` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: download_data.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: download_data.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_