prevs = chain([None], prevs) nexts = chain(islice(nexts, 1, None), [None]) return zip(prevs, items, nexts) ################################################################################ # World initialization FIRERS_DATA_FOLDER = os.environ["FIRERS_DATA"] FIRERS_DEM_DATA = os.path.join(FIRERS_DATA_FOLDER, 'dem') FIRERS_WIND_DATA = os.path.join(FIRERS_DATA_FOLDER, 'wind') FIRERS_LANDCOVER_DATA = os.path.join(FIRERS_DATA_FOLDER, 'landcover') THE_WORLD = g_environment.World( elevation_path=FIRERS_DEM_DATA, wind_path=FIRERS_WIND_DATA, landcover_path=FIRERS_LANDCOVER_DATA, wind_mesh_resolution='fine', landcover_to_fuel_remap=g_environment.EVERYTHING_FUELMODEL_REMAP) THE_WORLD.dem_wind_tile_split = 1 time_start = datetime.datetime(2020, 1, 1, 0, 0, 0, 0) ignition_center = TimedPoint(2776825.0, 2212175.0, time_start.timestamp()) area_default = ((ignition_center[0] - 2500, ignition_center[0] + 1500), (ignition_center[1] - 1500, ignition_center[1] + 2500)) def create_wildfire_propagation(area, ignition: ty.Sequence[TimedPoint], wind_speed=1., wind_direction=3 * np.pi / 4, world=THE_WORLD) -> FirePropagation: """Reference wildfire propagation"""
env, (ignition_point[0], ignition_point[1], 0), until=120 * 60) return f_propagation.ignitions() area = ((478500.0, 483500.0), (6210000.0, 6215000.0)) ignition_point = (area[0][0] + 2500.0, area[1][0] + 2100.0) area_wind = (10., np.pi / 4) ignition_times = None if not os.path.exists('/tmp/ignition.tif'): ignition_times = burn(area, ignition_point, area_wind) ignition_times.write_to_file('/tmp/ignition.tif') else: ignition_times = fire_rs.geodata.geo_data.GeoData.load_from_file( '/tmp/ignition.tif') world = environment.World() some_area = world.get_elevation(area) # Generate grid for plotting x = np.linspace(0, Lx, Nx) y = np.linspace(0, Ly, Ny) x, y = np.meshgrid(x, y) fig = plt.figure() ax = plt.axes(xlim=(0, Lx), ylim=(0, Ly)) plt.xlabel(r'x') plt.ylabel(r'y') z = ignition_times.data_display['ignition'] / 60 print(z)
import matplotlib.cm import fire_rs.geodata.environment as g_environment import fire_rs.geodata.display as display from fire_rs.geodata.geo_data import GeoData from fire_rs.firemodel.propagation import Environment, FirePropagation, TimedPoint FIRERS_DATA_FOLDER = '/home/rbailonr/firers_data_porto' FIRERS_DEM_DATA = os.path.join(FIRERS_DATA_FOLDER, 'dem') FIRERS_WIND_DATA = os.path.join(FIRERS_DATA_FOLDER, 'wind') FIRERS_LANDCOVER_DATA = os.path.join(FIRERS_DATA_FOLDER, 'landcover') the_world = g_environment.World( elevation_path=FIRERS_DEM_DATA, wind_path=FIRERS_WIND_DATA, landcover_path=FIRERS_LANDCOVER_DATA, wind_mesh_resolution='fine', landcover_to_fuel_remap=g_environment.CONSTANT_FUELMODEL_REMAP) the_world.dem_wind_tile_split = 1 area = ((2776825.0 - 1500, 2776825.0 + 1500), (2212175.0 - 500, 2212175.0 + 500)) ignition = TimedPoint(2776825.0, 2212175.0, 0) fire_env = Environment(area, 0., 0, the_world) fire_prop = FirePropagation(fire_env) fire_prop.set_ignition_point(ignition) propagation_end_time = 20 * 60 * 60
plot_plan_trajectories(sr.plan(plan), geodatadisplay, layers=output_options_plot["foreground"], time_range=time_range) if __name__ == "__main__": # WOLRD SETTINGS FIRERS_DATA_FOLDER = os.environ['FIRERS_DATA'] FIRERS_DEM_DATA = os.path.join(FIRERS_DATA_FOLDER, 'dem') FIRERS_WIND_DATA = os.path.join(FIRERS_DATA_FOLDER, 'wind') FIRERS_LANDCOVER_DATA = os.path.join(FIRERS_DATA_FOLDER, 'landcover') the_world = g_environment.World(elevation_path=FIRERS_DEM_DATA, wind_path=FIRERS_WIND_DATA, landcover_path=FIRERS_LANDCOVER_DATA) seganosa_fire_env = Environment([[2799134.0, 2805134.0], [2296388.0, 2302388.0]], 3, 0, the_world) # 6km by 6km around seganosa. Wind: 3m/s W->E # FIRE PROPAGATION ## Fire started 6 hours ago. Predict until 2 hours in the future fire_prop = FirePropagation(seganosa_fire_env) four_hours_ago = (datetime.datetime.now() - datetime.timedelta(hours=6)).timestamp() now = datetime.datetime.now().timestamp() four_hours_from_now = (datetime.datetime.now() + datetime.timedelta(hours=2)).timestamp() fire_start = TimedPoint(2802134.0 - 1500.0, 2299388.0, four_hours_ago) fire_prop.set_ignition_point(fire_start)
plot_plan_trajectories(sr.plan(plan), geodatadisplay, layers=output_options_plot["foreground"], time_range=time_range) if __name__ == "__main__": # WOLRD SETTINGS FIRERS_DATA_FOLDER = os.environ['FIRERS_DATA'] FIRERS_DEM_DATA = os.path.join(FIRERS_DATA_FOLDER, 'dem') FIRERS_WIND_DATA = os.path.join(FIRERS_DATA_FOLDER, 'wind') FIRERS_LANDCOVER_DATA = os.path.join(FIRERS_DATA_FOLDER, 'landcover') the_world = g_environment.World(elevation_path=FIRERS_DEM_DATA, wind_path=FIRERS_WIND_DATA, landcover_path=FIRERS_LANDCOVER_DATA, landcover_to_fuel_remap=g_environment.EVERYTHING_FUELMODEL_REMAP) seganosa_fire_env = Environment([[2799134.0, 2805134.0], [2296388.0, 2302388.0]], 3, 0, the_world) # 6km by 6km around seganosa. Wind: 3m/s W->E # FIRE PROPAGATION ## Fire started 6 hours ago. Predict until 2 hours in the future fire_prop = FirePropagation(seganosa_fire_env) four_hours_ago = (datetime.datetime.now() - datetime.timedelta(hours=6)).timestamp() now = datetime.datetime.now().timestamp() four_hours_from_now = (datetime.datetime.now() + datetime.timedelta(hours=2)).timestamp() fire_starts = [TimedPoint(2802134.0 - 1500.0, 2299388.0 + 1500.0, four_hours_ago), TimedPoint(2802134.0 - 1500.0, 2299388.0 - 1500.0, four_hours_ago)] for ig in fire_starts: