Skip to content

Commit 185866f

Browse files
committed
Merge branch 'develop' into calibrate-impact-functions
2 parents dda079d + ef410e1 commit 185866f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1237
-1385
lines changed

.jenkins_ci.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

.jenkins_ci_night.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

.jenkins_data.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Removed:
2828
- `climada.util.coordinates.match_centroids` method for matching (hazard) centroids to GeoDataFrames [#602](https://github.com/CLIMADA-project/climada_python/pull/602)
2929
- 'Extra' requirements `doc`, `test`, and `dev` for Python package [#712](https://github.com/CLIMADA-project/climada_python/pull/712)
3030
- Added method `Exposures.centroids_total_value` to replace the functionality of `Exposures.affected_total_value`. This method is temporary and deprecated. [#702](https://github.com/CLIMADA-project/climada_python/pull/702)
31-
- New method `climada.util.api_client.Client.purge_cache`: utility function to remove outdated files from the local file system to free disk space.
31+
- New method `climada.util.api_client.Client.purge_cache`: utility function to remove outdated files from the local file system to free disk space.
3232
([#737](https://github.com/CLIMADA-project/climada_python/pull/737))
3333

3434
### Changed
@@ -51,11 +51,20 @@ Removed:
5151
- Users can opt-out of the climada specific logging definitions and freely configure logging to their will, by setting the config value `logging.managed` to `false`. [#724](https://github.com/CLIMADA-project/climada_python/pull/724)
5252
- Add option to read additional variables from IBTrACS when using `TCTracks.from_ibtracs_netcdf` [#728](https://github.com/CLIMADA-project/climada_python/pull/728)
5353
- The `haz_type` attribute has been moved from `climada.hazard.tag.Tag` to `climada.hazard.Hazard` itself. [#736](https://github.com/CLIMADA-project/climada_python/pull/736)
54+
- New file format for `TCTracks` I/O with better performance. This change is not backwards compatible: If you stored `TCTracks` objects with `TCTracks.write_hdf5`, reload the original data and store them again. [#735](https://github.com/CLIMADA-project/climada_python/pull/735)
55+
- Add option to load only a subset when reading TC tracks using `TCTracks.from_simulations_emanuel`. [#741](https://github.com/CLIMADA-project/climada_python/pull/741)
56+
- Set `save_mat` to `False` in the `unsequa` module [#746](https://github.com/CLIMADA-project/climada_python/pull/746)
57+
- `list_dataset_infos` from `climada.util.api_client.Client`: the `properties` argument, a `dict`, can now have `None` as values. Before, only strings and lists of strings were allowed. Setting a particular property to `None` triggers a search for datasets where this property is not assigned. [#752](https://github.com/CLIMADA-project/climada_python/pull/752)
58+
- Reduce memory requirements of `TropCyclone.from_tracks` [#749](https://github.com/CLIMADA-project/climada_python/pull/749)
59+
- Support for different wind speed and pressure units in `TCTracks` when running `TropCyclone.from_tracks` [#749](https://github.com/CLIMADA-project/climada_python/pull/749)
5460

5561
### Fixed
5662

5763
- `util.lines_polys_handler` solve polygon disaggregation issue in metre-based projection [#666](https://github.com/CLIMADA-project/climada_python/pull/666)
5864
- Problem with `pyproj.CRS` as `Impact` attribute, [#706](https://github.com/CLIMADA-project/climada_python/issues/706). Now CRS is always stored as `str` in WKT format.
65+
- Correctly handle assertion errors in `Centroids.values_from_vector_files` and fix the associated test [#768](https://github.com/CLIMADA-project/climada_python/pull/768/)
66+
- Text in `Forecast` class plots can now be adjusted [#769](https://github.com/CLIMADA-project/climada_python/issues/769)
67+
- `Impact.impact_at_reg` now supports impact matrices where all entries are zero [#773](https://github.com/CLIMADA-project/climada_python/pull/773)
5968

6069
### Deprecated
6170

@@ -66,8 +75,8 @@ Removed:
6675
### Removed
6776

6877
- `Centroids.set_raster_from_pix_bounds` [#721](https://github.com/CLIMADA-project/climada_python/pull/721)
69-
7078
- `requirements/env_developer.yml` environment specs. Use 'extra' requirements when installing the Python package instead [#712](https://github.com/CLIMADA-project/climada_python/pull/712)
79+
- `Impact.tag` attribute. This change is not backwards-compatible with respect to the files written and read by the `Impact` class [#743](https://github.com/CLIMADA-project/climada_python/pull/743)
7180

7281
## v3.3.2
7382

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ unit_test : ## Unit tests execution with coverage and xml reports
2424

2525
.PHONY : install_test
2626
install_test : ## Test installation was successful
27-
pytest $(PYTEST_JUNIT_ARGS) climada/engine/test/test_cost_benefit.py \
28-
climada/engine/test/test_impact.py
27+
pytest $(PYTEST_JUNIT_ARGS) --pyargs climada.engine.test.test_cost_benefit \
28+
climada.engine.test.test_impact
2929

3030
.PHONY : data_test
3131
data_test : ## Test data APIs

climada/engine/forecast.py

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ def calc(self, force_reassign=False):
313313
def plot_imp_map(
314314
self,
315315
run_datetime=None,
316+
explain_str=None,
316317
save_fig=True,
317318
close_fig=False,
318319
polygon_file=None,
@@ -321,13 +322,17 @@ def plot_imp_map(
321322
figsize=(9, 13),
322323
adapt_fontsize=True,
323324
):
324-
"""plot a map of the impacts
325+
""" plot a map of the impacts
325326
326327
Parameters
327328
----------
328329
run_datetime : datetime.datetime, optional
329330
Select the used hazard by the run_datetime,
330331
default is first element of attribute run_datetime.
332+
explain_str : str, optional
333+
Short str which explains type of impact, explain_str is included
334+
in the title of the figure.
335+
default is 'mean building damage caused by wind'
331336
save_fig : bool, optional
332337
Figure is saved if True, folder is within your configurable
333338
save_dir and filename is derived from the method summary_str()
@@ -372,7 +377,7 @@ def plot_imp_map(
372377
"run_start": (
373378
run_datetime.strftime("%d.%m.%Y %HUTC +") + lead_time_str + "d"
374379
),
375-
"explain_text": ("mean building damage caused by wind"),
380+
"explain_text": "mean building damage caused by wind" if explain_str is None else explain_str,
376381
"model_text": "CLIMADA IMPACT",
377382
}
378383
fig, axes = self._plot_imp_map(
@@ -526,15 +531,24 @@ def _plot_imp_map(
526531
return fig, axis_sub
527532

528533
def plot_hist(
529-
self, run_datetime=None, save_fig=True, close_fig=False, figsize=(9, 8)
534+
self,
535+
run_datetime=None,
536+
explain_str=None,
537+
save_fig=True,
538+
close_fig=False,
539+
figsize=(9, 8),
530540
):
531-
"""plot histogram of the forecasted impacts all ensemble members
541+
""" plot histogram of the forecasted impacts all ensemble members
532542
533543
Parameters
534544
----------
535545
run_datetime : datetime.datetime, optional
536546
Select the used hazard by the run_datetime,
537547
default is first element of attribute run_datetime.
548+
explain_str : str, optional
549+
Short str which explains type of impact, explain_str is included
550+
in the title of the figure.
551+
default is 'total building damage'
538552
save_fig : bool, optional
539553
Figure is saved if True, folder is within your configurable
540554
save_dir and filename is derived from the method summary_str()
@@ -603,7 +617,7 @@ def plot_hist(
603617
axes.xaxis.set_ticks(x_ticks)
604618
axes.xaxis.set_ticklabels(x_ticklabels)
605619
plt.xticks(rotation=15, horizontalalignment="right")
606-
plt.xlim([(10**-0.25) * bins[0], (10**0.25) * bins[-1]])
620+
plt.xlim([(10 ** -0.25) * bins[0], (10 ** 0.25) * bins[-1]])
607621

608622
lead_time_str = "{:.0f}".format(
609623
self.lead_time(run_datetime).days
@@ -614,7 +628,7 @@ def plot_hist(
614628
"run_start": (
615629
run_datetime.strftime("%d.%m.%Y %HUTC +") + lead_time_str + "d"
616630
),
617-
"explain_text": ("total building damage"),
631+
"explain_text": ("total building damage") if explain_str is None else explain_str,
618632
"model_text": "CLIMADA IMPACT",
619633
}
620634
title_position = {
@@ -656,8 +670,9 @@ def plot_hist(
656670
plt.text(
657671
0.75,
658672
0.85,
659-
"mean damage:\nCHF "
660-
+ self._number_to_str(self._impact[haz_ind].at_event.mean()),
673+
"mean impact:\n "
674+
+ self._number_to_str(self._impact[haz_ind].at_event.mean())
675+
+ ' ' + self._impact[haz_ind].unit,
661676
horizontalalignment="center",
662677
verticalalignment="center",
663678
transform=axes.transAxes,
@@ -740,7 +755,7 @@ def plot_exceedence_prob(
740755
The default is (9, 13)
741756
adapt_fontsize : bool, optional
742757
If set to true, the size of the fonts will be adapted to the size of the figure.
743-
Otherwise the default matplotlib font size is used. Default is True.
758+
Otherwise, the default matplotlib font size is used. Default is True.
744759
745760
Returns
746761
-------
@@ -750,10 +765,10 @@ def plot_exceedence_prob(
750765
if run_datetime is None:
751766
run_datetime = self.run_datetime[0]
752767
haz_ind = np.argwhere(np.isin(self.run_datetime, run_datetime))[0][0]
753-
wind_map_file_name = (
768+
exceedence_map_file_name = (
754769
self.summary_str(run_datetime) + "_exceed_" + str(threshold) + "_map.jpeg"
755770
)
756-
wind_map_file_name_full = FORECAST_PLOT_DIR / wind_map_file_name
771+
exceedence_map_file_name_full = FORECAST_PLOT_DIR / exceedence_map_file_name
757772
lead_time_str = "{:.0f}".format(
758773
self.lead_time(run_datetime).days
759774
+ self.lead_time(run_datetime).seconds / 60 / 60 / 24
@@ -783,7 +798,7 @@ def plot_exceedence_prob(
783798
adapt_fontsize=adapt_fontsize,
784799
)
785800
if save_fig:
786-
plt.savefig(wind_map_file_name_full)
801+
plt.savefig(exceedence_map_file_name_full)
787802
if close_fig:
788803
plt.clf()
789804
plt.close(fig)
@@ -974,7 +989,7 @@ def plot_warn_map(
974989
Figure is not drawn if True. The default is False.
975990
adapt_fontsize : bool, optional
976991
If set to true, the size of the fonts will be adapted to the size of the figure.
977-
Otherwise the default matplotlib font size is used. Default is True.
992+
Otherwise, the default matplotlib font size is used. Default is True.
978993
979994
Returns
980995
-------
@@ -1086,7 +1101,7 @@ def _plot_warn(
10861101
decision_dict_functions[aggregation] = np.mean
10871102
else:
10881103
raise ValueError(
1089-
"Parameter area_aggregation of "
1104+
"Parameter " + aggregation + " of "
10901105
+ "Forecast.plot_warn_map() must eiter be "
10911106
+ "a float between [0..1], which "
10921107
+ "specifys a quantile. or 'sum' or 'mean'."

0 commit comments

Comments
 (0)