Skip to content

Commit

Permalink
Merge branch 'RC_v1.5.x' into dev_developer_guide
Browse files Browse the repository at this point in the history
  • Loading branch information
freemansw1 authored Jun 21, 2024
2 parents f75c850 + 8e7557c commit 460d0cb
Show file tree
Hide file tree
Showing 22 changed files with 474 additions and 216 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 17 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
"sphinx_rtd_theme",
"sphinx.ext.napoleon",
"nbsphinx",
"sphinx_gallery.load_style",
"sphinx_gallery.load_style",
]


html_theme = "sphinx_rtd_theme"

html_static_path = ["_static"]

exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


project = "tobac"
Expand Down Expand Up @@ -81,3 +80,18 @@ def setup(app):
napoleon_preprocess_types = False
napoleon_type_aliases = None
napoleon_attr_annotations = True

nbsphinx_thumbnails = {
"examples/Basics/Idealized-Case-1_Tracking-of-a-Test-Blob-in-2D": "_static/thumbnails/Basics_Idealized-Case-1_Tracking-of-a-Test-Blob-in-2D_Thumbnail.png",
"examples/Basics/Idealized-Case-2_Two_crossing_Blobs": "_static/thumbnails/Basics_Idealized-Case-2_Two_crossing_Blobs_Thumbnail.png",
"examples/Basics/Methods-and-Parameters-for-Feature-Detection_Part_1": "_static/thumbnails/Basics_Methods-and-Parameters-for-Feature-Detection_Part_1_Thumbnail.png",
"examples/Basics/Methods-and-Parameters-for-Feature-Detection_Part_2": "_static/thumbnails/Basics_Methods-and-Parameters-for-Feature-Detection_Part_2_Thumbnail.png",
"examples/Basics/Methods-and-Parameters-for-Linking": "_static/thumbnails/Basics_Methods-and-Parameters-for-Linking_Thumbnail.png",
"examples/Basics/Methods-and-Parameters-for-Segmentation": "_static/thumbnails/Basics_Methods-and-Parameters-for-Segmentation_Thumbnail.png",
"examples/Example_OLR_Tracking_model/Example_OLR_Tracking_model": "_static/thumbnails/Example_OLR_Tracking_model_Thumbnail.png",
"examples/Example_OLR_Tracking_satellite/Example_OLR_Tracking_satellite": "_static/thumbnails/Example_OLR_Tracking_satellite_Thumbnail.png",
"examples/Example_Precip_Tracking/Example_Precip_Tracking": "_static/thumbnails/Example_Precip_Tracking_Thumbnail.png",
"examples/Example_Track_on_Radar_Segment_on_Satellite/Example_Track_on_Radar_Segment_on_Satellite": "_static/thumbnails/Example_Track_on_Radar_Segment_on_Satellite_Thumbnail.png",
"examples/Example_Updraft_Tracking/Example_Updraft_Tracking": "_static/thumbnails/Example_Updraft_Tracking_Thumbnail.png",
"examples/Example_vorticity_tracking_model/Example_vorticity_tracking_model": "_static/thumbnails/Example_vorticity_tracking_model_Thumbnail.png",
}
File renamed without changes.
30 changes: 15 additions & 15 deletions doc/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ tobac is provided with a set of Jupyter notebooks that show examples of the appl
.. nbgallery::
:caption: Fundamentals of Detection and Tracking

Test Blob in 2D <examples4doc/Basics/Idealized-Case-1_Tracking-of-a-Test-Blob-in-2D>
Two crossing Blobs <examples4doc/Basics/Idealized-Case-2_Two_crossing_Blobs.ipynb>
On Feature Detection: Part 1 <examples4doc/Basics/Methods-and-Parameters-for-Feature-Detection_Part_1.ipynb>
On Feature Detection: Part 2 <examples4doc/Basics/Methods-and-Parameters-for-Feature-Detection_Part_2.ipynb>
On Segmentation <examples4doc/Basics/Methods-and-Parameters-for-Segmentation.ipynb>
On Linking <examples4doc/Basics/Methods-and-Parameters-for-Linking.ipynb>
Test Blob in 2D <examples/Basics/Idealized-Case-1_Tracking-of-a-Test-Blob-in-2D>
Two crossing Blobs <examples/Basics/Idealized-Case-2_Two_crossing_Blobs.ipynb>

On Feature Detection: Part 1 <examples/Basics/Methods-and-Parameters-for-Feature-Detection_Part_1.ipynb>
On Feature Detection: Part 2 <examples/Basics/Methods-and-Parameters-for-Feature-Detection_Part_2.ipynb>
On Segmentation <examples/Basics/Methods-and-Parameters-for-Segmentation.ipynb>
On Linking <examples/Basics/Methods-and-Parameters-for-Linking.ipynb>




.. nbgallery::
:caption: Examples of Using *tobac* with Observations
OLR from GOES-13 Satellite <examples4doc/Example_OLR_Tracking_satellite/Example_OLR_Tracking_satellite>
Combine Radar & Satellite <examples4doc/Example_Track_on_Radar_Segment_on_Satellite/Example_Track_on_Radar_Segment_on_Satellite>

