forked from AntSimi/py-eddy-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_obs.py
More file actions
36 lines (28 loc) · 1.02 KB
/
test_obs.py
File metadata and controls
36 lines (28 loc) · 1.02 KB
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
34
35
36
import zarr
from py_eddy_tracker.data import get_path
from py_eddy_tracker.observations.observation import EddiesObservations
a_filename, c_filename = (
get_path("Anticyclonic_20190223.nc"),
get_path("Cyclonic_20190223.nc"),
)
a = EddiesObservations.load_file(a_filename)
a_raw = EddiesObservations.load_file(a_filename, raw_data=True)
memory_store = zarr.group()
# Dataset was raw loaded from netcdf and save in zarr
a_raw.to_zarr(memory_store, chunck_size=100000)
# We load zarr data without raw option
a_zarr = EddiesObservations.load_from_zarr(memory_store)
c = EddiesObservations.load_file(c_filename)
def test_merge():
new = a.merge(c)
assert len(new) == len(a) + len(c)
def test_zarr_raw():
assert a == a_zarr
def test_index():
a_nc_subset = EddiesObservations.load_file(
a_filename, indexs=dict(obs=slice(500, 1000))
)
a_zarr_subset = EddiesObservations.load_from_zarr(
memory_store, indexs=dict(obs=slice(500, 1000)), buffer_size=50
)
assert a_nc_subset == a_zarr_subset