|
26 | 26 | "times_from_orbits": "vires_times_from_orbits.xml",
|
27 | 27 | "get_observatories": "vires_get_observatories.xml",
|
28 | 28 | "get_conjunctions": "vires_get_conjunctions.xml",
|
| 29 | + "get_collection_info": "vires_get_collection_info.xml", |
29 | 30 | }
|
30 | 31 |
|
31 | 32 | REFERENCES = {
|
@@ -2243,6 +2244,45 @@ def applied_filters(self):
|
2243 | 2244 | for filter_ in self._filterlist:
|
2244 | 2245 | print(filter_)
|
2245 | 2246 |
|
| 2247 | + def get_collection_info(self, collections): |
| 2248 | + """Get information about a list of collections |
| 2249 | +
|
| 2250 | + Args: |
| 2251 | + collections (str | list[str]): Collection or list of collections |
| 2252 | +
|
| 2253 | + Returns: |
| 2254 | + list[dict]: A list of dictionaries containing information about each collection |
| 2255 | +
|
| 2256 | + Examples: |
| 2257 | +
|
| 2258 | + .. code-block:: python |
| 2259 | +
|
| 2260 | + from viresclient import SwarmRequest |
| 2261 | + request = SwarmRequest("https://vires.services/ows") |
| 2262 | + info = request.get_collection_info("SW_OPER_MAGA_LR_1B") |
| 2263 | +
|
| 2264 | + gives:: |
| 2265 | +
|
| 2266 | + [{'name': 'SW_OPER_MAGA_LR_1B', |
| 2267 | + 'productType': 'SW_MAGx_LR_1B', |
| 2268 | + 'productCount': 3579, |
| 2269 | + 'timeExtent': {'start': '2013-11-25T11:02:52Z', |
| 2270 | + 'end': '2023-09-28T23:59:59Z'}}] |
| 2271 | + """ |
| 2272 | + if isinstance(collections, str): |
| 2273 | + collections = [collections] |
| 2274 | + if not isinstance(collections, list): |
| 2275 | + raise TypeError("collections must be a string or list") |
| 2276 | + templatefile = TEMPLATE_FILES["get_collection_info"] |
| 2277 | + template = JINJA2_ENVIRONMENT.get_template(templatefile) |
| 2278 | + request = template.render( |
| 2279 | + collections=",".join(collections), |
| 2280 | + response_type="application/json", |
| 2281 | + ).encode("UTF-8") |
| 2282 | + response = self._get(request, asynchronous=False, show_progress=False) |
| 2283 | + response = json.loads(response.decode("UTF-8")) |
| 2284 | + return response |
| 2285 | + |
2246 | 2286 | def get_times_for_orbits(
|
2247 | 2287 | self, start_orbit, end_orbit, mission="Swarm", spacecraft=None
|
2248 | 2288 | ):
|
|
0 commit comments