Skip to content

Commit 5ff0f7d

Browse files
author
Chahan Kropf
committed
Merge remote-tracking branch 'origin/develop' into feature/haz_type_in_step_impf
2 parents c280b92 + 20754b1 commit 5ff0f7d

File tree

4 files changed

+132
-11
lines changed

4 files changed

+132
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Removed:
2626
- Refactored `Exposure.assign_centroids` using a new util function `u_coord.match_centroids` [#602](https://github.com/CLIMADA-project/climada_python/pull/602)
2727
- Renamed `climada.util.coordinate.assign_grid_points` to `match_grid_points` and `climada.util.coordinates.assign_coordinates` to `match_coordinates`
2828
[#602](https://github.com/CLIMADA-project/climada_python/pull/602)
29-
- Modified the method to disaggregate lines in the lines_polygons_handler utility module in order to better conserve the total length of all lines on average [#679](https://github.com/CLIMADA-project/climada_python/pull/679).
29+
- Modified the method to disaggregate lines in the `lines_polys_handler` utility module in order to better conserve the total length of all lines on average [#679](https://github.com/CLIMADA-project/climada_python/pull/679).
30+
- Added test for non-default impact function id in the `lines_polys_handler` [#676](https://github.com/CLIMADA-project/climada_python/pull/676)
3031
- The sigmoid and step impact functions now require the user to define the hazard type. [#675](https://github.com/CLIMADA-project/climada_python/pull/675)
3132

3233
### Fixed

climada/util/test/test_lines_polys_handler.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import numpy as np
2626
import geopandas as gpd
27+
import copy
2728

2829
from shapely.geometry import Point
2930
from shapely.geometry import LineString
@@ -43,6 +44,7 @@
4344
HAZ = Client().get_hazard('storm_europe', name='test_haz_WS_nl', status='test_dataset')
4445

4546
EXP_POLY = Client().get_exposures('base', name='test_polygon_exp', status='test_dataset')
47+
EXP_POLY.gdf['impf_WS'] = 2
4648
GDF_POLY = EXP_POLY.gdf
4749

4850
EXP_LINE = Client().get_exposures('base', name='test_line_exp', status='test_dataset')
@@ -52,7 +54,9 @@
5254
GDF_POINT = EXP_POINT.gdf
5355

5456
IMPF = ImpfStormEurope.from_welker()
55-
IMPF_SET = ImpactFuncSet([IMPF])
57+
IMPF2 = copy.deepcopy(IMPF)
58+
IMPF2.id = 2
59+
IMPF_SET = ImpactFuncSet([IMPF, IMPF2])
5660

5761
COL_CHANGING = ['value', 'latitude', 'longitude', 'geometry', 'geometry_orig']
5862

@@ -511,6 +515,33 @@ def test_calc_geom_impact_mixed(self):
511515
])
512516
check_impact(self, imp2, HAZ, exp_mix, aai_agg2, eai_exp2)
513517

518+
# Check non-default impact function id
519+
impfdouble = copy.deepcopy(IMPF2)
520+
impfdouble.mdd *= 2
521+
impf_set = ImpactFuncSet([IMPF, impfdouble])
522+
imp3 = u_lp.calc_geom_impact(
523+
exp_mix, impf_set, HAZ,
524+
res=0.05, to_meters=False, disagg_met=u_lp.DisaggMethod.DIV,
525+
disagg_val=None, agg_met=u_lp.AggMethod.SUM
526+
)
527+
aai_agg3 = 4708604.47775332
528+
eai_exp3 = np.array([
529+
1.73069928e-04, 8.80741357e-04, 1.77657635e-01, 1.06413744e-02,
530+
1.15405492e-02, 3.40097761e-02, 8.91658032e-03, 4.19735141e-02,
531+
1.27160538e-02, 2.43849980e-01, 2.32808488e-02, 5.47043065e-03,
532+
5.44984095e-03, 5.80779958e-03, 1.06361040e-01, 4.67335812e-02,
533+
9.93703142e-02, 8.48207692e-03, 2.95633263e-02, 1.30223646e-01,
534+
3.84600393e-01, 2.05709279e-02, 1.39919480e-01, 1.61239410e-02,
535+
4.46991386e-02, 1.30045513e-02, 1.30045513e-02, 6.91177788e-04,
536+
3.22122197e+04, 2.14840968e+04, 2.89492139e+04, 1.43759256e+05,
537+
5.17612411e+04, 4.02632630e+05, 3.52142916e+05, 7.84964258e+05,
538+
5.80728653e+05, 1.81079871e+06, 3.89456421e+05, 1.02345938e+05,
539+
5.68448588e+02, 4.91876274e+02, 3.81288655e+02, 3.47850159e+02,
540+
3.52183678e+02, 8.86108346e+02, 8.82756302e+02, 9.48633609e+02,
541+
9.67746928e+02, 5.18003590e+02, 4.96400801e+02, 5.25991584e+02
542+
])
543+
check_impact(self, imp3, HAZ, exp_mix, aai_agg3, eai_exp3)
544+
514545
def test_impact_pnt_agg(self):
515546
"""Test impact agreggation method"""
516547
gdf_mix = GDF_LINE.append(GDF_POLY).append(GDF_POINT).reset_index(drop=True)

doc/guide/Guide_CLIMADA_Tutorial.ipynb

Lines changed: 97 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"\n",
1818
"- [Why tutorials](#Why-tutorials)\n",
1919
"- [Basic structure](#Basic-structure)\n",
20-
"- [Good examples](#Good-examples)"
20+
"- [Good examples](#Good-examples)\n",
21+
"- [Use only Markdown for headers and table of content](#Use-only-Markdown-for-headers-and-table-of-content)"
2122
]
2223
},
2324
{
@@ -27,15 +28,17 @@
2728
"source": [
2829
"## Why tutorials\n",
2930
"\n",
30-
"**Main goal:**<br>\n",
31+
"**Main goal:**\n",
32+
"\n",
3133
"The main goal of the tutorials is it to give a complete overview on:\n",
3234
"\n",
3335
"- essential CLIMADA components\n",
3436
"- introduce newly developed modules and features\n",
3537
"\n",
3638
"More specifically, tutorials should introduce CLIMADA users to the core functionalities and modules and guide users in their application. Hence, each new module created needs to be accompanied with a tutorial. The following sections give an overview of the basic structure desired for CLIMADA tutorials.\n",
3739
"\n",
38-
"**Important:**<br>\n",
40+
"**Important:**\n",
41+
"\n",
3942
"A tutorial needs to be included with the final pull request for every new feature."
4043
]
4144
},
@@ -85,9 +88,7 @@
8588
" - keep the size of data you use as examples in the tutorial in mind\n",
8689
" - we aim for computational efficiency\n",
8790
" - a lean, well-organized, concise notebook is more informative than a long, messy all-encompassing one.\n",
88-
"\n",
89-
"- follow the general CLIMADA naming convention for the notebook. For example: \"climada_hazard_TropCyclone.ipynb\"\n",
90-
"![image-2.png](attachment:image-2.png)"
91+
"- follow the general CLIMADA naming convention for the notebook. For example: \"climada_hazard_TropCyclone.ipynb\""
9192
]
9293
},
9394
{
@@ -99,8 +100,96 @@
99100
"\n",
100101
"The following examples can be used as templates and inspiration for your tutorial:\n",
101102
"\n",
102-
"- https://github.com/CLIMADA-project/climada_python/blob/main/doc/tutorial/climada_entity_Exposures.ipynb\n",
103-
"- https://github.com/CLIMADA-project/climada_python/blob/main/doc/tutorial/climada_hazard_Hazard.ipynb"
103+
"- [Exposure tutorial](https://github.com/CLIMADA-project/climada_python/blob/main/doc/tutorial/climada_entity_Exposures.ipynb)\n",
104+
"- [Hazard tutorial](https://github.com/CLIMADA-project/climada_python/blob/main/doc/tutorial/climada_hazard_Hazard.ipynb)"
105+
]
106+
},
107+
{
108+
"attachments": {},
109+
"cell_type": "markdown",
110+
"metadata": {},
111+
"source": [
112+
"## Use only Markdown for headers and table of content\n",
113+
"\n",
114+
"To create headers or a table of content with links, avoid using *hmtl* and prefer instead purely *Markdown* syntax. Follow *Markdown* conventions in the [Markdown Guide](https://www.markdownguide.org/basic-syntax/) and the following key points presented in the section below to know how to use correct *Markdown* syntax which is consistent with the rest of CLIMADA documentation. If in doubt, check existing tutorials to see how it is done."
115+
]
116+
},
117+
{
118+
"attachments": {},
119+
"cell_type": "markdown",
120+
"metadata": {},
121+
"source": [
122+
"### Headers\n",
123+
"\n",
124+
"To structure your tutorial, use headers of different levels to create sections and subsections.\n",
125+
"\n",
126+
"To create an header, write the symbol (#) before your header name\n",
127+
"\n",
128+
"**'#'** : create a header of level 1\n",
129+
"\n",
130+
"**'##'** : create a header of level 2 \n",
131+
"\n",
132+
"**'###'** : create a header of level 3 \n",
133+
"\n",
134+
"**'####'** : create a header of level 4 \n",
135+
"\n",
136+
"The title of the tutorial should be of level 1 (#), should have its own cell, and should be the first cell of the notebook."
137+
]
138+
},
139+
{
140+
"attachments": {},
141+
"cell_type": "markdown",
142+
"metadata": {},
143+
"source": [
144+
"## Table of content\n",
145+
"\n",
146+
"The second cell of the notebook should be the table of content and should have a header name *'Content'* and a level of 2 (##).\n",
147+
"\n",
148+
"To create the table of content, avoid using numbers to list the different sections, prefer instead simple dots by using '**-**' :\n",
149+
"\n",
150+
"\n",
151+
"-\n",
152+
"-\n",
153+
"\n",
154+
"\n",
155+
"Instead of numbers :\n",
156+
"\n",
157+
"1.\n",
158+
"2.\n",
159+
"\n",
160+
"\n",
161+
"Additionally, the table of content should only contain headers of level 2 (##).\n",
162+
"\n",
163+
"To create a link from the table of content to a certain section of the tutorial, write [Name of your choice] followed by (#Exactly-the-header-name-you-want-to-direct-the-user-to).\n",
164+
"\n",
165+
"Remember to fill white spaces with '-' and that links to headers are case sensitive! (#This-paRt-Is-CaSe-sEnSitIve).\n",
166+
"\n",
167+
"See the syntax of the example below to create a table of content. \n"
168+
]
169+
},
170+
{
171+
"attachments": {},
172+
"cell_type": "markdown",
173+
"metadata": {},
174+
"source": [
175+
"### Input:\n",
176+
"\n",
177+
"```markdown\n",
178+
"## Content\n",
179+
"\n",
180+
"- [My first header](#My-first-header)\n",
181+
"- [My second header](#My-second-header)\n",
182+
"- [My third header](#My-third-header)\n",
183+
"\n",
184+
"```\n",
185+
"\n",
186+
"### Output:\n",
187+
"\n",
188+
"## Content\n",
189+
"\n",
190+
"- [My first header](#My-first-header)\n",
191+
"- [My second header](#My-second-header)\n",
192+
"- [My third header](#My-third-header)"
104193
]
105194
}
106195
],

doc/guide/Guide_Continuous_Integration_and_Testing.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
"source": [
178178
"### System Tests\n",
179179
"\n",
180-
"Integration tests are meant to check whether the whole software package is working correctly.\n",
180+
"System tests are meant to check whether the whole software package is working correctly.\n",
181181
"\n",
182182
"In CLIMADA, the system test that checks the core functionality of the package is executed by calling `make install_test` from the installation directory."
183183
]

0 commit comments

Comments
 (0)