Ejemplo n.º 1
0
def read_intxt(input_file):
	
	strike_src=[]; dipangle_src=[]; rake_src=[]; magnitude_src=[]; faulting_type_src=[]; fault_center_lon_src=[]; fault_center_lat_src=[]; fault_dep_src=[];
	strike_rec=[]; dipangle_rec=[]; rake_rec=[]; length_rec=[]; width_rec=[]; updip_corner_lon_rec=[]; updip_corner_lat_rec=[]; updip_corner_dep_rec=[];
	
	ifile=open(input_file,'r');
	for line in ifile:
		temp=line.split();
		if len(temp)==0:
			continue;
		if temp[0]=='S:':
			[strike,rake,dip,magnitude,faulting_type,fault_center_lon,fault_center_lat,fault_center_depth]=read_source_line(line);
			strike_src.append(strike);
			rake_src.append(rake);
			dipangle_src.append(dip);
			magnitude_src.append(magnitude);
			faulting_type_src.append(faulting_type);
			fault_center_lon_src.append(fault_center_lon);
			fault_center_lat_src.append(fault_center_lat);
			fault_dep_src.append(fault_center_depth);
		elif temp[0]=='R:':
			[strike,rake,dip,length,width,updip_corner_lon,updip_corner_lat,updip_corner_dep]=read_receiver_line(line);
			strike_rec.append(strike);
			rake_rec.append(rake);
			dipangle_rec.append(dip);
			length_rec.append(length);
			width_rec.append(width);
			updip_corner_lon_rec.append(updip_corner_lon);
			updip_corner_lat_rec.append(updip_corner_lat);
			updip_corner_dep_rec.append(updip_corner_dep);
		elif temp[0]=='G:':
			[PR1,FRIC,minlon,maxlon,zerolon,minlat,maxlat,zerolat]=read_general_line(line);
		else:
			continue;
	ifile.close();

	# The main computing functions. 
	[start_gridx, finish_gridx, start_gridy, finish_gridy, xinc, yinc] = compute_grid_parameters(minlon, maxlon, zerolon, minlat, maxlat, zerolat);
	[xstart_src, xfinish_src, ystart_src, yfinish_src, Kode_src, rtlat_src, reverse_src, top_src, bottom_src, comment_src] = compute_params_for_source(strike_src, dipangle_src, rake_src, magnitude_src, faulting_type_src, fault_center_lon_src, fault_center_lat_src, fault_dep_src, zerolon, zerolat);
	[xstart_rec, xfinish_rec, ystart_rec, yfinish_rec, Kode_rec, rtlat_rec, reverse_rec, top_rec, bottom_rec, comment_rec] = compute_params_for_receiver(strike_rec, dipangle_rec, rake_rec, length_rec, width_rec, updip_corner_lon_rec, updip_corner_lat_rec, updip_corner_dep_rec, zerolon, zerolat);

	receivers=coulomb_collections.Faults_object(xstart=xstart_rec, xfinish=xfinish_rec, ystart=ystart_rec, yfinish=yfinish_rec, Kode=Kode_rec, rtlat=rtlat_rec, reverse=reverse_rec, strike=strike_rec, dipangle=dipangle_rec, rake=rake_rec, top=top_rec, bottom=bottom_rec, comment=comment_rec);
	sources=coulomb_collections.Faults_object(xstart=xstart_src, xfinish=xfinish_src, ystart=ystart_src, yfinish=yfinish_src, Kode=Kode_src, rtlat=rtlat_src, reverse=reverse_src, strike=strike_src, dipangle=dipangle_src, rake=rake_src, top=top_src, bottom=bottom_src, comment=comment_src);

	input_obj=coulomb_collections.Input_object(PR1=PR1,FRIC=FRIC, depth=0, start_gridx=start_gridx, finish_gridx=finish_gridx, start_gridy=start_gridy, finish_gridy=finish_gridy, 
		xinc=xinc, yinc=yinc, minlon=minlon, maxlon=maxlon, zerolon=zerolon, minlat=minlat, maxlat=maxlat, zerolat=zerolat, receiver_object=receivers, source_object=sources);

	return input_obj;
