Skip to content
Snippets Groups Projects
Commit 75e06a54 authored by Siddhant Tibrewal's avatar Siddhant Tibrewal
Browse files

fixed the failing test by reusing the hiopy's assumption of time attribute to exist

parent d7a3347a
No related branches found
No related tags found
1 merge request!54Improvements from integration of Hiopy into the Global Hackathon Atmo-only Runs
Pipeline #102868 waiting for manual action
......@@ -2,11 +2,8 @@
import logging
from math import ceil, prod
import numpy as np
from ._zarr_utils import get_time_axis
logger = logging.getLogger(__name__)
......@@ -49,9 +46,8 @@ def _estimate_size(*data_vars):
"""
size = 0.0
for dv in data_vars:
time_axis = get_time_axis(dv)
if time_axis is not None:
dt = time_axis[1] - time_axis[0]
if dv.time is not None:
dt = dv.time[1] - dv.time[0]
size += prod(dv.shape[1:]) * dv.dtype.itemsize / dt
return size
......
......@@ -18,7 +18,9 @@ def _create_test_vars():
time.attrs["units"] = "seconds since 2000-01-01"
var1 = zarr.zeros(shape=[10, 10], path="var1", store=store, chunks=(2, 5))
var1.time = time
var2 = zarr.zeros(shape=[10, 10], path="var2", store=store, chunks=(2, 5))
var2.time = time
for v in (var1, var2):
v.attrs["_ARRAY_DIMENSIONS"] = ("time", "cell")
......
......@@ -146,14 +146,14 @@ def main():
def_grid(coyote, data_vars[0], chunk_slice)
for v in data_vars:
dt = v["time"][1] - v["time"][0]
dt = v.time[1] - v.time[0]
# compute time start index
t0 = (
np.datetime64(start_datetime())
- np.datetime64(v["time"].attrs["units"][len("seconds since ") :])
- np.datetime64(v.time.attrs["units"][len("seconds since ") :])
) / np.timedelta64(1, "s") + dt
t0_idx = np.searchsorted(v["time"], t0)
assert v["time"][t0_idx] == t0, "start_datetime not found in time axis"
t0_idx = np.searchsorted(v.time, t0)
assert v.time[t0_idx] == t0, "start_datetime not found in time axis"
# see YAC_REDUCTION_TIME_NONE etc. (TODO: pass constants through coyote)
time_methods2yac = {"point": 0, "sum": 1, "mean": 2, "min": 3, "max": 4}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment