Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
slip_unrectified,success=fakequakes.make_KL_slip(fault_array,num_modes,eigenvals,V,mean_slip,max_slip,lognormal=False,seed=None)
slip,rejected,percent_negative=fakequakes.rectify_slip(slip_unrectified,percent_reject=13)
if rejected==True:
print('... ... ... negative slip threshold exceeeded with %d%% negative slip. Recomputing...' % (percent_negative))
else:
#Get lognormal values
C_log,mean_slip_log=fakequakes.get_lognormal(mean_slip,C,target_Mw[kmag],fault_array,vel_mod_file,slip_standard_deviation)
#Get eigen values and eigenvectors
eigenvals,V=fakequakes.get_eigen(C_log)
#Generate fake slip pattern
# slip,success=make_KL_slip(fault_array,num_modes,eigenvals,V,mean_slip_log,max_slip,lognormal=True,seed=kfault)
slip,success=fakequakes.make_KL_slip(fault_array,num_modes,eigenvals,V,mean_slip_log,max_slip,lognormal=True,seed=None)
#Slip pattern sucessfully made, moving on.
#Rigidities
foo,mu=fakequakes.get_mean_slip(target_Mw[kmag],whole_fault,vel_mod_file)
fault_out[:,13]=mu
#Calculate moment and magnitude of fake slip pattern
M0=sum(slip*fault_out[ifaults,10]*fault_out[ifaults,11]*mu[ifaults])
Mw=(2./3)*(log10(M0)-9.1)
#Check max_slip_rule
if max_slip_rule==True:
max_slip_from_rule=10**(-4.94+0.71*Mw) #From Allen & Hayes, 2017
max_slip_tolerance = 3
if slip.max() > max_slip_tolerance*max_slip_from_rule:
success = False
print('... ... ... max slip condition violated max_slip_rule, recalculating...')
Ls=17.7+0.34*Leff
else:
Ls=Lstrike
if Ldip=='auto': #Use scaling
#Ld=10**(-1.79+0.38*target_Mw)
Ld=1.0+(1./3)*Weff
elif Ldip=='MH2019':
Ld=6.8+0.4*Weff
else:
Ld=Ldip
#Get the mean uniform slip for the target magnitude
if mean_slip_name==None:
mean_slip,mu=fakequakes.get_mean_slip(target_Mw[kmag],fault_array,vel_mod_file)
else:
foo,mu=fakequakes.get_mean_slip(target_Mw[kmag],fault_array,vel_mod_file)
mean_fault=genfromtxt(mean_slip_name)
mean_slip=(mean_fault[:,8]**2+mean_fault[:,9]**2)**0.5
#keep onlt faults that have man slip inside the fault_array seelcted faults
mean_slip=mean_slip[ifaults]
#get the area in those selected faults
area=fault_array[:,-2]*fault_array[:,-1]
#get the moment in those selected faults
moment_on_selected=(area*mu*mean_slip).sum()
#target moment
target_moment=10**(1.5*target_Mw[kmag]+9.1)
#How much do I need to upscale?