Ejemplo n.º 2
0
def produce_outputs(params, inputs, out_object):
	call(['mkdir','-p',params.outdir],shell=False);
	subfaulted_inputs=coulomb_collections.Input_object(PR1=inputs.PR1,FRIC=inputs.FRIC,depth=inputs.depth,
		start_gridx=inputs.start_gridx,start_gridy=inputs.start_gridy,finish_gridx=inputs.finish_gridx,
		finish_gridy=inputs.finish_gridy,xinc=inputs.xinc,yinc=inputs.yinc,minlon=inputs.minlon,maxlon=inputs.maxlon,
		zerolon=inputs.zerolon,minlat=inputs.minlat,maxlat=inputs.maxlat,zerolat=inputs.zerolat,
		source_object=out_object.source_object,receiver_object=out_object.receiver_object); # make a new object of the subfaulted configuration.
	io_inp.write_inp(params.outdir+'subfaulted.inp',subfaulted_inputs);
	surface_def_plot(params,out_object);
	stress_plot(params,out_object,'shear');  
	stress_plot(params,out_object,'normal');
	stress_plot(params,out_object,'coulomb');
	map_plot(params, inputs, out_object);
	write_output_files(params,out_object);
	side_on_plot(params);
	return;
Ejemplo n.º 3
0
def split_subfault_receivers(params, inputs):
    strike_split = params.strike_num_receivers
    dip_split = params.dip_num_receivers

    if strike_split == 1 and dip_split == 1:
        # If we're not splitting the subfaults...
        subfaulted_receivers = inputs.receiver_object
        print("Not subdividing receiver faults further.")
    else:
        subfaulted_receivers = []
        print("Splitting %d receiver faults into %d subfaults each." %
              (len(inputs.receiver_object), strike_split * dip_split))

        for fault in inputs.receiver_object:  # for each receiver...
            # We find the depths corresponding to the tops and bottoms of our new sub-faults
            zsplit_array = get_split_z_array(fault.top, fault.bottom,
                                             dip_split)

            for j in range(dip_split):  # First we split it up by dip.
                # Get the new coordinates of the top of the fault plane.
                W = conversion_math.get_downdip_width(fault.top,
                                                      zsplit_array[j],
                                                      fault.dipangle)
                vector_mag = W * np.cos(np.deg2rad(fault.dipangle))
                # how far the bottom edge is displaced downdip from map-view

                # Get the starting points for the next row of fault subpatches.
                [start_x_top,
                 start_y_top] = conversion_math.add_vector_to_point(
                     fault.xstart, fault.ystart, vector_mag, fault.strike + 90)
                [finish_x_top,
                 finish_y_top] = conversion_math.add_vector_to_point(
                     fault.xfinish, fault.yfinish, vector_mag,
                     fault.strike + 90)

                [xsplit_array, ysplit_array
                 ] = get_split_x_y_arrays(start_x_top, finish_x_top,
                                          start_y_top, finish_y_top,
                                          strike_split)

                for k in range(strike_split):
                    single_subfaulted_receiver = coulomb_collections.Faults_object(
                        xstart=xsplit_array[k],
                        xfinish=xsplit_array[k + 1],
                        ystart=ysplit_array[k],
                        yfinish=ysplit_array[k + 1],
                        Kode=fault.Kode,
                        rtlat=0,
                        reverse=0,
                        potency=[],
                        strike=fault.strike,
                        dipangle=fault.dipangle,
                        rake=fault.rake,
                        top=zsplit_array[j],
                        bottom=zsplit_array[j + 1],
                        comment=fault.comment)
                    subfaulted_receivers.append(single_subfaulted_receiver)

    subfaulted_objects = coulomb_collections.Input_object(
        PR1=inputs.PR1,
        FRIC=inputs.FRIC,
        depth=inputs.depth,
        start_gridx=inputs.start_gridx,
        finish_gridx=inputs.finish_gridx,
        start_gridy=inputs.start_gridy,
        finish_gridy=inputs.finish_gridy,
        xinc=inputs.xinc,
        yinc=inputs.yinc,
        minlon=inputs.minlon,
        maxlon=inputs.maxlon,
        zerolon=inputs.zerolon,
        minlat=inputs.minlat,
        maxlat=inputs.maxlat,
        zerolat=inputs.zerolat,
        source_object=inputs.source_object,
        receiver_object=subfaulted_receivers)

    return subfaulted_objects
