ESDS-Leipzig / cubo

On-Demand Earth System Data Cubes (ESDCs) in Python
https://cubo.readthedocs.io/en/latest/
MIT License
164 stars 9 forks source link

Using Cubo to create Sentinel 5p data cubes #3

Closed Frankie91 closed 1 year ago

Frankie91 commented 1 year ago

Hello,

I've been trying to use Cubo to download cubes from the Sentinel 5p collection available on the planetary computer:

https://planetarycomputer.microsoft.com/dataset/sentinel-5p-l2-netcdf

The download process works quite well by simply adapting the code snippet you provide in the documentation. But whenever I then try to apply the to_numpy() method to the resulting DataArray i get the rasterio ValueError "Can't read closed raster file". This doesn't happen when attempting to do the same with the sentinel-2 l2a collection.

Here's the code snippet I'm using:

import cubo import xarray as xr

Not working

da = cubo.create( lat=49.80, lon=9.42, collection="sentinel-5p-l2-netcdf", bands=["no2"], start_date="2021-01-01", end_date="2021-01-01", )

da.to_numpy()

Thank you in advance and best regards!

davemlz commented 1 year ago

Hi @Frankie91!

Sorry I'm late answering. Two things:

  1. The Sentinel-2 collection from MPC is open. Sentinel-5 is closed and therefore you need a token to access this collection. See https://planetarycomputer.microsoft.com/docs/concepts/sas/
  2. Sentinel-5 is already provided as a netcdf. cubo uses stackstac as engine, so, it uses COGs to convert them into a multidimensional array. In the case of Sentinel-5, the data is already a multidimensional array. See https://stackstac.readthedocs.io/en/latest/api/main/stackstac.stack.html

I hope this solves your questions!

Best,

David