ESA-VirES / VirES-Python-Client

viresclient is a Python package for easy access to Swarm & Aeolus products as xarray.Dataset
https://viresclient.readthedocs.io
MIT License
17 stars 1 forks source link

Add model's validity to the list of available magnetic models (enhancement) #25

Closed lmar76 closed 5 years ago

lmar76 commented 5 years ago

The viresclient.SwarmRequest.available_models method provides a list of available magnetic models but it does not indicates their temporal validity. It could be very useful to add this information to the output.

pacesm commented 5 years ago

This should be easy to implement this feature as the server already provides this information via the get_model_info WPS call (used by the Web client).

smithara commented 5 years ago

Thanks for pointing this out - it's on my list of things to do! I will also use it to verify requests based on the combination of time window and models chosen. Probably I will put this in the next release along with the "model expressions"

smithara commented 5 years ago

I have implemented a new method, SwarmRequest.get_model_info() which you call with the same models and custom_model kwargs as in .set_products(), so you can do the following:

request.get_model_info(models=["MCO_SHA_2C", "MCO_SHA_2D"], custom_model="LCS-1.shc")

and you get a dictionary:

{'MCO_SHA_2C': {'expression': 'MCO_SHA_2C(max_degree=16,min_degree=0)',
  'validity': {'start': '2013-11-30T14:38:24Z',
   'end': '2018-01-01T00:00:00Z'}},
 'MCO_SHA_2D': {'expression': 'MCO_SHA_2D(max_degree=20,min_degree=0)',
  'validity': {'start': '2013-11-25T12:00:00.000003Z',
   'end': '2018-01-01T00:00:00Z'}},
 'Custom_Model': {'expression': 'Custom_Model(max_degree=185,min_degree=0)',
  'validity': {'start': '0001-01-01T00:00:00Z',
   'end': '4000-01-01T00:00:00Z'}}}

(This should also work with the new model expression behaviour)

I have used this to update the behaviour of SwarmRequest.available_models() so that calls like

request.available_models("MCO")

will return the information like this:

MCO_SHA_2C = MCO_SHA_2C(max_degree=16,min_degree=0)
  START: 2013-11-30T14:38:24Z
  END:   2018-01-01T00:00:00Z
DESCRIPTION:
[Comprehensive Inversion]: Core field of CIY4
 A comprehensive model of Earth’s magnetic field determined from 4 years of Swarm satellite observations, https://doi.org/10.1186/s40623-018-0896-3 
Validation: ftp://swarm-diss.eo.esa.int/Level2longterm/MCO/SW_OPER_MCO_VAL_2C_20131201T000000_20180101T000000_0401.ZIP 

MCO_SHA_2D = MCO_SHA_2D(max_degree=20,min_degree=0)
  START: 2013-11-25T12:00:00.000003Z
  END:   2018-01-01T00:00:00Z
DESCRIPTION:
[Dedicated Chain]: Core field
An algorithm for deriving core magnetic field models from the Swarm data set, https://doi.org/10.5047/eps.2013.07.005 
Validation: ftp://swarm-diss.eo.esa.int/Level2longterm/MCO/SW_OPER_MCO_VAL_2D_20131126T000000_20180101T000000_0401.ZIP 

MCO_SHA_2F = MCO_SHA_2F(max_degree=20,min_degree=0)
  START: 2013-11-25T12:00:00.000003Z
  END:   2017-07-17T02:23:59.999998Z
DESCRIPTION:
[Fast-Track Product]: Core field

The server is contacted so that the model validities will be up to date. (a dictionary with this information can be returned instead if you provide nice_output=False)

These changes should be ready for release soon.

smithara commented 5 years ago

This is now implemented in v0.2.6. I made a quick demo here: https://github.com/smithara/viresclient_examples/blob/master/model_details.ipynb