OLR from GOES-13 Satellite <examples/Example_OLR_Tracking_satellite/Example_OLR_Tracking_satellite>
Combine Radar & Satellite <examples/Example_Track_on_Radar_Segment_on_Satellite/Example_Track_on_Radar_Segment_on_Satellite>


.. nbgallery::
:caption: Examples of Using *tobac* with Model Data

WRF OLR <examples4doc/Example_OLR_Tracking_model/Example_OLR_Tracking_model>
WRF Precip <examples4doc/Example_Precip_Tracking/Example_Precip_Tracking>
WRF Updrafts <examples4doc/Example_Updraft_Tracking/Example_Updraft_Tracking>
WRF Mesoscale Vorticity <examples4doc/Example_vorticity_tracking_model/Example_vorticity_tracking_model>
WRF OLR <examples/Example_OLR_Tracking_model/Example_OLR_Tracking_model>
WRF Precip <examples/Example_Precip_Tracking/Example_Precip_Tracking>
WRF Updrafts <examples/Example_Updraft_Tracking/Example_Updraft_Tracking>
WRF Mesoscale Vorticity <examples/Example_vorticity_tracking_model/Example_vorticity_tracking_model>

The notebooks can be found in the **examples** folder as part of the python package. The necessary input data for these examples is avaliable on zenodo and can be downloaded automatically by the Jupyter notebooks.
The notebooks can be found in the **examples** folder as part of the python package. The necessary input data for these examples is avaliable on zenodo and can be downloaded automatically by the Jupyter notebooks.
5 changes: 2 additions & 3 deletions tobac/feature_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import iris
import xarray as xr

from tobac.tracking import build_distance_function
from tobac.utils import internal as internal_utils
from tobac.utils import decorators

Expand Down Expand Up @@ -1545,8 +1544,8 @@ def filter_min_distance(
# Check if we have PBCs.
if PBC_flag in ["hdim_1", "hdim_2", "both"]:
# Note that we multiply by dxy to get the distances in spatial coordinates
dist_func = build_distance_function(
min_h1 * dxy, max_h1 * dxy, min_h2 * dxy, max_h2 * dxy, PBC_flag
dist_func = pbc_utils.build_distance_function(
min_h1 * dxy, max_h1 * dxy, min_h2 * dxy, max_h2 * dxy, PBC_flag, is_3D
)
features_tree = BallTree(feature_locations, metric="pyfunc", func=dist_func)
neighbours = features_tree.query_radius(feature_locations, r=min_distance)
Expand Down
47 changes: 23 additions & 24 deletions tobac/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ def add_markers(
h2_end_coord=hdim_2_max,
PBC_flag=PBC_flag,
)
# Build distance function ahead of time, 3D always true as we then reduce
dist_func = pbc_utils.build_distance_function(
0, h1_len, 0, h2_len, PBC_flag, True
)
for seed_box in all_seed_boxes:
# Need to see if there are any other points seeded
# in this seed box first.
Expand All @@ -205,6 +209,7 @@ def add_markers(
local_index[1] + seed_box[0],
local_index[2] + seed_box[2],
)

# If it's a background marker, we can just set it
# with the feature we're working on.
if curr_box_pt == bg_marker:
Expand All @@ -213,18 +218,14 @@ def add_markers(
# it has another feature in it. Calculate the distance
# from its current set feature and the new feature.
if is_3D:
curr_coord = (row["vdim"], row["hdim_1"], row["hdim_2"])
curr_coord = np.array(
(row["vdim"], row["hdim_1"], row["hdim_2"])
)
else:
curr_coord = (0, row["hdim_1"], row["hdim_2"])

dist_from_curr_pt = pbc_utils.calc_distance_coords_pbc(
np.array(global_index),
np.array(curr_coord),
min_h1=0,
max_h1=h1_len,
min_h2=0,
max_h2=h2_len,
PBC_flag=PBC_flag,
curr_coord = np.array((0, row["hdim_1"], row["hdim_2"]))

dist_from_curr_pt = dist_func(
np.array(global_index), curr_coord
)

# This is technically an O(N^2) operation, but
Expand All @@ -234,21 +235,19 @@ def add_markers(
features["feature"] == curr_box_pt
].iloc[0]
if is_3D:
orig_coord = (
orig_row["vdim"],
orig_row["hdim_1"],
orig_row["hdim_2"],
orig_coord = np.array(
(
orig_row["vdim"],
orig_row["hdim_1"],
orig_row["hdim_2"],
)
)
else:
orig_coord = (0, orig_row["hdim_1"], orig_row["hdim_2"])
dist_from_orig_pt = pbc_utils.calc_distance_coords_pbc(
np.array(global_index),
np.array(orig_coord),
min_h1=0,
max_h1=h1_len,
min_h2=0,
max_h2=h2_len,
PBC_flag=PBC_flag,
orig_coord = np.array(
(0, orig_row["hdim_1"], orig_row["hdim_2"])
)
dist_from_orig_pt = dist_func(
np.array(global_index), orig_coord
)
# The current point center is further away
# than the original point center, so do nothing
Expand Down
Loading

0 comments on commit 460d0cb

Please sign in to comment.