def run_analysis(filename,mode,method): click.echo('Reading file : %s'%filename) data = IOfile.parsing_input_file(filename) click.echo('Creating class...') theclass = TFC(data) click.echo('Calculating transfer function using %s method'%method) if method=='tf_kramer286_sh': theclass.tf_kramer286_sh() elif method=='tf_knopoff_sh': theclass.tf_knopoff_sh() elif method=='tf_knopoff_sh_adv': theclass.tf_knopoff_sh_adv() plt.plot(theclass.freq,np.abs(theclass.tf[0]),label=method) plt.xlabel('frequency (Hz)') plt.ylabel('Amplification') plt.yscale('log') plt.xscale('log') plt.grid(True,which='both') plt.legend(loc='best',fancybox=True,framealpha=0.5) #plt.axis('tight') plt.autoscale(True,axis='x',tight=True) plt.tight_layout() plt.savefig('test.png', format='png') click.echo(click.style('Calculation has been finished!',fg='green'))
def calc_knopoff_psv(data): theclass = TFC(data) theclass.tf_knopoff_psv_adv() return theclass
def calc_knopoff_sh(data): theclass = TFC(data) theclass.tf_knopoff_sh() return theclass
def calc_kramer(data): theclass = TFC(data) theclass.tf_kramer286_sh() return theclass
def calc_kennet(data): theclass = TFC(data) theclass.tf_kennet_sh() return theclass
from TFCalculator import TFCalculator as TFC import TFDisplayTools # validity test for SH PSV case using S wave as an input # filename fname = 'sampleinput_linear_elastic_1layer_halfspace.dat' fname2 = 'sampleinput_psv_s_linear_elastic_1layer_halfspace.dat' # input file reading datash = IOfile.parsing_input_file(fname) datapsvs = IOfile.parsing_input_file(fname2) # kramer print 'TF calculatoin using kramer approach' theclass1 = TFC(datash) theclass1.tf_kramer286_sh() # check/verify kramer calculation print 'calculation has been finished!' # knopoff sh complete print 'TF calculation using complete knopoff sh approach' theclass3 = TFC(datash) theclass3.tf_knopoff_sh_adv() print 'calculation has been finished!' # knopoff psv-s print 'TF calculation using complete knopoff psv-s approach' theclass4 = TFC(datapsvs) theclass4.tf_knopoff_psv_adv() print theclass4.tf[1][19] print 'calculation has been finished!'
print(' --> OK') #003 - Kramer Transfer Function print('003 - kramer TF') f.write('003 - kramer TF\n') f.write('fID\telapsedrd\tstdevrd\telapsed\tstdev\tsizetf\n') for iid in inputfileid: elapsedRead = [] elapsedTF = [] elapsedTFbytes = [] for i in range(ntest): start = time.clock() data = IOfile.parsing_input_file(inputlist[iid]) elapsedRead.append(time.clock()-start) data['inputmotion']='dirac.dat' theclass = TFC(data) start = time.clock() theclass.tf_kramer286_sh() elapsedTF.append(time.clock()-start) elapsedTFbytes.append(numpy.array(theclass.tf).nbytes) f.write('%d\t%.2e\t%.2e\t%.2e\t%.2e\t%d\t\n'%(iid,np.mean(elapsedRead),np.std(elapsedRead), np.mean(elapsedTF),np.std(elapsedTF),np.max(elapsedTFbytes))) f.write('\n') print(' --> OK') #004 - Knopoff SH simple Transfer Function print('004 - knopoff SH simple TF') f.write('004 - knopoff SH simple TF\n') f.write('fID\telapsedrd\tstdevrd\telapsed\tstdev\tsizetf\n') for iid in inputfileid: