Skip to content

Commit b93bde6

Browse files
committed
correct int region_id and silence warning log world bank
1 parent 5de26f7 commit b93bde6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

climada/entity/exposures/black_marble.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import shapely.vectorized
1717
from cartopy.io import shapereader
1818
from iso3166 import countries as iso_cntry
19+
import warnings
1920

2021
from climada.entity.exposures.base import Exposures
2122
from climada.util.files_handler import download_file
@@ -164,7 +165,7 @@ def _set_one_country(cntry_info, nightlight, coord_nl, fn_nl, res_fact,
164165
_filter_admin1(exp_bkmrb, admin1)
165166

166167
exp_bkmrb.id = np.arange(1, exp_bkmrb.value.size+1)
167-
exp_bkmrb.region_id = np.ones(exp_bkmrb.value.shape) * cntry_info[0]
168+
exp_bkmrb.region_id = np.ones(exp_bkmrb.value.shape, int)*cntry_info[0]
168169
exp_bkmrb.impact_id = np.ones(exp_bkmrb.value.size, int)
169170
exp_bkmrb.ref_year = cntry_info[3]
170171
exp_bkmrb.tag.description = ("{} {:d} GDP: {:.3e} income group: {:d}"+\
@@ -341,10 +342,9 @@ def add_sea(exp, sea_res):
341342
np.append(exp.coord.lon, lon_mgrid[on_land])]).transpose()
342343
exp.value = np.append(exp.value, lat_mgrid[on_land]*0)
343344
exp.id = np.arange(1, exp.value.size+1)
344-
exp.region_id = np.append(exp.region_id, lat_mgrid[on_land]*0-1)
345+
exp.region_id = np.append(exp.region_id, lat_mgrid[on_land].astype(int)*0
346+
- 1)
345347
exp.impact_id = np.ones(exp.value.size, int)
346-
exp.deductible = np.zeros(exp.value.size)
347-
exp.cover = exp.value.copy()
348348

349349
def _fill_admin1_geom(iso3, admin1_rec, prov_list):
350350
"""Get admin1 polygons for each input province of country iso3.
@@ -449,7 +449,9 @@ def _get_gdp(cntry_info, ref_year, shp_file):
449449
wb_gdp_ind = 'NY.GDP.MKTP.CD'
450450
for cntry_iso, cntry_val in cntry_info.items():
451451
try:
452-
cntry_gdp = wb.download(indicator=wb_gdp_ind, country=cntry_iso,
452+
with warnings.catch_warnings():
453+
warnings.simplefilter("ignore")
454+
cntry_gdp = wb.download(indicator=wb_gdp_ind, country=cntry_iso,
453455
start=1960, end=2030)
454456
years = np.array([int(year) \
455457
for year in cntry_gdp.index.get_level_values('year')])

0 commit comments

Comments
 (0)