def event_pipeline_setup(self): """ Create target grids and set up the event accumulation pipeline for events that have been pre-aggregated using an event lookup table. Arguments: none Returns: outgrids -- tuple of grids (numpy arrays) for the target grids framer -- first stage of the pipeline that routes flashes to the correct time window for accumulation. """ (event_grid_area_fraction_key, energy_grids, n_frames, xedge, yedge, zedge, dx, dy, dz, x0, y0, z0, mapProj, geoProj) = ( self.gridspec_locals()) grid_shape = (xedge.shape[0]-1, yedge.shape[0]-1, n_frames) event_density_grid = np.zeros(grid_shape, dtype='float32') total_energy_grid = np.zeros(grid_shape, dtype='float32') all_frames = [] for i in range(n_frames): accum_event_density = accumulate_energy_on_grid( event_density_grid[:,:,i], xedge, yedge, label='event extent', grid_frac_weights=False) event_density_target = point_density(accum_event_density, weight_key='lutevent_count', weight_flashes=False) # total_energy is built from split_event_energy, which has # already divided up the event energy into the sub-event # corresponding to each pixel. We don't need to weight by the # grid fractional area. We just need to sum the 'power' variable # which mimic_lma assigns the values of split_event_energy. accum_total_energy = accumulate_energy_on_grid( total_energy_grid[:,:,i], xedge, yedge, label='total energy', grid_frac_weights=False) total_energy_target = point_density(accum_total_energy, weight_key='power', weight_flashes=False) broadcast_targets = ( project('lon', 'lat', 'alt', mapProj, geoProj, event_density_target, use_flashes=False), project('lon', 'lat', 'alt', mapProj, geoProj, total_energy_target, use_flashes=False), ) spew_to_density_types = broadcast( broadcast_targets ) all_frames.append(spew_to_density_types) frame_count_log = flash_count_log(self.flash_count_logfile) framer = flashes_to_frames(self.t_edges_seconds, all_frames, time_key='time', time_edges_datetime=self.t_edges, flash_counter=frame_count_log, do_events='time') outgrids = (event_density_grid, total_energy_grid) return outgrids, framer
def group_pipeline_setup(self): """ Create target grids and set up the flash accumulation pipeline. Also used to set up an equivalent group accumulation pipeline. Actually uses event-level data that have been pre-aggregated using an event lookup table. Arguments: none Returns: outgrids -- tuple of grids (numpy arrays) for the target grids framer -- first stage of the pipeline that routes flashes to the correct time window for accumulation. """ (event_grid_area_fraction_key, energy_grids, n_frames, xedge, yedge, zedge, dx, dy, dz, x0, y0, z0, mapProj, geoProj) = ( self.gridspec_locals()) grid_shape = (xedge.shape[0]-1, yedge.shape[0]-1, n_frames) init_density_grid = np.zeros(grid_shape, dtype='float32') extent_density_grid = np.zeros(grid_shape, dtype='float32') footprint_grid = np.zeros(grid_shape, dtype='float32') all_frames = [] for i in range(n_frames): # accum_total_energy = accumulate_energy_on_grid( # total_energy_grid[:,:,i], xedge, yedge, # label='total_energy', grid_frac_weights=False) # total_energy_target = point_density(accum_total_energy, # weight_key='power', weight_flashes=False) # accum_init_density = accumulate_points_on_grid( init_density_grid[:,:,i], xedge, yedge, label='init') accum_extent_density = accumulate_energy_on_grid( extent_density_grid[:,:,i], xedge, yedge, label='group extent', grid_frac_weights=False) accum_footprint = accumulate_energy_on_grid( footprint_grid[:,:,i], xedge, yedge, label='group area', grid_frac_weights=False) init_density_target = point_density(accum_init_density) extent_density_target = point_density(accum_extent_density, weight_key='lutevent_group_count', weight_flashes=False) mean_footprint_target = point_density(accum_footprint, weight_key='lutevent_total_group_area', weight_flashes=False) broadcast_targets = ( project('init_lon', 'init_lat', 'init_alt', mapProj, geoProj, init_density_target, use_flashes=True), project('lon', 'lat', 'alt', mapProj, geoProj, extent_density_target, use_flashes=False), project('lon', 'lat', 'alt', mapProj, geoProj, mean_footprint_target, use_flashes=False), ) spew_to_density_types = broadcast( broadcast_targets ) all_frames.append(spew_to_density_types) frame_count_log = flash_count_log(self.flash_count_logfile) framer = flashes_to_frames(self.t_edges_seconds, all_frames, time_key='start', time_edges_datetime=self.t_edges, flash_counter=frame_count_log, do_events='time') outgrids = (init_density_grid, extent_density_grid, footprint_grid, ) return outgrids, framer