Skip to content

Commit d5f901f

Browse files
committed
Adds integration tests and polish:
- Adds constants for columns name and other repeatedly used strings - Adds a reordering df columns function (also fixes column order inconsistencies) - Changes period AAI from sum to average - Fixes bugs when group_id not defined (also now returns None instead of empty df - Adds convenience function in Snapshot for ImpactCalc init - Now sorts snapshots list by date in base class - Now allows None for risk_disc_rates
1 parent c8495ea commit d5f901f

14 files changed

+1756
-591
lines changed

climada/test/test_trajectories.py

Lines changed: 698 additions & 2 deletions
Large diffs are not rendered by default.

climada/trajectories/constants.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
This file is part of CLIMADA.
3+
4+
Copyright (C) 2017 ETH Zurich, CLIMADA contributors listed in AUTHORS.
5+
6+
CLIMADA is free software: you can redistribute it and/or modify it under the
7+
terms of the GNU General Public License as published by the Free
8+
Software Foundation, version 3.
9+
10+
CLIMADA is distributed in the hope that it will be useful, but WITHOUT ANY
11+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12+
PARTICULAR PURPOSE. See the GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License along
15+
with CLIMADA. If not, see <https://www.gnu.org/licenses/>.
16+
17+
---
18+
19+
Define constants for trajectories module.
20+
"""
21+
22+
DEFAULT_TIME_RESOLUTION = "Y"
23+
DATE_COL_NAME = "date"
24+
PERIOD_COL_NAME = "period"
25+
GROUP_COL_NAME = "group"
26+
GROUP_ID_COL_NAME = "group_id"
27+
MEASURE_COL_NAME = "measure"
28+
NO_MEASURE_VALUE = "no_measure"
29+
METRIC_COL_NAME = "metric"
30+
UNIT_COL_NAME = "unit"
31+
RISK_COL_NAME = "risk"
32+
COORD_ID_COL_NAME = "coord_id"
33+
34+
DEFAULT_PERIOD_INDEX_NAME = "date"
35+
36+
DEFAULT_RP = [20, 50, 100]
37+
"""Default return periods to use when computing return period impact estimates."""
38+
39+
DEFAULT_ALLGROUP_NAME = "All"
40+
"""Default string to use to define the exposure subgroup containing all exposure points."""
41+
42+
EAI_METRIC_NAME = "eai"
43+
AAI_METRIC_NAME = "aai"
44+
AAI_PER_GROUP_METRIC_NAME = "aai_per_group"
45+
CONTRIBUTIONS_METRIC_NAME = "risk_contributions"
46+
RETURN_PERIOD_METRIC_NAME = "return_periods"
47+
RP_VALUE_PREFIX = "rp"
48+
49+
50+
CONTRIBUTION_BASE_RISK_NAME = "base risk"
51+
CONTRIBUTION_TOTAL_RISK_NAME = "total risk"
52+
CONTRIBUTION_EXPOSURE_NAME = "exposure contribution"
53+
CONTRIBUTION_HAZARD_NAME = "hazard contribution"
54+
CONTRIBUTION_VULNERABILITY_NAME = "vulnerability contribution"
55+
CONTRIBUTION_INTERACTION_TERM_NAME = "interaction contribution"

0 commit comments

Comments
 (0)