-
Notifications
You must be signed in to change notification settings - Fork 0
/
zarr_test.py
35 lines (25 loc) · 894 Bytes
/
zarr_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import xarray as xr
import numpy as np
# create data
data = np.random.randn(2, 3)
# create coords
rows = [1,2]
cols = [1,2,3]
# put data into a dataset
ds = xr.Dataset(
data_vars=dict(
variable=(["x", "y"], data)
),
coords=dict(
lon=(["x"], rows),
lat=(["y"], cols),
),
attrs=dict(description="coords with vectors"),
)
encoding={'variable': {'_FillValue': -9999, 'scale_factor': 0.01, 'add_offset': -1.0, 'dtype': 'int16'}}
ds.to_zarr("example.zarr",encoding=encoding)
ds.to_netcdf("example.nc",encoding=encoding)
reopened = xr.open_dataset("example.zarr",engine='zarr')
reopened
remote_zarr=xr.open_dataset("https://nx7384.your-storageshare.de/apps/sharingpath/wetwin/public/test/example.zarr",engine="zarr")
remote_nc=xr.open_dataset("https://nx7384.your-storageshare.de/apps/sharingpath/wetwin/public/test/example.nc",engine="h5netcdf")