Ejemplo n.º 4
0
def read_intxt(input_file):
    print("Reading source and receiver fault information from file %s " %
          input_file)
    sources = []
    receivers = []

    ifile = open(input_file, 'r')
    for line in ifile:
        temp = line.split()
        if len(temp) == 0:
            continue
        if temp[0] == 'S:':
            if " SS " in line or " N " in line or " R " in line or " ALL " in line:  # reading wells and coppersmith convenient format
                [
                    strike, rake, dip, magnitude, faulting_type, fault_lon,
                    fault_lat, fault_depth
                ] = read_source_line_WCconvention(line)
                [
                    xstart, xfinish, ystart, yfinish, Kode, rtlat, reverse,
                    top, bottom, comment
                ] = compute_params_for_WC_source(strike, dip, rake,
                                                 fault_depth, magnitude,
                                                 faulting_type, fault_lon,
                                                 fault_lat, zerolon, zerolat)
            else:  # reading the source-slip convenient format
                [
                    strike, rake, dip, L, W, slip, fault_lon, fault_lat,
                    fault_depth
                ] = read_source_line_slip_convention(line)
                [
                    xstart, xfinish, ystart, yfinish, Kode, rtlat, reverse,
                    top, bottom, comment
                ] = compute_params_for_slip_source(strike, dip, rake,
                                                   fault_depth, L, W,
                                                   fault_lon, fault_lat, slip,
                                                   zerolon, zerolat)
            one_source_object = coulomb_collections.Faults_object(
                xstart=xstart,
                xfinish=xfinish,
                ystart=ystart,
                yfinish=yfinish,
                Kode=Kode,
                rtlat=rtlat,
                reverse=reverse,
                potency=[],
                strike=strike,
                dipangle=dip,
                rake=rake,
                top=top,
                bottom=bottom,
                comment=comment)
            sources.append(one_source_object)
            print("RtLat slip: %f m, Reverse slip: %f m" % (rtlat, reverse))
        elif temp[0] == 'R:':
            [strike, rake, dip, L, W, fault_lon, fault_lat,
             fault_depth] = read_receiver_line(line)
            [
                xstart, xfinish, ystart, yfinish, Kode, rtlat, reverse, top,
                bottom, comment
            ] = compute_params_for_slip_source(strike, dip, rake, fault_depth,
                                               L, W, fault_lon, fault_lat, 0,
                                               zerolon, zerolat)
            one_receiver_object = coulomb_collections.Faults_object(
                xstart=xstart,
                xfinish=xfinish,
                ystart=ystart,
                yfinish=yfinish,
                Kode=Kode,
                rtlat=rtlat,
                reverse=reverse,
                potency=[],
                strike=strike,
                dipangle=dip,
                rake=rake,
                top=top,
                bottom=bottom,
                comment=comment)
            receivers.append(one_receiver_object)
        elif temp[0] == 'G:':
            [PR1, FRIC, minlon, maxlon, zerolon, minlat, maxlat,
             zerolat] = read_general_line(line)
        else:
            continue
    ifile.close()

    # Wrapping up the inputs.
    [start_gridx, finish_gridx, start_gridy, finish_gridy, xinc,
     yinc] = compute_grid_parameters(minlon, maxlon, zerolon, minlat, maxlat,
                                     zerolat)
    input_obj = coulomb_collections.Input_object(PR1=PR1,
                                                 FRIC=FRIC,
                                                 depth=0,
                                                 start_gridx=start_gridx,
                                                 finish_gridx=finish_gridx,
                                                 start_gridy=start_gridy,
                                                 finish_gridy=finish_gridy,
                                                 xinc=xinc,
                                                 yinc=yinc,
                                                 minlon=minlon,
                                                 maxlon=maxlon,
                                                 zerolon=zerolon,
                                                 minlat=minlat,
                                                 maxlat=maxlat,
                                                 zerolat=zerolat,
                                                 receiver_object=receivers,
                                                 source_object=sources)
    return input_obj
