diff --git a/docs/capabilities.rst b/docs/capabilities.rst index 495a038..754d902 100644 --- a/docs/capabilities.rst +++ b/docs/capabilities.rst @@ -21,6 +21,7 @@ VirES provides more than just *access* to data. Some operations can be peformed | :py:meth:`viresclient.SwarmRequest.available_times` | :py:meth:`viresclient.SwarmRequest.get_orbit_number` | :py:meth:`viresclient.SwarmRequest.get_times_for_orbits` + | :py:meth:`viresclient.SwarmRequest.get_collection_info` **Geomagnetic model evaluation** | Forwards evaluation of magnetic field models when a magnetic dataset is selected (e.g. ``MAGx_LR``). For more detail, see :ref:`Geomagnetic model handling`. | :py:meth:`viresclient.SwarmRequest.available_models` diff --git a/docs/release_notes.rst b/docs/release_notes.rst index 74c6e86..bcf0cce 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -15,6 +15,7 @@ Changes from 0.11.6 to 0.12.0 - conjunction information within ``"MM_CON_SPH_2_:crossover"`` and ``"MM_CON_SPH_2_:plane_alignment"`` - Added CHAMP magnetic dataset, ``CH_ME_MAG_LR_3`` +- Added :py:meth:`viresclient.SwarmRequest.get_collection_info` Changes from 0.11.5 to 0.11.6 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/viresclient/_client_swarm.py b/src/viresclient/_client_swarm.py index 03375af..2956df4 100644 --- a/src/viresclient/_client_swarm.py +++ b/src/viresclient/_client_swarm.py @@ -26,6 +26,7 @@ "times_from_orbits": "vires_times_from_orbits.xml", "get_observatories": "vires_get_observatories.xml", "get_conjunctions": "vires_get_conjunctions.xml", + "get_collection_info": "vires_get_collection_info.xml", } REFERENCES = { @@ -2042,6 +2043,43 @@ def applied_filters(self): for filter_ in self._filterlist: print(filter_) + def get_collection_info(self, collections): + """Get information about a list of collections + + Args: + collections (list[str]): List of collections to get information for + + Returns: + list[dict]: A list of dictionaries containing information about each collection + + Examples: + + .. code-block:: python + + from viresclient import SwarmRequest + request = SwarmRequest("https://vires.services/ows") + info = request.get_collection_info(["SW_OPER_MAGA_LR_1B"]) + + gives:: + + [{'name': 'SW_OPER_MAGA_LR_1B', + 'productType': 'SW_MAGx_LR_1B', + 'productCount': 3579, + 'timeExtent': {'start': '2013-11-25T11:02:52Z', + 'end': '2023-09-28T23:59:59Z'}}] + """ + if not isinstance(collections, list): + raise TypeError("collections must be a list") + templatefile = TEMPLATE_FILES["get_collection_info"] + template = JINJA2_ENVIRONMENT.get_template(templatefile) + request = template.render( + collections=",".join(collections), + response_type="application/json", + ).encode("UTF-8") + response = self._get(request, asynchronous=False, show_progress=False) + response = json.loads(response.decode("UTF-8")) + return response + def get_times_for_orbits( self, start_orbit, end_orbit, mission="Swarm", spacecraft=None ): diff --git a/src/viresclient/_wps/templates/vires_get_collection_info.xml b/src/viresclient/_wps/templates/vires_get_collection_info.xml new file mode 100644 index 0000000..2d96684 --- /dev/null +++ b/src/viresclient/_wps/templates/vires_get_collection_info.xml @@ -0,0 +1,17 @@ + + + vires:get_collection_info + + + collection + + {{ collections }} + + + + + + output + + +