From 5d9a4bf064826a1a9a02ddb01f075212bd8b8eed Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Mon, 2 Oct 2023 20:04:40 +0100 Subject: [PATCH 1/3] Add .get_collection_info --- docs/capabilities.rst | 1 + docs/release_notes.rst | 3 ++- src/viresclient/__init__.py | 2 +- src/viresclient/_client_swarm.py | 26 ++++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) 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 7431398..2dfe72e 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -4,10 +4,11 @@ Release notes Change log ---------- -Changes from 0.11.3 to 0.11.4 +Changes from 0.11.3 to 0.12.0 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Beginning support for (L1B) FAST data +- Added :py:meth:`viresclient.SwarmRequest.get_collection_info` Changes from 0.11.2 to 0.11.3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/viresclient/__init__.py b/src/viresclient/__init__.py index 0ca134a..9f642de 100644 --- a/src/viresclient/__init__.py +++ b/src/viresclient/__init__.py @@ -35,4 +35,4 @@ from ._config import ClientConfig, set_token from ._data_handling import ReturnedData, ReturnedDataFile -__version__ = "0.11.4-alpha" +__version__ = "0.12.0-alpha" diff --git a/src/viresclient/_client_swarm.py b/src/viresclient/_client_swarm.py index af6c165..bc86799 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 = { @@ -1870,6 +1871,31 @@ 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: + request = SwarmRequest("https://vires.services/ows") + info = request.get_collection_info(["SW_OPER_MAGA_LR_1B", "SW_OPER_MAGB_LR_1B"]) + """ + 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 ): From 582ad1a520b15e72daee5acd34d6c399977a0427 Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Mon, 2 Oct 2023 20:04:55 +0100 Subject: [PATCH 2/3] Fix docstring --- src/viresclient/_client_swarm.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/viresclient/_client_swarm.py b/src/viresclient/_client_swarm.py index bc86799..054fb3b 100644 --- a/src/viresclient/_client_swarm.py +++ b/src/viresclient/_client_swarm.py @@ -1881,8 +1881,20 @@ def get_collection_info(self, collections): list[dict]: A list of dictionaries containing information about each collection Examples: - request = SwarmRequest("https://vires.services/ows") - info = request.get_collection_info(["SW_OPER_MAGA_LR_1B", "SW_OPER_MAGB_LR_1B"]) + + .. 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") From ad7bfe7220648b5e780c2aec015a2c73a3718484 Mon Sep 17 00:00:00 2001 From: Ashley Smith Date: Mon, 2 Oct 2023 21:42:04 +0100 Subject: [PATCH 3/3] Add missing template file --- .../templates/vires_get_collection_info.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/viresclient/_wps/templates/vires_get_collection_info.xml 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 + + +