def prepare_benchmark(duration: float, ignitions, wind_predicted,
                      wind_observed, observation_passes):
    """ roduce the necessary input arguments for a benchmark:

    current_time, ignition_list, prediction_propagation,
         observation_propagation, observation_passes
    """
    current_time = time_start.timestamp() + duration

    ignition_list = [
        TimedPoint(p["x"], p["y"],
                   time_start.timestamp() + p["time"]) for p in ignitions
    ]

    prediction_propagation = create_wildfire_propagation(
        area_default,
        ignition_list,
        wind_speed=wind_predicted[0],
        wind_direction=wind_predicted[1],
        world=THE_WORLD)
    observation_propagation = create_wildfire_propagation(
        area_default,
        ignition_list,
        wind_speed=wind_observed[0],
        wind_direction=wind_observed[1],
        world=THE_WORLD)

    for op in observation_passes:
        op["time"] += time_start.timestamp()

    return current_time, ignition_list, prediction_propagation, observation_propagation, \
           observation_passes
# 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"""
    fire_env = Environment(area, wind_speed, wind_direction, world)

    fire_prop = FirePropagation(fire_env)
    for ig in ignition:
        fire_prop.set_ignition_point(ig)
    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

fire_env = Environment(((480025.0, 485025.0), (6210000.5, 6215000.5)), 5,
                       1.75 * np.pi, the_world)

# fire_env = Environment(((470010.0, 485010.0), (6210010.0, 6225010.0)), 5, 0, the_world)
# fire_env = Environment(((574995.0, 575005.0), (6199995.0, 6200005.0)), 5, 0, the_world)
fire_prop = FirePropagation(fire_env)
# now = 0
now = datetime.datetime(2020, 1, 1, 0, 0).timestamp()
ignitionpoint1 = TimedPoint(482000, 6212000.0, now)
ignitionpoint2 = TimedPoint(482000 - 250, 6212000.0 + 1800, now)
ignitionpoint3 = TimedPoint(482000 + 2000, 6212000.0 + 2000, now)

fire_prop.set_ignition_point(ignitionpoint1)
fire_prop.set_ignition_point(ignitionpoint2)
fire_prop.set_ignition_point(ignitionpoint3)
# fire_prop.set_ignition_point(TimedPoint(575000.0, 6200000.0, 0))

propagation_end_time = now + 60 * 60 * 4
export_front = (7000, 7100)

fire_prop.propagate(propagation_end_time)

fire_prop.ignitions().write_to_file("demo_propagation_highres_firemap.tif")
Ejemplo n.º 4
0
    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)

    fire_prop.propagate(until=four_hours_from_now)

    ## Figure terrain + ignition contour + ignition point
    gdd = display.GeoDataDisplay.pyplot_figure(
        seganosa_fire_env.raster.combine(fire_prop.ignitions().slice(["ignition"])),
        frame=(0., 0.))
    gdd.draw_elevation_shade(with_colorbar=False, cmap=matplotlib.cm.terrain)
    gdd.draw_wind_quiver()
    gdd.draw_ignition_contour(with_labels=True, cmap=matplotlib.cm.plasma)
    gdd.draw_ignition_points(fire_start)

    # gdd.figure.show()
    gdd.figure.savefig(".".join(("demo_seganosa_propagation", "svg")), dpi=150, bbox_inches='tight')
# 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(2776812.5 + 1000, 2212112.5 + 1000,
                             time_start.timestamp())
area_default = ((ignition_center[0] - 2500, ignition_center[0] + 1500),
                (ignition_center[1] - 1500, ignition_center[1] + 2500))


def draw_connecting_arrows(ax, observed_cell_list,
                           corresponding_cells_in_prediction, **kwargs):
    for s, e in zip(observed_cell_list, corresponding_cells_in_prediction):
        # ax.arrow(e[0], e[1], s[0] - e[0], s[1] - e[1], **kwargs)
        ax.annotate("",
                    xy=(s[0], s[1]),
                    xytext=(e[0], e[1]),
                    arrowprops=dict(arrowstyle="->"),
                    **kwargs)

################################################################################
# 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.SLOW_FUELMODEL_REMAP)
the_world.dem_wind_tile_split = 1

area = ((2776825.0 - 200, 2776825.0 + 200), (2212175.0 - 200, 2212175.0 + 200))
ignition = TimedPoint(2776825.0+25, 2212175.0-75, 0)

################################################################################
# Reference fire propagation
fire_env = Environment(area, 2., 3 * np.pi / 4, the_world)

fire_prop = FirePropagation(fire_env)
fire_prop.set_ignition_point(ignition)

propagation_end_time = 60 * 60 * 60
propagation_end_time = np.inf

fire_prop.propagate(propagation_end_time)

################################################################################
# Reference fire display
Ejemplo n.º 7
0
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

fire_prop.propagate(propagation_end_time)

# Figure terrain + ignition contour + ignition point
gdd = display.GeoDataDisplay.pyplot_figure(fire_env.raster.combine(
    fire_prop.ignitions().slice(["ignition"])),
                                           frame=(0., 0.))
gdd.draw_elevation_shade(with_colorbar=False, cmap=matplotlib.cm.terrain)
Ejemplo n.º 8
0
    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:
        fire_prop.set_ignition_point(ig)

    fire_prop.propagate(until=four_hours_from_now)

    ## Figure terrain + ignition contour + ignition point
    gdd = display.GeoDataDisplay.pyplot_figure(
        seganosa_fire_env.raster.combine(fire_prop.ignitions().slice(["ignition"])),
        frame=(0., 0.))
    gdd.draw_elevation_shade(with_colorbar=False, cmap=matplotlib.cm.terrain)
    gdd.draw_wind_quiver()
    gdd.draw_ignition_contour(with_labels=True, cmap=matplotlib.cm.plasma)
    gdd.draw_ignition_points(fire_starts)