Skip to content

Commit 4c7bf9a

Browse files
committed
Fix GREGORIAN calendar for ocean
1 parent f4cba25 commit 4c7bf9a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/access_mopper/cmip6_cmoriser.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ def _check_units(self, var: str, expected: str) -> bool:
8484
def _check_calendar(self, var: str):
8585
calendar = self.ds[var].attrs.get("calendar")
8686
units = self.ds[var].attrs.get("units")
87+
88+
# TODO: Remove at some point. ESM1.6 should have this fixed.
89+
if calendar == "GREGORIAN":
90+
# Replace GREGORIAN with Proleptic Gregorian
91+
self.ds[var].attrs["calendar"] = "proleptic_gregorian"
92+
# Replace calendar type attribute with proleptic_gregorian
93+
if "calendar_type" in self.ds[var].attrs:
94+
self.ds[var].attrs["calendar_type"] = "proleptic_gregorian"
95+
calendar = calendar.lower() if calendar else None
96+
8797
if not calendar or not units:
8898
return
8999
try:
@@ -604,6 +614,9 @@ def update_attributes(self):
604614
self.type_mapping.get(var_type, np.float64)
605615
)
606616

617+
# Check calendar and units
618+
self._check_calendar("time")
619+
607620
# TODO need to refactor this.
608621
def run(self):
609622
# self.load_dataset()

0 commit comments

Comments
 (0)