Skip to content

Commit

Permalink
update docstrings and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasColombi committed Feb 6, 2025
1 parent 7e3a70e commit e0f20a3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Code freeze date: YYYY-MM-DD

### Added

- `climada.hazard.tc_tracks.compute_track_density` function [#1003](https://github.com/CLIMADA-project/climada_python/pull/1003)
- Add `osm-flex` package to CLIMADA core [#981](https://github.com/CLIMADA-project/climada_python/pull/981)
- `doc.tutorial.climada_entity_Exposures_osm.ipynb` tutorial explaining how to use `osm-flex`with CLIMADA
- `climada.util.coordinates.bounding_box_global` function [#980](https://github.com/CLIMADA-project/climada_python/pull/980)
Expand Down
17 changes: 11 additions & 6 deletions climada/hazard/tc_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2870,18 +2870,23 @@ def _zlib_from_dataarray(data_var: xr.DataArray) -> bool:


def compute_track_density(
tc_track: TCTracks, res: int = 5, time_step: float = 0.5, mode: str = "normalized"
tc_track: TCTracks, res: int = 5, time_step: float = 1, mode: str = "absolute"
) -> tuple[np.ndarray, tuple]:
"""Compute absolute and normalized tropical cyclone track density as the number of points per
grid cell.
"""Compute absolute and normalized tropical cyclone track density. First, the function ensure
the same temporal resolution of all tracks by calling :py:meth:`equal_timestep`. Second, it
creates 2D bins of the specified resolution (e.g. 1° x 1°). Third, since tracks are not lines
but a series of points, it counts the number of points per bin. Lastly, it returns the absolute
or normalized count per bin. This function works under the hood of :py:meth:`plot_track_density`
but can be used separtly as input data for more sophisticated track density plots.
Parameters:
----------
res: int (optional)
res: int (optional) Default: 5°
resolution in degrees of the grid bins in which the density will be computed
time_step: float (optional)
time_step: float (optional) default: 1h
temporal resolution in hours to be apllied to the tracks, to ensure that every track
will have the same resolution.
mode: str (optional)
mode: str (optional) default: absolute
"normalized" or "absolute" density
Returns:
Expand Down
2 changes: 1 addition & 1 deletion climada/hazard/test/test_tc_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ def test_track_land_params(self):
)

def test_compute_density_tracks(self):
"""Test compute density track to ensure proper density count."""
"""Test :py:meth:`compute_track_density` to ensure proper density count."""
# create track
track = xr.Dataset(
{
Expand Down

0 comments on commit e0f20a3

Please sign in to comment.