Ejemplo n.º 5
0
def read_inp(input_file, fixed_rake):
    # inp files require a fixed rake for the receiver faults, since they don't provide a fault-specific one inside the input file.
    read_faults = 0
    read_maps = 0
    read_grid = 0
    minlon = []
    maxlon = []
    zerolon = []
    minlat = []
    maxlat = []
    zerolat = []
    start_grix = []
    start_gridy = []
    finish_gridx = []
    finish_gridy = []
    xinc = []
    yinc = []
    xstart_rec = []
    xfinish_rec = []
    ystart_rec = []
    yfinish_rec = []
    Kode_rec = []
    rtlat_rec = []
    reverse_rec = []
    strike_rec = []
    dipangle_rec = []
    rake_rec = []
    top_rec = []
    bottom_rec = []
    comment_rec = []
    xstart_src = []
    xfinish_src = []
    ystart_src = []
    yfinish_src = []
    Kode_src = []
    rtlat_src = []
    reverse_src = []
    strike_src = []
    dipangle_src = []
    rake_src = []
    top_src = []
    bottom_src = []
    comment_src = []

    ifile = open(input_file)
    for line in ifile:
        temp = line.split()
        if 'PR1=' in line:
            prspot = temp.index('PR1=')
            PR1 = float(temp[prspot + 1])
            dpspot = temp.index('DEPTH=')
            depth = float(temp[dpspot + 1])
        if 'FRIC=' in line:
            fric_place = temp.index('FRIC=')
            FRIC = float(temp[fric_place + 1])
        if 'xxxxxxxxxx' in line:  # Moving into the fault definitions
            read_faults = 1
            continue
        if read_faults == 1:
            if len(temp) == 0:
                read_faults = 0
                continue
                # Getting out of fault definitions
            else:
                slip = abs(float(temp[6])) + abs(float(temp[7]))
                if slip > 0.0000001:  # Here we have a source fault
                    xstart_src.append(float(temp[1]))
                    ystart_src.append(float(temp[2]))
                    xfinish_src.append(float(temp[3]))
                    yfinish_src.append(float(temp[4]))
                    Kode_src.append(int(temp[5]))
                    rtlat_src.append(float(temp[6]))
                    reverse_src.append(float(temp[7]))
                    dipangle_src.append(float(temp[8]))
                    top_src.append(float(temp[9]))
                    bottom_src.append(float(temp[10]))
                    comment_src.append(" ".join(temp[11:-1]))
                    deltax = xfinish_src[-1] - xstart_src[-1]
                    deltay = yfinish_src[-1] - ystart_src[-1]
                    strike = conversion_math.get_strike(deltax, deltay)
                    strike_src.append(strike)
                    rake = conversion_math.get_rake(rtlat_src[-1],
                                                    reverse_src[-1])
                    rake_src.append(rake)
                else:  # here we have a receiver fault
                    xstart_rec.append(float(temp[1]))
                    ystart_rec.append(float(temp[2]))
                    xfinish_rec.append(float(temp[3]))
                    yfinish_rec.append(float(temp[4]))
                    Kode_rec.append(int(temp[5]))
                    rtlat_rec.append(float(temp[6]))
                    reverse_rec.append(float(temp[7]))
                    dipangle_rec.append(float(temp[8]))
                    top_rec.append(float(temp[9]))
                    bottom_rec.append(float(temp[10]))
                    comment_rec.append(" ".join(temp[11:-1]))
                    deltax = xfinish_rec[-1] - xstart_rec[-1]
                    deltay = yfinish_rec[-1] - ystart_rec[-1]
                    strike = conversion_math.get_strike(deltax, deltay)
                    strike_rec.append(strike)
                    rake = fixed_rake
                    rake_rec.append(rake)
        # Moving into Grid Parameters and Map Information
        if 'Grid Parameters' in line:
            read_grid = 1
            continue
        if read_grid == 1:
            if '  1  -' in line:
                start_gridx = float(temp[-1])
            elif '  2  -' in line:
                start_gridy = float(temp[-1])
            elif '  3  -' in line:
                finish_gridx = float(temp[-1])
            elif '  4  -' in line:
                finish_gridy = float(temp[-1])
            elif '  5  -' in line:
                xinc = float(temp[-1])
            elif '  6  -' in line:
                yinc = float(temp[-1])
            else:
                read_grid = 0
                continue

        # Reading Map Information
        if 'Map info' in line:
            read_maps = 1
            continue
        if read_maps == 1:
            if '  1  -' in line:
                minlon = float(temp[-1])
            elif '  2  -' in line:
                maxlon = float(temp[-1])
            elif '  3  -' in line:
                zerolon = float(temp[-1])
            elif '  4  -' in line:
                minlat = float(temp[-1])
            elif '  5  -' in line:
                maxlat = float(temp[-1])
            elif '  6  -' in line:
                zerolat = float(temp[-1])
            else:
                read_maps = 0
                continue

    ifile.close()

    receivers = coulomb_collections.Faults_object(xstart=xstart_rec,
                                                  xfinish=xfinish_rec,
                                                  ystart=ystart_rec,
                                                  yfinish=yfinish_rec,
                                                  Kode=Kode_rec,
                                                  rtlat=rtlat_rec,
                                                  reverse=reverse_rec,
                                                  strike=strike_rec,
                                                  dipangle=dipangle_rec,
                                                  rake=rake_rec,
                                                  top=top_rec,
                                                  bottom=bottom_rec,
                                                  comment=comment_rec)
    sources = coulomb_collections.Faults_object(xstart=xstart_src,
                                                xfinish=xfinish_src,
                                                ystart=ystart_src,
                                                yfinish=yfinish_src,
                                                Kode=Kode_src,
                                                rtlat=rtlat_src,
                                                reverse=reverse_src,
                                                strike=strike_src,
                                                dipangle=dipangle_src,
                                                rake=rake_src,
                                                top=top_src,
                                                bottom=bottom_src,
                                                comment=comment_src)

    input_obj = coulomb_collections.Input_object(PR1=PR1,
                                                 FRIC=FRIC,
                                                 depth=depth,
                                                 start_gridx=start_gridx,
                                                 finish_gridx=finish_gridx,
                                                 start_gridy=start_gridy,
                                                 finish_gridy=finish_gridy,
                                                 xinc=xinc,
                                                 yinc=yinc,
                                                 minlon=minlon,
                                                 maxlon=maxlon,
                                                 zerolon=zerolon,
                                                 minlat=minlat,
                                                 maxlat=maxlat,
                                                 zerolat=zerolat,
                                                 receiver_object=receivers,
                                                 source_object=sources)

    return input_obj
