def fig_observation_contour(base_propagation: FirePropagation, cells: ty.Mapping[ty.Tuple[int, int], float], cmap="Greens_r", binary=True, gdd=None) -> display.GeoDataDisplay: gd = GeoData.full_like(base_propagation.prop_data, np.inf) for cell, time in cells.items(): gd.data["ignition"][cell] = time if not binary else 1.0 if not gdd: gdd = display.GeoDataDisplay.pyplot_figure(gd, frame=(0., 0.)) gdd.draw_ignition_shade(cmap=cmap, geodata=gd) return gdd
# output_format="pdf" area = ((481000.0, 484000.0), (6211000.0, 6213500.0)) expected_env = propagation.Environment(area, wind_speed=5., wind_dir=0.) now = datetime.datetime.now().timestamp() ignition_point = TimedPoint(area[0][0] + 1000.0, area[1][0] + 1000.0, now) expected_fire = propagation.propagate_from_points( expected_env, ignition_point, now + datetime.timedelta(hours=2).total_seconds()) env = propagation.Environment(area, wind_speed=6., wind_dir=0.) fire = propagation.propagate_from_points( env, ignition_point, now + datetime.timedelta(hours=2).total_seconds()) # Create fire perimeter geodata fire_perimeter = GeoData.full_like(fire.prop_data.slice("ignition"), np.nan) # Create contour with scikit-image contours = skimage.measure.find_contours(fire.prop_data.data["ignition"], now + datetime.timedelta(hours=1).total_seconds()) # Draw contour in the geodata for contour in contours: for pt_i in range(len(contour)): if pt_i < len(contour) / 3: continue rr, cc = skimage.draw.line(*np.asarray(contour[pt_i - 1], dtype=int), *np.asarray(contour[pt_i], dtype=int)) fire_perimeter.data[rr, cc] = fire.prop_data.data["ignition"][rr, cc] contours = skimage.measure.find_contours(fire.prop_data.data["ignition"], now + datetime.timedelta(minutes=30).total_seconds()) # Draw contour in the geodata