-
Notifications
You must be signed in to change notification settings - Fork 5
/
designing_classes.py
387 lines (334 loc) · 13.3 KB
/
designing_classes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# -*- coding: utf-8 -*-
"""
.. module:: designing_classes.py
:synopsis: Set of CIM v2 ontology type definitions.
"""
def axis_member():
"""PLACEHOLDER for the real axis_member.
"""
return {
'type': 'class',
'base': None,
'is_abstract': False,
'properties': [
]
}
def domain_requirements():
"""Properties of the domain which needs to be simulated, extent and/or resolution.
"""
return {
'type': 'class',
'base': 'designing.numerical_requirement',
'is_abstract': False,
'properties': [
('required_extent', 'science.topic', '0.1',
"Constraint on extent of domain to be simulated."),
('required_resolution', 'science.topic', '0.1',
"Constraint on resolution required in simulated domain.")
],
'constraints': [
('cardinality', 'additional_requirements', '0.0')
]
}
def ensemble_requirement():
"""Defines an experiment ensemble.
"""
return {
'type': 'class',
'base': 'designing.numerical_requirement',
'is_abstract': False,
'properties': [
('ensemble_member', 'linked_to(designing.numerical_requirement)', '0.N',
"Constraint on each ensemble member."),
('ensemble_type', 'designing.ensemble_types', '1.1',
"Type of ensemble."),
('minimum_size', 'int', '1.1',
"Minimum number of members.")
],
'constraints': [
('cardinality', 'additional_requirements', '0.0')
]
}
def ensemble_types():
"""Defines the various axes along which one can set up an ensemble, whether
as an experiment designer, or in designing a 'response' ensemble around an
experiment.
"""
return {
'type': 'enum',
'is_open': False,
'members': [
("Perturbed Physics", "Members differ in some aspects of their physics."),
("Initialisation Method", "Members differ in how they are initialised."),
("Realization", "Members initialised to sample possible initial conditions."),
("Start Date", "Members initialised at different starting dates."),
("Forced", "Members have differing forcing data."),
("Resolution", "Members are/should-be run at different resolutions."),
("Driven", "Members are/should-be driven by different models.")
]
}
def forcing_constraint():
"""Identifies a model forcing constraint.
"""
return {
'type': 'class',
'base': 'designing.numerical_requirement',
'is_abstract': False,
'properties': [
('additional_constraint', 'str', '0.1',
"Additional information, e.g. hold constant from 2100-01-01."),
('category', 'str', '0.1',
"Category to which this belongs (from a CV, e.g. GASES)."),
('code', 'str', '0.1',
"Programme wide code from a controlled vocabulary (e.g. N2O)."),
('data_link', 'data.dataset', '0.1',
"A data record used by the forcing "),
('forcing_type', 'designing.forcing_types', '1.1',
"Type of integration."),
('group', 'str', '0.1',
"Sub-Category (e.g. GHG)."),
('origin', 'shared.citation', '0.1',
"Pointer to origin, e.g. CMIP6 RCP database.")
],
'constraints': [
('cardinality', 'additional_requirements', '0.0')
]
}
def forcing_types():
"""Defines the possible set of forcing types for a forcing constraint.
"""
return {
'type': 'enum',
'is_open': False,
'members': [
("historical", "Best estimates of actual state (included synthesized)"),
("idealised", "Simplified and/or exemplar, e.g. 1%C02"),
("scenario", "Intended to represent a possible future, e.g. RCP4.5"),
("driven", "Driven from another simulation")
]
}
def initialisation_requirement():
"""A requirement on how a particular simulation should be initialised.
"""
return {
'type': 'class',
'base': 'designing.numerical_requirement',
'is_abstract': False,
'properties': [
('branch_time_in_initialisation_source', 'time.date_time', '0.1',
"If appropriate, the time in the initialisation_source (whether observed or simulated)."),
('initialise_from_data', 'data.dataset', '0.1',
"Initialisation should use this primary dataset."),
('initialise_from_experiment', 'designing.numerical_experiment', '0.1',
"This experiment should be initialised from the output of this experiment.")
],
'constraints': [
('mutually_exclusive', ('initialise_from_experiment', 'initialise_from_data'), '1.1')
]
}
def multi_ensemble():
"""In the case of multiple ensemble axes, defines how they
are set up and ordered.
"""
return {
'type': 'class',
'base': 'designing.numerical_requirement',
'is_abstract': False,
'properties': [
('ensemble_axis', 'linked_to(designing.ensemble_requirement)', '1.N',
"List of orthogonal ensembles.")
],
'constraints': [
('cardinality', 'additional_requirements', '0.0')
]
}
def numerical_experiment():
"""Defines a numerical experiment.
"""
return {
'type': 'class',
'base': 'activity.activity',
'is_abstract': False,
'properties': [
('tier', 'int', '0.1',
"Relative importance of experiment within a MIP."),
('related_experiments', 'designing.numerical_experiment', '0.N',
"Other experiments which have defined relationships to this one."),
('governing_mips', 'linked_to(designing.project)', '0.N',
"MIP(s) overseeing experimental design protocol."),
('related_mips', 'linked_to(designing.project)', '0.N',
"MIP's that require this experiment."),
('required_period', 'linked_to(designing.temporal_constraint)', '1.1',
"Constraint on start date and duration."),
('requirements', 'linked_to(designing.numerical_requirement)', '0.N',
"Additional requirements that conformant simulations need to satisfy.")
],
'constraints': [
('cardinality', 'duration', '0.0'),
('cardinality', 'rationale', '1.1')
]
}
def experimental_relationships():
"""Defines the canonical set of experimental relationships.
"""
return {
'type': 'enum',
'is_open': True,
'members': [
('is_constrained_by',
"The experiment that provides constraint(s) for the target experiment (e.g SST forcing)."),
('is_constrainer_of',
"The set of experiments constrained by the experiment."),
('is_perturbation_from',
"The experiment that provides a control for the target experiment."),
('is_control_for',
"The set of experiments that use the experiment as a control."),
('is_initialized_by',
"The experiment providing initialization for the experiment."),
('is_initializer_of',
"The set of experiments initialized by the experiment."),
('is_sibling_of',
"Part of a family (e.g. experiments where solar forcing is either increased or reduced)."),
]
}
def numerical_requirement():
"""A numerical requirement associated with a numerical experiment.
"""
return {
'type': 'class',
'base': 'activity.activity',
'is_abstract': False,
'alternatives': [
'designing.temporal_constraint',
'designing.forcing_constraint',
'designing.ensemble_requirement',
'designing.multi_ensemble',
'designing.start_date_ensemble',
'designing.output_requirement',
'designing.domain_requirements',
'designing.initialisation_requirement'
],
'properties': [
('additional_requirements', 'linked_to(designing.numerical_requirement)', '0.N',
"Additional detail for this requirement."),
('is_conformance_requested', 'bool', '1.1',
"Indicator as to whether ensemble documentation should include conformance information for this requirement."),
('is_conformance_info_required', 'bool', '1.1',
"Indicator as to whether an institute is expected to provide informationas to how it confirmed."),
('scope', 'designing.numerical_requirement_scope', '0.1',
"Scope allows us to categorise a requirement in terms of how widely it is shared.")
],
'constraints': [
('cardinality', 'duration', '0.0')
]
}
def numerical_requirement_scope():
"""The scope to which a numerical requirement may or may not apply.
"""
return {
'type': 'enum',
'is_open': False,
'members': [
("mip-era", "MIP era wide e.g. 'concentration of pre-industrial CO2' & 'Impose AMIP SSTs'"),
("mip-group", "Shared across a group of MIPs e.g. aerosol forcing in GeoMIP and AerChemMIP."),
("mip", "Shared within a single MIP e.g. spin-up protocol for land surface experiments in LUMIP."),
("experiment", "Applies to a single experiment e.g. CFMIP 'zonally uniform SST plus 4K'")
]
}
def output_requirement():
"""Provides details of what output is required and when from an experiment.
"""
return {
'type': 'class',
'base': 'designing.numerical_requirement',
'is_abstract': False,
'properties': [
('formal_data_request', 'shared.online_resource', '0.1',
"If available, link to a 'cmip' style online request.")
],
'constraints': [
('cardinality', 'additional_requirements', '0.0')
]
}
def project():
"""Describes a scientific project.
"""
return {
'type': 'class',
'base': 'activity.activity',
'is_abstract': False,
'properties': [
('homepage', 'str', '0.1',
"Project homepage."),
('objectives', 'str', '0.N',
"Project objectives."),
('previous_projects', 'linked_to(designing.project)', '0.N',
"Previous projects with similar aims."),
('required_experiments', 'linked_to(designing.numerical_experiment)', '0.N',
"Experiments required to deliver project."),
('governed_experiments', 'linked_to(designing.numerical_experiment)', '0.N',
"Experiments governed by this project."),
('sub_projects', 'linked_to(designing.project)', '0.N',
"Activities within the project with their own name and aim(s).")
],
'constraints': [
('cardinality', 'description', '1.1')
]
}
def simulation_plan():
"""Describes a simulation that needs to be run.
"""
return {
'type': 'class',
'base': 'activity.activity',
'is_abstract': False,
'properties': [
('expected_model', 'linked_to(science.model)', '1.1',
"The model used to run the simulation."),
('expected_performance_sypd', 'float', '0.1',
"Expected performance in simulated years per real day."),
('expected_platform', 'linked_to(platform.machine)', '0.1',
"The machine on which the simulation will be run."),
('will_support_experiments', 'linked_to(designing.numerical_experiment)', '1.N',
"An experiment with which the planned simulation will be associated.")
],
'constraints': [
('cardinality', 'duration', '1.1')
]
}
def start_date_ensemble():
"""Defines an experiment ensemble with multiple start dates.
"""
return {
'type': 'class',
'base': 'designing.numerical_requirement',
'is_abstract': False,
'properties': [
('ensemble_members', 'time.datetime_set', '1.1',
"Description of date or time set of start dates.")
],
'constraints': [
('cardinality', 'additional_requirements', '0.0')
]
}
def temporal_constraint():
"""A spatio-temporal constraint on a numerical experiment.
"""
return {
'type': 'class',
'base': 'designing.numerical_requirement',
'is_abstract': False,
'properties': [
('required_calendar', 'time.calendar', '0.1',
"Required calendar (e.g. for paleo simulations)."),
('required_duration', 'time.time_period', '0.1',
"Constraint on time or length of simulation."),
('start_date', 'time.date_time', '0.1',
"Required start date."),
('start_flexibility', 'time.time_period', '0.1',
"Amount of time before required start date that it is permissible to begin integration.")
],
'constraints': [
('cardinality', 'additional_requirements', '0.0')
]
}