def plot_slip(self, slip, fn): mplt = MapPlotFault( '/home/zy/workspace/viscojapan/inversions/static_inversion/coseismic_inversion_wider/fault_model/fault_He50km_east.h5' ) mplt.plot_slip(slip) plt.savefig(join(self.outs_dir, fn)) plt.close()
def test_dip(self): dips = self.read_pars('dip') MapPlotFault(fault_file=self.original_fault_file).plot_slip( dips.reshape([-1, 1])) plt.title('dip') plt.savefig(join(self.outs_dir, 'dip.png')) plt.close()
def plot_file(file): name = basename(file) fname = 'plots/%s.pdf' % name #fname = 'plots/%s.png'%name if exists(fname): print('Skip %s!' % fname) return print(fname) with h5py.File(file, 'r') as fid: slip = nres = fid['Bm'][...] mplt = MapPlotSlab() mplt.plot_top() mplt = MapPlotFault(fault_file) mplt.plot_slip(slip) mplt = vj.MapPlotDisplacement() mplt.plot_sites_seafloor(sites_seafloor=sites_seafloor) mo, mw = vj.MomentCalculator(fault_file, earth_file).moment(slip) plt.title('Mo=%g, Mw=%.2f' % (mo, mw)) #plt.show() plt.savefig(fname) plt.close()
def plot_file(file): name = basename(file) fname = 'plots/%s.png' % name if exists(fname): print('Skip %s!' % fname) return print(fname) with h5py.File(file, 'r') as fid: slip = nres = fid['Bm'][...] mplt = MapPlotSlab() mplt.plot_top() mplt = MapPlotFault('../fault_bott40km.h5') mplt.plot_slip(slip) mplt = vj.MapPlotDisplacement() mplt.plot_sites_seafloor(sites_seafloor=sites_seafloor) #plt.show() plt.savefig(fname) plt.close()
def test(): gaussian_slip = GaussianSlip() gaussian_slip.num_subflts_in_dip = 10 gaussian_slip.num_subflts_in_strike = 25 gaussian_slip.mu_dip = 4. gaussian_slip.mu_stk = 12. gaussian_slip.sig_dip = 2 gaussian_slip.sig_stk = 5 # temporal part gaussian_slip.max_slip0 = 10. gaussian_slip.log_mag = 1. gaussian_slip.tau = 5. t = 1100 z = gaussian_slip(t) MapPlotFault( '/home/zy/workspace/viscojapan/fault_model/fault_model2/fault.h5' ).plot_slip(z) clim([0, gaussian_slip.max_slip(t)]) savefig(join(this_script_dir, 'gaussian_slip.pdf')) close()
import h5py from viscojapan.plots import MapPlotFault, plt import viscojapan as vj fault_file = '../../fault_model/fault_bott60km.h5' earth_file = 'earth.model_He63km_VisM1.0E19' for ano in range(30): with h5py.File('outs/ano_%02d.h5' % ano, 'r') as fid: Bm = nres = fid['Bm'][...] slip = Bm[0:-1] mplt = MapPlotFault(fault_file) mplt.plot_slip(slip) mplt = vj.plots.MapPlotDisplacement() mplt.plot_sites_seafloor(text=False) mplt = vj.plots.MapPlotSlab() mplt.plot_top() mo, mw = vj.MomentCalculator(fault_file, earth_file).moment(slip) plt.title('Mo = %.5g, Mw = %.4f' % (mo, mw)) #plt.show() plt.savefig('plots/ano_%02d.png' % ano) plt.close()
scale = 20 for file in files: print(file) bn = os.path.basename(file).split('.')[0] plot_dir = 'plots/%s'%bn if not exists(plot_dir): makedirs(plot_dir) with h5py.File(file) as fid: Bm = fid['Bm'][...] d_pred = fid['d_pred'][...] for nth, epoch in enumerate(epochs[1:]): print(epoch) mplt = MapPlotFault(fault_file) mplt.plot_slip(Bm[nth*num_subflts: (nth+1)*num_subflts]) ## mplt = vj.MapPlotDisplacement() ## mplt.plot_disp(d_pred[nth*num_obs: ## (nth+1)*num_obs],sites, scale=scale) ## sites = [ii.decode() for ii in d_ep.sites] ## mplt.plot_disp(d_ep[epoch], sites, color='red', scale=scale) mplt = MapPlotSlab() mplt.plot_top() savefig(join(plot_dir, 'incr_slip_%04d.png'%epoch)) # plt.show() plt.close()
import h5py from viscojapan.plots import MapPlotFault, plt for ano in range(30): with h5py.File('outs/ano_%02d.h5' % ano, 'r') as fid: Bm = nres = fid['Bm'][...] slip = Bm[0:-1] mplt = MapPlotFault('../../greens_function/fault_He50km.h5') mplt.plot_slip(slip) #plt.show() plt.savefig('plots/ano_%02d.png' % ano) plt.close()
import h5py from viscojapan.plots import MapPlotFault, plt import viscojapan as vj fault_file = '../../fault_model/fault_bott60km.h5' earth_file = 'earth.model_He63km_VisM1.0E19' for ano in range(30): with h5py.File('outs/ano_%02d.h5' % ano, 'r') as fid: Bm = nres = fid['Bm'][...] slip = Bm[0:-1] mplt = MapPlotFault(fault_file) mplt.plot_slip(slip) mplt = vj.plots.MapPlotSlab() mplt.plot_top() mo, mw = vj.MomentCalculator(fault_file, earth_file).moment(slip) plt.title('Mo = %.5g, Mw = %.4f' % (mo, mw)) #plt.show() plt.savefig('plots/ano_%02d.pdf' % ano) plt.close()
if_plot = True fault_file = '../../fault_model/fault_bott80km.h5' dip_patch_size = 3 strike_patch_size = 4 #gslip = GaussianSlip.create_from_fault_file(fault_file) slip = vj.inv.test.gen_checkerboard_slip_from_fault_file( fault_file, dip_patch_size = dip_patch_size, strike_patch_size = strike_patch_size) slip *= 2. if if_plot: mplt = MapPlotFault(fault_file) mplt.plot_slip(slip, zorder=-2, cb_shrink=0.7, cb_pad = 0.1) mplt = vj.plots.MapPlotSlab() mplt.plot_top() #plt.show() plt.savefig('slip_d_simu_dip%d_stk%d.png'%(dip_patch_size, strike_patch_size)) plt.savefig('slip_d_simu_dip%d_stk%d.pdf'%(dip_patch_size, strike_patch_size)) plt.close() file_G = '../../green_function/G0_He50km_VisM6.3E18_Rake83.h5' g = vj.inv.ep.EpochG(file_G) sites = g.get_sites()
def plot_slip(self, slip, fn): fault_file = '/home/zy/workspace/viscojapan/tests/share/fault_bott80km.h5' mplt = MapPlotFault(fault_file) mplt.plot_slip(slip) plt.savefig(join(self.outs_dir, fn)) plt.close()
d0_rake90 = G_rake90.get_epoch_value(0)[:, fno] d_rake90 = G_rake90.get_epoch_value(epoch)[:, fno] mplt = MapPlotDisplacement(basemap=bm) mplt.plot_disp(d_rake90 - d0_rake90, G_rake95.sites, U=U, label=label, X=0.1, Y=0.8, color='black', scale=scale) mplt.plot_disp(d_rake95 - d0_rake95, G_rake90.sites, U=U, label=label, X=0.1, Y=0.7, color='red', scale=scale) ##mplt.plot_G_file('../G_He45km.h5', epoch, fno, scale=scale) ##mplt.plot_G_file('../G_He55km.h5', epoch, fno, ## color='red', scale=scale) mplt = MapPlotFault('../../fault_model/fault_He50km.h5', basemap=bm) mplt.plot_fault(fno) plt.show()
def plot_original_fault(self): MapPlotFault(fault_file=self.original_fault_file).plot_fault()
def test_dep_top(self): dips = self.read_pars('top') MapPlotFault(fault_file=self.original_fault_file).pcolor_on_fault(dips) plt.title('top') plt.savefig(join(self.outs_dir, 'dep_top.png')) plt.close()
import h5py from viscojapan.plots import MapPlotFault, plt for ano in range(30): with h5py.File('outs/ano_%02d.h5'%ano,'r') as fid: slip = nres = fid['Bm'][...] mplt = MapPlotFault('../fault_model/fault_He50km.h5') mplt.plot_slip(slip) #plt.show() plt.savefig('plots/ano_%02d.png'%ano) plt.close()
def plot_slip(self, slip, fn): fault_file = '/home/zy/workspace/viscojapan/tests/share/fault_bott80km.h5' mplt = MapPlotFault(fault_file) mplt.plot_slip(slip) plt.savefig(join(self.outs_dir,fn)) plt.close()
def plot_slip(self, slip, fn): mplt = MapPlotFault('/home/zy/workspace/viscojapan/inversions/static_inversion/coseismic_inversion_wider/fault_model/fault_He50km_east.h5') mplt.plot_slip(slip) plt.savefig(join(self.outs_dir,fn)) plt.close()
from numpy import dot from viscojapan.inversion.inversion_test import GaussianSlip, gen_error_for_sites from viscojapan.plots import MapPlotFault, plt, MapPlotDisplacement from viscojapan import EpochalG import viscojapan as vj if_plot = True fault_file = '../greens_function/fault_He50km.h5' gslip = GaussianSlip.create_from_fault_file(fault_file) slip = gslip(0) if if_plot: mplt = MapPlotFault(fault_file) mplt.plot_slip(slip) plt.show() file_G = '../greens_function/G_Rake80.h5' g = EpochalG(file_G) sites = g.sites G = g(0) d_pred = dot(G,slip.reshape([-1,1])) if if_plot: mplt = MapPlotDisplacement() mplt.plot_disp(d_pred, sites) plt.show()
from viscojapan.fault_model.fault_file_reader import FaultFileIO from viscojapan.plots import MapPlotFault, plt, MapPlotSlab mplt = MapPlotFault('fault_He50km_1.h5') mplt.plot_fault() mplt = MapPlotFault('fault_He50km_2.h5') mplt.plot_fault(color='red') MapPlotSlab().plot_top() plt.show()
import glob from os.path import basename, exists import h5py from viscojapan.plots import MapPlotFault, plt files = glob.glob('outs/ano_??_edg_??.h5') for ano in range(30): for file in files: name = basename(file) fname = 'plots/%s.png'%name if exists(fname): print('Skip %s!'%fname) continue print(fname) with h5py.File(file,'r') as fid: slip = nres = fid['Bm'][...] mplt = MapPlotFault('fault_bott40km.h5') mplt.plot_slip(slip) #plt.show() plt.savefig(fname) plt.close()
import h5py import glob import os import viscojapan as vj from viscojapan.plots import MapPlotFault, plt files = sorted(glob.glob('outs/dip3_stk4_ano_??.h5')) for file in files: f1 = os.path.basename(file) with h5py.File(file, 'r') as fid: slip = nres = fid['Bm'][...] mplt = MapPlotFault('../../fault_model/fault_bott80km.h5') mplt.plot_slip(slip, zorder=-2, cb_shrink=0.7, cb_pad=0.1) mplt = vj.plots.MapPlotSlab() mplt.plot_top() plt.clim([0, 2]) #plt.show() plt.savefig(os.path.join('plots', f1.split('.')[0] + '.png')) plt.savefig(os.path.join('plots', f1.split('.')[0] + '.pdf')) plt.close()
from numpy import dot from viscojapan.inversion.inversion_test import GaussianSlip, gen_error_for_sites from viscojapan.plots import MapPlotFault, plt, MapPlotDisplacement from viscojapan import EpochalG import viscojapan as vj if_plot = False fault_file = '../fault_model/fault_He50km.h5' gslip = GaussianSlip.create_from_fault_file(fault_file) slip = gslip(0) if if_plot: mplt = MapPlotFault(fault_file) mplt.plot_slip(slip) plt.show() file_G = '../greens_function/G_Rake80.h5' g = EpochalG(file_G) sites = g.sites G = g(0) d_pred = dot(G, slip.reshape([-1, 1])) if if_plot: mplt = MapPlotDisplacement() mplt.plot_disp(d_pred, sites) plt.show()
import h5py from viscojapan.plots import MapPlotFault, plt import viscojapan as vj fault_file = '../../fault_model/fault_bott60km.h5' earth_file = 'earth.model_He63km_VisM1.0E19' for ano in range(30): with h5py.File('outs/ano_%02d.h5'%ano,'r') as fid: Bm = nres = fid['Bm'][...] slip = Bm[0:-1] mplt = MapPlotFault(fault_file) mplt.plot_slip(slip) mplt = vj.plots.MapPlotSlab() mplt.plot_top() mo, mw = vj.MomentCalculator(fault_file, earth_file).moment(slip) plt.title('Mo = %.5g, Mw = %.4f'%(mo, mw)) #plt.show() plt.savefig('plots/ano_%02d.png'%ano) plt.close()
import h5py import glob import os import viscojapan as vj from viscojapan.plots import MapPlotFault, plt files = sorted(glob.glob('outs/dip3_stk4_ano_??.h5')) for file in files: f1 = os.path.basename(file) with h5py.File(file ,'r') as fid: slip = nres = fid['Bm'][...] mplt = MapPlotFault('../../fault_model/fault_bott80km.h5') mplt.plot_slip(slip, zorder=-2, cb_shrink=0.7, cb_pad = 0.1) mplt = vj.plots.MapPlotSlab() mplt.plot_top() plt.clim([0,2]) #plt.show() plt.savefig( os.path.join('plots',f1.split('.')[0]+'.png') ) plt.savefig( os.path.join('plots',f1.split('.')[0]+'.pdf')
import glob from os.path import basename, exists import h5py from viscojapan.plots import MapPlotFault, plt files = glob.glob('outs/ano_??_edg_??.h5') for ano in range(30): for file in files: name = basename(file) fname = 'plots/%s.png' % name if exists(fname): print('Skip %s!' % fname) continue print(fname) with h5py.File(file, 'r') as fid: slip = nres = fid['Bm'][...] mplt = MapPlotFault('fault_bott40km.h5') mplt.plot_slip(slip) #plt.show() plt.savefig(fname) plt.close()