tctrack 0.2__tar.gz → 0.3__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.
- tctrack-0.3/.pre-commit-config.yaml +27 -0
- {tctrack-0.2 → tctrack-0.3}/PKG-INFO +10 -7
- {tctrack-0.2 → tctrack-0.3}/README.md +4 -2
- {tctrack-0.2 → tctrack-0.3}/docs/api/index.rst +2 -0
- tctrack-0.3/docs/api/preprocessing_api.rst +6 -0
- tctrack-0.3/docs/api/utils_api.rst +8 -0
- {tctrack-0.2 → tctrack-0.3}/docs/data/preprocessing_data.rst +107 -5
- {tctrack-0.2 → tctrack-0.3}/docs/developer/guidelines.rst +7 -4
- {tctrack-0.2 → tctrack-0.3}/docs/getting-started/index.rst +5 -5
- {tctrack-0.2 → tctrack-0.3}/docs/getting-started/tutorial.rst +2 -2
- {tctrack-0.2 → tctrack-0.3}/docs/tracking-algorithms/tstorms.rst +9 -10
- {tctrack-0.2 → tctrack-0.3}/pyproject.toml +5 -4
- tctrack-0.3/src/tctrack/__init__.py +5 -0
- {tctrack-0.2 → tctrack-0.3}/src/tctrack/core/__init__.py +2 -0
- {tctrack-0.2 → tctrack-0.3}/src/tctrack/core/tracker.py +185 -23
- tctrack-0.3/src/tctrack/preprocessing.py +584 -0
- {tctrack-0.2 → tctrack-0.3}/src/tctrack/tempest_extremes/tempest_extremes.py +10 -72
- {tctrack-0.2 → tctrack-0.3}/src/tctrack/track/track.py +27 -58
- {tctrack-0.2 → tctrack-0.3}/src/tctrack/tstorms/tstorms.py +34 -136
- tctrack-0.3/src/tctrack/utils/__init__.py +8 -0
- tctrack-0.3/src/tctrack/utils/metadata.py +104 -0
- {tctrack-0.2 → tctrack-0.3}/src/tctrack.egg-info/PKG-INFO +10 -7
- {tctrack-0.2 → tctrack-0.3}/src/tctrack.egg-info/SOURCES.txt +14 -3
- {tctrack-0.2 → tctrack-0.3}/src/tctrack.egg-info/requires.txt +5 -4
- tctrack-0.3/src/tctrack.egg-info/scm_file_list.json +73 -0
- tctrack-0.3/src/tctrack.egg-info/scm_version.json +8 -0
- tctrack-0.3/tests/conftest.py +6 -0
- tctrack-0.3/tests/integration/test_tracker_integration.py +109 -0
- {tctrack-0.2/tests/unit/utils → tctrack-0.3/tests/unit/core}/test_netcdf.py +6 -2
- {tctrack-0.2 → tctrack-0.3}/tests/unit/core/test_tracker.py +88 -26
- tctrack-0.3/tests/unit/preprocessing/test_preprocessing.py +303 -0
- {tctrack-0.2 → tctrack-0.3}/tests/unit/tempest_extremes/test_tempest_extremes.py +35 -13
- {tctrack-0.2 → tctrack-0.3}/tests/unit/track/test_track.py +25 -15
- {tctrack-0.2 → tctrack-0.3}/tests/unit/tstorms/test_tstorms.py +27 -20
- tctrack-0.3/tests/unit/utils/test_metadata.py +145 -0
- {tctrack-0.2 → tctrack-0.3}/tutorial/install_tstorms.sh +2 -2
- tctrack-0.3/tutorial/preprocess_data.py +151 -0
- {tctrack-0.2 → tctrack-0.3}/tutorial/run_tstorms.py +1 -1
- tctrack-0.2/src/tctrack/__init__.py +0 -5
- tctrack-0.2/src/tctrack/utils/__init__.py +0 -7
- tctrack-0.2/tutorial/regrid.py +0 -195
- {tctrack-0.2 → tctrack-0.3}/.github/workflows/codequality.yaml +0 -0
- {tctrack-0.2 → tctrack-0.3}/.github/workflows/release.yaml +0 -0
- {tctrack-0.2 → tctrack-0.3}/.github/workflows/unit-tests.yaml +0 -0
- {tctrack-0.2 → tctrack-0.3}/.gitignore +0 -0
- {tctrack-0.2 → tctrack-0.3}/.readthedocs.yaml +0 -0
- {tctrack-0.2 → tctrack-0.3}/LICENSE +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/Makefile +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/api/core_api.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/api/tempest_extremes_api.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/api/track_api.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/api/tstorms_api.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/conf.py +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/data/index.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/data/output_file.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/developer/adding_algorithms.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/developer/index.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/images/TCTrack_Logo.svg +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/images/data_tracks_plot.png +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/images/inigo_inspire.png +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/index.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/make.bat +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/references.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/tracking-algorithms/index.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/tracking-algorithms/tempest_extremes.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/docs/tracking-algorithms/track.rst +0 -0
- {tctrack-0.2 → tctrack-0.3}/setup.cfg +0 -0
- {tctrack-0.2 → tctrack-0.3}/setup.py +0 -0
- /tctrack-0.2/src/tctrack/utils/utils.py → /tctrack-0.3/src/tctrack/core/netcdf.py +0 -0
- {tctrack-0.2 → tctrack-0.3}/src/tctrack/core/trajectory.py +0 -0
- {tctrack-0.2 → tctrack-0.3}/src/tctrack/tempest_extremes/__init__.py +0 -0
- {tctrack-0.2 → tctrack-0.3}/src/tctrack/track/__init__.py +0 -0
- {tctrack-0.2 → tctrack-0.3}/src/tctrack/tstorms/__init__.py +0 -0
- {tctrack-0.2 → tctrack-0.3}/src/tctrack.egg-info/dependency_links.txt +0 -0
- {tctrack-0.2 → tctrack-0.3}/src/tctrack.egg-info/top_level.txt +0 -0
- {tctrack-0.2 → tctrack-0.3}/tests/unit/core/test_trajectory.py +0 -0
- {tctrack-0.2 → tctrack-0.3}/tutorial/README.md +0 -0
- {tctrack-0.2 → tctrack-0.3}/tutorial/fetch_data.sh +0 -0
- {tctrack-0.2 → tctrack-0.3}/tutorial/install_tempest_extremes.sh +0 -0
- {tctrack-0.2 → tctrack-0.3}/tutorial/plot_tracks.py +0 -0
- {tctrack-0.2 → tctrack-0.3}/tutorial/run_tempest_extremes.py +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
default_install_hook_types: [pre-commit]
|
|
2
|
+
|
|
3
|
+
repos:
|
|
4
|
+
|
|
5
|
+
# Ruff linting / formatting
|
|
6
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
7
|
+
rev: v0.15.17
|
|
8
|
+
hooks:
|
|
9
|
+
- id: ruff-check
|
|
10
|
+
files: (src|tests)/.*\.py
|
|
11
|
+
args: [ --fix ]
|
|
12
|
+
- id: ruff-format
|
|
13
|
+
files: (src|tests)/.*\.py
|
|
14
|
+
|
|
15
|
+
# Mypy type checking
|
|
16
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
17
|
+
rev: v2.1.0
|
|
18
|
+
hooks:
|
|
19
|
+
- id: mypy
|
|
20
|
+
|
|
21
|
+
# Docs formatting with blackdoc
|
|
22
|
+
- repo: https://github.com/keewis/blackdoc
|
|
23
|
+
rev: v0.4.2
|
|
24
|
+
hooks:
|
|
25
|
+
- id: blackdoc
|
|
26
|
+
files: docs/
|
|
27
|
+
additional_dependencies: ["black==25.9.0"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tctrack
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3
|
|
4
4
|
Summary: A Python package for generating tropical cyclone tracks.
|
|
5
5
|
Author-email: Jack Atkinson <jwa34@cam.ac.uk>, Sam Avis <sa2329@cam.ac.uk>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -32,20 +32,21 @@ Requires-Dist: cftime
|
|
|
32
32
|
Provides-Extra: test
|
|
33
33
|
Requires-Dist: pytest; extra == "test"
|
|
34
34
|
Requires-Dist: pytest-mock; extra == "test"
|
|
35
|
+
Requires-Dist: xarray; extra == "test"
|
|
35
36
|
Provides-Extra: lint
|
|
36
37
|
Requires-Dist: ruff; extra == "lint"
|
|
37
|
-
Requires-Dist: blackdoc
|
|
38
|
-
Requires-Dist: black
|
|
38
|
+
Requires-Dist: blackdoc>=0.4.2; extra == "lint"
|
|
39
|
+
Requires-Dist: black>=25.9.0; extra == "lint"
|
|
39
40
|
Requires-Dist: mypy; extra == "lint"
|
|
40
41
|
Requires-Dist: pytest; extra == "lint"
|
|
42
|
+
Requires-Dist: xarray; extra == "lint"
|
|
41
43
|
Provides-Extra: doc
|
|
42
44
|
Requires-Dist: sphinx<8.2.0; extra == "doc"
|
|
43
45
|
Requires-Dist: sphinx_rtd_theme; extra == "doc"
|
|
44
46
|
Requires-Dist: sphinx_autodoc_typehints; extra == "doc"
|
|
45
|
-
Requires-Dist: blackdoc<=0.4.2; extra == "doc"
|
|
46
|
-
Requires-Dist: black<=25.1.0; extra == "doc"
|
|
47
47
|
Provides-Extra: dev
|
|
48
48
|
Requires-Dist: tctrack[doc,lint,test]; extra == "dev"
|
|
49
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
49
50
|
Dynamic: license-file
|
|
50
51
|
|
|
51
52
|
<div align="center">
|
|
@@ -59,6 +60,7 @@ Dynamic: license-file
|
|
|
59
60
|
[](https://tctrack.readthedocs.io/en/latest/?badge=latest)
|
|
60
61
|
[](https://github.com/astral-sh/ruff)
|
|
61
62
|
[](https://www.python.org/downloads/)
|
|
63
|
+
[](https://joss.theoj.org/papers/5bfc7127397fb0fd3583de541eab4c49)
|
|
62
64
|
|
|
63
65
|
|
|
64
66
|
TCTrack is a Python library providing bindings to tracking algorithms for tropical
|
|
@@ -90,7 +92,7 @@ pip install tctrack
|
|
|
90
92
|
|
|
91
93
|
See the
|
|
92
94
|
[documentation](https://tctrack.readthedocs.io/en/latest/getting-started/index.html#installation).
|
|
93
|
-
for
|
|
95
|
+
for further details about installation and dependencies, including how to install the
|
|
94
96
|
individual tracking algorithms.
|
|
95
97
|
|
|
96
98
|
|
|
@@ -119,9 +121,10 @@ address an [open issue](https://github.com/Cambridge-ICCS/TCTrack/issues), pleas
|
|
|
119
121
|
[fork the repository](https://github.com/Cambridge-ICCS/TCTrack/fork) and open a
|
|
120
122
|
pull request.
|
|
121
123
|
|
|
122
|
-
Additional dependencies for
|
|
124
|
+
Additional dependencies for development can be installed as follows:
|
|
123
125
|
```sh
|
|
124
126
|
pip install --editable .[dev]
|
|
127
|
+
pre-commit install
|
|
125
128
|
```
|
|
126
129
|
|
|
127
130
|
Full details for contribution and developers can be found in the
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
[](https://tctrack.readthedocs.io/en/latest/?badge=latest)
|
|
10
10
|
[](https://github.com/astral-sh/ruff)
|
|
11
11
|
[](https://www.python.org/downloads/)
|
|
12
|
+
[](https://joss.theoj.org/papers/5bfc7127397fb0fd3583de541eab4c49)
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
TCTrack is a Python library providing bindings to tracking algorithms for tropical
|
|
@@ -40,7 +41,7 @@ pip install tctrack
|
|
|
40
41
|
|
|
41
42
|
See the
|
|
42
43
|
[documentation](https://tctrack.readthedocs.io/en/latest/getting-started/index.html#installation).
|
|
43
|
-
for
|
|
44
|
+
for further details about installation and dependencies, including how to install the
|
|
44
45
|
individual tracking algorithms.
|
|
45
46
|
|
|
46
47
|
|
|
@@ -69,9 +70,10 @@ address an [open issue](https://github.com/Cambridge-ICCS/TCTrack/issues), pleas
|
|
|
69
70
|
[fork the repository](https://github.com/Cambridge-ICCS/TCTrack/fork) and open a
|
|
70
71
|
pull request.
|
|
71
72
|
|
|
72
|
-
Additional dependencies for
|
|
73
|
+
Additional dependencies for development can be installed as follows:
|
|
73
74
|
```sh
|
|
74
75
|
pip install --editable .[dev]
|
|
76
|
+
pre-commit install
|
|
75
77
|
```
|
|
76
78
|
|
|
77
79
|
Full details for contribution and developers can be found in the
|
|
@@ -6,6 +6,11 @@ we detail how to perform some of the typically required preprocessing steps usin
|
|
|
6
6
|
cf-python library. Other tools can be used for the same tasks, however we focus on
|
|
7
7
|
cf-python since it provides a uniform interface and it is a dependency of TCTrack.
|
|
8
8
|
|
|
9
|
+
We also provide simple wrapper functions in :mod:`tctrack.preprocessing` that can
|
|
10
|
+
simplify each of these tasks. Examples of these are given in each of the subsections
|
|
11
|
+
below. These functions also return the fields so the output files do not need to be
|
|
12
|
+
written every time.
|
|
13
|
+
|
|
9
14
|
For full documentation of the routines described on these pages and more see the
|
|
10
15
|
`cf python documentation <https://ncas-cms.github.io/cf-python/>`_.
|
|
11
16
|
|
|
@@ -31,6 +36,17 @@ cf-python:
|
|
|
31
36
|
# Write the combined data to a single file
|
|
32
37
|
cf.write(field, "combined-output.nc")
|
|
33
38
|
|
|
39
|
+
Or, equivalently, in TCTrack you can use
|
|
40
|
+
:func:`tctrack.preprocessing.select_time_range`, as below. All of the other
|
|
41
|
+
preprocessing functions can also be used to combine files if a specific time range is
|
|
42
|
+
not required.
|
|
43
|
+
|
|
44
|
+
.. code-block:: python
|
|
45
|
+
|
|
46
|
+
tctrack.preprocessing.select_time_range(
|
|
47
|
+
input_files, ["1950-01-01", "1950-04-01"], output_file="combined-output.nc"
|
|
48
|
+
)
|
|
49
|
+
|
|
34
50
|
Combine Variables
|
|
35
51
|
-----------------
|
|
36
52
|
|
|
@@ -46,6 +62,14 @@ read them in separately and then write them together:
|
|
|
46
62
|
# Write the combined fields to a single file
|
|
47
63
|
cf.write([field1, field2], "combined_file.nc")
|
|
48
64
|
|
|
65
|
+
Using TCTrack:
|
|
66
|
+
|
|
67
|
+
.. code-block:: python
|
|
68
|
+
|
|
69
|
+
tctrack.preprocessing.read_files(
|
|
70
|
+
["var1_file.nc", "var2_file.nc"], output_file="combined_file.nc"
|
|
71
|
+
)
|
|
72
|
+
|
|
49
73
|
Separating Variables
|
|
50
74
|
--------------------
|
|
51
75
|
|
|
@@ -61,6 +85,15 @@ If variables instead need to be separated into multiple files, such as in :doc:`
|
|
|
61
85
|
cf.write(field1, "var1_file.nc")
|
|
62
86
|
cf.write(field2, "var2_file.nc")
|
|
63
87
|
|
|
88
|
+
Using TCTrack:
|
|
89
|
+
|
|
90
|
+
.. code-block:: python
|
|
91
|
+
|
|
92
|
+
tctrack.preprocessing.separate_variables(
|
|
93
|
+
"combined_file.nc",
|
|
94
|
+
{"var1": "var1_file.nc", "var2": "var2_file.nc"},
|
|
95
|
+
)
|
|
96
|
+
|
|
64
97
|
Subsampling
|
|
65
98
|
-----------
|
|
66
99
|
|
|
@@ -99,6 +132,19 @@ To remove the single-valued coordinate from the field use cf-python's
|
|
|
99
132
|
# or, for a new field
|
|
100
133
|
field3 = field2.squeeze()
|
|
101
134
|
|
|
135
|
+
Using TCTrack, single-valued coordinates can be removed using the ``squeeze`` argument
|
|
136
|
+
(see the first example below).
|
|
137
|
+
|
|
138
|
+
.. code-block:: python
|
|
139
|
+
|
|
140
|
+
field2 = tctrack.preprocessing.subsample_field(
|
|
141
|
+
"var1_file.nc", {"Z": [5]}, squeeze=True
|
|
142
|
+
)
|
|
143
|
+
field3 = tctrack.preprocessing.subsample_field("var1_file.nc", {"X": [0, 5]})
|
|
144
|
+
field4 = tctrack.preprocessing.subsample_field(
|
|
145
|
+
"var1_file.nc", {"Y": slice(3, -3, 2)}
|
|
146
|
+
)
|
|
147
|
+
|
|
102
148
|
Operations
|
|
103
149
|
----------
|
|
104
150
|
|
|
@@ -116,12 +162,20 @@ For example, to calculate vorticity from coincident velocity data we can use ``c
|
|
|
116
162
|
# calculate vorticity
|
|
117
163
|
w_field = cf.curl_xy(u_field, v_field, radius="earth")
|
|
118
164
|
w_field.nc_set_variable("vorticity")
|
|
119
|
-
w_field.set_property("standard_name", "
|
|
165
|
+
w_field.set_property("standard_name", "atmosphere_upward_relative_vorticity")
|
|
120
166
|
w_field.set_property("units", "s-1")
|
|
121
167
|
|
|
122
168
|
# Save the new variable to NetCDF
|
|
123
169
|
cf.write(w_field, "vorticity_file.nc")
|
|
124
170
|
|
|
171
|
+
Using TCTrack:
|
|
172
|
+
|
|
173
|
+
.. code-block:: python
|
|
174
|
+
|
|
175
|
+
tctrack.preprocessing.calculate_vorticity(
|
|
176
|
+
"u_file.nc", "v_file.nc", output_file="vorticity_file.nc"
|
|
177
|
+
)
|
|
178
|
+
|
|
125
179
|
Or to take a mean over a coordinate:
|
|
126
180
|
|
|
127
181
|
.. code-block:: python
|
|
@@ -136,19 +190,32 @@ Or to take a mean over a coordinate:
|
|
|
136
190
|
# Save the new variable to NetCDF
|
|
137
191
|
cf.write(field_zonal_mean, "zonal_mean_file.nc")
|
|
138
192
|
|
|
193
|
+
Using TCTrack:
|
|
194
|
+
|
|
195
|
+
.. code-block:: python
|
|
196
|
+
|
|
197
|
+
tctrack.preprocessing.collapse_field(
|
|
198
|
+
"file.nc", "mean", "X", output_file="zonal_mean_file.nc"
|
|
199
|
+
)
|
|
200
|
+
|
|
139
201
|
Setting Fill Values
|
|
140
202
|
^^^^^^^^^^^^^^^^^^^
|
|
141
203
|
|
|
142
|
-
Sometimes it
|
|
204
|
+
Sometimes it is useful to replace the 'fill values' after an operation but before
|
|
205
|
+
writing to file.
|
|
143
206
|
This can be done using cf-python's ``filled`` routine.
|
|
144
|
-
For example,
|
|
145
|
-
vorticity above use
|
|
207
|
+
For example, to set any null or masked values to ``0.0`` (e.g. after calculating
|
|
208
|
+
vorticity above) use the following before writing to file.
|
|
146
209
|
|
|
147
210
|
.. code-block:: python
|
|
148
211
|
|
|
149
212
|
w_field.filled(fill_value=0.0, inplace=True)
|
|
150
213
|
|
|
151
|
-
|
|
214
|
+
Using TCTrack:
|
|
215
|
+
|
|
216
|
+
.. code-block:: python
|
|
217
|
+
|
|
218
|
+
tctrack.preprocessing.replace_fill_value(w_field, 0.0, output_file="output.nc")
|
|
152
219
|
|
|
153
220
|
Set NetCDF Variable Name
|
|
154
221
|
------------------------
|
|
@@ -167,6 +234,17 @@ To set specfic NetCDF variable names for the fields and coordinates you can use
|
|
|
167
234
|
# Save with the new netcdf variable names
|
|
168
235
|
cf.write(field, "slp_file.nc")
|
|
169
236
|
|
|
237
|
+
Using TCTrack:
|
|
238
|
+
|
|
239
|
+
.. code-block:: python
|
|
240
|
+
|
|
241
|
+
tctrack.preprocessing.set_netcdf_variable_name(
|
|
242
|
+
"var1_file.nc",
|
|
243
|
+
"slp",
|
|
244
|
+
coord_names={"latitude": "lat"},
|
|
245
|
+
output_file="slp_file.nc",
|
|
246
|
+
)
|
|
247
|
+
|
|
170
248
|
Regridding
|
|
171
249
|
----------
|
|
172
250
|
|
|
@@ -208,6 +286,22 @@ To regrid onto a new grid:
|
|
|
208
286
|
|
|
209
287
|
Note that regridding can be performed inplace using ``inplace=True``.
|
|
210
288
|
|
|
289
|
+
Using TCTrack:
|
|
290
|
+
|
|
291
|
+
.. code-block:: python
|
|
292
|
+
|
|
293
|
+
# Regrid onto a different variable
|
|
294
|
+
tctrack.preprocessing.regrid_to_field(
|
|
295
|
+
"var1_file.nc", "var2_file.nc", output_file="var1_regridded.nc"
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
# Regrid onto a new grid
|
|
299
|
+
latitude = np.arange(-90, 91, 1)
|
|
300
|
+
longitude = np.arange(-180, 181, 1)
|
|
301
|
+
tctrack.preprocessing.regrid_to_lat_lon(
|
|
302
|
+
"var1_file.nc", latitude, longitude, output_file="var1_regridded.nc"
|
|
303
|
+
)
|
|
304
|
+
|
|
211
305
|
Gaussian Grid
|
|
212
306
|
^^^^^^^^^^^^^
|
|
213
307
|
|
|
@@ -238,3 +332,11 @@ objects to be used for the regridding.
|
|
|
238
332
|
# Regrid
|
|
239
333
|
field = field.regrids((lat_coord, lon_coord), method="linear")
|
|
240
334
|
field.nc_clear_dataset_chunksizes() # Avoids a possible error when writing
|
|
335
|
+
|
|
336
|
+
Using TCTrack:
|
|
337
|
+
|
|
338
|
+
.. code-block:: python
|
|
339
|
+
|
|
340
|
+
tctrack.preprocessing.regrid_to_gaussian(
|
|
341
|
+
"var1_file.nc", 256, output_file="var1_regridded.nc"
|
|
342
|
+
)
|
|
@@ -167,11 +167,14 @@ Thus, good style is a requirement for submitting code to *TCTrack*.
|
|
|
167
167
|
- `mypy <http://mypy-lang.org/>`_ for static type checking of
|
|
168
168
|
`type hints <https://docs.python.org/3/library/typing.html>`_.
|
|
169
169
|
|
|
170
|
-
These will be checked on all pull requests and commits to main,
|
|
171
|
-
run them on your code before committing.
|
|
170
|
+
These will be checked on all pull requests and commits to main, but it is suggested that you install the ``pre-commit`` hooks so that any changes will be checked each time you commit:
|
|
172
171
|
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
.. code-block:: shell
|
|
173
|
+
|
|
174
|
+
pre-commit install
|
|
175
|
+
|
|
176
|
+
To manually run the checks instead, run the following bash commands from the root
|
|
177
|
+
directory with a development installation:
|
|
175
178
|
|
|
176
179
|
.. code-block:: shell
|
|
177
180
|
|
|
@@ -67,9 +67,10 @@ pip can then be run to install the code from the source into the environment::
|
|
|
67
67
|
pip install .
|
|
68
68
|
|
|
69
69
|
If you are developing TCTrack you should install as an editable package with the
|
|
70
|
-
additional developer dependencies::
|
|
70
|
+
additional developer dependencies and the pre-commit hooks installed::
|
|
71
71
|
|
|
72
72
|
pip install --editable .[dev]
|
|
73
|
+
pre-commit install
|
|
73
74
|
|
|
74
75
|
The `dev` optional dependencies include the `test`, `lint`, and `doc` subgroups.
|
|
75
76
|
|
|
@@ -101,11 +102,10 @@ noting that we may need to add the library to the dynamic path e.g.::
|
|
|
101
102
|
esmpy
|
|
102
103
|
~~~~~
|
|
103
104
|
|
|
104
|
-
Any regridding of data
|
|
105
|
-
<https://earthsystemmodeling.org/esmpy/>`_ and `ESMF
|
|
105
|
+
Any preprocessing that involves regridding of data using :mod:`tctrack.preprocessing` or
|
|
106
|
+
cf-python requires `esmpy <https://earthsystemmodeling.org/esmpy/>`_ and `ESMF
|
|
106
107
|
<https://earthsystemmodeling.org/>`_ as dependencies. This is not needed directly in the
|
|
107
|
-
|
|
108
|
-
tutorial and described in the :doc:`../data/preprocessing_data` page.
|
|
108
|
+
tracking algorithms.
|
|
109
109
|
|
|
110
110
|
These are not pip-installable but can be installed in a conda environment::
|
|
111
111
|
|
|
@@ -90,9 +90,9 @@ before running.
|
|
|
90
90
|
Pre-processing of Data
|
|
91
91
|
----------------------
|
|
92
92
|
|
|
93
|
-
From inside the conda environment run the
|
|
93
|
+
From inside the conda environment run the script to pre-process the data::
|
|
94
94
|
|
|
95
|
-
python
|
|
95
|
+
python preprocess_data.py
|
|
96
96
|
|
|
97
97
|
This will pre-process the downloaded data as required for our codes and place it in
|
|
98
98
|
``data_processed/``.
|
|
@@ -32,23 +32,22 @@ number of fixes for hard-coded filepaths etc. over the original to aid usability
|
|
|
32
32
|
|
|
33
33
|
TSTORMS comprises two codes, one for storm detection (``tstorms_driver``) and another
|
|
34
34
|
for generating trajectories (``trajectory_analysis``).
|
|
35
|
-
The code is built using Make and requires a Fortran compiler
|
|
36
|
-
|
|
35
|
+
The code is built using Make and requires a Fortran compiler and an installation of
|
|
36
|
+
NetCDF.
|
|
37
37
|
The steps are summarised here::
|
|
38
38
|
|
|
39
39
|
git clone https://github.com/Cambridge-ICCS/TSTORMS.git
|
|
40
40
|
cd TSTORMS/
|
|
41
41
|
cd tstorms_driver/
|
|
42
|
-
make
|
|
42
|
+
make FC=gfortran
|
|
43
43
|
cd ../trajectory_analysis/
|
|
44
|
-
make
|
|
44
|
+
make FC=gfortran
|
|
45
45
|
|
|
46
46
|
This will clone the TSTORMS code and then then build the two TSTORMS executables using
|
|
47
47
|
Make.
|
|
48
|
-
|
|
49
|
-
``tstorms_driver/mkmf_template`` and
|
|
50
|
-
|
|
51
|
-
This will be required if building with gfortran or Intel oneAPI compilers >= 2025 (ifx).
|
|
48
|
+
``ifort`` or ``ifx`` can also be used for the compilation. Any other compilers will
|
|
49
|
+
require modification to both ``tstorms_driver/mkmf_template`` and
|
|
50
|
+
``trajectory_analysis/mkmf_template``.
|
|
52
51
|
|
|
53
52
|
Once this is complete the TSTORMS executables can then be found at
|
|
54
53
|
``/path/to/TSTORMS_installation/tstorms_driver/tstorms_driver.exe`` and
|
|
@@ -115,7 +114,7 @@ documentation:
|
|
|
115
114
|
# Initialize the tracker
|
|
116
115
|
tracker = TSTORMSTracker(tstorms_params, detect_params)
|
|
117
116
|
|
|
118
|
-
detect_call = tracker.detect(
|
|
117
|
+
detect_call = tracker.detect(verbosity=2)
|
|
119
118
|
|
|
120
119
|
The result of this will be a ``cyclones`` file in the prescribed output directory with
|
|
121
120
|
candidate storms organised by date in the format described in :meth:`~TSTORMSTracker.detect`.
|
|
@@ -145,7 +144,7 @@ Full details of each input are given in the :class:`TSTORMSStitchParameters` doc
|
|
|
145
144
|
lat_bound_s=-70.0,
|
|
146
145
|
)
|
|
147
146
|
tracker = TSTORMSTracker(tstorms_params, detect_params, stitch_params)
|
|
148
|
-
stitching_call = tracker.stitch(
|
|
147
|
+
stitching_call = tracker.stitch(verbosity=2)
|
|
149
148
|
|
|
150
149
|
The result of this will be the following set of files at the output location
|
|
151
150
|
provided in :class:`TSTORMSStitchParameters`:
|
|
@@ -44,23 +44,24 @@ dependencies = [
|
|
|
44
44
|
test = [
|
|
45
45
|
"pytest",
|
|
46
46
|
"pytest-mock",
|
|
47
|
+
"xarray",
|
|
47
48
|
]
|
|
48
49
|
lint = [
|
|
49
50
|
"ruff",
|
|
50
|
-
"blackdoc
|
|
51
|
-
"black
|
|
51
|
+
"blackdoc>=0.4.2", # Pin versions for black-blackdoc compatibilty.
|
|
52
|
+
"black>=25.9.0", # See https://blackdoc.readthedocs.io/en/latest/changelog.html
|
|
52
53
|
"mypy",
|
|
53
54
|
"pytest",
|
|
55
|
+
"xarray",
|
|
54
56
|
]
|
|
55
57
|
doc = [
|
|
56
58
|
"sphinx<8.2.0", # Pin version due to autodoc type hints incompatibilities
|
|
57
59
|
"sphinx_rtd_theme",
|
|
58
60
|
"sphinx_autodoc_typehints",
|
|
59
|
-
"blackdoc<=0.4.2",
|
|
60
|
-
"black<=25.1.0", # Pin version due to blackdoc incompatibility. Remove once resolved
|
|
61
61
|
]
|
|
62
62
|
dev = [
|
|
63
63
|
"tctrack[test,lint,doc]",
|
|
64
|
+
"pre-commit",
|
|
64
65
|
]
|
|
65
66
|
|
|
66
67
|
[project.urls]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Package providing core utilities used throughout TCTrack."""
|
|
2
2
|
|
|
3
|
+
from .netcdf import lat_lon_sizes
|
|
3
4
|
from .tracker import (
|
|
4
5
|
TCTracker,
|
|
5
6
|
TCTrackerMetadata,
|
|
@@ -16,4 +17,5 @@ __all__ = [
|
|
|
16
17
|
"TCTrackerParameters",
|
|
17
18
|
"TCTrackerTimeMetadata",
|
|
18
19
|
"Trajectory",
|
|
20
|
+
"lat_lon_sizes",
|
|
19
21
|
]
|