xcube-dev / xcube-cds

An xcube plugin to generate data cubes from the Climate Data Store (CDS) API
MIT License
3 stars 1 forks source link

Soil moisture store ignores bounding box in request #17

Closed gunbra32 closed 3 years ago

gunbra32 commented 3 years ago

Bounding box in a request in the soil moisture store is ignored. Instead the full spatial coverage is returned.

grafik

grafik

pont-us commented 3 years ago

I'm not sure which version the bug report relates to, but in the current repository master branch this bug has been fixed. Demonstration -- first, checking allowed parameters:

store.get_open_data_params_schema().to_dict()
...
  'bbox': {'type': 'array',
   'items': [{'type': 'number', 'minimum': -180, 'maximum': 180},
    {'type': 'number', 'minimum': -90, 'maximum': 90},
    {'type': 'number', 'minimum': -180, 'maximum': 180},
    {'type': 'number', 'minimum': -90, 'maximum': 90}]},
...

(That is: bbox is accepted as a parameter, but the only valid values correspond to the entire globe.) Now, attempting the request given in the bug report:

dataset = store.open_data('satellite-soil-moisture:saturation:daily',
                          variable_names=['soil_moisture_saturation'],
                          bbox=[5,10,50,55],
                          spatial_res=0.25,
                          time_range=['2009-12-01', '2010-12-31'],
                          time_period='1D')

...

ValidationError: 5 is greater than the maximum of -180

Failed validating 'maximum' in schema['properties']['bbox']['items'][0]:
    {'maximum': -180, 'minimum': -180, 'type': 'number'}

On instance['bbox'][0]:
    5

The request now correctly fails to validate due to the unsupported bounding box, and an informative error message is produced.

pont-us commented 3 years ago

As a further improvement, PR #19 has now made the bbox parameter optional (since a required parameter with precisely one permitted value is a somewhat redundant).