|
841 | 841 | "source": [ |
842 | 842 | "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", |
843 | 843 | "\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", |
846 | 844 | "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." |
847 | 845 | ] |
848 | 846 | }, |
| 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 | + }, |
849 | 889 | { |
850 | 890 | "cell_type": "code", |
851 | 891 | "execution_count": 10, |
|
0 commit comments