def _compute_disp_caused_by_coseismic_slip(self): self.co_slip = vj.EpochalIncrSlip(self.file_slip0)[0] coseismic_disp = [] ep = vj.EpochalG(self.file_G0, self.sites) for nth, epoch in enumerate(self.epochs): G = ep[epoch] d_co = np.dot(G, self.co_slip) coseismic_disp.append(d_co) self.coseismic_disp = np.vstack(coseismic_disp)
import viscojapan as vj f1 = vj.EpochalG('../G_Rake66.h5') G1 = f1[0] f2 = vj.EpochalG('../G_Rake90.h5') G2 = f2[0] f3 = vj.EpochalG('../G_Rake95.h5') G3 = f3[0] fno = 285 bm = vj.MyBasemap(region_code='near') scale = 2e-2 mplt = vj.MapPlotDisplacement(basemap=bm) mplt.plot_disp(G1[:, fno], f1.sites, scale=scale) mplt.plot_disp(G2[:, fno], f2.sites, scale=scale, color='red') mplt.plot_disp(G3[:, fno], f3.sites, scale=scale, color='blue') vj.MapPlotFault('../fault_He50km.h5', basemap=bm).plot_fault(fno) vj.plt.show()
import numpy as np import viscojapan as vj res_file = '../../inversions/inversion10/iter2/run7/outs/nrough_05_naslip_11.h5' fault_file = '../fault_model/fault_bott80km.h5' reader = vj.inv.SlipResultReader(res_file, fault_file) slip = reader.get_3d_cumu_slip() slip = slip[-1].reshape([-1, 1]) ep = vj.EpochalG( '../green_function_large_scale/G0_He51km_VisM7.9E18_Rake83.h5') epochs = ep.get_epochs() G = ep[3650] disp = np.dot(G, slip).reshape([-1, 3]) pos = np.loadtxt('../green_function_large_scale/stations_large_scale.in', '4a, f, f') with open('pred_10yr', 'wt') as fid: for tp, y in zip(pos, disp): lon = tp[1] lat = tp[2] mag = np.sqrt(y[0]**2 + y[1]**2) fid.write('%f %f %f\n' % (lon, lat, mag))
import h5py from numpy import dot from numpy.linalg import norm import viscojapan as vj g = vj.EpochalG('../../../greens_function/G_Rake80.h5') G = g[0] with h5py.File('../outs/ano_10.h5','r') as fid: Bm = fid['Bm'][...] slip = Bm[:-1,:] ##with h5py.File('../../../final_slip/outs/ano_10.h5','r') as fid: ## Bm = fid['Bm'][...] ##slip = Bm d_pred = dot(G,slip) print(d_pred) d_ep = vj.EpochalDisplacement('../../../true_model/d_simu.h5') d_true = d_ep[0] print(d_true) print(norm(d_pred-d_true))
sites = np.loadtxt('../sites', '4a') ##ep = vj.EpochalDisplacement('../../cumu_post_with_seafloor.h5','../sites') ##slip_co = ep[0] ## ## ##mplt = vj.MapPlotDisplacement() ## ##mplt.plot_disp(slip_co,sites) ##plt.show() ep = vj.EpochalSlip('../slip0/incr_slip0.h5') slip_co = ep[0] ##mplt = vj.MapPlotFault('../fault_model/fault_bott50km.h5') ##mplt.plot_slip(slip_co) ep_obs = vj.EpochalDisplacement('../../cumu_post_with_seafloor.h5', '../sites') f_G = '../green_function/G_He50km_Vis5.8E18_Rake90.h5' ep_co_disp = vj.EpochalG(f_G, filter_sites=sites) for epoch in epochs: G = ep_co_disp[epoch] disp = np.dot(G, slip_co) disp_obs = ep_obs[epoch] mplt = vj.MapPlotDisplacement() mplt.plot_disp(disp_obs, sites, color='red') mplt.plot_disp(disp, sites) plt.title('%d' % epoch) plt.show()