Skip to content

Commit e95741f

Browse files
committed
centroid assign section
1 parent a9a3e33 commit e95741f

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

doc/user-guide/climada_engine_Impact.ipynb

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,11 +841,51 @@
841841
"source": [
842842
"We are finally ready for the impact computation. This is the simplest step. Just give the exposure, impact function and hazard to the ImpactCalc.impact() method.\n",
843843
"\n",
844-
"Note: we did not specifically assign centroids to the exposures. Hence, the default is used - each exposure is associated with the closest centroids. Since we defined the centroids from the exposures, this is a one-to-one mapping.\n",
845-
"\n",
846844
"Note: we did not define an `Entity` in this impact calculations. Recall that `Entity` is a container class for __[Exposures](climada_entity_Exposures.ipynb)__, __[Impact Functions](climada_entity_ImpactFuncSet.ipynb)__, __[Discount Rates](climada_entity_DiscRates.ipynb)__ and __[Measures](climada_entity_MeasureSet.ipynb)__. Since we had only one Exposure and one Impact Function, the container would not have added any value, but for more complex projects, the Entity class is very useful."
847845
]
848846
},
847+
{
848+
"cell_type": "markdown",
849+
"metadata": {},
850+
"source": [
851+
"#### Assigning centroids manually"
852+
]
853+
},
854+
{
855+
"cell_type": "markdown",
856+
"metadata": {},
857+
"source": [
858+
"It is best to create centroids from exposures directly as we have done above, to ensure `Hazard` and `Exposure` are matching well. However, sometimes you may have pre-defined `Hazard` and `Exposure` data. In those cases, it can make sense to manually match `Centroids` and `Exposure`.\n",
859+
"\n",
860+
"The matching could then look like this:\n",
861+
"```\n",
862+
"exp_lp.assign_centroids(tc, distance=\"euclidean\", threshold=0.1) # assign centroids manually\n",
863+
"```\n",
864+
"The `threshold` argument defines the maximum distance of the nearest neighbor in the units of the `Exposure` crs.\n",
865+
"\n",
866+
"When assingning `Centroids` manually, make sure to pass `assign_centroids=False` to the impact calculation, so that the assignment is not lost:\n",
867+
"```\n",
868+
"imp = ImpactCalc(exp_lp, impf_set, tc).impact(\n",
869+
" save_mat=False,\n",
870+
" assign_centroids=False, # false, since we assign centroids manually\n",
871+
") \n",
872+
"```"
873+
]
874+
},
875+
{
876+
"cell_type": "markdown",
877+
"metadata": {},
878+
"source": [
879+
"#### Assigning centroids automatically"
880+
]
881+
},
882+
{
883+
"cell_type": "markdown",
884+
"metadata": {},
885+
"source": [
886+
"If we do not specifically assign centroids to the exposures. Hence, the default (i.e. assign_centroids=True) is used - each exposure is associated with the closest centroids. Since we defined the centroids from the exposures above, this is a one-to-one mapping."
887+
]
888+
},
849889
{
850890
"cell_type": "code",
851891
"execution_count": 10,

0 commit comments

Comments
 (0)