Ejemplo n.º 6
0
def read_inp(input_file, fixed_rake):

    print(
        "Reading source and receiver information from file %s with fixed_rake = %f "
        % (input_file, fixed_rake))
    # inp files require a fixed rake for the receiver faults, since they don't provide a fault-specific one inside the input file.

    [minlon, maxlon, zerolon, minlat, maxlat,
     zerolat] = get_map_info(input_file)

    read_faults = 0
    read_grid = 0
    sources = []
    receivers = []

    ifile = open(input_file)
    for line in ifile:
        temp = line.split()
        if 'PR1=' in line:
            prspot = temp.index('PR1=')
            PR1 = float(temp[prspot + 1])
            dpspot = temp.index('DEPTH=')
            depth = float(temp[dpspot + 1])
        if 'FRIC=' in line:
            fric_place = temp.index('FRIC=')
            FRIC = float(temp[fric_place + 1])
        if 'xxxxxxxxxx' in line:  # Moving into the fault definitions
            read_faults = 1
            continue
        if read_faults == 1:
            if len(temp) == 0:
                read_faults = 0
                continue
                # Getting out of fault definitions
            else:
                slip = abs(float(temp[6])) + abs(float(temp[7]))
                if slip > 0.0000001:  # Here we have a source fault
                    [
                        xstart, ystart, xfinish, yfinish, Kode, rtlat, reverse,
                        strike, dipangle, top, bottom, comment
                    ] = read_fault_line(line)
                    rake = conversion_math.get_rake(rtlat, reverse)
                    one_source_object = coulomb_collections.Faults_object(
                        xstart=xstart,
                        xfinish=xfinish,
                        ystart=ystart,
                        yfinish=yfinish,
                        Kode=Kode,
                        rtlat=rtlat,
                        reverse=reverse,
                        potency=[],
                        strike=strike,
                        dipangle=dipangle,
                        rake=rake,
                        top=top,
                        bottom=bottom,
                        comment=comment)
                    sources.append(one_source_object)
                else:  # here we have a receiver fault
                    [
                        xstart, ystart, xfinish, yfinish, Kode, rtlat, reverse,
                        strike, dipangle, top, bottom, comment
                    ] = read_fault_line(line)
                    rake = fixed_rake
                    one_receiver_object = coulomb_collections.Faults_object(
                        xstart=xstart,
                        xfinish=xfinish,
                        ystart=ystart,
                        yfinish=yfinish,
                        Kode=Kode,
                        rtlat=0,
                        reverse=0,
                        potency=[],
                        strike=strike,
                        dipangle=dipangle,
                        rake=rake,
                        top=top,
                        bottom=bottom,
                        comment=comment)
                    receivers.append(one_receiver_object)
        # Moving into Grid Parameters and Map Information
        if 'Grid Parameters' in line:
            read_grid = 1
            continue
        if read_grid == 1:
            if '  1  -' in line:
                start_gridx = float(temp[-1])
            elif '  2  -' in line:
                start_gridy = float(temp[-1])
            elif '  3  -' in line:
                finish_gridx = float(temp[-1])
            elif '  4  -' in line:
                finish_gridy = float(temp[-1])
            elif '  5  -' in line:
                xinc = float(temp[-1])
            elif '  6  -' in line:
                yinc = float(temp[-1])
            else:
                read_grid = 0
                continue
    ifile.close()

    input_obj = coulomb_collections.Input_object(PR1=PR1,
                                                 FRIC=FRIC,
                                                 depth=depth,
                                                 start_gridx=start_gridx,
                                                 finish_gridx=finish_gridx,
                                                 start_gridy=start_gridy,
                                                 finish_gridy=finish_gridy,
                                                 xinc=xinc,
                                                 yinc=yinc,
                                                 minlon=minlon,
                                                 maxlon=maxlon,
                                                 zerolon=zerolon,
                                                 minlat=minlat,
                                                 maxlat=maxlat,
                                                 zerolat=zerolat,
                                                 receiver_object=receivers,
                                                 source_object=sources)

    return input_obj
