def extent_density(x0, y0, dx, dy, target, flash_id_key='flash_id', weight_key=None): """ This function assumes a regular grid in x and y with spacing dx, dy x0, y0 is the x coordinate of the lower left corner of the lower-left grid cell, i.e., the lower left node of the grid mesh in cartesian space Eliminates duplicate points in gridded space and sends the reduced set of points to the target. """ while True: # assumes x,y,z are in same order as events events, flash, x,y,z = (yield) # print 'Doing extent density', x_i = np.floor( (x-x0)/dx ).astype('int32') y_i = np.floor( (y-y0)/dy ).astype('int32') if len(x_i) > 0: print 'extent with points numbering', len(x_i), ' with weights', weight_key unq_idx = unique_vectors(x_i, y_i, events[flash_id_key]) # if x[unq_idx].shape[0] > 1: if weight_key <> None: weight_lookup = dict(zip(flash[flash_id_key], flash[weight_key])) weights = [weight_lookup[fi] for fi in events[unq_idx]['flash_id']] #puts weights in same order as x[unq_idx], y[unq_idx] del weight_lookup else: weights = None target.send((x[unq_idx], y[unq_idx], weights)) del weights, unq_idx # else: # print '' del events, flash, x, y, z, x_i, y_i
def extent_density(x0, y0, dx, dy, target, flash_id_key='flash_id', weight_key=None): """ This function assumes a regular grid in x and y with spacing dx, dy x0, y0 is the x coordinate of the lower left corner of the lower-left grid cell, i.e., the lower left node of the grid mesh in cartesian space Eliminates duplicate points in gridded space and sends the reduced set of points to the target. """ while True: # assumes x,y,z are in same order as events events, flash, x, y, z = (yield) # print 'Doing extent density', x_i = np.floor((x - x0) / dx).astype('int32') y_i = np.floor((y - y0) / dy).astype('int32') if len(x_i) > 0: print 'extent with points numbering', len( x_i), ' with weights', weight_key unq_idx = unique_vectors(x_i, y_i, events[flash_id_key]) # if x[unq_idx].shape[0] > 1: if weight_key <> None: weight_lookup = dict( zip(flash[flash_id_key], flash[weight_key])) weights = [ weight_lookup[fi] for fi in events[unq_idx]['flash_id'] ] #puts weights in same order as x[unq_idx], y[unq_idx] del weight_lookup else: weights = None target.send((x[unq_idx], y[unq_idx], weights)) del weights, unq_idx # else: # print '' del events, flash, x, y, z, x_i, y_i
def footprint_mean(flash_id_key='flash_id', area_key='area'): """ Takes x, y, z flash locations and gets Extent density unique pixels, average all flashes """ while True: events, flash, x,y,z = (yield) # print 'Doing extent density', x_i = np.floor( (x-x0)/dx ).astype('int32') y_i = np.floor( (y-y0)/dy ).astype('int32') if len(x_i) > 0: footprints = dict(zip(flash[flash_id_key], flash[area_key])) # print 'with points numbering', len(x_i) unq_idx = unique_vectors(x_i, y_i, events['flash_id']) # if x[unq_idx].shape[0] > 1: fl_id = events['flash_id'][unq_idx] areas = [footprints[fi] for fi in fl_id] #puts areas in same order as x[unq_idx], y[unq_idx] # counts normalized by areas target.send((x[unq_idx],y[unq_idx],areas)) del footprints, unq_idx, fl_id, areas # else: # print '' del events, flash, x, y, z, x_i, y_i
def footprint_mean(flash_id_key='flash_id', area_key='area'): """ Takes x, y, z flash locations and gets Extent density unique pixels, average all flashes """ while True: events, flash, x, y, z = (yield) # print 'Doing extent density', x_i = np.floor((x - x0) / dx).astype('int32') y_i = np.floor((y - y0) / dy).astype('int32') if len(x_i) > 0: footprints = dict(zip(flash[flash_id_key], flash[area_key])) # print 'with points numbering', len(x_i) unq_idx = unique_vectors(x_i, y_i, events['flash_id']) # if x[unq_idx].shape[0] > 1: fl_id = events['flash_id'][unq_idx] areas = [footprints[fi] for fi in fl_id ] #puts areas in same order as x[unq_idx], y[unq_idx] # counts normalized by areas target.send((x[unq_idx], y[unq_idx], areas)) del footprints, unq_idx, fl_id, areas # else: # print '' del events, flash, x, y, z, x_i, y_i