Skip to content

Commit 09b176b

Browse files
authored
Merge pull request #237 from tobac-project/hotfix
Version 1.4.1 release
2 parents 49c4c27 + 3fefe10 commit 09b176b

File tree

10 files changed

+202
-86
lines changed

10 files changed

+202
-86
lines changed

.zenodo.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
"affiliation": "Leibniz Institute for Tropospheric Research, Leipzig (Germany)",
5656
"orcid": "0000-0002-5350-1445"
5757
},
58+
{
59+
"name": "Lettl, Kolya",
60+
"affiliation": "Leibniz Institute for Tropospheric Research, Leipzig (Germany)",
61+
"orcid": "0000-0002-4524-8152"
62+
},
5863
{
5964
"name": "Raut, Bhupendra A.",
6065
"affiliation": "Northwestern-Argonne Institute of Science and Engineering, Argonne National Laboratory",

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
### Tobac Changelog
22

3+
_**Version 1.4.1:**_
4+
5+
**Bug fixes**
6+
7+
- Fixed a bug with predictive tracking that would duplicate column names if the input dataset has coordinates x and/or y [#217](https://github.com/tobac-project/tobac/pull/217)
8+
- Set extrapolate parameter to 0 in example notebooks to prevent not implemented error [#217](https://github.com/tobac-project/tobac/pull/217)
9+
10+
**Documentation**
11+
12+
- Regenerated example notebooks so that they are up to date for the present version [#233](https://github.com/tobac-project/tobac/pull/233)
13+
314
_**Version 1.4.0:**_
415

516
**Enhancements**

examples/Example_OLR_Tracking_model/Example_OLR_Tracking_model.ipynb

Lines changed: 14 additions & 28 deletions
Large diffs are not rendered by default.

examples/Example_OLR_Tracking_satellite/Example_OLR_Tracking_satellite.ipynb

Lines changed: 19 additions & 19 deletions
Large diffs are not rendered by default.

examples/Example_Precip_Tracking/Example_Precip_Tracking.ipynb

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

examples/Example_Updraft_Tracking/Example_Updraft_Tracking.ipynb

Lines changed: 77 additions & 13 deletions
Large diffs are not rendered by default.

tobac/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@
7777
from . import merge_split
7878

7979
# Set version number
80-
__version__ = "1.4.0"
80+
__version__ = "1.4.1"

tobac/tests/test_feature_detection.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,36 @@ def test_feature_detection_threshold_sort(test_threshs, target):
194194
target=target,
195195
)
196196
assert_frame_equal(fd_output_first, fd_output_test)
197+
198+
199+
def test_feature_detection_coords():
200+
"""Tests that the output features dataframe contains all the coords of the input iris cube"""
201+
test_dset_size = (50, 50)
202+
test_hdim_1_pt = 20.0
203+
test_hdim_2_pt = 20.0
204+
test_hdim_1_sz = 5
205+
test_hdim_2_sz = 5
206+
test_amp = 2
207+
test_min_num = 2
208+
209+
test_data = np.zeros(test_dset_size)
210+
test_data = tbtest.make_feature_blob(
211+
test_data,
212+
test_hdim_1_pt,
213+
test_hdim_2_pt,
214+
h1_size=test_hdim_1_sz,
215+
h2_size=test_hdim_2_sz,
216+
amplitude=test_amp,
217+
)
218+
test_data_iris = tbtest.make_dataset_from_arr(test_data, data_type="iris")
219+
fd_output_first = feat_detect.feature_detection_multithreshold_timestep(
220+
test_data_iris,
221+
0,
222+
threshold=[1, 2, 3],
223+
n_min_threshold=test_min_num,
224+
dxy=1,
225+
target="maximum",
226+
)
227+
228+
for coord in test_data_iris.coords():
229+
assert coord.name() in fd_output_first

tobac/tests/test_tracking.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ def test_linking_trackpy():
4949
expected_out_feature.sort_index(axis=1), actual_out_feature.sort_index(axis=1)
5050
)
5151

52+
# Check that we only add two columns, and all the other columns are the same as the input features
53+
assert len(actual_out_feature.columns.tolist()) == len(
54+
set(actual_out_feature.columns.tolist())
55+
)
56+
assert set(actual_out_feature.columns.tolist()) - set(
57+
test_feature.columns.tolist()
58+
) == {"cell"}
59+
5260

5361
@pytest.mark.parametrize(
5462
"max_trackpy, max_tobac, adaptive_step, adaptive_stop",
@@ -142,6 +150,10 @@ def test_trackpy_predict():
142150

143151
assert_frame_equal(expected_output.sort_index(), output.sort_index())
144152

153+
# Check that we only add two columns, and all the other columns are the same as the input features
154+
assert len(output.columns.tolist()) == len(set(output.columns.tolist()))
155+
assert set(output.columns.tolist()) - set(features.columns.tolist()) == {"cell"}
156+
145157

146158
def test_tracking_extrapolation():
147159
"""Tests the extrapolation capabilities of tracking.

tobac/tracking.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
The individual features and associated area/volumes identified in
44
each timestep have to be linked into trajectories to analyse
55
the time evolution of their properties for a better understanding of
6-
the underlying physical processes.
6+
the underlying physical processes.
77
The implementations are structured in a way that allows for the future
88
addition of more complex tracking methods recording a more complex
99
network of relationships between features at different points in
10-
time.
10+
time.
1111
1212
References
1313
----------
1414
.. Heikenfeld, M., Marinescu, P. J., Christensen, M.,
1515
Watson-Parris, D., Senf, F., van den Heever, S. C.
16-
& Stier, P. (2019). tobac 1.2: towards a flexible
17-
framework for tracking and analysis of clouds in
16+
& Stier, P. (2019). tobac 1.2: towards a flexible
17+
framework for tracking and analysis of clouds in
1818
diverse datasets. Geoscientific Model Development,
1919
12(11), 4551-4570.
2020
"""
@@ -233,12 +233,12 @@ def linking_trackpy(
233233
tp.linking.Linker.MAX_SUB_NET_SIZE_ADAPTIVE = subnetwork_size
234234

235235
# deep copy to preserve features field:
236-
features_linking = deepcopy(features)
236+
features = deepcopy(features)
237237

238238
if method_linking == "random":
239239
# link features into trajectories:
240240
trajectories_unfiltered = tp.link(
241-
features_linking,
241+
features,
242242
search_range=search_range,
243243
memory=memory,
244244
t_column="frame",
@@ -251,6 +251,9 @@ def linking_trackpy(
251251
elif method_linking == "predict":
252252

253253
# avoid setting pos_columns by renaimng to default values to avoid trackpy bug
254+
features.rename(
255+
columns={"y": "__temp_y_coord", "x": "__temp_x_coord"}, inplace=True
256+
)
254257
features.rename(columns={"hdim_1": "y", "hdim_2": "x"}, inplace=True)
255258

256259
# generate list of features as input for df_link_iter to avoid bug in df_link
@@ -280,7 +283,9 @@ def linking_trackpy(
280283
trajectories_unfiltered.rename(
281284
columns={"y": "hdim_1", "x": "hdim_2"}, inplace=True
282285
)
283-
features.rename(columns={"y": "hdim_1", "x": "hdim_2"}, inplace=True)
286+
trajectories_unfiltered.rename(
287+
columns={"__temp_y_coord": "y", "__temp_x_coord": "x"}, inplace=True
288+
)
284289
else:
285290
raise ValueError("method_linking unknown")
286291

0 commit comments

Comments
 (0)