def make_utility_map(firemap: GeoData, flight_window: TimeWindow = TimeWindow(-np.inf, np.inf), layer="ignition", output_layer="utility") -> GeoData: """Compute a utility map from a wildfire map""" gradient = rate_of_spread_map(firemap, layer=layer, output_layer="ros") grad_array = gradient["ros"] grad_array[grad_array >= np.inf] = np.NaN utility = 1 - (grad_array - np.nanmin(grad_array)) / ( np.nanmax(grad_array) - np.nanmin(grad_array)) utility[np.isnan(utility)] = 0. utility[(firemap[layer] < flight_window.start) | (firemap[layer] > flight_window.end)] = 0. return firemap.clone(data_array=utility, dtype=[(output_layer, 'float64')])
def empty_firemap(base_raster: GeoData, layer: str = "ignition") -> GeoData: """Create an empty fire map from a base raster""" return base_raster.clone(fill_value=np.inf, dtype=[(layer, 'float64')])
def make_flat_utility_map(firemap: GeoData, flight_window: TimeWindow = TimeWindow(-np.inf, np.inf), layer="ignition", output_layer="utility") -> GeoData: """Create a constant utility map""" utility = firemap.clone(fill_value=1., dtype=[(output_layer, 'float64')]) utility[output_layer][(firemap[layer] < flight_window.start) | (firemap[layer] > flight_window.end)] = 0. return utility