def make_fault_dtopo(subfault_params, bounds, verbose=False): """Create GeoClaw fault object and dtopo for deformation of sea floor due to earthquake. Uses the Okada model with fault parameters and mesh specified below. Parameters ---------- subfault_params : pandas DataFrame DataFrame containing the 9 Okada parameters for each subfault. bounds : dict Dictionary containing the model bounds. Keys are 'lon_min','lon_max', 'lat_min', 'lat_max' verbose : bool Flag for verbose output, optional. Default is False. If true, prints the fault's subfault parameters as well as the momement magnitude and seismic moment of the fault. Returns ------- fault : GeoClaw BaseFault Object A GeoClaw fault object describing the topography changes and subfaults. """ subfaults = [] for _, params in subfault_params.iterrows(): subfault = dtopotools.SubFault() subfault.coordinate_specification = "centroid" subfault.latitude = params['latitude'] subfault.longitude = params['longitude'] subfault.strike = params['strike'] subfault.length = params['length'] subfault.width = params['width'] subfault.slip = params['slip'] subfault.depth = params['depth'] subfault.dip = params['dip'] subfault.rake = params['rake'] subfaults.append(subfault) fault = dtopotools.Fault() fault.subfaults = subfaults if verbose: print(fault.subfaults) if verbose: print("Mw = ", fault.Mw()) if verbose: print("Mo = ", fault.Mo()) times = [1.] points_per_degree = 60 # 1 arcminute resolution dx = 1 / points_per_degree lon_min, lon_max = bounds['lon_min'], bounds['lon_max'] lat_min, lat_max = bounds['lat_min'], bounds['lat_max'] n = int((lon_max - lon_min) / dx + 1) lon_max = lon_min + (n - 1) * dx m = int((lat_max - lat_min) / dx + 1) lat_max = lat_min + (m - 1) * dx lon = np.linspace(lon_min, lon_max, n) lat = np.linspace(lat_min, lat_max, m) fault.create_dtopography(lon, lat, times, verbose=verbose) return fault
def set_params(self, params): """ Set the subfault parameters. """ subfault = dtopotools.SubFault() subfault.longitude = params[0] subfault.latitude = params[1] subfault.depth = params[2] subfault.strike = params[3] subfault.dip = params[4] subfault.length = params[5] subfault.width = params[6] subfault.rake = params[7] subfault.slip = params[8] subfault.coordinate_specification = "top center" fault = dtopotools.Fault() fault.subfaults = [subfault] return fault, subfault
def make_dtopo(makeplots=False): """ Create dtopo data file for deformation of sea floor due to earthquake. Uses the Okada model with fault parameters and mesh specified below. """ from clawpack.geoclaw import dtopotools import numpy dtopo_fname = os.path.join(scratch_dir, "dtopo_usgs100227.tt3") # Specify subfault parameters for this simple fault model consisting # of a single subfault: usgs_subfault = dtopotools.SubFault() usgs_subfault.strike = 16. usgs_subfault.length = 450.e3 usgs_subfault.width = 100.e3 usgs_subfault.depth = 35.e3 usgs_subfault.slip = 15. usgs_subfault.rake = 104. usgs_subfault.dip = 14. usgs_subfault.longitude = -72.668 usgs_subfault.latitude = -35.826 usgs_subfault.coordinate_specification = "top center" fault = dtopotools.Fault() fault.subfaults = [usgs_subfault] print "Mw = ", fault.Mw() if os.path.exists(dtopo_fname): print "*** Not regenerating dtopo file (already exists): %s" \ % dtopo_fname else: print "Using Okada model to create dtopo file" x = numpy.linspace(-77, -67, 100) y = numpy.linspace(-40, -30, 100) times = [1.] fault.create_dtopography(x, y, times) dtopo = fault.dtopo dtopo.write(dtopo_fname, dtopo_type=3) if makeplots: from matplotlib import pyplot as plt if fault.dtopo is None: # read in the pre-existing file: print "Reading in dtopo file..." dtopo = dtopotools.DTopography() dtopo.read(dtopo_fname, dtopo_type=3) x = dtopo.x y = dtopo.y plt.figure(figsize=(12, 7)) ax1 = plt.subplot(121) ax2 = plt.subplot(122) fault.plot_subfaults(axes=ax1, slip_color=True) ax1.set_xlim(x.min(), x.max()) ax1.set_ylim(y.min(), y.max()) dtopo.plot_dZ_colors(1., axes=ax2) fname = os.path.splitext(os.path.split(dtopo_fname)[-1])[0] + '.png' plt.savefig(fname) print "Created ", fname
"latitude": 0, "longitude": 1, "depth": 2, "slip": 3, "rake": 4, "strike": 5, "dip": 6 } defaults = {'length': 30, 'width': 20} coordinate_specification = 'top center' input_units = {'slip': 'cm', 'depth': 'km', 'length': 'km', 'width': 'km'} rupture_type = 'static' skiprows = 11 delimiter = None # white space is the default fault = dtopotools.Fault() fault.read(fault_geometry_file, column_map, coordinate_specification, rupture_type, skiprows, delimiter, input_units, defaults) print "There are %s subfaults" % len(fault.subfaults) x, y = fault.create_dtopo_xy() dtopo = fault.create_dtopography(x, y, verbose=True) figure(figsize=(7, 5)) ax1 = subplot(111) fault.plot_subfaults(axes=ax1, slip_color=True) axis([-75, -70, -39, -32]) savefigp('chile2010_slip.png') figure(figsize=(7, 5)) ax1 = subplot(111)
# For example, the first triangular fault in the given geometry of CSZ has the nodes # In[ ]: print(cascadia[0, 4:7]) print(cascadia[0, 7:10]) print(cascadia[0, 10:13]) # ### Plot the subfaults: # Set up a fault model with these subfaults, without yet specifying a particular earthquake scenario. # In[ ]: fault0 = dtopotools.Fault() fault0.subfaults = [] nsubfaults = cascadia.shape[0] for j in range(nsubfaults): subfault0 = dtopotools.SubFault() node1 = cascadia[j, 4:7].tolist() node2 = cascadia[j, 7:10].tolist() node3 = cascadia[j, 10:13].tolist() node_list = [node1, node2, node3] subfault0.set_corners(node_list, projection_zone='10T') fault0.subfaults.append(subfault0) # Now we can plot the triangular subplots:
def make_dtopo(params, makeplots=False): """ Create dtopo data file for deformation of sea floor due to earthquake. Uses the Okada model with fault parameters and mesh specified below. """ dtopo_fname = os.path.join('./InputData/', "dtopo.tt3") # number of cols = number of rectangles * number of changing params + number of constant params n = (len(params) - 4) // 5 # Specify subfault parameters for this simple fault model consisting # of a single subfault: subfaults = [] for i in range(n): usgs_subfault = dtopotools.SubFault() usgs_subfault.strike = params['Strike' + str(i + 1)] usgs_subfault.length = params['Sublength'] usgs_subfault.width = params['Subwidth'] usgs_subfault.depth = params['Depth' + str(i + 1)] usgs_subfault.slip = params['Slip'] usgs_subfault.rake = params['Rake'] usgs_subfault.dip = params['Dip' + str(i + 1)] usgs_subfault.longitude = params['Longitude' + str(i + 1)] usgs_subfault.latitude = params['Latitude' + str(i + 1)] usgs_subfault.coordinate_specification = "centroid" subfaults.append(usgs_subfault) fault = dtopotools.Fault() fault.subfaults = subfaults print(fault.subfaults) print("Mw = ", fault.Mw()) print("Mo = ", fault.Mo()) if os.path.exists(dtopo_fname): print("*** Not regenerating dtopo file (already exists): %s" \ % dtopo_fname) else: print("Using Okada model to create dtopo file") #x = numpy.linspace(-77, -67, 100) #y = numpy.linspace(-40, -30, 100) times = [1.] with open('./PreRun/InputData/model_bounds.txt') as json_file: model_bounds = json.load(json_file) xlower = model_bounds['xlower'] xupper = model_bounds['xupper'] ylower = model_bounds['ylower'] yupper = model_bounds['yupper'] # dtopo parameters points_per_degree = 60 # 1 minute resolution dx = 1. / points_per_degree mx = int((xupper - xlower) / dx + 1) xupper = xlower + (mx - 1) * dx my = int((yupper - ylower) / dx + 1) yupper = ylower + (my - 1) * dx print("New upper bounds:\n") print("latitude:", yupper) print("longitude:", xupper) x = np.linspace(xlower, xupper, mx) y = np.linspace(ylower, yupper, my) fault.create_dtopography(x, y, times, verbose=True) dtopo = fault.dtopo dtopo.write(dtopo_fname, dtopo_type=3) if makeplots: from matplotlib import pyplot as plt if fault.dtopo is None: # read in the pre-existing file: print("Reading in dtopo file...") dtopo = dtopotools.DTopography() dtopo.read(dtopo_fname, dtopo_type=3) x = dtopo.x y = dtopo.y plt.figure(figsize=(12, 7)) ax1 = plt.subplot(121) ax2 = plt.subplot(122) fault.plot_subfaults(axes=ax1, slip_color=True) ax1.set_xlim(x.min(), x.max()) ax1.set_ylim(y.min(), y.max()) dtopo.plot_dZ_colors(1., axes=ax2) fname = os.path.splitext(os.path.split(dtopo_fname)[-1])[0] + '.png' plt.savefig(fname) print("Created ", fname)
"longitude": 1, "latitude": 2, "depth": 3, "strike": 4, "length": 5, "width": 6, "dip": 7 } defaults = {'rake': 90, 'slip': 1.0} coordinate_specification = 'top center' input_units = {'slip': 'm', 'depth': 'km', 'length': 'km', 'width': 'km'} rupture_type = 'static' skiprows = 1 delimiter = ',' fault = dtopotools.Fault() fault.read('CSZe01.csv', column_map, coordinate_specification, rupture_type, skiprows, delimiter, input_units, defaults) print "There are %s subfaults" % len(fault.subfaults) for s in fault.subfaults: s.longitude = s.longitude - 360. # adjust to W coordinates figure(figsize=(12, 6)) ax = subplot(121) fault.plot_subfaults(ax) xticks(range(-128, -123)) # Now subdivide each subfault further new_subfaults = [] # to accumulate all new subfaults