Ejemplo n.º 7
0
def read_intxt(input_file):
    print("Reading source and receiver fault information from file %s " %
          input_file)
    sources = []
    receivers = []
    ifile = open(input_file, 'r')
    for line in ifile:
        temp = line.split()
        if len(temp) == 0:
            continue
        if temp[0] == 'S:':
            [strike, rake, dip, lon, lat, depth, magnitude, mu,
             lame1] = read_point_source_line(line)
            [x, y, Kode, rtlat, reverse, potency, comment
             ] = compute_params_for_point_source(strike, dip, rake, magnitude,
                                                 lon, lat, zerolon, zerolat,
                                                 mu, lame1)
            one_source_object = coulomb_collections.Faults_object(
                xstart=x,
                xfinish=x,
                ystart=y,
                yfinish=y,
                Kode=Kode,
                rtlat=rtlat,
                reverse=reverse,
                potency=potency,
                strike=strike,
                dipangle=dip,
                rake=rake,
                top=depth,
                bottom=depth,
                comment=comment)
            sources.append(one_source_object)
        elif temp[0] == 'R:':
            [strike, rake, dip, L, W, fault_lon, fault_lat,
             fault_depth] = io_intxt.read_receiver_line(line)
            [
                xstart, xfinish, ystart, yfinish, Kode, rtlat, reverse, top,
                bottom, comment
            ] = io_intxt.compute_params_for_slip_source(
                strike, dip, rake, fault_depth, L, W, fault_lon, fault_lat, 0,
                zerolon, zerolat)
            one_receiver_object = coulomb_collections.Faults_object(
                xstart=xstart,
                xfinish=xfinish,
                ystart=ystart,
                yfinish=yfinish,
                Kode=Kode,
                rtlat=rtlat,
                reverse=reverse,
                potency=[],
                strike=strike,
                dipangle=dip,
                rake=rake,
                top=top,
                bottom=bottom,
                comment=comment)
            receivers.append(one_receiver_object)
        elif temp[0] == 'G:':
            [PR1, FRIC, minlon, maxlon, zerolon, minlat, maxlat,
             zerolat] = io_intxt.read_general_line(line)
        else:
            continue
    ifile.close()

    # Wrapping up the inputs
    [start_gridx, finish_gridx, start_gridy, finish_gridy, xinc,
     yinc] = io_intxt.compute_grid_parameters(minlon, maxlon, zerolon, minlat,
                                              maxlat, zerolat)
    input_obj = coulomb_collections.Input_object(PR1=PR1,
                                                 FRIC=FRIC,
                                                 depth=0,
                                                 start_gridx=start_gridx,
                                                 finish_gridx=finish_gridx,
                                                 start_gridy=start_gridy,
                                                 finish_gridy=finish_gridy,
                                                 xinc=xinc,
                                                 yinc=yinc,
                                                 minlon=minlon,
                                                 maxlon=maxlon,
                                                 zerolon=zerolon,
                                                 minlat=minlat,
                                                 maxlat=maxlat,
                                                 zerolat=zerolat,
                                                 receiver_object=receivers,
                                                 source_object=sources)
    return input_obj
