Skip to content

Commit d022094

Browse files
sarah-hlsnleonie-villigerviggowatemanuel-schmidpeanutfun
authored
Improved readability of the developer guide (#808)
* Move exception handling and logging to new guide * change headings in Exception Handling guide * move reviewer guide and checklist to new file * remove installation instruction duplicate * move "Does it belong in CLIMADA?" * add overview of useful apps and tools * more descriptive label for overview in install.rst * add link to GitHub actions in overview table * adapt testing and continuous integration guides * format CI guide * Update AUTHORS.md * update mamba recommendation in app overview * Python_Dos: fix syntax highlighting * update changelog * fix broken links * updated data API table * move overview from install to get started * Improve information on coverage in guides --------- Co-authored-by: leonie-villiger <[email protected]> Co-authored-by: leonie-villiger <[email protected]> Co-authored-by: viggowat <[email protected]> Co-authored-by: emanuel-schmid <[email protected]> Co-authored-by: Lukas Riedel <[email protected]>
1 parent 1300e3d commit d022094

15 files changed

+823
-896
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Code freeze date: YYYY-MM-DD
1717

1818
### Changed
1919

20+
- Update Developer and Installation Guides for easier accessibility by new developers. [808](https://github.com/CLIMADA-project/climada_python/pull/808)
2021
- Add `shapes` argument to `geo_im_from_array` to allow flexible turning on/off of plotting coastline in `plot_intensity`. [#805](https://github.com/CLIMADA-project/climada_python/pull/805)
2122
- Update `CONTRIBUTING.md` to better explain types of contributions to this repository [#797](https://github.com/CLIMADA-project/climada_python/pull/797)
2223
- The default tile layer in Exposures maps is not Stamen Terrain anymore, but [CartoDB Positron](https://github.com/CartoDB/basemap-styles). Affected methods are `climada.engine.Impact.plot_basemap_eai_exposure`,`climada.engine.Impact.plot_basemap_impact_exposure` and `climada.entity.Exposures.plot_basemap`. [#798](https://github.com/CLIMADA-project/climada_python/pull/798)
Lines changed: 28 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,7 @@
88
}
99
},
1010
"source": [
11-
"# Miscellaneous CLIMADA conventions"
12-
]
13-
},
14-
{
15-
"cell_type": "markdown",
16-
"metadata": {
17-
"slideshow": {
18-
"slide_type": "slide"
19-
},
20-
"tags": [],
21-
"toc": true
22-
},
23-
"source": [
24-
"## Contents\n",
25-
"\n",
26-
"- [Dependencies (python packages)](#Dependencies-(python-packages))\n",
27-
"- [Class inheritance](#Class-inheritance)\n",
28-
"- [Does it belong into CLIMADA?](#Does-it-belong-into-CLIMADA?)\n",
29-
"- [Paper repository](#Paper-repository)\n",
30-
"- [Utility function](#Utility-function)\n",
31-
"- [Impact function renaming - if to impf](#Impact-function-renaming---if-to-impf)\n",
32-
"- [Data dependencies](#Data-dependencies)\n",
33-
"- [Side Note on Parameters](#Side-Note-on-Parameters)"
11+
"# CLIMADA coding conventions"
3412
]
3513
},
3614
{
@@ -59,13 +37,13 @@
5937
"Thus, when you are coding, follow these priorities:\n",
6038
"\n",
6139
"1. [Python standard library](https://docs.python.org/3/library/index.html)\n",
62-
"2. Funktions and methods already implemented in CLIMADA (do NOT introduce circulary imports though)\n",
40+
"2. Functions and methods already implemented in CLIMADA (do NOT introduce circulary imports though)\n",
6341
"3. [Packages already included in CLIMADA](https://github.com/CLIMADA-project/climada_python/network/dependencies)\n",
6442
"4. Before adding a new dependency: \n",
6543
" - Contact a [repository admin](https://github.com/CLIMADA-project/climada_python/wiki/Developer-Board) to get permission\n",
6644
" - Open an [issue](https://github.com/CLIMADA-project/climada_python/issues)\n",
6745
" \n",
68-
"Hence, first try to solve your problem with the standard library and function/methods already implemented in CLIMADA (see in particular the [util functions](#id)) then use the packages included in CLIMADA, and if this is not enough, propose the addition of a new package. Do not hesitate to propose new packages if this is needed for your work!"
46+
"Hence, first try to solve your problem with the standard library and function/methods already implemented in CLIMADA (see in particular the [utility functions](#Utility-functions)) then use the packages included in CLIMADA, and if this is not enough, propose the addition of a new package. Do not hesitate to propose new packages if this is needed for your work!"
6947
]
7048
},
7149
{
@@ -81,35 +59,7 @@
8159
"source": [
8260
"In Python, a [class can inherit from other classes](https://docs.python.org/3/tutorial/classes.html), which is a very useful mechanism in certain circumstances. However, it is wise to think about inheritance before implementing it. Very important, is that CLIMADA classes do not inherit from external library classes. For example, Exposure directly inherited from Geopandas. This caused problems in CLIMADA when the package Geopandas was updated.\n",
8361
"\n",
84-
"**CLIMADA classes shall NOT inherit classes from external modules**"
85-
]
86-
},
87-
{
88-
"cell_type": "markdown",
89-
"metadata": {
90-
"slideshow": {
91-
"slide_type": "slide"
92-
}
93-
},
94-
"source": [
95-
"## Does it belong into CLIMADA? "
96-
]
97-
},
98-
{
99-
"cell_type": "markdown",
100-
"metadata": {
101-
"slideshow": {
102-
"slide_type": "slide"
103-
}
104-
},
105-
"source": [
106-
"When developing for CLIMADA, it is important to distinguish between core content and particular applications. Core content is meant to be included into the [climada_python](https://github.com/CLIMADA-project/climada_python) repository and will be subject to a code review. Any new addition should first be discussed with one of the [repository admins](https://github.com/CLIMADA-project/climada_python/wiki/Developer-Board). The purpose of this discussion is to see\n",
107-
"\n",
108-
"- How does the planed module fit into CLIMADA?\n",
109-
"- What is an optimal architecture for the new module?\n",
110-
"- What parts might already exist in other parts of the code?\n",
111-
"\n",
112-
"Applications made with CLIMADA, such as an [ECA study](https://eca-network.org/) can be stored in the [paper repository](https://github.com/CLIMADA-project/climada_papers) once they have been published. For other types of work, consider making a separate repository that imports CLIMADA as an external package."
62+
"**CLIMADA classes shall NOT inherit classes from external modules.**"
11363
]
11464
},
11565
{
@@ -131,14 +81,14 @@
13181
}
13282
},
13383
"source": [
134-
"Applications made with CLIMADA which are published in the form of a paper or a report are very much encouraged to be submited to the [climada/paper](https://github.com/CLIMADA-project/climada_papers) repository. You can either:\n",
84+
"Applications made with CLIMADA which are published in the form of a paper or a report are very much encouraged to be submitted to the [climada/paper](https://github.com/CLIMADA-project/climada_papers) repository. You can either:\n",
13585
"\n",
13686
"- Prepare a well-commented jupyter notebook with the code necessary to reproduce your results and upload it to the [climada/paper](https://github.com/CLIMADA-project/climada_papers) repository. Note however that the repository cannot be used for storing data files.\n",
13787
"- Upload the code necessary to reproduce your results to a separate repository of your own. Then, add a link to your repository and to your publication to the readme file on the [climada/paper](https://github.com/CLIMADA-project/climada_papers) repository.\n",
13888
"\n",
13989
"**Notes about DOI**\n",
14090
"\n",
141-
"Some journals requires you to provide a DOI to the code and data used for your publication. In this case, we encourage to create a separate repository for your code and create a DOI using [Zenodo](https://zenodo.org/) or any specific service from your institution (e.g. [ETH Zürich](https://documentation.library.ethz.ch/display/DOID/DOI+Registration+Manual)).\n",
91+
"Some journals require you to provide a DOI to the code and data used for your publication. In this case, we encourage you to create a separate repository for your code and create a DOI using [Zenodo](https://zenodo.org/) or any specific service from your institution (e.g. [ETH Zürich](https://documentation.library.ethz.ch/display/DOID/DOI+Registration+Manual)).\n",
14292
"\n",
14393
"The CLIMADA releases are also identified with a DOI."
14494
]
@@ -151,7 +101,7 @@
151101
}
152102
},
153103
"source": [
154-
"## Utility function"
104+
"## Utility functions"
155105
]
156106
},
157107
{
@@ -175,32 +125,6 @@
175125
"It is very important to not reinvent the wheel and to avoid unnecessary redundancies in the code. This makes maintenance and debugging very tedious.\n"
176126
]
177127
},
178-
{
179-
"cell_type": "markdown",
180-
"metadata": {
181-
"slideshow": {
182-
"slide_type": "slide"
183-
}
184-
},
185-
"source": [
186-
"## Impact function renaming - if to impf "
187-
]
188-
},
189-
{
190-
"cell_type": "markdown",
191-
"metadata": {
192-
"slideshow": {
193-
"slide_type": "slide"
194-
}
195-
},
196-
"source": [
197-
"In the original CLIMADA code, the impact function is often referred to as `if` or `if_`. This is easy to confuse with the conditional operator *if*. Hence, in future a transition from\n",
198-
"\n",
199-
"`if` ---------> `impf`\n",
200-
"\n",
201-
"will be performed. Once the change is active, known developers will be notified and this message updated."
202-
]
203-
},
204128
{
205129
"cell_type": "markdown",
206130
"metadata": {},
@@ -221,19 +145,17 @@
221145
"\n",
222146
"As indicated in the software and tutorials, other data might need to be downloaded manually by the user. The following table shows these last data sources, their version used, its current availability and where they are used within CLIMADA:\n",
223147
"\n",
224-
"| Availability | Name | Version | Link | CLIMADA class | CLIMADA version | CLIMADA tutorial reference |\n",
225-
"|--------------|-------------------------------------------------|---------|------|---------------|-----------------|-------------------------------|\n",
226-
"| OK | Fire Information for Resource Management System | |[FIRMS](https://firms.modaps.eosdis.nasa.gov/download/) | BushFire | >V1.2.5 | climada_hazard_BushFire.ipynb |\n",
227-
"| OK | Gridded Population of the World (GPW) | v4.11 |[GPW4.11](https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-rev11) | LitPop | > v1.2.3 | climada_entity_LitPop.ipynb |\n",
228-
"| FAILED | Gridded Population of the World (GPW) | v4.10 |[GPW1.10](https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-rev10) | LitPop | >= v1.2.0 | climada_entity_LitPop.ipynb |\n",
229-
"| | | | | | | |"
148+
"| Name | Version | Link | CLIMADA class | CLIMADA version | CLIMADA tutorial reference |\n",
149+
"|-------------------------------------------------|---------|------|---------------|-----------------|-------------------------------|\n",
150+
"| Fire Information for Resource Management System | |[FIRMS](https://firms.modaps.eosdis.nasa.gov/download/) | BushFire | > v1.2.5 | climada_hazard_BushFire.ipynb |\n",
151+
"| Gridded Population of the World (GPW) | v4.11 |[GPW4.11](https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-count-rev11) | LitPop | > v1.2.3 | climada_entity_LitPop.ipynb |\n"
230152
]
231153
},
232154
{
233155
"cell_type": "markdown",
234156
"metadata": {},
235157
"source": [
236-
"## Side Note on Parameters"
158+
"## Side note on parameters"
237159
]
238160
},
239161
{
@@ -249,7 +171,7 @@
249171
},
250172
{
251173
"cell_type": "code",
252-
"execution_count": 4,
174+
"execution_count": 2,
253175
"metadata": {},
254176
"outputs": [
255177
{
@@ -276,9 +198,17 @@
276198
},
277199
{
278200
"cell_type": "code",
279-
"execution_count": null,
201+
"execution_count": 3,
280202
"metadata": {},
281-
"outputs": [],
203+
"outputs": [
204+
{
205+
"name": "stdout",
206+
"output_type": "stream",
207+
"text": [
208+
"1 2 6\n"
209+
]
210+
}
211+
],
282212
"source": [
283213
"# usually just fine\n",
284214
"def g(x, y, z):\n",
@@ -295,9 +225,9 @@
295225
"### Decrease the number of parameters.\n",
296226
"\n",
297227
"Though CLIMADA's pylint configuration .pylintrc allows 7 arguments for any method or function before it complains, it is advisable to aim for less.\n",
298-
"It is quite likely that a function with so many parameters has an inherent design flaw.\\\n",
228+
"It is quite likely that a function with so many parameters has an inherent design flaw.\n",
299229
"\n",
300-
"There are very well designed command line tools with innumerable optional arguments, e.g., rsync - but these are command line tools. There are also methods like pandas.DataFrame.plot() with countless optional arguments and it makes perfectly sense.\n",
230+
"There are very well designed command line tools with inumerable optional arguments, e.g., rsync - but these are command line tools. There are also methods like `pandas.DataFrame.plot()` with countless optional arguments and it makes perfectly sense.\n",
301231
"\n",
302232
"But within the climada package it probably doesn't.\n",
303233
"divide et impera!\n",
@@ -332,7 +262,7 @@
332262
"def f(a, b, c, d, e, f, g, h):\n",
333263
" print(f'f does many things with a lot of arguments: {a, b, c, d, e, f, g, h}')\n",
334264
" return sum([a, b, c, d, e, f, g, h])\n",
335-
" \n",
265+
"\n",
336266
"f(1, 2, 3, 4, 5, 6, 7, 8)"
337267
]
338268
},
@@ -382,7 +312,7 @@
382312
"metadata": {},
383313
"source": [
384314
"This of course pleads the case on a strictly formal level. No real complexities have been reduced during the making of this example.\\\n",
385-
"Nevertheless there is the benefit of reduced test case requirements. And in real life real complexity _will_ be reduced."
315+
"Nevertheless there is the benefit of reduced test case requirements. And in real life, real complexity _will_ be reduced."
386316
]
387317
}
388318
],
@@ -404,7 +334,7 @@
404334
"name": "python",
405335
"nbconvert_exporter": "python",
406336
"pygments_lexer": "ipython3",
407-
"version": "3.8.12"
337+
"version": "3.9.16"
408338
},
409339
"latex_envs": {
410340
"LaTeX_envs_menu_present": true,

doc/guide/Guide_Configuration.ipynb

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,6 @@
77
"# Constants and Configuration"
88
]
99
},
10-
{
11-
"cell_type": "markdown",
12-
"metadata": {},
13-
"source": [
14-
"## Content\n",
15-
"\n",
16-
"- [Constants](#Constants)\n",
17-
" - [Hard Coded](#Hard-Coded)\n",
18-
" - [Configurable](#Configurable)\n",
19-
" - [Where to put constants?](#Where-to-put-constants?)\n",
20-
"- [Configuration](#Configurable)\n",
21-
" - [Configuration files](#Configuration-files)\n",
22-
" - [Accessing configuration values](#Accessing-configuration-values)\n",
23-
" - [Default Configuration](#Default-Configuration)\n",
24-
" - [Test Configuration](#Test-Configuration)\n"
25-
]
26-
},
2710
{
2811
"cell_type": "markdown",
2912
"metadata": {
@@ -172,10 +155,10 @@
172155
"source": [
173156
"### Configurable\n",
174157
"\n",
175-
"When it comes to absolute paths, it is urgently suggested to not use hard coded constant values, for the obvious reasons. But also relative paths can cause problems. In particular, they may point to a location where the user has not sufficient access permissions. In order to avoid these problems, _all_ paths constants in CLIMADA are supposed to be defined through configuration.\\\n",
158+
"When it comes to absolute paths, it is urgently suggested to not use hard coded constant values, for obvious reasons. But also relative paths can cause problems. In particular, they may point to a location where the user has not sufficient access permissions. In order to avoid these problems, _all_ paths constants in CLIMADA are supposed to be defined through configuration.\\\n",
176159
"<b style='color:darkred;font-size:100%'> &rarr; paths must be configurable </b>\n",
177160
"\n",
178-
"The same applies to urls to external resources, databases or websites. Since they may change at any time, there addresses are supposed to be defined through configuration. Like this it will be possible to access them without the need of tampering with the source code or waiting for a new release.\\\n",
161+
"The same applies to urls to external resources, databases or websites. Since they may change at any time, their addresses are supposed to be defined through configuration. Like this it will be possible to access them without the need of tampering with the source code or waiting for a new release.\\\n",
179162
"<b style='color:darkred;font-size:100%'> &rarr; urls must be configurable </b>\n",
180163
"\n",
181164
"Another category of constants that should go into the configuration file are system specifications, such as number of CPU's available for CLIMADA or memory settings.\\\n",
@@ -188,7 +171,7 @@
188171
"source": [
189172
"### Where to put constants? \n",
190173
"\n",
191-
"As a general rule, constants are defined in the module where they intrinsically belong to. If they belong equally to different modules though or they are meant to be used globally, there is the module `climada.util.constants` which is compiling constants CLIMADA wide."
174+
"As a general rule, constants are defined in the module where they intrinsically belong to. If they belong equally to different modules though or they are meant to be used globally, there is the module `climada.util.constants` which is compiling constants CLIMADA-wide."
192175
]
193176
},
194177
{
@@ -235,7 +218,7 @@
235218
"A configuration file is a JSON file, with the additional restriction, that all keys must be strings without a '.' (dot) character .\\\n",
236219
"The JSON format looks a lot like a Python `dict`. But note, that all strings must be surrounded by double quotes and trailing commas are not allowed anywhere.\n",
237220
"\n",
238-
"For configuration values that belong to a particular module it is suggested to reflect the code repositories file structure in the json object. For example if a configuration for `my_config_value` that belongs to the module `climada.util.dates_times` is wanted, it would be defined as \n",
221+
"For configuration values that belong to a particular module it is suggested to reflect the code repositories file structure in the json object. For example, if a configuration for `my_config_value` that belongs to the module `climada.util.dates_times` is wanted, it would be defined as \n",
239222
"```json\n",
240223
"{\n",
241224
" \"util\": {\n",
@@ -334,7 +317,7 @@
334317
"cell_type": "markdown",
335318
"metadata": {},
336319
"source": [
337-
"The actual configuration values can be accessed as basic types (bool, float, int, str), provided the definition is according to the respective data type:"
320+
"The actual configuration values can be accessed as basic types (bool, float, int, str), provided that the definition is according to the respective data type:"
338321
]
339322
},
340323
{

doc/guide/Guide_Euler.ipynb

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,6 @@
77
"# Using Climada on the Euler Cluster (ETH internal)"
88
]
99
},
10-
{
11-
"cell_type": "markdown",
12-
"metadata": {},
13-
"source": [
14-
"\n",
15-
"## Content\n",
16-
"\n",
17-
"- [Access to Euler](#Access-to-Euler)\n",
18-
"- [Installation and working directories](#Installation-and-working-directories)\n",
19-
"- [Pre-installed version of Climada](#Pre-installed-version-of-Climada)\n",
20-
"- [Working with Git branches](#Working-with-Git-branches)\n",
21-
"- [Fallback: Conda installation](#Fallback:-Conda)\n",
22-
"- [Run a Jupyter Notebook on Euler](#Run-Jupyter-Notebook-on-Euler)\n",
23-
"- [Trouble shooting](#Trouble-shooting)"
24-
]
25-
},
2610
{
2711
"cell_type": "markdown",
2812
"metadata": {},
@@ -156,7 +140,7 @@
156140
"\n",
157141
"### 1. Load dependencies \n",
158142
"\n",
159-
"See [Load dependencies](#1.-Load-dependencies) above."
143+
"See [Load dependencies](#1.-load-dependencies) above."
160144
]
161145
},
162146
{
@@ -224,7 +208,7 @@
224208
"\n",
225209
"### 6. Adjust the Climada configuration\n",
226210
"\n",
227-
"See [Adjust the Climada configuration](#3.-Adjust-the-Climada-configuration) above."
211+
"See [Adjust the Climada configuration](#3.-adjust-the-climada-configuration) above."
228212
]
229213
},
230214
{
@@ -234,7 +218,7 @@
234218
"\n",
235219
"### 7. Run a job\n",
236220
"\n",
237-
"See [Run a job](#4.-Run-a-job) above."
221+
"See [Run a job](#4.-run-a-job) above."
238222
]
239223
},
240224
{
@@ -443,7 +427,7 @@
443427
"\n",
444428
"### Using a virtual environment in a Jupyter notebook\n",
445429
"\n",
446-
"By default the pre-installed climada version is running in your notebooks. If you want to use climada from source you can simply install a python kernel from the `climada_venv` environment, see [Working with Git branches](#Working-with-Git-branches)\n",
430+
"By default the pre-installed climada version is running in your notebooks. If you want to use climada from source you can simply install a python kernel from the `climada_venv` environment, see [Working with Git branches](#working-with-git-branches)\n",
447431
"\n",
448432
"Install an IPyhton-kernel:\n",
449433
"\n",

0 commit comments

Comments
 (0)