climate-ref-core 0.6.3__py3-none-any.whl → 0.6.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- climate_ref_core/constraints.py +18 -8
- climate_ref_core/providers.py +8 -10
- {climate_ref_core-0.6.3.dist-info → climate_ref_core-0.6.5.dist-info}/METADATA +1 -1
- {climate_ref_core-0.6.3.dist-info → climate_ref_core-0.6.5.dist-info}/RECORD +7 -7
- {climate_ref_core-0.6.3.dist-info → climate_ref_core-0.6.5.dist-info}/WHEEL +0 -0
- {climate_ref_core-0.6.3.dist-info → climate_ref_core-0.6.5.dist-info}/licenses/LICENCE +0 -0
- {climate_ref_core-0.6.3.dist-info → climate_ref_core-0.6.5.dist-info}/licenses/NOTICE +0 -0
climate_ref_core/constraints.py
CHANGED
|
@@ -200,17 +200,27 @@ class AddSupplementaryDataset:
|
|
|
200
200
|
for facet, values in supplementary_facets.items():
|
|
201
201
|
mask = supplementary_group[facet].isin(values)
|
|
202
202
|
supplementary_group = supplementary_group[mask]
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
facets =
|
|
203
|
+
if not supplementary_group.empty:
|
|
204
|
+
matching_facets = list(self.matching_facets)
|
|
205
|
+
facets = matching_facets + list(self.optional_matching_facets)
|
|
206
206
|
datasets = group[facets].drop_duplicates()
|
|
207
207
|
indices = set()
|
|
208
208
|
for i in range(len(datasets)):
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
dataset = datasets.iloc[i]
|
|
210
|
+
# Restrict the supplementary datasets to those that match the main dataset.
|
|
211
|
+
supplementaries = supplementary_group[
|
|
212
|
+
(supplementary_group[matching_facets] == dataset[matching_facets]).all(1)
|
|
213
|
+
]
|
|
214
|
+
if not supplementaries.empty:
|
|
215
|
+
# Select the best matching supplementary dataset based on the optional matching facets.
|
|
216
|
+
scores = (supplementaries[facets] == dataset).sum(axis=1)
|
|
217
|
+
matches = supplementaries[scores == scores.max()]
|
|
218
|
+
if "version" in facets:
|
|
219
|
+
# Select the latest version if there are multiple matches
|
|
220
|
+
matches = matches[matches["version"] == matches["version"].max()]
|
|
221
|
+
# Select one match per dataset
|
|
222
|
+
indices.add(matches.index[0])
|
|
223
|
+
|
|
214
224
|
supplementary_group = supplementary_group.loc[list(indices)].drop_duplicates()
|
|
215
225
|
|
|
216
226
|
return pd.concat([group, supplementary_group])
|
climate_ref_core/providers.py
CHANGED
|
@@ -136,7 +136,7 @@ def import_provider(fqn: str) -> DiagnosticProvider:
|
|
|
136
136
|
fqn
|
|
137
137
|
Full package and attribute name of the provider to import
|
|
138
138
|
|
|
139
|
-
For example: `climate_ref_example
|
|
139
|
+
For example: `climate_ref_example:provider` will use the `provider` attribute from the
|
|
140
140
|
`climate_ref_example` package.
|
|
141
141
|
|
|
142
142
|
If only a package name is provided, the default attribute name is `provider`.
|
|
@@ -153,24 +153,22 @@ def import_provider(fqn: str) -> DiagnosticProvider:
|
|
|
153
153
|
:
|
|
154
154
|
DiagnosticProvider instance
|
|
155
155
|
"""
|
|
156
|
-
if "
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
name = "provider"
|
|
156
|
+
if ":" not in fqn:
|
|
157
|
+
fqn = f"{fqn}:provider"
|
|
158
|
+
|
|
159
|
+
entrypoint = importlib.metadata.EntryPoint(name="provider", value=fqn, group="climate-ref.providers")
|
|
161
160
|
|
|
162
161
|
try:
|
|
163
|
-
|
|
164
|
-
provider = getattr(imp, name)
|
|
162
|
+
provider = entrypoint.load()
|
|
165
163
|
if not isinstance(provider, DiagnosticProvider):
|
|
166
164
|
raise InvalidProviderException(fqn, f"Expected DiagnosticProvider, got {type(provider)}")
|
|
167
165
|
return provider
|
|
168
166
|
except ModuleNotFoundError:
|
|
169
167
|
logger.error(f"Module '{fqn}' not found")
|
|
170
|
-
raise InvalidProviderException(fqn,
|
|
168
|
+
raise InvalidProviderException(fqn, "Module not found")
|
|
171
169
|
except AttributeError:
|
|
172
170
|
logger.error(f"Provider '{fqn}' not found")
|
|
173
|
-
raise InvalidProviderException(fqn,
|
|
171
|
+
raise InvalidProviderException(fqn, "Provider not found in module")
|
|
174
172
|
|
|
175
173
|
|
|
176
174
|
class CommandLineDiagnosticProvider(DiagnosticProvider):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: climate-ref-core
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.5
|
|
4
4
|
Summary: Core library for the CMIP Rapid Evaluation Framework
|
|
5
5
|
Author-email: Jared Lewis <jared.lewis@climate-resource.com>, Mika Pflueger <mika.pflueger@climate-resource.com>, Bouwe Andela <b.andela@esciencecenter.nl>, Jiwoo Lee <lee1043@llnl.gov>, Min Xu <xum1@ornl.gov>, Nathan Collier <collierno@ornl.gov>, Dora Hegedus <dora.hegedus@stfc.ac.uk>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
climate_ref_core/__init__.py,sha256=MtmPThF2F9_2UODEN6rt1x30LDxrHIZ0wyRN_wsHx5I,127
|
|
2
|
-
climate_ref_core/constraints.py,sha256=
|
|
2
|
+
climate_ref_core/constraints.py,sha256=ocduDnuhTbOeX6hstWMFfcHvdguEI-5BE24QRKlbgK0,12399
|
|
3
3
|
climate_ref_core/dataset_registry.py,sha256=sQp2VT9xSVAaWsf0tF4E_VQxuEsvIxU2MZm5uNX1ynw,7172
|
|
4
4
|
climate_ref_core/datasets.py,sha256=TK50WQwTfbase26s8wPEGEN1BwcedrOd8nk6IlEf3Ww,6124
|
|
5
5
|
climate_ref_core/diagnostics.py,sha256=5KCtHuhToSpATqjW4HBi56PsOxT5WX4VkqoZPUvYR60,18769
|
|
@@ -7,7 +7,7 @@ climate_ref_core/env.py,sha256=Ph2dejVxTELfP3bL0xES086WLGvV5H6KvsOwCkL6m-k,753
|
|
|
7
7
|
climate_ref_core/exceptions.py,sha256=7Mkz22P-kbiL-ZevAhlOuQaaeTio6zpwE9YA45OTGvs,1909
|
|
8
8
|
climate_ref_core/executor.py,sha256=QiVOca-d9JxKIktQIinQQYZGr3ecV5mL3nvUwCdMiJQ,5372
|
|
9
9
|
climate_ref_core/logging.py,sha256=cg6CK2DHGjyLaoRJm75p-Ja82hnVhBBQ4riOKk3l9XY,7063
|
|
10
|
-
climate_ref_core/providers.py,sha256=
|
|
10
|
+
climate_ref_core/providers.py,sha256=HZTpz1VFa9yZLPr1Cwofag2TCuwn6P4VPOrBaXbhn0A,12746
|
|
11
11
|
climate_ref_core/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
climate_ref_core/metric_values/__init__.py,sha256=aHfwRrqzLOmmaBKf1-4q97DnHb8KwmW0Dhwd79ZQiNQ,634
|
|
13
13
|
climate_ref_core/metric_values/typing.py,sha256=2DpzmjqQ7tqOPAyjthZ_O14c0-MhiYt-A_n9p6-bOao,1903
|
|
@@ -17,8 +17,8 @@ climate_ref_core/pycmec/controlled_vocabulary.py,sha256=_GZ2Y6KAYF12I3IS27g8YdFB
|
|
|
17
17
|
climate_ref_core/pycmec/cv_cmip7_aft.yaml,sha256=gx5QyW88pZQVUfiYXmsJtJO6AJg6NbIZgdU4vDIa3fE,4390
|
|
18
18
|
climate_ref_core/pycmec/metric.py,sha256=zymXoutnjbdcxvG_fMJugFLLcBrfSPG0XoV-2tA0ujA,18499
|
|
19
19
|
climate_ref_core/pycmec/output.py,sha256=4-RQ439sfgNLeQZVDPB1pewF_kTwX7nCK0Z4U6bvbd0,5709
|
|
20
|
-
climate_ref_core-0.6.
|
|
21
|
-
climate_ref_core-0.6.
|
|
22
|
-
climate_ref_core-0.6.
|
|
23
|
-
climate_ref_core-0.6.
|
|
24
|
-
climate_ref_core-0.6.
|
|
20
|
+
climate_ref_core-0.6.5.dist-info/METADATA,sha256=cZdSd_IyqVtP1L8EJAtvTKNpqjruVVf2yx5fjL3puSs,2930
|
|
21
|
+
climate_ref_core-0.6.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
22
|
+
climate_ref_core-0.6.5.dist-info/licenses/LICENCE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
23
|
+
climate_ref_core-0.6.5.dist-info/licenses/NOTICE,sha256=4qTlax9aX2-mswYJuVrLqJ9jK1IkN5kSBqfVvYLF3Ws,128
|
|
24
|
+
climate_ref_core-0.6.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|