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 flash_pipeline_setup(self): """ Create target grids and set up the flash accumulation pipeline. Also used to set up an equivalent group accumulation pipeline. 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') # flashsize_std_grid = np.zeros(grid_shape, dtype='float32') all_frames = [] for i in range(n_frames): accum_init_density = accumulate_points_on_grid( init_density_grid[:, :, i], xedge, yedge, label='init') accum_extent_density = accumulate_points_on_grid( extent_density_grid[:, :, i], xedge, yedge, label='extent', grid_frac_weights=True) accum_footprint = accumulate_points_on_grid(footprint_grid[:, :, i], xedge, yedge, label='footprint', grid_frac_weights=True) # accum_flashstd = accumulate_points_on_grid_sdev( # flashsize_std_grid[:,:,i], footprint_grid[:,:,i], xedge, yedge, # label='flashsize_std', grid_frac_weights=True) init_density_target = point_density(accum_init_density) extent_density_target = extent_density( x0, y0, dx, dy, accum_extent_density, event_grid_area_fraction_key=event_grid_area_fraction_key) mean_footprint_target = extent_density( x0, y0, dx, dy, accum_footprint, weight_key='area', event_grid_area_fraction_key=event_grid_area_fraction_key) # std_flashsize_target = extent_density(x0, y0, dx, dy, # accum_flashstd, weight_key='area', # event_grid_area_fraction_key=event_grid_area_fraction_key) 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), # project('lon', 'lat', 'alt', mapProj, geoProj, # std_flashsize_target, use_flashes=False), ) spew_to_density_types = broadcast(broadcast_targets) all_frames.append( extract_events_for_flashes(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) outgrids = ( init_density_grid, extent_density_grid, footprint_grid, # flashsize_std_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_init_density = accumulate_points_on_grid( init_density_grid[:, :, i], xedge, yedge, label='init') accum_extent_density = accumulate_var_on_grid_direct_idx( extent_density_grid[:, :, i], 'lutevent_group_count', 'mesh_xi', 'mesh_yi') accum_footprint = accumulate_var_on_grid_direct_idx( footprint_grid[:, :, i], 'lutevent_total_group_area', 'mesh_xi', 'mesh_yi') init_density_target = point_density(accum_init_density) broadcast_targets = ( no_projection('ctr_x', 'ctr_y', 'ctr_z', init_density_target, use_flashes=True), select_dataset(accum_extent_density, use_event_data=True), select_dataset(accum_footprint, use_event_data=True), ) 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