Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	doc/guide/Guide_Installation.ipynb
  • Loading branch information
emanuel-schmid committed Feb 2, 2022
2 parents 2111c49 + 545f38a commit 293a633
Show file tree
Hide file tree
Showing 114 changed files with 17,793 additions and 20,090 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ climada/engine/test/data/test_imp_mat.npz
climada/engine/test/data/test.xlsx
climada/entity/impact_funcs/test/data/test_write.xlsx
climada/hazard/test/data/tc_tracks_nc/*
climada/hazard/test/data/tc_tracks.h5
climada/hazard/test/data/test_centr.h5
climada/hazard/test/data/test_haz.h5
climada/test/data/1988234N13299.nc
Expand Down
9 changes: 8 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
version: 2

build:
os: "ubuntu-20.04"
tools:
python: "mambaforge-4.10"

conda:
file: requirements/env_docs.yml
environment: requirements/env_docs.yml
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include climada/conf/climada.conf
graft climada/*/*/test
graft climada/test
graft data
global-exclude *.py[co]
2 changes: 1 addition & 1 deletion climada.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"_comment": "this is a climada configuration file meant to supersede the default configuration in climada/conf during test",
"test_directory": "./climada",
"test_directory": ".../climada",
"test_data": "{test_directory}/test/data",
"disc_rates": {
"test_data": "{test_directory}/entity/disc_rates/test/data"
Expand Down
24 changes: 24 additions & 0 deletions climada/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,32 @@
}


def test_installation():
"""Run this function to check whether climada is working properly.
If the invoked tests pass and an OK is printed out, the installation was successfull.
"""
from unittest import TestLoader, TextTestRunner
suite = TestLoader().discover(start_dir='climada.engine.test',
pattern='test_cost_benefit.py')
suite.addTest(TestLoader().discover(start_dir='climada.engine.test',
pattern='test_impact.py'))
TextTestRunner(verbosity=2).run(suite)


def setup_climada_data(reload=False):
"""This function is called when climada is imported.
It creates a climada directory by default in the home directory.
Other locations can be configured in the climada.conf file.
The directory is filled with data files from the repository and is also the default target
directory for files downloaded from climada.ethz.ch via the data api.
Parameters
----------
reload : bool, optional
in case system or demo data have changed in the github repository, the local copies of
these files can be updated by setting reload to True,
by default False
"""
for dirpath in [DEMO_DIR, SYSTEM_DIR, GSDP_DIR]:
dirpath.mkdir(parents=True, exist_ok=True)

Expand Down
2 changes: 1 addition & 1 deletion climada/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.0.1'
__version__ = '3.1.0'
11 changes: 8 additions & 3 deletions climada/conf/climada.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,19 @@
"forecast_dir": "{local_data.save_dir}/forecast/hazards"
}
},
"util": {
"coordinates": {
"dist_to_coast_nasa_url": "https://oceancolor.gsfc.nasa.gov/docs/distfromcoast/GMT_intermediate_coast_distance_01d.zip",
"dist_to_coast_nasa_tif": "GMT_intermediate_coast_distance_01d.tif"
}
},
"log_level": "WARNING",
"max_matrix_size": 1000000000,
"data_api": {
"host": "https://climada.ethz.ch",
"url": "https://climada.ethz.ch/data-api/v1/",
"chunk_size": 8192,
"cache_db": "{local_data.system}/.downloads.db",
"supported_hazard_types": ["river_flood", "tropical_cyclone", "storm_europe"],
"supported_exposures_types": ["litpop", "crop_production"],
"mutual_properties": ["exponents", "fin_mode", "rcp", "resolution", "unit"]
"supported_exposures_types": ["litpop", "crop_production"]
}
}
15 changes: 5 additions & 10 deletions climada/engine/calibration_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ def init_impf(impf_name_or_instance, param_dict, df_out=pd.DataFrame(index=[0]))
ImpactFunc_final = None
if isinstance(impf_name_or_instance, str):
if impf_name_or_instance == 'emanuel':
ImpactFunc_final = ImpfTropCyclone()
ImpactFunc_final.set_emanuel_usa(**param_dict)
ImpactFunc_final = ImpfTropCyclone.from_emanuel_usa(**param_dict)
ImpactFunc_final.haz_type = 'TC'
ImpactFunc_final.id = 1
df_out['impact_function'] = impf_name_or_instance
Expand Down Expand Up @@ -455,10 +454,8 @@ def specific_calib(x):
#
#
# ## tryout calib_all
# hazard = TropCyclone()
# hazard.read_hdf5('C:/Users/ThomasRoosli/tc_NA_hazard.hdf5')
# exposure = LitPop()
# exposure.read_hdf5('C:/Users/ThomasRoosli/DOM_LitPop.hdf5')
# hazard = TropCyclone.from_hdf5('C:/Users/ThomasRoosli/tc_NA_hazard.hdf5')
# exposure = LitPop.from_hdf5('C:/Users/ThomasRoosli/DOM_LitPop.hdf5')
# impf_name_or_instance = 'emanuel'
# param_full_dict = {'v_thresh': [25.7, 20], 'v_half': [70], 'scale': [1, 0.8]}
#
Expand All @@ -472,10 +469,8 @@ def specific_calib(x):
#
#
# ## tryout calib_optimize
# hazard = TropCyclone()
# hazard.read_hdf5('C:/Users/ThomasRoosli/tc_NA_hazard.hdf5')
# exposure = LitPop()
# exposure.read_hdf5('C:/Users/ThomasRoosli/DOM_LitPop.hdf5')
# hazard = TropCyclone.from_hdf5('C:/Users/ThomasRoosli/tc_NA_hazard.hdf5')
# exposure = LitPop.from_hdf5('C:/Users/ThomasRoosli/DOM_LitPop.hdf5')
# impf_name_or_instance = 'emanuel'
# param_dict = {'v_thresh': 25.7, 'v_half': 70, 'scale': 0.6}
# year_range = [2004, 2017]
Expand Down
Loading

0 comments on commit 293a633

Please sign in to comment.