Skip to content

Commit dd4ed16

Browse files
author
schmide
committed
Merge branch 'develop' into main
# Conflicts: # climada/_version.py # requirements/env_climada.yml # requirements/env_docs.yml
2 parents 130d4ed + f3c8727 commit dd4ed16

File tree

175 files changed

+15397
-5450
lines changed

Some content is hidden

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

175 files changed

+15397
-5450
lines changed

.coveragerc

Whitespace-only changes.

.gitignore

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,20 @@ coverage.xml
5151
.hypothesis/
5252

5353
# Temporary data generated by unit tests
54+
climada/engine/test/data/supplychain/*
5455
climada/engine/test/data/test.csv
55-
climada/engine/test/data/test.xlsx
5656
climada/engine/test/data/test_imp_mat.npz
57-
climada/entity/impact_funcs/test/test_write.xlsx
58-
climada/hazard/test/data/test_haz.h5
57+
climada/engine/test/data/test.xlsx
58+
climada/entity/impact_funcs/test/data/test_write.xlsx
5959
climada/hazard/test/data/tc_tracks_nc/*
60+
climada/hazard/test/data/test_centr.h5
61+
climada/hazard/test/data/test_haz.h5
6062
climada/test/data/1988234N13299.nc
63+
climada/test/data/exposure_buildings_default_47_7.h5
6164
climada/test/data/exposure_high_47_8.h5
6265
climada/test/data/test_write_hazard.tif
6366
climada/util/test/data/save_test.pkl
67+
climada/util/test/data/test_write_raster.tif
6468

6569
# Translations
6670
*.mo
@@ -122,7 +126,7 @@ venv.bak/
122126
# mac finder files
123127
.DS_Store
124128

125-
# directory with input data for hazard emulator tutorial
129+
# directory with input data for hazard emulator tutorial
126130
data/emulator
127131

128132
# climada system data files
@@ -166,11 +170,10 @@ data/system/GMT_intermediate_coast*
166170
# climada system data files: folders for hazard and exposure data
167171
data/system/hazard/
168172
data/system/litpop/
169-
data/system/litpop_2014/
173+
data/system/litpop_2014/
170174

171175
# climada data: ISIMIP crop data folder:
172176
data/ISIMIP_crop/
173177

174178
# climada data results folder:
175-
data/results/
176-
179+
results/

.pylintrc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ ignore-on-opaque-inference=yes
147147
# List of class names for which member attributes should not be checked (useful
148148
# for classes with dynamically set attributes). This supports the use of
149149
# qualified names.
150-
ignored-classes=optparse.Values,thread._local,_thread._local
150+
# Config is excluded from pylint, because its members are dynamically created
151+
# from the climada.conf file
152+
ignored-classes=optparse.Values,thread._local,_thread._local,climada.util.config.Config
151153

152154
# List of module names for which member attributes should not be checked
153155
# (useful for modules/projects where namespaces are manipulated during runtime
@@ -288,10 +290,10 @@ const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
288290
docstring-min-length=-1
289291

290292
# Naming hint for function names
291-
function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
293+
function-name-hint=(([a-z][a-z0-9_]{2,40})|(_[a-z0-9_]*))$
292294

293295
# Regular expression matching correct function names
294-
function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
296+
function-rgx=(([a-z][a-z0-9_]{2,40})|(_[a-z0-9_]*))$
295297

296298
# Good variable names which should always be accepted, separated by a comma
297299
good-names=i,j,k,ex,Run,_

AUTHORS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ Evelyn Mühlhofer
1212
Rachel Bungerer
1313
Inga Sauer
1414
Samuel Lüthi
15-
Mannie Kam
15+
Pui Man (Mannie) Kam
1616
Simona Meiler
1717
Alessio Ciullo
1818
Thomas Vogt
19+
Benoit P. Guillod
20+
Chahan Kropf

Jenkinsfile

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@ pipeline {
1212
source activate climada_env
1313
pylint -ry climada | tee pylint.log'''
1414

15-
step([
16-
$class: 'WarningsPublisher',
17-
parserConfigurations: [[
18-
parserName: 'PyLint',
19-
pattern : 'pylint.log'
20-
]],
21-
unstableTotalHigh: '25',
22-
usePreviousBuildAsReference: true
23-
])
15+
recordIssues tools: [pyLint(pattern: 'pylint.log')]
2416
}
2517
}
2618

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lint : ## Static code analysis with Pylint
1212

1313
.PHONY : unit_test
1414
unit_test : ## Unit tests execution with coverage and xml reports
15-
python -m coverage run tests_runner.py unit
15+
python -m coverage run tests_runner.py unit
1616
python -m coverage xml -o coverage.xml
1717
python -m coverage html -d coverage
1818

climada.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"_comment": "this is a climada configuration file meant to supersede the default configuration in climada/conf during test",
3+
"test_directory": "./climada",
4+
"test_data": "{test_directory}/test/data",
5+
"disc_rates": {
6+
"test_data": "{test_directory}/entity/disc_rates/test/data"
7+
},
8+
"engine": {
9+
"test_data": "{test_directory}/engine/test/data"
10+
},
11+
"exposures": {
12+
"test_data": "{test_directory}/entity/exposures/test/data"
13+
},
14+
"impact_funcs": {
15+
"test_data": "{test_directory}/entity/impact_funcs/test/data"
16+
},
17+
"hazard": {
18+
"test_data": "{test_directory}/hazard/test/data"
19+
},
20+
"measures": {
21+
"test_data": "{test_directory}/entity/measures/test/data"
22+
},
23+
"util": {
24+
"test_data": "{test_directory}/util/test/data"
25+
},
26+
"log_level": "INFO"
27+
}

climada/__init__.py

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,91 @@
1818
1919
climada init
2020
"""
21+
from shutil import copyfile
22+
from pathlib import Path
2123

22-
from .util.config import CONFIG, setup_conf_user, setup_logging
23-
setup_conf_user()
24-
setup_logging(CONFIG['global']['log_level'])
24+
from .util.config import CONFIG, setup_logging
25+
from .util.constants import *
26+
27+
28+
__all__ = ['init']
29+
30+
31+
NGI_UNEP_DIR = SYSTEM_DIR.joinpath('ls_pr_NGI_UNEP')
32+
GSDP_DIR = SYSTEM_DIR.joinpath('GSDP')
33+
34+
REPO_DATA = {
35+
'data/system': [
36+
ISIMIP_GPWV3_NATID_150AS,
37+
GLB_CENTROIDS_MAT,
38+
ENT_TEMPLATE_XLS,
39+
HAZ_TEMPLATE_XLS,
40+
RIVER_FLOOD_REGIONS_CSV,
41+
NATEARTH_CENTROIDS[150],
42+
NATEARTH_CENTROIDS[360],
43+
SYSTEM_DIR.joinpath('GDP2Asset_converter_2.5arcmin.nc'),
44+
SYSTEM_DIR.joinpath('WEALTH2GDP_factors_CRI_2016.csv'),
45+
SYSTEM_DIR.joinpath('GDP_TWN_IMF_WEO_data.csv'),
46+
SYSTEM_DIR.joinpath('FAOSTAT_data_country_codes.csv'),
47+
SYSTEM_DIR.joinpath('rcp_db.xls'),
48+
SYSTEM_DIR.joinpath('tc_if_cal_v01_TDR1.0.csv'),
49+
SYSTEM_DIR.joinpath('tc_if_cal_v01_EDR.csv'),
50+
SYSTEM_DIR.joinpath('tc_if_cal_v01_RMSF.csv'),
51+
],
52+
'data/system/ls_pr_NGI_UNEP': [
53+
NGI_UNEP_DIR.joinpath('ls_pr_md.xml'),
54+
NGI_UNEP_DIR.joinpath('ls_pr.tfw'),
55+
NGI_UNEP_DIR.joinpath('ls_pr.tif'),
56+
NGI_UNEP_DIR.joinpath('ls_pr.xml'),
57+
],
58+
'data/system/GSDP': [
59+
GSDP_DIR.joinpath(f'{cc}_GSDP.xls')
60+
for cc in ['AUS', 'BRA', 'CAN', 'CHE', 'CHN', 'DEU', 'FRA', 'IDN', 'IND', 'JPN', 'MEX',
61+
'TUR', 'USA', 'ZAF']
62+
],
63+
'data/demo': [
64+
ENT_DEMO_TODAY,
65+
ENT_DEMO_FUTURE,
66+
EXP_DEMO_H5,
67+
HAZ_DEMO_FL,
68+
HAZ_DEMO_FLDDPH,
69+
HAZ_DEMO_FLDFRC,
70+
HAZ_DEMO_MAT,
71+
HAZ_DEMO_H5,
72+
TC_ANDREW_FL,
73+
DEMO_GDP2ASSET,
74+
DEMO_DIR.joinpath('demo_emdat_impact_data_2020.csv'),
75+
DEMO_DIR.joinpath('histsoc_landuse-15crops_annual_FR_DE_DEMO_2001_2005.nc'),
76+
DEMO_DIR.joinpath('hist_mean_mai-firr_1976-2005_DE_FR.hdf5'),
77+
DEMO_DIR.joinpath('FAOSTAT_data_producer_prices.csv'),
78+
DEMO_DIR.joinpath('FAOSTAT_data_production_quantity.csv'),
79+
DEMO_DIR.joinpath('lpjml_ipsl-cm5a-lr_ewembi_historical_2005soc_co2_yield-whe-noirr_annual_FR_DE_DEMO_1861_2005.nc'),
80+
DEMO_DIR.joinpath('h08_gfdl-esm2m_ewembi_historical_histsoc_co2_dis_global_daily_DEMO_FR_2001_2003.nc'),
81+
DEMO_DIR.joinpath('h08_gfdl-esm2m_ewembi_historical_histsoc_co2_dis_global_daily_DEMO_FR_2004_2005.nc'),
82+
DEMO_DIR.joinpath('gepic_gfdl-esm2m_ewembi_historical_2005soc_co2_yield-whe-noirr_global_DEMO_TJANJIN_annual_1861_2005.nc'),
83+
DEMO_DIR.joinpath('pepic_miroc5_ewembi_historical_2005soc_co2_yield-whe-firr_global_annual_DEMO_TJANJIN_1861_2005.nc'),
84+
DEMO_DIR.joinpath('pepic_miroc5_ewembi_historical_2005soc_co2_yield-whe-noirr_global_annual_DEMO_TJANJIN_1861_2005.nc'),
85+
DEMO_DIR.joinpath('WS_ERA40_sample.mat'),
86+
DEMO_DIR.joinpath('WS_Europe.xls'),
87+
] + WS_DEMO_NC
88+
}
89+
90+
91+
def setup_climada_data():
92+
93+
for dirpath in [DEMO_DIR, SYSTEM_DIR, NGI_UNEP_DIR, GSDP_DIR]:
94+
dirpath.mkdir(parents=True, exist_ok=True)
95+
96+
for src_dir, path_list in REPO_DATA.items():
97+
for path in path_list:
98+
if not path.exists():
99+
src = Path(__file__).parent.parent.joinpath(src_dir, path.name)
100+
copyfile(src, path)
101+
102+
103+
def init():
104+
setup_climada_data()
105+
setup_logging(CONFIG.log_level.str())
106+
107+
108+
init()

climada/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.5.1'
1+
__version__ = '2.0.0-dev'

climada/conf/climada.conf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"_comment": "this is the climada default configuration, it will be (partially) superseded by the first climada.conf files that are present in the user's home directory and the working directory or its parent directories",
3+
"local_data": {
4+
"system": "~/climada/data",
5+
"demo": "~/climada/demo/data",
6+
"save_dir": "./results"
7+
},
8+
"exposures": {
9+
"crop_production": {
10+
"local_data": "{local_data.system}/ISIMIP_crop"
11+
},
12+
"litpop": {
13+
"resources": {
14+
"world_bank_inc_group": "http://databank.worldbank.org/data/download/site-content/OGHIST.xls"
15+
}
16+
},
17+
"spam_agrar": {
18+
"resources": {
19+
"spam2005_api_access": "https://dataverse.harvard.edu/api/access/datafile/:persistentId?persistentId=doi:10.7910/DVN/DHXBJX/",
20+
"spam2005_dataset": "https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/DHXBJX"
21+
}
22+
}
23+
},
24+
"hazard": {
25+
"drought": {
26+
"resources": {
27+
"spei_file_url": "http://digital.csic.es/bitstream/10261/153475/8"
28+
}
29+
},
30+
"landslide": {
31+
"resources": {
32+
"opensearch": "https://pmmpublisher.pps.eosdis.nasa.gov/opensearch",
33+
"climatology_monthly": "https://svs.gsfc.nasa.gov/vis/a000000/a004600/a004631/frames/9600x5400_16x9_30p/MonthlyClimatology/[01-12]_ClimatologyMonthly_032818_9600x5400.tif"
34+
},
35+
"local_data": "."
36+
},
37+
"relative_cropyield": {
38+
"local_data": "{exposures.crop_production.local_data}"
39+
},
40+
"trop_cyclone": {
41+
"random_seed": 54
42+
}
43+
},
44+
"log_level": "WARNING",
45+
"max_matrix_size": 1000000000
46+
}

0 commit comments

Comments
 (0)