Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Code freeze date: YYYY-MM-DD
- Fixed asset count in impact logging message [#1195](https://github.com/CLIMADA-project/climada_python/pull/1195).
- `Hazard.from_raster_xarray` now returns a sparse matrix instead of a sparse array [#1261](https://github.com/CLIMADA-project/climada_python/pull/1261).
- Fix TCTracks.from_FAST duplicate loading from year loop [#1269](github.com/CLIMADA-project/climada_python/pull/1269)
- Fixed inverted resolution check in `climada.util.lines_polys_handler._line_to_pnts`: the "under-resolved lines" warning was triggered for lines *longer* than `10 * resolution` instead of *shorter*, so genuinely under-resolved line exposures were silently disaggregated to too few points (overestimating the re-aggregated impact) while well-resolved lines produced a spurious warning. The warning message wording and typos were also corrected [#1303](https://github.com/CLIMADA-project/climada_python/pull/1303)

### Deprecated
- `Impact.calc_freq_curve()` should not be given the parameter `return_per`. Use the parameter `return_periods` in `Impact.calc_freq_curve().interpolate()` instead.
Expand Down
9 changes: 5 additions & 4 deletions climada/util/lines_polys_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,13 +957,14 @@ def _line_to_pnts(gdf_lines, res, to_meters):
line_lengths = gdf_lines.length

# Add warning if lines are too short w.r.t. resolution
failing_res_check_count = len(line_lengths[line_lengths > 10 * res])
failing_res_check_count = len(line_lengths[line_lengths < 10 * res])
if failing_res_check_count > 0:
LOGGER.warning(
"%d lines with a length < 10*resolution were found. "
"Each of these lines is disaggregate to one point. "
"Reaggregatint values will thus likely lead to overestimattion. "
"Consider chosing a smaller resolution or filter out the short lines. ",
"Each of these lines is disaggregated to very few points, possibly "
"a single one. Reaggregating values will thus likely lead to "
"overestimation. Consider choosing a smaller resolution or filtering "
"out the short lines. ",
failing_res_check_count,
)

Expand Down
11 changes: 7 additions & 4 deletions climada/util/test/test_lines_polys_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,8 @@ def test_line_fractions(self):
)

def test_resolution_warning(self):
# Only the first line is shorter than 10 * resolution (10 * 1 = 10) and is
# therefore under-resolved; the two longer lines must not trigger the warning.
lines = [
LineString([[0, 0], [0, 2]]),
LineString([[0, 0], [0, 12]]),
Expand All @@ -1109,10 +1111,11 @@ def test_resolution_warning(self):
u_lp._line_to_pnts(gdf_lines, 1, False)
self.assertEqual(
ctx.records[0].message,
f"{2} lines with a length < 10*resolution were found. "
"Each of these lines is disaggregate to one point. "
"Reaggregatint values will thus likely lead to overestimattion. "
"Consider chosing a smaller resolution or filter out the short lines. ",
f"{1} lines with a length < 10*resolution were found. "
"Each of these lines is disaggregated to very few points, possibly "
"a single one. Reaggregating values will thus likely lead to "
"overestimation. Consider choosing a smaller resolution or filtering "
"out the short lines. ",
)

def test_gdf_to_grid(self):
Expand Down