This notebook demonstrates how to use the features of the xcube JupyterLab integration.
The notebook demonstrates three scenarios how xcube Viewer is utilized in JupyterLab.
In particular, we open xcube Viewer for any xarray.Dataset instances
persisted in deepesdl public s3 storage (saved datasets)
opened or otherwise created in this Notebook (in-memory datasets)
using a configuration file for customising stlyes.
We use the xcube datastore framework here to open the dataset, but it could also be opened by other means, e.g., xr.open_dataset(), provided it has variables with dimensions ["time", "y", "x"] or ["y", "x"].
ERA5 hourly data on single levels from 1959 to present
date_modified :
2022-11-04 15:41:36.233472
description :
ERA5 Reanalysis Products
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.875
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.875
geospatial_lon_min :
-179.875
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Mean Air Temperature at 2 m
original_add_offset :
0.0
original_name :
t2m
original_scale_factor :
1.0
processing_steps :
['Merging nc files', 'Resampling by daily mean', 'Converting to °C from K', 'Resampling by 8-day mean', 'Resampling to 0.25 degrees using bilinear interpolation']
ERA5 hourly data on single levels from 1959 to present
date_modified :
2022-11-04 15:41:36.233472
description :
ERA5 Reanalysis Products
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.875
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.875
geospatial_lon_min :
-179.875
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Evaporation
original_add_offset :
0.0
original_name :
e
original_scale_factor :
1.0
processing_steps :
['Merging nc files', 'Resampling by daily sum', 'Converting to mm from m', 'Resampling by 8-day mean', 'Resampling to 0.25 degrees using bilinear interpolation']
MODIS/Terra+Aqua BRDF/Albedo Nadir BRDF-Adjusted Reflectance Daily L3 Global 0.05 Deg CMG and Vegetation Indices
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.87499999998977
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.87500000008183
geospatial_lon_min :
-179.87499999999997
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Kernel Normalized Difference Vegetation Index
original_add_offset :
0.0
original_name :
kNDVI
original_scale_factor :
1.0
processing_steps :
['Merging hdf files', 'Computing NDVI, NIRv, and kNDVI', 'resampling by 8-day mean', 'Downsampling to 0.25 deg with mean', 'Interpolating NA with linear interpolation', 'Masking water using GLEAM as reference']
ERA5 hourly data on single levels from 1959 to present
date_modified :
2022-11-04 15:41:36.233472
description :
ERA5 Reanalysis Products
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.875
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.875
geospatial_lon_min :
-179.875
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Maximum Air Temperature at 2 m
original_add_offset :
0.0
original_name :
t2m_max
original_scale_factor :
1.0
processing_steps :
['Merging nc files', 'Resampling by daily max', 'Converting to °C from K', 'Resampling by 8-day max', 'Resampling to 0.25 degrees using bilinear interpolation']
ERA5 hourly data on single levels from 1959 to present
date_modified :
2022-11-04 15:41:36.233472
description :
ERA5 Reanalysis Products
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.875
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.875
geospatial_lon_min :
-179.875
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Minimum Air Temperature at 2 m
original_add_offset :
0.0
original_name :
t2m_min
original_scale_factor :
1.0
processing_steps :
['Merging nc files', 'Resampling by daily min', 'Converting to °C from K', 'Resampling by 8-day min', 'Resampling to 0.25 degrees using bilinear interpolation']
MODIS/Terra+Aqua BRDF/Albedo Nadir BRDF-Adjusted Reflectance Daily L3 Global 0.05 Deg CMG and Vegetation Indices
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.87499999998977
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.87500000008183
geospatial_lon_min :
-179.87499999999997
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Nadir BRDF Adjusted Reflectance of Band 3 (blue)
original_add_offset :
0.0
original_name :
Nadir_Reflectance_Band3
original_scale_factor :
1.0
processing_steps :
['Merging hdf files', 'Computing NDVI, NIRv, and kNDVI', 'resampling by 8-day mean', 'Downsampling to 0.25 deg with mean', 'Interpolating NA with linear interpolation', 'Masking water using GLEAM as reference']
MODIS/Terra+Aqua BRDF/Albedo Nadir BRDF-Adjusted Reflectance Daily L3 Global 0.05 Deg CMG and Vegetation Indices
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.87499999998977
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.87500000008183
geospatial_lon_min :
-179.87499999999997
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Nadir BRDF Adjusted Reflectance of Band 4 (green)
original_add_offset :
0.0
original_name :
Nadir_Reflectance_Band4
original_scale_factor :
1.0
processing_steps :
['Merging hdf files', 'Computing NDVI, NIRv, and kNDVI', 'resampling by 8-day mean', 'Downsampling to 0.25 deg with mean', 'Interpolating NA with linear interpolation', 'Masking water using GLEAM as reference']
MODIS/Terra+Aqua BRDF/Albedo Nadir BRDF-Adjusted Reflectance Daily L3 Global 0.05 Deg CMG and Vegetation Indices
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.87499999998977
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.87500000008183
geospatial_lon_min :
-179.87499999999997
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Nadir BRDF Adjusted Reflectance of Band 2 (NIR)
original_add_offset :
0.0
original_name :
Nadir_Reflectance_Band2
original_scale_factor :
1.0
processing_steps :
['Merging hdf files', 'Computing NDVI, NIRv, and kNDVI', 'resampling by 8-day mean', 'Downsampling to 0.25 deg with mean', 'Interpolating NA with linear interpolation', 'Masking water using GLEAM as reference']
MODIS/Terra+Aqua BRDF/Albedo Nadir BRDF-Adjusted Reflectance Daily L3 Global 0.05 Deg CMG and Vegetation Indices
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.87499999998977
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.87500000008183
geospatial_lon_min :
-179.87499999999997
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Nadir BRDF Adjusted Reflectance of Band 1 (red)
original_add_offset :
0.0
original_name :
Nadir_Reflectance_Band1
original_scale_factor :
1.0
processing_steps :
['Merging hdf files', 'Computing NDVI, NIRv, and kNDVI', 'resampling by 8-day mean', 'Downsampling to 0.25 deg with mean', 'Interpolating NA with linear interpolation', 'Masking water using GLEAM as reference']
MODIS/Terra+Aqua BRDF/Albedo Nadir BRDF-Adjusted Reflectance Daily L3 Global 0.05 Deg CMG and Vegetation Indices
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.87499999998977
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.87500000008183
geospatial_lon_min :
-179.87499999999997
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Nadir BRDF Adjusted Reflectance of Band 5 (SWIR1)
original_add_offset :
0.0
original_name :
Nadir_Reflectance_Band5
original_scale_factor :
1.0
processing_steps :
['Merging hdf files', 'Computing NDVI, NIRv, and kNDVI', 'resampling by 8-day mean', 'Downsampling to 0.25 deg with mean', 'Interpolating NA with linear interpolation', 'Masking water using GLEAM as reference']
MODIS/Terra+Aqua BRDF/Albedo Nadir BRDF-Adjusted Reflectance Daily L3 Global 0.05 Deg CMG and Vegetation Indices
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.87499999998977
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.87500000008183
geospatial_lon_min :
-179.87499999999997
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Nadir BRDF Adjusted Reflectance of Band 6 (SWIR2)
original_add_offset :
0.0
original_name :
Nadir_Reflectance_Band6
original_scale_factor :
1.0
processing_steps :
['Merging hdf files', 'Computing NDVI, NIRv, and kNDVI', 'resampling by 8-day mean', 'Downsampling to 0.25 deg with mean', 'Interpolating NA with linear interpolation', 'Masking water using GLEAM as reference']
MODIS/Terra+Aqua BRDF/Albedo Nadir BRDF-Adjusted Reflectance Daily L3 Global 0.05 Deg CMG and Vegetation Indices
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.87499999998977
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.87500000008183
geospatial_lon_min :
-179.87499999999997
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Nadir BRDF Adjusted Reflectance of Band 7 (SWIR3)
original_add_offset :
0.0
original_name :
Nadir_Reflectance_Band7
original_scale_factor :
1.0
processing_steps :
['Merging hdf files', 'Computing NDVI, NIRv, and kNDVI', 'resampling by 8-day mean', 'Downsampling to 0.25 deg with mean', 'Interpolating NA with linear interpolation', 'Masking water using GLEAM as reference']
MODIS/Terra+Aqua BRDF/Albedo Nadir BRDF-Adjusted Reflectance Daily L3 Global 0.05 Deg CMG and Vegetation Indices
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.87499999998977
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.87500000008183
geospatial_lon_min :
-179.87499999999997
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Normalized Difference Vegetation Index
original_add_offset :
0.0
original_name :
NDVI
original_scale_factor :
1.0
processing_steps :
['Merging hdf files', 'Computing NDVI, NIRv, and kNDVI', 'resampling by 8-day mean', 'Downsampling to 0.25 deg with mean', 'Interpolating NA with linear interpolation', 'Masking water using GLEAM as reference']
MODIS/Terra+Aqua BRDF/Albedo Nadir BRDF-Adjusted Reflectance Daily L3 Global 0.05 Deg CMG and Vegetation Indices
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.87499999998977
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.87500000008183
geospatial_lon_min :
-179.87499999999997
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Near Infrared Reflectance of Vegetation
original_add_offset :
0.0
original_name :
NIRv
original_scale_factor :
1.0
processing_steps :
['Merging hdf files', 'Computing NDVI, NIRv, and kNDVI', 'resampling by 8-day mean', 'Downsampling to 0.25 deg with mean', 'Interpolating NA with linear interpolation', 'Masking water using GLEAM as reference']
ERA5 hourly data on single levels from 1959 to present
date_modified :
2022-11-04 15:41:36.233472
description :
ERA5 Reanalysis Products
geospatial_lat_max :
89.875
geospatial_lat_min :
-89.875
geospatial_lat_resolution :
0.25
geospatial_lon_max :
179.875
geospatial_lon_min :
-179.875
geospatial_lon_resolution :
0.25
license :
Terms and conditions of the DeepESDL data distribution
long_name :
Total Precipitation
original_add_offset :
0.0
original_name :
tp
original_scale_factor :
1.0
processing_steps :
['Merging nc files', 'Resampling by daily sum', 'Converting to mm from m', 'Resampling by 8-day mean', 'Resampling to 0.25 degrees using bilinear interpolation']
404 GET /viewer/config/config.json (127.0.0.1): xcube viewer has not been been configured
404 GET /viewer/config/config.json (127.0.0.1) 3.24ms
501 GET /viewer/state?key=sentinel (127.0.0.1) 0.42ms
404 GET /viewer/ext/contributions (127.0.0.1) 68.60ms
In [6]:
Copied!
viewer.add_dataset(dataset)
viewer.add_dataset(dataset)
Out[6]:
'4ae13077-8b73-4765-83e4-93adf6dc8cf7'
You can click on the viewer link to open xcube Viewer in a new browser tab:
Scenario 2: Open xcube Viewer for a dataset instances opened or otherwise created in this Notebook (in-memory datasets).
Below, let's fetch a dataset from the Open Data Portal of the ESA Climate Change Initiative (CCI) on the fly, without persisting it - for more details about the xcube CCI datastore please checkout the example notebook in xcube-datastores GENERATE CCI CUBES. Be aware of performance loss, so in case you plan to use a dataset a lot for analysis or visualisation, please persist it into the team s3 storage. The public cubes provided within DeepESDL are already persisted in S3, so you should not duplicate them in your team storage.
404 GET /viewer/config/config.json (127.0.0.1): xcube viewer has not been been configured
404 GET /viewer/config/config.json (127.0.0.1) 2.94ms
501 GET /viewer/state?key=sentinel (127.0.0.1) 0.27ms
404 GET /viewer/ext/contributions (127.0.0.1) 0.47ms
Scenario 3: Use custom server configuration to start server and pass it to the viewer constructor. In this example, we have create a local file with the configuration and load it as a dictionary and pass it to the viewer.
The configuration file is pointing to your team storage as input source. If you don't have anything stored in your team S3 storage, the viewer will not be able to display any data. Please check other example notebooks and create some sample datasets in your team storage to visualize the content.
The custom configuration allows you to predefined your value ranges, the colormaps that should be used as well as which bands should be used to create an RGB image, then the RGB switch in the viewer will display the RGB image.
If you do not have a server-config.yaml file in your directory, please create one with the following content:
DataStores:-Identifier:deep-esdl-team-storageStoreId:s3StoreParams:root:$S3_USER_STORAGE_BUCKETstorage_options:anon:falsekey:$S3_USER_STORAGE_KEYsecret:$S3_USER_STORAGE_SECRETDatasets:-Path:"*.zarr"Style:default# ChunkCacheSize: 1GStyles:-Identifier:defaultColorMappings:analysed_sst:ColorBar:plasmaValueRange:[270,310]## if you have bands that can create an RGB image, you can specify them as below. # rgb:# Red:# Variable: B04# ValueRange: [0., 0.25]# Green:# Variable: B03# ValueRange: [0., 0.25]# Blue:# Variable: B02# ValueRange: [0., 0.25]