def plot_r_tau_density(filename, aTau, aR, dPar, majorEQ): a_Tbin = np.arange(dPar['Tmin'], dPar['Tmax'] + 2 * dPar['binx'], dPar['binx']) a_Rbin = np.arange(dPar['Rmin'], dPar['Rmax'] + 2 * dPar['biny'], dPar['biny']) XX, YY, ZZ = density_2D(aTau, aR, a_Tbin, a_Rbin, sigma=dPar['sigma']) plt.figure(1, figsize=(8, 10)) ax = plt.subplot(111) normZZ = ZZ * (dPar['binx'] * dPar['biny'] * len(aTau)) plot1 = ax.pcolormesh(XX, YY, normZZ, cmap=dPar['cmap']) cbar = plt.colorbar( plot1, orientation='horizontal', shrink=.5, aspect=20, ) # plot eta_0 to divide clustered and background mode ax.plot([dPar['Tmin'], dPar['Tmax']], -np.array([dPar['Tmin'], dPar['Tmax']]) + dPar['eta_0'], '-', lw=1.5, color='w') ax.plot([dPar['Tmin'], dPar['Tmax']], -np.array([dPar['Tmin'], dPar['Tmax']]) + dPar['eta_0'], '--', lw=1.5, color='.5') cbar.set_label('Number of Event Pairs', labelpad=-40) ax.set_xlabel('Rescaled Time') ax.set_ylabel('Rescaled Distance') ax.set_title("Year:%d Mag:%.1f/nNearest Neighbor Pairs in R-T" % (majorEQ.data['Time'], majorEQ.data['Mag'])) plt.savefig(filename, dpi=500) plt.clf()
'D': dPar['D'], 'Mc': f_Mc }, correct_co_located=True) RT_file = 'data/df1.8/%s_RT_Mc_%.1f.mat' % (file_in.split('.')[0], f_Mc) scipy.io.savemat(RT_file, {'R': a_R, 'T': a_T}, do_compression=True) #==================================4============================================================== # T-R density plots #================================================================================================= a_Tbin = np.arange(dPar['Tmin'], dPar['Tmax'] + 2 * dPar['binx'], dPar['binx']) a_Rbin = np.arange(dPar['Rmin'], dPar['Rmax'] + 2 * dPar['biny'], dPar['biny']) XX, YY, ZZ = data_utils.density_2D(np.log10(a_T), np.log10(a_R), a_Tbin, a_Rbin, sigma=dPar['sigma']) plt.figure(1, figsize=(8, 10)) ax = plt.subplot(111) ax.set_title('Nearest Neighbor Pairs in R-T') #------------------------------------------------------------------------------ normZZ = ZZ * (dPar['binx'] * dPar['biny'] * eqCatMc.size()) plot1 = ax.pcolormesh(XX, YY, normZZ, cmap=dPar['cmap']) cbar = plt.colorbar( plot1, orientation='horizontal', shrink=.5, aspect=20, )
#================================================================================================= catChild = EqCat() catParent= EqCat() catChild.copy( ranCat) catParent.copy( ranCat) catChild.selEventsFromID( dNND['aEqID_c'], repeats = True) catParent.selEventsFromID( dNND['aEqID_p'], repeats = True) print( catChild.size(), catParent.size(), eqCatMc.size()) a_R, a_T = clustering.rescaled_t_r( catChild, catParent, dConst, correct_co_located = True) a_Tbin = np.arange( dPar['Tmin'], dPar['Tmax']+2*dPar['binx'], dPar['binx']) a_Rbin = np.arange( dPar['Rmin'], dPar['Rmax']+2*dPar['biny'], dPar['biny']) a_log_T = np.log10( a_T) a_log_R = np.log10( a_R) XX, YY, ZZ = data_utils.density_2D( a_log_T, a_log_R, a_Tbin, a_Rbin, sigma = dPar['sigma']) plt.figure(2, figsize= (8,10)) ax = plt.subplot(111) ax.set_title( 'Nearest Neighbor Pairs in R-T') #------------------------------------------------------------------------------ normZZ = ZZ*( dPar['binx']*dPar['biny']*eqCatMc.size()) plot1 = ax.pcolormesh( XX, YY, normZZ, cmap=dPar['cmap']) cbar = plt.colorbar(plot1, orientation = 'horizontal', shrink = .5, aspect = 20,) #ax.plot( np.log10( a_T), np.log10( a_R), 'wo', ms = 1.5, alpha = .2) # plot eta_0 to divide clustered and background mode ax.plot( [dPar['Tmin'], dPar['Tmax']], -np.array([dPar['Tmin'], dPar['Tmax']])+a_Eta_0[i_Bs], '-', lw = 1.5, color = 'w' ) ax.plot( [dPar['Tmin'], dPar['Tmax']], -np.array([dPar['Tmin'], dPar['Tmax']])+a_Eta_0[i_Bs],'--', lw = 1.5, color = '.5' ) #-----------------------labels and legends------------------------------------------------------- #cbar.set_label( 'Event Pair Density [#ev./dRdT]') cbar.set_label( 'Number of Event Pairs',labelpad=-40)