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/src/viresclient/__init__.py b/src/viresclient/__init__.py index 321bc8d..280b0c1 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.12.3" +__version__ = "0.13.0" diff --git a/src/viresclient/_client_swarm.py b/src/viresclient/_client_swarm.py index fc8f0d6..dd082ad 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 = { @@ -2243,6 +2244,45 @@ 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 (str | list[str]): Collection or list of collections + + 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 isinstance(collections, str): + collections = [collections] + if not isinstance(collections, list): + raise TypeError("collections must be a string or 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 + + +