xcube-dev / xcube

xcube is a Python package for generating and exploiting data cubes powered by xarray, dask, and zarr.
https://xcube.readthedocs.io/
MIT License
183 stars 17 forks source link

How to change the method for upsampling and downsampling when using store.open_data() #1062

Closed dpabon closed 6 days ago

dpabon commented 3 weeks ago

Hi, This is a question more than an issue... I would like to change the default method used by store.open_data() from 'NEAREST' to 'bilinear'. I'm not sure how to change this in the following code:

store = new_data_store('sentinelhub', **sh_config)

dataset_majadas = store.open_data('S2L2A',
                         variable_names = ['B07', 'B03', 'SCL'],
                         bbox = bbox_majadas,
                         spatial_res = 0.00018,
                         time_range = ('2023-05-01', '2024-05-01'),
                                 chunks={'time': -1, 
                                         'lat':-1,
                                        'lon':-1})

when I check the metadata of dataset_majadas I got:

    [{'program': 'xcube_sh.chunkstore.SentinelHubChunkStore', 'cube_config': {'dataset_name': 'S2L2A', 'band_names': ['B07', 'B03', 'SCL'], 'band_fill_values': None, 'band_sample_types': None, 'band_units': None, 'tile_size': [390, 300], 'bbox': [-5.813785003206277, 39.9156710718201, -5.743585003206277, 39.9696710718201], 'spatial_res': 0.00018, 'crs': 'WGS84', 'upsampling': 'NEAREST', 'downsampling': 'NEAREST', 'mosaicking_order': 'mostRecent', 'time_range': ['2023-05-01T00:00:00+00:00', '2024-05-01T00:00:00+00:00'], 'time_period': None, 'time_tolerance': '0 days 00:10:00', 'collection_id': None, 'four_d': False}}]

Thanks in advance for your help. Cheers, Daniel

forman commented 1 week ago

Hi @dpabon , sorry for responding only now - it's holiday time.

You can specify them like so:

dataset_majadas = store.open_data(..., downsampling="BILINEAR", upsampling="BICUBIC")

This is how you can inspect the available open parameters for the "sentinelhub" data store using the "S2L2A" dataset:

image

Nore, you cannot change the default sampling methods, they are hardcoded in the "sentinelhub" data store of the xcube-sh plugin.

dpabon commented 1 week ago

Hi @forman No worries. Thanks for the help!

I'm confused with the last part of your reply:

'Note, you cannot change the default sampling methods, they are hardcoded in the "sentinelhub" data store of the xcube-sh plugin.'

Does this mean that even if I do, downsampling="BILINEAR", upsampling="BICUBIC" "NEAREST" will be applied?

Or that it is only possible to select between "NEAREST", "BILINEAR", "BICUBIC"?

Thanks for your time.

Best, Daniel

forman commented 1 week ago

Hi Daniel,

I was referring to default values only. Default values are used if you do not provide values for downsampling and upsampling explicitly.

Does this mean that even if I do, downsampling="BILINEAR", upsampling="BICUBIC" "NEAREST" will be applied?

No. Your settings will be used.