easysnowdata.processing.add_water_year_coords#
- easysnowdata.processing.add_water_year_coords(obj: Dataset | DataArray, hemisphere: str = 'northern', *, dim: str = 'time', names: tuple[str, str] = ('water_year', 'dowy'), station_dim: str = 'station', latitude: str = 'latitude') Dataset | DataArray[source]#
Attach
water_yearanddowycoordinates along dim.Both are plain integer coordinates, so
obj.groupby("water_year")andobj.swap_dims({"time": "dowy"})work directly.hemisphere is
"northern","southern"or"auto"."auto"reads each station’s hemisphere from the latitude coordinate on station_dim and records it as ahemispherecoordinate there:every station in one hemisphere: the coordinates stay 1-D on dim, exactly as with that hemisphere named;
stations in both: the coordinates become 2-D,
(station_dim, dim), so a southern station’s April–March season is one water year while a northern one’s is October–September.groupby("water_year")still works and compares like with like (water year N peaks in calendar year N in both hemispheres);swap_dimsneeds one station first, e.g.ds.sel(station=code).swap_dims({"time": "dowy"}).
Without a latitude coordinate
"auto"falls back to northern with a warning.