CSET 0.1.0__tar.gz
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.
- CSET-0.1.0/LICENCE +202 -0
- CSET-0.1.0/PKG-INFO +50 -0
- CSET-0.1.0/README.md +36 -0
- CSET-0.1.0/pyproject.toml +105 -0
- CSET-0.1.0/setup.cfg +25 -0
- CSET-0.1.0/src/CSET/__init__.py +65 -0
- CSET-0.1.0/src/CSET/__main__.py +18 -0
- CSET-0.1.0/src/CSET/operators/RECIPES/__init__.py +25 -0
- CSET-0.1.0/src/CSET/operators/__init__.py +22 -0
- CSET-0.1.0/src/CSET/operators/_internal.py +121 -0
- CSET-0.1.0/src/CSET/operators/constraints.py +148 -0
- CSET-0.1.0/src/CSET/operators/filters.py +55 -0
- CSET-0.1.0/src/CSET/operators/misc.py +35 -0
- CSET-0.1.0/src/CSET/operators/plot.py +50 -0
- CSET-0.1.0/src/CSET/operators/read.py +48 -0
- CSET-0.1.0/src/CSET/operators/write.py +50 -0
- CSET-0.1.0/src/CSET.egg-info/PKG-INFO +50 -0
- CSET-0.1.0/src/CSET.egg-info/SOURCES.txt +29 -0
- CSET-0.1.0/src/CSET.egg-info/dependency_links.txt +1 -0
- CSET-0.1.0/src/CSET.egg-info/entry_points.txt +2 -0
- CSET-0.1.0/src/CSET.egg-info/requires.txt +8 -0
- CSET-0.1.0/src/CSET.egg-info/top_level.txt +1 -0
- CSET-0.1.0/tests/test_cli.py +34 -0
- CSET-0.1.0/tests/test_constraints.py +76 -0
- CSET-0.1.0/tests/test_filters.py +36 -0
- CSET-0.1.0/tests/test_misc.py +22 -0
- CSET-0.1.0/tests/test_plots.py +29 -0
- CSET-0.1.0/tests/test_read.py +27 -0
- CSET-0.1.0/tests/test_recipe_parser.py +75 -0
- CSET-0.1.0/tests/test_write.py +34 -0
CSET-0.1.0/LICENCE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
CSET-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: CSET
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Convective Scale Evaluation Tool for evaluation and investigation of regional models.
|
|
5
|
+
Author: Met Office, NIWA
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Documentation, https://metoffice.github.io/CSET
|
|
8
|
+
Project-URL: Source, https://github.com/MetOffice/CSET
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENCE
|
|
14
|
+
|
|
15
|
+
# CSET
|
|
16
|
+
|
|
17
|
+
CSET is a tool to aid in evaluating regional model configurations. It aims to
|
|
18
|
+
replace the collection of bespoke scripts littering people’s home directories,
|
|
19
|
+
reducing effort wasted on duplicating already existing code. This centralisation
|
|
20
|
+
of diagnostics should also make evaluations more consistent and comparable.
|
|
21
|
+
Development takes place in the CSET repository on GitHub.
|
|
22
|
+
|
|
23
|
+
Please read [the documentation](https://metoffice.github.io/CSET) to learn more
|
|
24
|
+
about CSET, and how to use it.
|
|
25
|
+
|
|
26
|
+
## Contributing
|
|
27
|
+
|
|
28
|
+
Contributions are readily welcomed! To get started with developing CSET visit
|
|
29
|
+
the [Working
|
|
30
|
+
Practices](https://metoffice.github.io/CSET/working-practices/#getting-started)
|
|
31
|
+
section of the documentation.
|
|
32
|
+
|
|
33
|
+
In addition to reading the working practices, the key
|
|
34
|
+
recommendation is early communication. Open an [issue on
|
|
35
|
+
Github](https://github.com/MetOffice/CSET/issues) with your proposed change or
|
|
36
|
+
addition in the design phase, and then others can provide guidance early.
|
|
37
|
+
|
|
38
|
+
## Licence
|
|
39
|
+
|
|
40
|
+
Copyright © 2022-2023 Met Office and contributors.
|
|
41
|
+
|
|
42
|
+
Licensed under the [Apache License, Version 2.0](LICENCE) (the "License"); You
|
|
43
|
+
may obtain a copy of the License at
|
|
44
|
+
|
|
45
|
+
<http://www.apache.org/licenses/LICENSE-2.0>
|
|
46
|
+
|
|
47
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
48
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
49
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
50
|
+
specific language governing permissions and limitations under the License.
|
CSET-0.1.0/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# CSET
|
|
2
|
+
|
|
3
|
+
CSET is a tool to aid in evaluating regional model configurations. It aims to
|
|
4
|
+
replace the collection of bespoke scripts littering people’s home directories,
|
|
5
|
+
reducing effort wasted on duplicating already existing code. This centralisation
|
|
6
|
+
of diagnostics should also make evaluations more consistent and comparable.
|
|
7
|
+
Development takes place in the CSET repository on GitHub.
|
|
8
|
+
|
|
9
|
+
Please read [the documentation](https://metoffice.github.io/CSET) to learn more
|
|
10
|
+
about CSET, and how to use it.
|
|
11
|
+
|
|
12
|
+
## Contributing
|
|
13
|
+
|
|
14
|
+
Contributions are readily welcomed! To get started with developing CSET visit
|
|
15
|
+
the [Working
|
|
16
|
+
Practices](https://metoffice.github.io/CSET/working-practices/#getting-started)
|
|
17
|
+
section of the documentation.
|
|
18
|
+
|
|
19
|
+
In addition to reading the working practices, the key
|
|
20
|
+
recommendation is early communication. Open an [issue on
|
|
21
|
+
Github](https://github.com/MetOffice/CSET/issues) with your proposed change or
|
|
22
|
+
addition in the design phase, and then others can provide guidance early.
|
|
23
|
+
|
|
24
|
+
## Licence
|
|
25
|
+
|
|
26
|
+
Copyright © 2022-2023 Met Office and contributors.
|
|
27
|
+
|
|
28
|
+
Licensed under the [Apache License, Version 2.0](LICENCE) (the "License"); You
|
|
29
|
+
may obtain a copy of the License at
|
|
30
|
+
|
|
31
|
+
<http://www.apache.org/licenses/LICENSE-2.0>
|
|
32
|
+
|
|
33
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
34
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
35
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
36
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "CSET"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Convective Scale Evaluation Tool for evaluation and investigation of regional models."
|
|
5
|
+
authors = [{ name = "Met Office" }, { name = "NIWA" }]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = { text = "Apache-2.0" }
|
|
8
|
+
requires-python = ">=3.8"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"License :: OSI Approved :: Apache Software License",
|
|
11
|
+
"Topic :: Scientific/Engineering :: GIS",
|
|
12
|
+
]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"numpy",
|
|
15
|
+
"scitools-iris",
|
|
16
|
+
"tomli >= 1.1.0 ; python_version < '3.11'",
|
|
17
|
+
"importlib_resources >= 3.0.0 ; python_version < '3.9'",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Documentation = "https://metoffice.github.io/CSET"
|
|
22
|
+
Source = "https://github.com/MetOffice/CSET"
|
|
23
|
+
|
|
24
|
+
[project.scripts]
|
|
25
|
+
cset = "CSET:main"
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["setuptools>=61.0"]
|
|
29
|
+
build-backend = "setuptools.build_meta"
|
|
30
|
+
|
|
31
|
+
[tool.pytest.ini_options]
|
|
32
|
+
addopts = ["--import-mode=importlib", "--verbose", "--cov"]
|
|
33
|
+
pythonpath = ["src"]
|
|
34
|
+
filterwarnings = ['ignore::DeprecationWarning:pytest']
|
|
35
|
+
|
|
36
|
+
[tool.coverage.run]
|
|
37
|
+
branch = true
|
|
38
|
+
relative_files = true
|
|
39
|
+
source = ["src"]
|
|
40
|
+
|
|
41
|
+
[tool.coverage.report]
|
|
42
|
+
# This should be steadily increased to ~95% as we add more tests.
|
|
43
|
+
fail_under = 80.0
|
|
44
|
+
|
|
45
|
+
[tool.tox]
|
|
46
|
+
legacy_tox_ini = '''
|
|
47
|
+
[tox]
|
|
48
|
+
requires = tox-conda
|
|
49
|
+
isolated_build = True
|
|
50
|
+
envlist =
|
|
51
|
+
coverage-clean
|
|
52
|
+
py310-linux-tests
|
|
53
|
+
py310-linux-docs
|
|
54
|
+
|
|
55
|
+
[testenv:py{38,39,310,311}-lock]
|
|
56
|
+
allowlist_externals = cp
|
|
57
|
+
conda_channels = conda-forge
|
|
58
|
+
conda_create_args = --override-channels
|
|
59
|
+
conda_deps =
|
|
60
|
+
pip
|
|
61
|
+
conda-lock
|
|
62
|
+
description = Create explicit environment specification conda lock files for CSET dependencies.
|
|
63
|
+
skip_install = true
|
|
64
|
+
setenv =
|
|
65
|
+
LOCKDIR = {toxinidir}{/}requirements{/}locks{/}
|
|
66
|
+
TMPFILE = {envtmpdir}{/}environment.yml
|
|
67
|
+
YMLFILE = {toxinidir}{/}requirements{/}environment.yml
|
|
68
|
+
commands =
|
|
69
|
+
cp "{env:YMLFILE}" "{env:TMPFILE}"
|
|
70
|
+
# Hacky script to avoid having to have per-python-version yaml files.
|
|
71
|
+
python3 -c 'from sys import version_info as v; fh = open("{env:TMPFILE}", "a"); fh.write(f"\n - python =\{v.major\}.\{v.minor\}\n")'
|
|
72
|
+
conda-lock --channel conda-forge --kind explicit --file {env:TMPFILE} --platform linux-64 --filename-template "{env:LOCKDIR}{envname}-\{platform\}.txt" {posargs}
|
|
73
|
+
|
|
74
|
+
[testenv:py{38,39,310,311}-{linux,osx,win}-tests]
|
|
75
|
+
description = Run unit and integration tests with PyTest.
|
|
76
|
+
conda_spec =
|
|
77
|
+
py38-linux: {toxinidir}{/}requirements{/}locks{/}py38-lock-linux-64.txt
|
|
78
|
+
py39-linux: {toxinidir}{/}requirements{/}locks{/}py39-lock-linux-64.txt
|
|
79
|
+
py310-linux: {toxinidir}{/}requirements{/}locks{/}py310-lock-linux-64.txt
|
|
80
|
+
py311-linux: {toxinidir}{/}requirements{/}locks{/}py311-lock-linux-64.txt
|
|
81
|
+
usedevelop = true
|
|
82
|
+
depends = coverage-clean
|
|
83
|
+
commands = pytest --cov-append {posargs}
|
|
84
|
+
|
|
85
|
+
[testenv:py{38,39,310,311}-{linux,osx,win}-docs]
|
|
86
|
+
description = Invoke sphinx-build to build the HTML docs.
|
|
87
|
+
conda_spec =
|
|
88
|
+
py38-linux: {toxinidir}{/}requirements{/}locks{/}py38-lock-linux-64.txt
|
|
89
|
+
py39-linux: {toxinidir}{/}requirements{/}locks{/}py39-lock-linux-64.txt
|
|
90
|
+
py310-linux: {toxinidir}{/}requirements{/}locks{/}py310-lock-linux-64.txt
|
|
91
|
+
py311-linux: {toxinidir}{/}requirements{/}locks{/}py311-lock-linux-64.txt
|
|
92
|
+
usedevelop = true
|
|
93
|
+
commands = sphinx-build -d "docs/build/doctree" docs/source "docs/build/html" --color -W -bhtml {posargs}
|
|
94
|
+
|
|
95
|
+
[testenv:build-package]
|
|
96
|
+
description = Build sdist and wheel packages.
|
|
97
|
+
deps = build
|
|
98
|
+
skip_install = true
|
|
99
|
+
commands = python3 -m build
|
|
100
|
+
|
|
101
|
+
[testenv:coverage-clean]
|
|
102
|
+
deps = coverage
|
|
103
|
+
skip_install = true
|
|
104
|
+
commands = coverage erase
|
|
105
|
+
'''
|
CSET-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[flake8]
|
|
2
|
+
max-line-length = 88
|
|
3
|
+
max-complexity = 19
|
|
4
|
+
docstring-convention = numpy
|
|
5
|
+
select = C,D,E,F,W,B,B950
|
|
6
|
+
ignore =
|
|
7
|
+
E203,
|
|
8
|
+
E226,
|
|
9
|
+
E231,
|
|
10
|
+
E402,
|
|
11
|
+
E501,
|
|
12
|
+
E731,
|
|
13
|
+
W503,
|
|
14
|
+
W504
|
|
15
|
+
exclude =
|
|
16
|
+
.eggs
|
|
17
|
+
_build
|
|
18
|
+
cli.py
|
|
19
|
+
per-file-ignores =
|
|
20
|
+
__init__.py: F401
|
|
21
|
+
|
|
22
|
+
[egg_info]
|
|
23
|
+
tag_build =
|
|
24
|
+
tag_date = 0
|
|
25
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Copyright 2022-2023 Met Office and contributors.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
CSET: Convective Scale Evaluation Tool
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import logging
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def main():
|
|
25
|
+
"""CLI entrypoint."""
|
|
26
|
+
parser = argparse.ArgumentParser(
|
|
27
|
+
prog="cset", description="Convective Scale Evaluation Tool."
|
|
28
|
+
)
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"--verbose",
|
|
31
|
+
"-v",
|
|
32
|
+
action="count",
|
|
33
|
+
default=0,
|
|
34
|
+
help="increase output verbosity, may be specified multiple times",
|
|
35
|
+
)
|
|
36
|
+
# https://docs.python.org/3/library/argparse.html#sub-commands
|
|
37
|
+
subparsers = parser.add_subparsers(title="subcommands", dest="subparser")
|
|
38
|
+
|
|
39
|
+
# Run operator chain
|
|
40
|
+
parser_operators = subparsers.add_parser(
|
|
41
|
+
"operators", help="run a chain of operators"
|
|
42
|
+
)
|
|
43
|
+
parser_operators.add_argument("input_file", type=Path, help="input file to read")
|
|
44
|
+
parser_operators.add_argument("output_file", type=Path, help="output file to write")
|
|
45
|
+
parser_operators.add_argument(
|
|
46
|
+
"recipe_file", type=Path, help="recipe file to execute"
|
|
47
|
+
)
|
|
48
|
+
parser_operators.set_defaults(func=_run_operators)
|
|
49
|
+
args = parser.parse_args()
|
|
50
|
+
# Logging verbosity
|
|
51
|
+
if args.verbose >= 2:
|
|
52
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
53
|
+
elif args.verbose >= 1:
|
|
54
|
+
logging.basicConfig(level=logging.INFO)
|
|
55
|
+
|
|
56
|
+
if args.subparser:
|
|
57
|
+
args.func(args)
|
|
58
|
+
else:
|
|
59
|
+
parser.print_help()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _run_operators(args):
|
|
63
|
+
from .operators import execute_recipe
|
|
64
|
+
|
|
65
|
+
execute_recipe(args.recipe_file, args.input_file, args.output_file)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Copyright 2022-2023 Met Office and contributors.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
import sys # pragma: no cover
|
|
16
|
+
from . import main # pragma: no cover
|
|
17
|
+
|
|
18
|
+
sys.exit(main()) # pragma: no cover
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright 2022-2023 Met Office and contributors.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""
|
|
16
|
+
This module has an attribute for each recipe, holding the Path to that recipe.
|
|
17
|
+
"""
|
|
18
|
+
try:
|
|
19
|
+
from importlib.resources import files
|
|
20
|
+
except ImportError:
|
|
21
|
+
# importlib has the files API from python 3.9
|
|
22
|
+
from importlib_resources import files
|
|
23
|
+
import CSET.operators.RECIPES as recipes
|
|
24
|
+
|
|
25
|
+
extract_instant_air_temp = files(recipes).joinpath("extract_instant_air_temp.toml")
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Copyright 2022-2023 Met Office and contributors.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""This subpackage contains all of CSET's operators."""
|
|
16
|
+
from . import RECIPES, constraints, read, write, filters, plot, misc
|
|
17
|
+
from ._internal import execute_recipe
|
|
18
|
+
|
|
19
|
+
# Stop iris giving a warning whenever it loads something.
|
|
20
|
+
from iris import FUTURE
|
|
21
|
+
|
|
22
|
+
FUTURE.datum_support = True
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Copyright 2022-2023 Met Office and contributors.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
"""Internal functions used to run operators."""
|
|
16
|
+
|
|
17
|
+
import logging
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
import tomllib
|
|
22
|
+
except ModuleNotFoundError:
|
|
23
|
+
# tomllib is in standard library from 3.11.
|
|
24
|
+
import tomli as tomllib
|
|
25
|
+
|
|
26
|
+
import CSET.operators
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_operator(name: str):
|
|
30
|
+
"""
|
|
31
|
+
Gets an operator by its name.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
name: str
|
|
36
|
+
The name of the desired operator.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
function
|
|
41
|
+
The named operator.
|
|
42
|
+
|
|
43
|
+
Raises
|
|
44
|
+
------
|
|
45
|
+
ValueError
|
|
46
|
+
If name is not an operator.
|
|
47
|
+
|
|
48
|
+
Examples
|
|
49
|
+
--------
|
|
50
|
+
>>> CSET.operators.get_operator("read.read_cubes")
|
|
51
|
+
<function read_cubes at 0x7fcf9353c8b0>
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
name_sections = name.split(".")
|
|
56
|
+
operator = CSET.operators
|
|
57
|
+
for section in name_sections:
|
|
58
|
+
operator = getattr(operator, section)
|
|
59
|
+
if callable(operator):
|
|
60
|
+
return operator
|
|
61
|
+
else:
|
|
62
|
+
raise AttributeError
|
|
63
|
+
except (AttributeError, TypeError):
|
|
64
|
+
raise ValueError(f"Unknown operator: {name}")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def execute_recipe(recipe_file: Path, input_file: Path, output_file: Path) -> None:
|
|
68
|
+
"""Parses and executes a recipe file.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
recipe_file: Path
|
|
73
|
+
Pathlike to a configuration file indicating the operators that need
|
|
74
|
+
running.
|
|
75
|
+
|
|
76
|
+
input_file: Path
|
|
77
|
+
Pathlike to netCDF (or something else that iris read) file to be used as
|
|
78
|
+
input.
|
|
79
|
+
|
|
80
|
+
output_file: Path
|
|
81
|
+
Pathlike indicating desired location of output.
|
|
82
|
+
|
|
83
|
+
Raises
|
|
84
|
+
------
|
|
85
|
+
FileNotFoundError
|
|
86
|
+
The recipe or input file cannot be found.
|
|
87
|
+
|
|
88
|
+
ValueError
|
|
89
|
+
The recipe file is not well formed.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
def step_parser(step, step_io, output_file_path: Path) -> str:
|
|
93
|
+
if "input" in step:
|
|
94
|
+
if type(step["input"]) == dict:
|
|
95
|
+
logging.debug(f"Recursing into input: {step['input']}")
|
|
96
|
+
step_io = step_parser(step["input"], step_io, output_file_path)
|
|
97
|
+
else:
|
|
98
|
+
step_io = step["input"]
|
|
99
|
+
kwargs = {}
|
|
100
|
+
if "args" in step:
|
|
101
|
+
for key in step["args"].keys():
|
|
102
|
+
if type(step["args"][key]) == dict:
|
|
103
|
+
logging.debug(f"Recursing into args: {step['args']}")
|
|
104
|
+
kwargs[key] = step_parser(
|
|
105
|
+
step["args"][key], step_io, output_file_path
|
|
106
|
+
)
|
|
107
|
+
elif step["args"][key] == "MAGIC_OUTPUT_PATH":
|
|
108
|
+
kwargs[key] = output_file_path
|
|
109
|
+
else:
|
|
110
|
+
kwargs[key] = step["args"][key]
|
|
111
|
+
operator = get_operator(step["operator"])
|
|
112
|
+
logging.info(f"operator = {step['operator']}")
|
|
113
|
+
logging.debug(f"step_input = {step_io}")
|
|
114
|
+
logging.debug(f"args = {kwargs}")
|
|
115
|
+
return operator(step_io, **kwargs)
|
|
116
|
+
|
|
117
|
+
with open(recipe_file, "rb") as f:
|
|
118
|
+
recipe = tomllib.load(f)
|
|
119
|
+
step_io = input_file
|
|
120
|
+
for step in recipe["steps"]:
|
|
121
|
+
step_io = step_parser(step, step_io, output_file)
|