Skip to content

Commit 293a633

Browse files
Merge branch 'develop'
# Conflicts: # doc/guide/Guide_Installation.ipynb
2 parents 2111c49 + 545f38a commit 293a633

File tree

114 files changed

+17793
-20090
lines changed

Some content is hidden

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

114 files changed

+17793
-20090
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ climada/engine/test/data/test_imp_mat.npz
5757
climada/engine/test/data/test.xlsx
5858
climada/entity/impact_funcs/test/data/test_write.xlsx
5959
climada/hazard/test/data/tc_tracks_nc/*
60+
climada/hazard/test/data/tc_tracks.h5
6061
climada/hazard/test/data/test_centr.h5
6162
climada/hazard/test/data/test_haz.h5
6263
climada/test/data/1988234N13299.nc

.readthedocs.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1+
version: 2
2+
3+
build:
4+
os: "ubuntu-20.04"
5+
tools:
6+
python: "mambaforge-4.10"
7+
18
conda:
2-
file: requirements/env_docs.yml
9+
environment: requirements/env_docs.yml

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include climada/conf/climada.conf
2+
graft climada/*/*/test
3+
graft climada/test
4+
graft data
5+
global-exclude *.py[co]

climada.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"_comment": "this is a climada configuration file meant to supersede the default configuration in climada/conf during test",
3-
"test_directory": "./climada",
3+
"test_directory": ".../climada",
44
"test_data": "{test_directory}/test/data",
55
"disc_rates": {
66
"test_data": "{test_directory}/entity/disc_rates/test/data"

climada/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,32 @@
6262
}
6363

6464

65+
def test_installation():
66+
"""Run this function to check whether climada is working properly.
67+
If the invoked tests pass and an OK is printed out, the installation was successfull.
68+
"""
69+
from unittest import TestLoader, TextTestRunner
70+
suite = TestLoader().discover(start_dir='climada.engine.test',
71+
pattern='test_cost_benefit.py')
72+
suite.addTest(TestLoader().discover(start_dir='climada.engine.test',
73+
pattern='test_impact.py'))
74+
TextTestRunner(verbosity=2).run(suite)
75+
76+
6577
def setup_climada_data(reload=False):
78+
"""This function is called when climada is imported.
79+
It creates a climada directory by default in the home directory.
80+
Other locations can be configured in the climada.conf file.
81+
The directory is filled with data files from the repository and is also the default target
82+
directory for files downloaded from climada.ethz.ch via the data api.
6683
84+
Parameters
85+
----------
86+
reload : bool, optional
87+
in case system or demo data have changed in the github repository, the local copies of
88+
these files can be updated by setting reload to True,
89+
by default False
90+
"""
6791
for dirpath in [DEMO_DIR, SYSTEM_DIR, GSDP_DIR]:
6892
dirpath.mkdir(parents=True, exist_ok=True)
6993

climada/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '3.0.1'
1+
__version__ = '3.1.0'

climada/conf/climada.conf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,19 @@
5353
"forecast_dir": "{local_data.save_dir}/forecast/hazards"
5454
}
5555
},
56+
"util": {
57+
"coordinates": {
58+
"dist_to_coast_nasa_url": "https://oceancolor.gsfc.nasa.gov/docs/distfromcoast/GMT_intermediate_coast_distance_01d.zip",
59+
"dist_to_coast_nasa_tif": "GMT_intermediate_coast_distance_01d.tif"
60+
}
61+
},
5662
"log_level": "WARNING",
5763
"max_matrix_size": 1000000000,
5864
"data_api": {
59-
"host": "https://climada.ethz.ch",
65+
"url": "https://climada.ethz.ch/data-api/v1/",
6066
"chunk_size": 8192,
6167
"cache_db": "{local_data.system}/.downloads.db",
6268
"supported_hazard_types": ["river_flood", "tropical_cyclone", "storm_europe"],
63-
"supported_exposures_types": ["litpop", "crop_production"],
64-
"mutual_properties": ["exponents", "fin_mode", "rcp", "resolution", "unit"]
69+
"supported_exposures_types": ["litpop", "crop_production"]
6570
}
6671
}

climada/engine/calibration_opt.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ def init_impf(impf_name_or_instance, param_dict, df_out=pd.DataFrame(index=[0]))
141141
ImpactFunc_final = None
142142
if isinstance(impf_name_or_instance, str):
143143
if impf_name_or_instance == 'emanuel':
144-
ImpactFunc_final = ImpfTropCyclone()
145-
ImpactFunc_final.set_emanuel_usa(**param_dict)
144+
ImpactFunc_final = ImpfTropCyclone.from_emanuel_usa(**param_dict)
146145
ImpactFunc_final.haz_type = 'TC'
147146
ImpactFunc_final.id = 1
148147
df_out['impact_function'] = impf_name_or_instance
@@ -455,10 +454,8 @@ def specific_calib(x):
455454
#
456455
#
457456
# ## tryout calib_all
458-
# hazard = TropCyclone()
459-
# hazard.read_hdf5('C:/Users/ThomasRoosli/tc_NA_hazard.hdf5')
460-
# exposure = LitPop()
461-
# exposure.read_hdf5('C:/Users/ThomasRoosli/DOM_LitPop.hdf5')
457+
# hazard = TropCyclone.from_hdf5('C:/Users/ThomasRoosli/tc_NA_hazard.hdf5')
458+
# exposure = LitPop.from_hdf5('C:/Users/ThomasRoosli/DOM_LitPop.hdf5')
462459
# impf_name_or_instance = 'emanuel'
463460
# param_full_dict = {'v_thresh': [25.7, 20], 'v_half': [70], 'scale': [1, 0.8]}
464461
#
@@ -472,10 +469,8 @@ def specific_calib(x):
472469
#
473470
#
474471
# ## tryout calib_optimize
475-
# hazard = TropCyclone()
476-
# hazard.read_hdf5('C:/Users/ThomasRoosli/tc_NA_hazard.hdf5')
477-
# exposure = LitPop()
478-
# exposure.read_hdf5('C:/Users/ThomasRoosli/DOM_LitPop.hdf5')
472+
# hazard = TropCyclone.from_hdf5('C:/Users/ThomasRoosli/tc_NA_hazard.hdf5')
473+
# exposure = LitPop.from_hdf5('C:/Users/ThomasRoosli/DOM_LitPop.hdf5')
479474
# impf_name_or_instance = 'emanuel'
480475
# param_dict = {'v_thresh': 25.7, 'v_half': 70, 'scale': 0.6}
481476
# year_range = [2004, 2017]

0 commit comments

Comments
 (0)