Skip to content

Commit 0781747

Browse files
Merge pull request #78 from euro-cordex/drs_format_change_fix
DRS format change fix
2 parents e401a07 + e92e1d4 commit 0781747

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

cc_plugin_cc6/base.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class MIPCVCheck(BaseNCCheck, MIPCVCheckBase):
6161
def make_result(cls, level, score, out_of, name, messages):
6262
return Result(level, (score, out_of), name, messages)
6363

64+
def __del__(self):
65+
xrds = getattr(self, "xrds", None)
66+
if xrds is not None and hasattr(xrds, "close"):
67+
xrds.close()
68+
6469
def setup(self, dataset):
6570
# netCDF4.Dataset
6671
self.dataset = dataset
@@ -620,8 +625,11 @@ def _map_drs_blocks(self):
620625
drs_filename_template = re.findall(
621626
r"<([^<>]*)\>", self.CV["DRS"]["filename_template"]
622627
)
623-
self.drs_suffix = ".".join(
624-
self.CV["DRS"]["filename_template"].split(".")[1:]
628+
# Fix for new DRS template format
629+
if "time_range" not in drs_filename_template:
630+
drs_filename_template.append("time_range")
631+
self.drs_suffix = (
632+
".".join(self.CV["DRS"]["filename_template"].split(".")[1:]) or "nc"
625633
)
626634
except KeyError:
627635
raise KeyError("The CV does not contain DRS information.")

cc_plugin_cc6/cc6.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,18 @@ def setup(self, dataset):
5151
CORDEX_CMIP6_CMOR_TABLES_URL + "CORDEX-CMIP6_" + table + ".json",
5252
filename,
5353
tables_path,
54-
force=self.options.get("force_table_download", False),
54+
force="force_table_download" in self.options
55+
and (
56+
self.options["force_table_download"] is None
57+
or (
58+
isinstance(self.options["force_table_download"], bool)
59+
and self.options["force_table_download"]
60+
)
61+
or (
62+
isinstance(self.options["force_table_download"], str)
63+
and self.options["force_table_download"].lower() != "false"
64+
)
65+
),
5566
)
5667
if os.path.basename(os.path.realpath(filename_retrieved)) != filename:
5768
raise AssertionError(

0 commit comments

Comments
 (0)