Ejemplo n.º 8
0
def split_subfaults(params, inputs):
    receiver_object = inputs.receiver_object
    strike_split = params.strike_num_receivers
    dip_split = params.dip_num_receivers

    if strike_split == 1 and dip_split == 1:
        # If we're not splitting the subfaults...
        subfaulted_receivers = inputs.receiver_object
        print("Not subdividing receiver faults further.")
    else:
        print("Split %d receiver faults into %d subfaults each." %
              (len(receiver_object.xstart), strike_split * dip_split))
        new_xstart = []
        new_xfinish = []
        new_ystart = []
        new_yfinish = []
        new_Kode = []
        new_rtlat = []
        new_reverse = []
        new_strike = []
        new_dipangle = []
        new_rake = []
        new_top = []
        new_bottom = []
        new_comment = []

        for i in range(len(receiver_object.xstart)):
            # For each receiver...

            # We find the depths corresponding to the tops and bottoms of our new sub-faults
            zsplit_array = get_split_z_array(inputs.receiver_object.top[i],
                                             inputs.receiver_object.bottom[i],
                                             dip_split)
            x0 = inputs.receiver_object.xstart[i]
            y0 = inputs.receiver_object.ystart[i]
            x1 = inputs.receiver_object.xfinish[i]
            y1 = inputs.receiver_object.yfinish[i]

            for j in range(dip_split):
                # First we split it up by dip.

                # Get the new coordinates of the top of the fault plane.
                W = conversion_math.get_downdip_width(
                    inputs.receiver_object.top[i], zsplit_array[j],
                    inputs.receiver_object.dipangle[i])
                vector_mag = W * np.cos(
                    np.deg2rad(inputs.receiver_object.dipangle[i]))
                # how far the bottom edge is displaced downdip from map-view

                # Get the starting points for the next row of fault subpatches.
                [start_x_top,
                 start_y_top] = conversion_math.add_vector_to_point(
                     x0, y0, vector_mag, inputs.receiver_object.strike[i] + 90)
                [finish_x_top,
                 finish_y_top] = conversion_math.add_vector_to_point(
                     x1, y1, vector_mag, inputs.receiver_object.strike[i] + 90)

                [xsplit_array, ysplit_array
                 ] = get_split_x_y_arrays(start_x_top, finish_x_top,
                                          start_y_top, finish_y_top,
                                          strike_split)

                for k in range(strike_split):
                    new_xstart.append(xsplit_array[k])
                    new_xfinish.append(xsplit_array[k + 1])
                    new_ystart.append(ysplit_array[k])
                    new_yfinish.append(ysplit_array[k + 1])
                    new_Kode.append(receiver_object.Kode[i])
                    new_rtlat.append(receiver_object.rtlat[i])
                    new_reverse.append(receiver_object.reverse[i])
                    new_strike.append(receiver_object.strike[i])
                    new_dipangle.append(receiver_object.dipangle[i])
                    new_rake.append(receiver_object.rake[i])
                    new_top.append(zsplit_array[j])
                    new_bottom.append(zsplit_array[j + 1])
                    new_comment.append(receiver_object.comment[i])

        subfaulted_receivers = coulomb_collections.Faults_object(
            xstart=new_xstart,
            xfinish=new_xfinish,
            ystart=new_ystart,
            yfinish=new_yfinish,
            Kode=new_Kode,
            rtlat=new_rtlat,
            reverse=new_reverse,
            strike=new_strike,
            dipangle=new_dipangle,
            rake=new_rake,
            top=new_top,
            bottom=new_bottom,
            comment=new_comment)

    subfaulted_inputs = coulomb_collections.Input_object(
        PR1=inputs.PR1,
        FRIC=inputs.FRIC,
        depth=inputs.depth,
        start_gridx=inputs.start_gridx,
        finish_gridx=inputs.finish_gridx,
        start_gridy=inputs.start_gridy,
        finish_gridy=inputs.finish_gridy,
        xinc=inputs.xinc,
        yinc=inputs.yinc,
        minlon=inputs.minlon,
        maxlon=inputs.maxlon,
        zerolon=inputs.zerolon,
        minlat=inputs.minlat,
        maxlat=inputs.maxlat,
        zerolat=inputs.zerolat,
        source_object=inputs.source_object,
        receiver_object=subfaulted_receivers)

    return subfaulted_inputs