GFDRR / CCDR-tools

Geoanalytics for climate and disaster risk screening
https://gfdrr.github.io/CCDR-tools/
12 stars 8 forks source link

Impact function used in classification? #5

Closed matamadio closed 2 years ago

matamadio commented 2 years ago

So I tried to create new notebook for heat stress. It requires classification only, with multiple RPs. So I stripped down the code of ifs related to function, including the lines that specify impact_array.

        if exp_cat_dd.value == 'pop':
            impact_array = mortality_factor(fld_array)
        elif exp_cat_dd.value == 'builtup':
            impact_array = damage_factor_builtup(fld_array)
        elif exp_cat_dd.value == 'agri':
            impact_array = damage_factor_agri(fld_array)

But these are required to build the impac_rst, which seems to be used in both procedures??

        # Create raster from array
        impact_rst = xr.DataArray(np.array([impact_array]).astype(np.float32), 
                                  coords=hazard_data.coords, 
                                  dims=hazard_data.dims)

        if save_inter_rst_chk.value:
            impact_rst.rio.to_raster(os.path.join(OUTPUT_DIR, f"{country}_LS_{rp}_{exp_cat}_hazard_imp_factor.tif"))

Please clarify, am I messing things? impact_array should not be part of the classification approach! I checked the results for classification and I'm pretty sure they are correct - no function used. But then why the script doesn't work if function is not specified? :(

The expected notebook for this has: