def compute_params_for_WC_source(strike, dip, rake, depth, magnitude, faulting_type, fault_lon, fault_lat, zerolon, zerolat): [xcenter, ycenter] = conversion_math.latlon2xy(fault_lon, fault_lat, zerolon, zerolat) L = wells_and_coppersmith.RLD_from_M(magnitude, faulting_type) # rupture length W = wells_and_coppersmith.RW_from_M(magnitude, faulting_type) # rupture width slip = wells_and_coppersmith.rectangular_slip(L * 1000, W * 1000, magnitude) # must input in meters # xstart,ystart=conversion_math.add_vector_to_point(xcenter,ycenter,-L/2,strike[i]); # if the hypocenter is really the center of the rupture # xfinish,yfinish=conversion_math.add_vector_to_point(xcenter,ycenter,L/2,strike[i]); xstart, ystart = conversion_math.add_vector_to_point( xcenter, ycenter, 0, strike) # if the hypocenter is on one side of the rupture xfinish, yfinish = conversion_math.add_vector_to_point( xcenter, ycenter, L, strike) rtlat, reverse = conversion_math.get_rtlat_dip_slip(slip, rake) top, bottom = conversion_math.get_top_bottom(depth, W, dip) Kode = 100 comment = '' return [ xstart, xfinish, ystart, yfinish, Kode, rtlat, reverse, top, bottom, comment ]
def gps_input_manager(params): # Reads file, and then performs coodinate transformation. # Returns an object with: # a vector of ux, uy, uz (3*ngps x 1). # a vector of lon, lat (2*ngps x 1). # a vector of x, y (2*ngps x 1). if params.mode == "SIMPLE_TEST": return [] # Input of data [gps_lon, gps_lat, ux, uy, uz] = read_gps_file(params.gps_input_file) # Doing the geographic conversion and wrapping into an object gps_x = [] gps_y = [] for i in range(len(gps_lon)): kx, ky = conversion_math.latlon2xy(gps_lon[i], gps_lat[i], params.lon0, params.lat0) gps_x.append(kx) gps_y.append(ky) gps_obs_vector = np.concatenate((ux, uy, uz)) gps_xy_vector = np.concatenate((gps_x, gps_y)) gps_ll_vector = np.concatenate((gps_lon, gps_lat)) GPSObject = mcmc_collections.GPS_disp_object(gps_ll_vector=gps_ll_vector, gps_xy_vector=gps_xy_vector, gps_obs_vector=gps_obs_vector) return GPSObject
def compute_params_for_source(strike, dip, rake, mag, eq_type, eqlon, eqlat, eqdep, zerolon, zerolat): xstart=[]; xfinish=[]; ystart=[]; yfinish=[]; Kode=[]; rtlat=[]; reverse=[]; top=[]; bottom=[]; comment=[]; # Useful when you have earthquake catalog information, and you want the source information. # The depth/eqlon/eqlat parameters refer to the center of the fault plane by assumption. # Takes lists of parameters. for i in range(len(strike)): [xcenter,ycenter]=conversion_math.latlon2xy(eqlon[i],eqlat[i],zerolon,zerolat); # print("EQ location: %f %f " % (eqlon[i],eqlat[i]) ); # print("Ref location: %f %f " % (zerolon, zerolat) ); # print("Coordinates: %f %f " % (x,y) ); L=wells_and_coppersmith.RLD_from_M(mag[i],eq_type[i]); # rupture length W=wells_and_coppersmith.RW_from_M(mag[i],eq_type[i]); # rupture width slip = wells_and_coppersmith.rectangular_slip(L*1000,W*1000,mag[i]); # must input in meters print("Fault slip: %f" % slip); # xistart,yistart=conversion_math.add_vector_to_point(xcenter,ycenter,-L/2,strike[i]); # if the hypocenter is really the center of the rupture xistart,yistart=conversion_math.add_vector_to_point(xcenter,ycenter,0,strike[i]); # if the hypocenter is on one side of the rupture xifinish,yifinish=conversion_math.add_vector_to_point(xcenter,ycenter,L,strike[i]); rtlati,reversei=conversion_math.get_rtlat_dip_slip(slip, rake[i]); topi, bottomi=conversion_math.get_top_bottom(eqdep[i],W,dip[i]); xstart.append(xistart); ystart.append(yistart); xfinish.append(xifinish); yfinish.append(yifinish); Kode.append(100); rtlat.append(rtlati); reverse.append(reversei); top.append(topi); bottom.append(bottomi); comment.append(''); return [xstart, xfinish, ystart, yfinish, Kode, rtlat, reverse, top, bottom, comment];
def compute_params_for_point_source(strike, dipangle, rake, magnitude, lon, lat, zerolon, zerolat, mu, lame1): # Given information about point sources from focal mechanisms, # Return the right components that get packaged into input_obj. [xcenter, ycenter] = conversion_math.latlon2xy(lon, lat, zerolon, zerolat) potency = get_DC_potency(rake, magnitude, mu, lame1) # Filler variables for the point source case Kode = 100 comment = '' return [xcenter, ycenter, Kode, 0, 0, potency, comment]
def compute_params_for_slip_source(strike, dip, rake, depth, L, W, fault_lon, fault_lat, slip, zerolon, zerolat): [xcorner, ycorner] = conversion_math.latlon2xy(fault_lon, fault_lat, zerolon, zerolat) xstart, ystart = conversion_math.add_vector_to_point( xcorner, ycorner, 0, strike) xfinish, yfinish = conversion_math.add_vector_to_point( xcorner, ycorner, L, strike) rtlat, reverse = conversion_math.get_rtlat_dip_slip(slip, rake) top, bottom = conversion_math.get_top_bottom_from_top(depth, W, dip) Kode = 100 comment = '' return [ xstart, xfinish, ystart, yfinish, Kode, rtlat, reverse, top, bottom, comment ]
def compute_params_for_receiver(strike, dip, rake, length, width, lon, lat, depth, zerolon, zerolat): xstart=[]; xfinish=[]; ystart=[]; yfinish=[]; Kode=[]; rtlat=[]; reverse=[]; top=[]; bottom=[]; comment=[]; # Useful when you have a receiver and you want to compute stresses on it. # The depth/lon/lat parameters refer to the updip fault corner where you're looking down the strike direction, and the dip is off to your right. # Takes lists of parameters. for i in range(len(strike)): [xistart,yistart]=conversion_math.latlon2xy(lon[i],lat[i],zerolon,zerolat); xifinish,yifinish=conversion_math.add_vector_to_point(xistart,yistart,length[i],strike[i]); topi, bottomi=conversion_math.get_top_bottom_from_top(depth[i],width[i],dip[i]); xstart.append(xistart); ystart.append(yistart); xfinish.append(xifinish); yfinish.append(yifinish); Kode.append(100); rtlat.append(0); reverse.append(0); top.append(topi); bottom.append(bottomi); comment.append(''); return [xstart, xfinish, ystart, yfinish, Kode, rtlat, reverse, top, bottom, comment];
def compute_ll_def(params, inputs, disp_points): # Loop through a list of lon/lat and compute their displacements due to all sources put together. x = [] y = [] for i in range(len(disp_points.lon)): [xi, yi] = conversion_math.latlon2xy(disp_points.lon[i], disp_points.lat[i], inputs.zerolon, inputs.zerolat) x.append(xi) y.append(yi) u_ll = np.zeros(len(x)) v_ll = np.zeros(len(x)) w_ll = np.zeros(len(x)) # For each coordinate requested. for k in range(len(x)): u_disp, v_disp, w_disp = compute_surface_disp_point( params, inputs, x[k], y[k]) u_ll[k] = u_disp v_ll[k] = v_disp w_ll[k] = w_disp return [u_ll, v_ll, w_ll]
def make_data_dc3d(): # USER SELECTED PARAMETER [strike, dip, rake] = [325, 80, 160] # [strike, dip, rake] = [343, 44, -62]; [L, W, depth] = [23, 14, 15] # comes from Wells and Coppersmith, normal fault, M6.5. [lon0, lat0] = [-121.0, 34.5] # the top back corner of the fault plane, the natural reference point of the system. Mw = 6.5 # magnitude of event mu = 30e9 # 30 GPa for shear modulus alpha = 0.66667 # usually don't touch this. gps_xrange = [-123, -119] gps_yrange = [32.5, 36.0] number_gps_points = 100 outname = 'example_gps_' + str(Mw) + '_' + str(strike) + '.txt' # Derived quantities slip = conversion_math.get_slip_from_mw_area(Mw, L, W, mu) strike_slip, dip_slip = conversion_math.get_lflat_dip_slip(slip, rake) print("strike slip:", strike_slip, "m (positive is left-lateral)") print("dip slip:", dip_slip, "m (positive is reverse)") gps_lon = [] gps_lat = [] for i in range(number_gps_points): gps_lon.append(random.uniform(gps_xrange[0], gps_xrange[1])) gps_lat.append(random.uniform(gps_yrange[0], gps_yrange[1])) # Coordinate transformation gps_x = [] gps_y = [] for i in range(number_gps_points): kx, ky = conversion_math.latlon2xy(gps_lon[i], gps_lat[i], lon0, lat0) gps_x.append(kx) gps_y.append(ky) # Mechanical part. # Assumes top back corner of fault plane is located at 0,0 # Given strike, dip, rake, depth, alpha, strike_slip, and dip_slip... # Given vectors of gps_x and gps_y... # Returns vectors of gps_u, gps_v, and gps_w. print("Strike = ", strike) print("Dip = ", dip) print("Rake = ", rake) print("Depth = ", depth) print("Length = ", L) print("Width = ", W) print("Alpha = ", alpha) print("Strikeslip = ", strike_slip) print("Dip slip = ", dip_slip) ux, uy, uz = okada_class.okada_at_origin(strike, dip, rake, depth, L, W, alpha, strike_slip, dip_slip, gps_x, gps_y) # Add some random noise ux = np.add(ux, 0.001 * np.random.randn(len(ux))) uy = np.add(uy, 0.001 * np.random.randn(len(ux))) uz = np.add(uz, 0.002 * np.random.randn(len(ux))) plt.figure(figsize=(16, 16)) plt.scatter(gps_lon, gps_lat, marker='o', s=150, c=uz, vmin=-0.015, vmax=0.015) plt.colorbar() plt.quiver(gps_lon, gps_lat, ux, uy, linewidths=0.01, edgecolors=('k'), scale=0.05) plt.xlim([np.min(gps_lon), np.max(gps_lon)]) plt.ylim([np.min(gps_lat), np.max(gps_lat)]) plt.grid() plt.title('strike=%d' % (strike)) plt.plot(lon0, lat0, '.r', marker='o') plt.savefig("Displacement_model_" + str(Mw) + '_' + str(strike) + ".png") io_gps_mcmc.write_gps_file(gps_lon, gps_lat, ux, uy, uz, outname) return