'Events': '-', 'n_avg': '-', 'Time': [event.time for event in events], 'Distance': ['-'] * len(events), 'x': [event.x for event in events], 'y': [event.y for event in events], 'Generation': [0] * len(events), 'Distance_from_origin': [event.distance_from_origin for event in events] }) cols = [ 'n_avg', 'Events', 'Magnitude', 'Generation', 'x', 'y', 'Distance', 'Time', 'Distance_from_origin' ] catalog = catalog.reindex(columns=cols) r0 = np.array([ np.mean([event.x for event in events]), np.mean([event.y for event in events]) ]) #np.array([3557.418383, -324.384367]) catalog['x'] = r0[0] - catalog.x # shift so that main shock position is (0,0) catalog['y'] = r0[1] - 50 - catalog.y catalog['Distance_from_origin'] = (catalog.x**2 + catalog.y**2)**0.5 #for i in range(1000,3886): eq.plot_catalog( catalog, 1, np.array([0, 0]), color='Density' ) #, savepath = 'fentonprog_frames/{}.png'.format(i), saveplot = True) print((datetime.now() - start).total_seconds())
catalog = catalog.reindex(columns=cols) r0 = np.array([ np.mean([event.x for event in events]), np.mean([event.y for event in events]) ]) #np.array([3557.418383, -324.384367]) catalog['x'] = r0[0] - catalog.x # shift so that main shock position is (0,0) catalog['y'] = r0[1] - catalog.y catalog['Distance_from_origin'] = (catalog.x**2 + catalog.y**2)**0.5 catalog = catalog.dropna() # reduce events to a random sample of k elements #catalog = catalog.sample(frac=0.45, replace=False) #============================================================================== eq.plot_catalog(catalog, 1, np.array([0, 0]), color='Generation') N = len(catalog) k = 20 # int(N**0.5) r, densities = eq.plot_ED(catalog, k=k, plot=False) # get distance, density df_dens = pd.DataFrame({'distance': r, 'density': densities}) #df_dens = df_dens[(df_dens.distance > 10**1.2) & (df_dens.distance < 10**2.6)] r = df_dens.distance densities = df_dens.density #* np.exp() #rho0 = np.mean(densities[0:100]) #rmax = (r.max()) #rmin = (r.min()) #n_edges = 30 ##bin_edges = np.linspace(np.log10(rmin), np.log10(rmax), n_edges) #np.array([r[i] for i in range(0, len(r), q)])
data_raw = pd.read_csv('habanero_data.csv') data = data_raw.drop(['z','elapsed time (s)'], axis = 1) data = data.rename(index = str, columns = {'elapsed time (s) corrected': 'Time'}) nrows = data.shape[0] data['n_avg'] = pd.Series(['-'] * nrows, index = data.index) data['Events'] = pd.Series(['-'] * nrows, index = data.index) data['Magnitude'] = pd.Series([2] * nrows, index = data.index) data['Generation'] = pd.Series([0] * nrows, index = data.index) data['Distance'] = pd.Series(['-'] * nrows, index = data.index) cols = ['n_avg','Events','Magnitude','Generation','x','y','Distance','Time','Distance_from_origin'] data = data.reindex(columns = cols) start = datetime.now() # plot data #x0 = 475513.1 #y0 = 6922782.2 x0 = np.mean(data.x) y0 = np.mean(data.y) data['x'] = x0 - data.x # shift so that main shock position is (0,0) data['y'] = y0 - data.y data['Distance_from_origin'] = (data.x**2 + data.y**2)**0.5 data = data[data.Distance_from_origin < 10**3.2] for i in range(322,4001): eq.plot_catalog(data[:i], 1, np.array([0,0]), color = 'Generation', savepath = 'habanero_frames/{}.png'.format(i), saveplot = True) print(datetime.now() - start)
# format events in the pd dataframe format defined by generate_catalog etc. catalog0 = pd.DataFrame({'Magnitude': [event.magnitude for event in events_all], 'Time':[event.time for event in events_all], 'x':[event.x for event in events_all], 'y':[event.y for event in events_all], 'Generation':[0] * len(events_all), 'Distance_from_origin': [event.distance_from_origin for event in events_all], 'Date':[datetime(int(event.split()[0]),int(event.split()[2]),int(event.split()[3]),hour=int(event.split()[4]),minute=int(event.split()[5]),second=int(float(event.split()[6]))) for event in flines]}) cols = ['Magnitude','Generation','x','y','Time','Distance_from_origin','Date'] catalog0 = catalog0.reindex(columns = cols) catalog0 = catalog0[metrics.loc[fname].range] # get events from time period of interest #catalog0 = catalog0[0:2000] catalog0.Time = catalog0.Time - catalog0.Time.min() + metrics.loc[fname].T_adjust # shift time so that first event occurs however long after injection began N = len(catalog0) #k = 6 eq.plot_catalog(catalog0, 1, np.array([0,0]), color = 'Generation', saveplot = False, savepath = fname.split(sep='.')[0]+'_positions.png') nsplit = 3 amount = np.ceil(np.linspace(N/nsplit, N, nsplit)) r_all = [] dens_all = [] t = [] T = metrics.loc[fname].T_inj for i, n in enumerate(amount): catalog = catalog0.copy() catalog = catalog[:int(n)] # only get first injection round k = int(np.ceil(len(catalog)**0.5)) # print(len(catalog)) assert len(catalog) > k, "Number of nearest neighbours exceed catalog size" r, densities = eq.plot_ED(catalog, k = k, plot = False) # get distance, density