Skip to content

Commit dc39768

Browse files
committed
add temporal discoverability function
1 parent aa6b122 commit dc39768

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/cchdo/hydro/discoverability.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44
import xarray as xr
55

66

7+
def temporal(ds: xr.Dataset) -> xr.Dataset:
8+
"""Set the temporal extent global attributes
9+
10+
This includes:
11+
* time_coverage_start
12+
* time_coverage_end
13+
"""
14+
ds_ = ds.copy()
15+
16+
fmt = "%Y-%m-%dT%H:%M:%SZ"
17+
attrs = {
18+
"time_coverage_start": ds_.time.min().dt.strftime(fmt).item(),
19+
"time_coverage_end": ds_.time.max().dt.strftime(fmt).item(),
20+
}
21+
22+
ds_.attrs.update(attrs)
23+
return ds_
24+
25+
726
def geospatial(ds: xr.Dataset) -> xr.Dataset:
827
"""Set the geospatial extent global attributes
928

0 commit comments

Comments
 (0)