Skip to content

Commit 107eff4

Browse files
committed
More improvements
1 parent 784cb7c commit 107eff4

2 files changed

Lines changed: 35 additions & 22 deletions

File tree

esmvalcore/config/configurations/data-xcube-ccizarr.yml renamed to esmvalcore/config/configurations/data-xcube-cci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@ projects:
77
ccizarr:
88
type: "esmvalcore.io.xcube.XCubeDataSource"
99
data_store_id: "ccizarr"
10+
priority: 1
11+
esa-cci-kc:
12+
type: "esmvalcore.io.xcube.XCubeDataSource"
13+
data_store_id: "esa-cci-kc"
14+
priority: 2
15+
cciodp:
16+
type: "esmvalcore.io.xcube.XCubeDataSource"
17+
data_store_id: "cciodp"
18+
priority: 3

esmvalcore/io/xcube.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
logger = logging.getLogger(__name__)
3333

3434
FREQUENCIES = {
35-
"P1M": "mon",
3635
"P1D": "day",
36+
"P1M": "mon",
37+
"P1Y": "yr",
3738
}
3839

3940

@@ -113,6 +114,9 @@ def to_iris(self) -> iris.cube.CubeList:
113114
return dataset_to_iris(dataset)
114115

115116

117+
_DATASETS_LOGGED: set[str] = set()
118+
119+
116120
@dataclass
117121
class XCubeDataSource(esmvalcore.io.protocol.DataSource):
118122
"""Data source for finding files on a local filesystem."""
@@ -168,6 +172,13 @@ def find_data(self, **facets: FacetValue) -> list[XCubeDataset]: # noqa: C901,P
168172
if isinstance(requested_datasets, str | int | float):
169173
requested_datasets = [str(requested_datasets)]
170174
available_datasets = store.list_data_ids()
175+
if self.data_store_id not in _DATASETS_LOGGED:
176+
_DATASETS_LOGGED.add(self.data_store_id)
177+
logger.debug(
178+
"Available datasets in %s are:\n%s",
179+
self.data_store_id,
180+
"\n".join(sorted(available_datasets)),
181+
)
171182

172183
for data_id in available_datasets:
173184
for dataset_pattern in requested_datasets:
@@ -185,8 +196,10 @@ def find_data(self, **facets: FacetValue) -> list[XCubeDataset]: # noqa: C901,P
185196
"No variable matching % found in %s. Available variables are: %s",
186197
requested_short_names,
187198
data_id,
188-
available_short_names,
199+
", ".join(sorted(available_short_names)),
189200
)
201+
continue
202+
190203
# TODO: Maybe this is too complicated and we should only
191204
# decide which variables to keep/drop after load and conversion
192205
# to iris cube.
@@ -215,37 +228,28 @@ def find_data(self, **facets: FacetValue) -> list[XCubeDataset]: # noqa: C901,P
215228
"-",
216229
"",
217230
)
218-
native_frequency = description.attrs[
219-
"time_coverage_resolution"
220-
]
221-
frequency = FREQUENCIES.get(
222-
native_frequency,
223-
native_frequency,
224-
)
225-
226231
dataset = XCubeDataset(
227232
name=data_id,
228233
facets={
229234
"dataset": data_id,
230-
"short_name": short_names
231-
if len(short_names) > 1
232-
else short_names[0],
233-
"frequency": frequency,
235+
"short_name": (
236+
short_names[0]
237+
if len(short_names) == 1
238+
else short_names
239+
),
234240
"timerange": timerange,
235241
},
236242
store=store,
237243
open_params=open_params,
238244
)
245+
frequency = FREQUENCIES.get(
246+
description.attrs.get("time_coverage_resolution", ""),
247+
)
248+
if frequency:
249+
# Assign the frequency facet if it is a known frequency.
250+
dataset.facets["frequency"] = frequency
239251
dataset.attributes = description.attrs
240252

241253
result.append(dataset)
242254

243-
if not result:
244-
logger.debug(
245-
"No datasets matching %s found in %s. Available datasets are: %s",
246-
requested_datasets,
247-
self.data_store_id,
248-
available_datasets,
249-
)
250-
251255
return result

0 commit comments

Comments
 (0)