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

WPSError when requesting model values for filtered Swarm data #99

Closed ancklo closed 1 year ago

ancklo commented 1 year ago

Dear all,

I wanted to download a specific Swarm-A track with predictions from the MIO_SHA_2C model, but a WPSError was raised. Here is the code that I used:

import viresclient as vs
import datetime as dt

request = vs.SwarmRequest()
request.set_collection("SW_OPER_MAGA_LR_1B")

request.set_products(
    measurements=["F"],
    models=["MIO_SHA_2C"],
    auxiliaries=['Timestamp', 'Radius', 'Latitude', 'Longitude', 'OrbitNumber'],
    residuals=False,
    sampling_step="PT1M"
)

request.set_choice_filter('OrbitNumber', 30584)  # specific orbit on May 3, 2019

dataset = request.get_between(
    start_time=dt.datetime(2019, 5, 3),
    end_time=dt.datetime(2019, 5, 4)
)

The error message was:

WPSError: WPS Request Failed! Reason: NoApplicableCode [ValueError]: Dataset length mismatch! 1440 != 93

I noticed something similar when I tried to download filtered data and model values from the VirES for Swarm website. Interestingly, it works without the filter or when I ask for the CHAOS-MMA model instead of MIO_SHA_2C. So it seems that the WPSError is raised depending on the filter used and the requested model.

This wasn't a critical issue for me because I could filter the data after downloading the entire day. But I think you should be aware of it.

Thank you for your help.

smithara commented 1 year ago

Hi Clemens

Thank you for the report. This looks like a server issue

By the way, probably the better way to do this is to use request.get_times_for_orbits() to find the start and end of the chosen orbits, e.g.

start, end = request.get_times_for_orbits(30584, 30584, mission="Swarm", spacecraft="A")
dataset = request.get_between(start, end)

(might need to adjust for an off-by-one issue there)

pacesm commented 1 year ago

This seems like a server error. It seems like the error is triggered by the orbit number filter:

request.set_choice_filter('OrbitNumber', 30584) 

When this line is removed the requests passes successfully.

I will investigate the issue.

I second @smithara that using request.get_times_for_orbits() should be the preferred way of extracting data by orbits.

pacesm commented 1 year ago

Should be fixed. Please check.

ancklo commented 1 year ago

It works for me now. Thank you for the quick fix.

@smithara Thank you, Ashley. It is certainly smarter to use get_orbit_times. I'll keep it in mind.

Regards.