Skip to content

Commit e0f20a3

Browse files
update docstrings and changelog
1 parent 7e3a70e commit e0f20a3

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Code freeze date: YYYY-MM-DD
1212

1313
### Added
1414

15+
- `climada.hazard.tc_tracks.compute_track_density` function [#1003](https://github.com/CLIMADA-project/climada_python/pull/1003)
1516
- Add `osm-flex` package to CLIMADA core [#981](https://github.com/CLIMADA-project/climada_python/pull/981)
1617
- `doc.tutorial.climada_entity_Exposures_osm.ipynb` tutorial explaining how to use `osm-flex`with CLIMADA
1718
- `climada.util.coordinates.bounding_box_global` function [#980](https://github.com/CLIMADA-project/climada_python/pull/980)

climada/hazard/tc_tracks.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2870,18 +2870,23 @@ def _zlib_from_dataarray(data_var: xr.DataArray) -> bool:
28702870

28712871

28722872
def compute_track_density(
2873-
tc_track: TCTracks, res: int = 5, time_step: float = 0.5, mode: str = "normalized"
2873+
tc_track: TCTracks, res: int = 5, time_step: float = 1, mode: str = "absolute"
28742874
) -> tuple[np.ndarray, tuple]:
2875-
"""Compute absolute and normalized tropical cyclone track density as the number of points per
2876-
grid cell.
2875+
"""Compute absolute and normalized tropical cyclone track density. First, the function ensure
2876+
the same temporal resolution of all tracks by calling :py:meth:`equal_timestep`. Second, it
2877+
creates 2D bins of the specified resolution (e.g. 1° x 1°). Third, since tracks are not lines
2878+
but a series of points, it counts the number of points per bin. Lastly, it returns the absolute
2879+
or normalized count per bin. This function works under the hood of :py:meth:`plot_track_density`
2880+
but can be used separtly as input data for more sophisticated track density plots.
2881+
28772882
Parameters:
28782883
----------
2879-
res: int (optional)
2884+
res: int (optional) Default: 5°
28802885
resolution in degrees of the grid bins in which the density will be computed
2881-
time_step: float (optional)
2886+
time_step: float (optional) default: 1h
28822887
temporal resolution in hours to be apllied to the tracks, to ensure that every track
28832888
will have the same resolution.
2884-
mode: str (optional)
2889+
mode: str (optional) default: absolute
28852890
"normalized" or "absolute" density
28862891
28872892
Returns:

climada/hazard/test/test_tc_tracks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ def test_track_land_params(self):
12031203
)
12041204

12051205
def test_compute_density_tracks(self):
1206-
"""Test compute density track to ensure proper density count."""
1206+
"""Test :py:meth:`compute_track_density` to ensure proper density count."""
12071207
# create track
12081208
track = xr.Dataset(
12091209
{

0 commit comments

Comments
 (0)