Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_collection_info #100

Open
wants to merge 7 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/capabilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
1 change: 1 addition & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
38 changes: 38 additions & 0 deletions src/viresclient/_client_swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
):
Expand Down
17 changes: 17 additions & 0 deletions src/viresclient/_wps/templates/vires_get_collection_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<wps:Execute xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" version="1.0.0" service="WPS">
<ows:Identifier>vires:get_collection_info</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>collection</ows:Identifier>
<wps:Data>
<wps:LiteralData>{{ collections }}</wps:LiteralData>
</wps:Data>
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:RawDataOutput mimeType="{{ response_type }}">
<ows:Identifier>output</ows:Identifier>
</wps:RawDataOutput>
</wps:ResponseForm>
</wps:Execute>
Loading