Skip to content

Commit

Permalink
Merge branch 'develop' into overview_developer_guide
Browse files Browse the repository at this point in the history
  • Loading branch information
sarah-hlsn committed Nov 6, 2023
2 parents f37c859 + 98fccb7 commit 4c67572
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 39 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Code freeze date: YYYY-MM-DD

### Changed

- The default tile layer in Exposures maps is not Stamen Terrain anymore, but [CartoDB Positron](https://github.com/CartoDB/basemap-styles). Affected methods are `climada.engine.Impact.plot_basemap_eai_exposure`,`climada.engine.Impact.plot_basemap_impact_exposure` and `climada.entity.Exposures.plot_basemap`. [#798](https://github.com/CLIMADA-project/climada_python/pull/798)

### Fixed

- Fix the dist_approx util function when used with method="geosphere" and log=True and points that are very close. [#792](https://github.com/CLIMADA-project/climada_python/pull/792)
Expand Down
8 changes: 4 additions & 4 deletions climada/engine/impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def plot_raster_eai_exposure(self, res=None, raster_res=None, save_tiff=None,

def plot_basemap_eai_exposure(self, mask=None, ignore_zero=False, pop_name=True,
buffer=0.0, extend='neither', zoom=10,
url=ctx.providers.Stamen.Terrain,
url=ctx.providers.CartoDB.Positron,
axis=None, **kwargs):
"""Plot basemap expected impact of each exposure within a period of 1/frequency_unit.
Expand All @@ -694,7 +694,7 @@ def plot_basemap_eai_exposure(self, mask=None, ignore_zero=False, pop_name=True,
zoom : int, optional
zoom coefficient used in the satellite image
url : str, optional
image source, e.g. ctx.providers.OpenStreetMap.Mapnik
image source, default: ctx.providers.CartoDB.Positron
axis : matplotlib.axes.Axes, optional
axis to use
kwargs : dict, optional
Expand Down Expand Up @@ -764,7 +764,7 @@ def plot_hexbin_impact_exposure(self, event_id=1, mask=None, ignore_zero=False,

def plot_basemap_impact_exposure(self, event_id=1, mask=None, ignore_zero=False,
pop_name=True, buffer=0.0, extend='neither', zoom=10,
url=ctx.providers.Stamen.Terrain,
url=ctx.providers.CartoDB.Positron,
axis=None, **kwargs):
"""Plot basemap impact of an event at each exposure.
Requires attribute imp_mat.
Expand All @@ -789,7 +789,7 @@ def plot_basemap_impact_exposure(self, event_id=1, mask=None, ignore_zero=False,
zoom : int, optional
zoom coefficient used in the satellite image
url : str, optional
image source, e.g. ctx.providers.OpenStreetMap.Mapnik
image source, default: ctx.providers.CartoDB.Positron
axis : matplotlib.axes.Axes, optional
axis to use
kwargs : dict, optional
Expand Down
4 changes: 2 additions & 2 deletions climada/entity/exposures/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ def plot_raster(self, res=None, raster_res=None, save_tiff=None,

def plot_basemap(self, mask=None, ignore_zero=False, pop_name=True,
buffer=0.0, extend='neither', zoom=10,
url=None, axis=None, **kwargs):
url=ctx.providers.CartoDB.Positron, axis=None, **kwargs):
"""Scatter points over satellite image using contextily
Parameters
Expand All @@ -771,7 +771,7 @@ def plot_basemap(self, mask=None, ignore_zero=False, pop_name=True,
zoom coefficient used in the satellite image
url : Any, optional
image source, e.g., ``ctx.providers.OpenStreetMap.Mapnik``.
Default: ``ctx.providers.Stamen.Terrain``
Default: ``ctx.providers.CartoDB.Positron``
axis : matplotlib.axes._subplots.AxesSubplot, optional
axis to use
kwargs : optional
Expand Down
5 changes: 1 addition & 4 deletions climada/test/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ def test_ctx_osm_pass(self):
myexp.gdf['value'] = np.array([1, 1, 1])
myexp.check()

try:
myexp.plot_basemap(url=ctx.providers.OpenStreetMap.Mapnik)
except urllib.error.HTTPError:
self.assertEqual(1, 0)
myexp.plot_basemap(url=ctx.providers.OpenStreetMap.Mapnik)

def test_disc_rates(self):
"""Test plot function of discount rates."""
Expand Down
2 changes: 1 addition & 1 deletion climada/util/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def _divide_straight_from_multi(properties):
elif isinstance(_v, list):
multis[k] = _v
else:
raise ValueError("properties must be a string or a list of strings")
raise ValueError("the value of a property must be a string or a list of strings")
return straights, multis

@staticmethod
Expand Down
42 changes: 15 additions & 27 deletions doc/tutorial/climada_entity_Exposures.ipynb

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion requirements/env_climada.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ dependencies:
- xarray>=2023.8
- xlrd>=2.0
- xlsxwriter>=3.1
- xyzservices=2023.10.0

0 comments on commit 4c67572

Please sign in to comment.