def main(): """ NAME foldtest.py DESCRIPTION does a fold test (Tauxe, 2010) on data INPUT FORMAT dec inc dip_direction dip SYNTAX foldtest.py [command line options] OPTIONS -h prints help message and quits -f FILE file with input data -F FILE for confidence bounds on fold test -u ANGLE (circular standard deviation) for uncertainty on bedding poles -b MIN MAX bounds for quick search of percent untilting [default is -10 to 150%] -n NB number of bootstrap samples [default is 1000] -fmt FMT, specify format - default is svg OUTPUT PLOTS Geographic: is an equal area projection of the input data in original coordinates Stratigraphic: is an equal area projection of the input data in tilt adjusted coordinates % Untilting: The dashed (red) curves are representative plots of maximum eigenvalue (tau_1) as a function of untilting The solid line is the cumulative distribution of the % Untilting required to maximize tau for all the bootstrapped data sets. The dashed vertical lines are 95% confidence bounds on the % untilting that yields the most clustered result (maximum tau_1). Command line: prints out the bootstrapped iterations and finally the confidence bounds on optimum untilting. If the 95% conf bounds include 0, then a pre-tilt magnetization is indicated If the 95% conf bounds include 100, then a post-tilt magnetization is indicated If the 95% conf bounds exclude both 0 and 100, syn-tilt magnetization is possible as is vertical axis rotation or other pathologies Geographic: is an equal area projection of the input data in OPTIONAL OUTPUT FILE: The output file has the % untilting within the 95% confidence bounds nd the number of bootstrap samples """ kappa=0 fmt='svg' nb=1000 # number of bootstraps min,max=-10,150 if '-h' in sys.argv: # check if help is needed print main.__doc__ sys.exit() # graceful quit if '-F' in sys.argv: ind=sys.argv.index('-F') outfile=open(sys.argv[ind+1],'w') else: outfile="" if '-f' in sys.argv: ind=sys.argv.index('-f') file=sys.argv[ind+1] DIDDs=numpy.loadtxt(file) else: print main.__doc__ sys.exit() if '-fmt' in sys.argv: ind=sys.argv.index('-fmt') fmt=sys.argv[ind+1] if '-b' in sys.argv: ind=sys.argv.index('-b') min=float(sys.argv[ind+1]) max=float(sys.argv[ind+2]) if '-n' in sys.argv: ind=sys.argv.index('-n') nb=int(sys.argv[ind+1]) if '-u' in sys.argv: ind=sys.argv.index('-u') csd=float(sys.argv[ind+1]) kappa=(81./csd)**2 # # get to work # PLTS={'geo':1,'strat':2,'taus':3} # make plot dictionary pmagplotlib.plot_init(PLTS['geo'],5,5) pmagplotlib.plot_init(PLTS['strat'],5,5) pmagplotlib.plot_init(PLTS['taus'],5,5) pmagplotlib.plotEQ(PLTS['geo'],DIDDs,'Geographic') D,I=pmag.dotilt_V(DIDDs) TCs=numpy.array([D,I]).transpose() pmagplotlib.plotEQ(PLTS['strat'],TCs,'Stratigraphic') pmagplotlib.drawFIGS(PLTS) Percs=range(min,max) Cdf,Untilt=[],[] pylab.figure(num=PLTS['taus']) print 'doing ',nb,' iterations...please be patient.....' for n in range(nb): # do bootstrap data sets - plot first 25 as dashed red line if n%50==0:print n Taus=[] # set up lists for taus PDs=pmag.pseudo(DIDDs) if kappa!=0: for k in range(len(PDs)): d,i=pmag.fshdev(kappa) dipdir,dip=pmag.dodirot(d,i,PDs[k][2],PDs[k][3]) PDs[k][2]=dipdir PDs[k][3]=dip for perc in Percs: tilt=numpy.array([1.,1.,1.,0.01*perc]) D,I=pmag.dotilt_V(PDs*tilt) TCs=numpy.array([D,I]).transpose() ppars=pmag.doprinc(TCs) # get principal directions Taus.append(ppars['tau1']) if n<25:pylab.plot(Percs,Taus,'r--') Untilt.append(Percs[Taus.index(numpy.max(Taus))]) # tilt that gives maximum tau Cdf.append(float(n)/float(nb)) pylab.plot(Percs,Taus,'k') pylab.xlabel('% Untilting') pylab.ylabel('tau_1 (red), CDF (green)') Untilt.sort() # now for CDF of tilt of maximum tau pylab.plot(Untilt,Cdf,'g') lower=int(.025*nb) upper=int(.975*nb) pylab.axvline(x=Untilt[lower],ymin=0,ymax=1,linewidth=1,linestyle='--') pylab.axvline(x=Untilt[upper],ymin=0,ymax=1,linewidth=1,linestyle='--') tit= '%i - %i %s'%(Untilt[lower],Untilt[upper],'Percent Unfolding') print tit print 'range of all bootstrap samples: ', Untilt[0], ' - ', Untilt[-1] pylab.title(tit) outstring= '%i - %i; %i\n'%(Untilt[lower],Untilt[upper],nb) if outfile!="":outfile.write(outstring) pmagplotlib.drawFIGS(PLTS) ans= raw_input('S[a]ve all figures, <Return> to quit ') if ans!='a': print "Good bye" sys.exit() else: files={} for key in PLTS.keys(): files[key]=('foldtest_'+'%s'%(key.strip()[:2])+'.'+fmt) pmagplotlib.saveP(PLTS,files)
def main(): """ NAME find_EI.py DESCRIPTION Applies series of assumed flattening factor and "unsquishes" inclinations assuming tangent function. Finds flattening factor that gives elongation/inclination pair consistent with TK03. Finds bootstrap confidence bounds SYNTAX find_EI.py [command line options] OPTIONS -h prints help message and quits -i allows interactive input of file name -f FILE specify input file name -nb N specify number of bootstraps - the more the better, but slower!, default is 1000 -fmt [svg,png,eps,pdf..] change plot format, default is svg INPUT dec/inc pairs, delimited with space or tabs OUTPUT four plots: 1) equal area plot of original directions 2) Elongation/inclination pairs as a function of f, data plus 25 bootstrap samples 3) Cumulative distribution of bootstrapped optimal inclinations plus uncertainties. Estimate from original data set plotted as solid line 4) Orientation of principle direction through unflattening NOTE: If distribution does not have a solution, plot labeled: Pathological. Some bootstrap samples may have valid solutions and those are plotted in the CDFs and E/I plot. """ fmt,nb='svg',1000 if '-i' in sys.argv: file=raw_input("Enter file name for processing: ") elif '-f' in sys.argv: ind=sys.argv.index('-f') file=sys.argv[ind+1] else: print main.__doc__ sys.exit() if '-nb' in sys.argv: ind=sys.argv.index('-nb') nb=int(sys.argv[ind+1]) if '-fmt' in sys.argv: ind=sys.argv.index('-fmt') fmt=sys.argv[ind+1] data=numpy.loadtxt(file) upper,lower=int(round(.975*nb)),int(round(.025*nb)) E,I=[],[] PLTS={'eq':1,'ei':2,'cdf':3,'v2':4} pmagplotlib.plot_init(PLTS['eq'],6,6) pmagplotlib.plot_init(PLTS['ei'],5,5) pmagplotlib.plot_init(PLTS['cdf'],5,5) pmagplotlib.plot_init(PLTS['v2'],5,5) pmagplotlib.plotEQ(PLTS['eq'],data,'Data') pmagplotlib.drawFIGS(PLTS) ppars=pmag.doprinc(data) Io=ppars['inc'] n=ppars["N"] Es,Is,Fs,V2s=find_f(data) Inc,Elong=Is[-1],Es[-1] pmagplotlib.plotEI(PLTS['ei'],Es,Is,Fs[-1]) pmagplotlib.plotV2s(PLTS['v2'],V2s,Is,Fs[-1]) b=0 print "Bootstrapping.... be patient" while b<nb: bdata=pmag.pseudo(data) Es,Is,Fs,V2s=find_f(bdata) if b<25: pmagplotlib.plotEI(PLTS['ei'],Es,Is,Fs[-1]) if Es[-1]!=0: ppars=pmag.doprinc(bdata) I.append(abs(Is[-1])) E.append(Es[-1]) b+=1 if b%25==0:print b,' out of ',nb I.sort() E.sort() Eexp=[] for i in I: Eexp.append(EI(i)) if Inc==0: title= 'Pathological Distribution: '+'[%7.1f, %7.1f]' %(I[lower],I[upper]) else: title= '%7.1f [%7.1f, %7.1f]' %( Inc, I[lower],I[upper]) pmagplotlib.plotEI(PLTS['ei'],Eexp,I,1) pmagplotlib.plotCDF(PLTS['cdf'],I,'Inclinations','r',title) pmagplotlib.plotVs(PLTS['cdf'],[I[lower],I[upper]],'b','--') pmagplotlib.plotVs(PLTS['cdf'],[Inc],'g','-') pmagplotlib.plotVs(PLTS['cdf'],[Io],'k','-') pmagplotlib.drawFIGS(PLTS) print "Io Inc I_lower, I_upper, Elon, E_lower, E_upper" print '%7.1f %s %7.1f _ %7.1f ^ %7.1f: %6.4f _ %6.4f ^ %6.4f' %(Io, " => ", Inc, I[lower],I[upper], Elong, E[lower],E[upper]) ans= raw_input("S[a]ve plots - <return> to quit: ") if ans!='a': print "\n Good bye\n" sys.exit() files={} files['eq']='findEI_eq.'+fmt files['ei']='findEI_ei.'+fmt files['cdf']='findEI_cdf.'+fmt files['v2']='findEI_v2.'+fmt pmagplotlib.saveP(PLTS,files)
def main(): """ NAME foldtest_magic.py DESCRIPTION does a fold test (Tauxe, 2007) on data INPUT FORMAT pmag_specimens format file, er_samples.txt format file (for bedding) SYNTAX foldtest_magic.py [command line options] OPTIONS -h prints help message and quits -f pmag_sites formatted file [default is pmag_sites.txt] -fsa er_samples formatted file [default is er_samples.txt] -exc use pmag_criteria.txt to set acceptance criteria -n NB, set number of bootstraps, default is 500 -b MIN, MAX, set bounds for untilting, default is -10, 150 OUTPUT Geographic: is an equal area projection of the input data in original coordinates Stratigraphic: is an equal area projection of the input data in tilt adjusted coordinates % Untilting: The dashed (red) curves are representative plots of maximum eigenvalue (tau_1) as a function of untilting The solid line is the cumulative distribution of the % Untilting required to maximize tau for all the bootstrapped data sets. The dashed vertical lines are 95% confidence bounds on the % untilting that yields the most clustered result (maximum tau_1). Command line: prints out the bootstrapped iterations and finally the confidence bounds on optimum untilting. If the 95% conf bounds include 0, then a pre-tilt magnetization is indicated If the 95% conf bounds include 100, then a post-tilt magnetization is indicated If the 95% conf bounds exclude both 0 and 100, syn-tilt magnetization is possible as is vertical axis rotation or other pathologies """ kappa=0 nb=500 # number of bootstraps min,max=-10,150 dir_path='.' infile,orfile='pmag_sites.txt','er_samples.txt' critfile='pmag_criteria.txt' if '-WD' in sys.argv: ind=sys.argv.index('-WD') dir_path=sys.argv[ind+1] if '-h' in sys.argv: # check if help is needed print main.__doc__ sys.exit() # graceful quit if '-n' in sys.argv: ind=sys.argv.index('-n') nb=int(sys.argv[ind+1]) if '-b' in sys.argv: ind=sys.argv.index('-b') min=int(sys.argv[ind+1]) max=int(sys.argv[ind+2]) if '-f' in sys.argv: ind=sys.argv.index('-f') infile=sys.argv[ind+1] if '-fsa' in sys.argv: ind=sys.argv.index('-fsa') orfile=sys.argv[ind+1] orfile=dir_path+'/'+orfile infile=dir_path+'/'+infile critfile=dir_path+'/'+critfile data,file_type=pmag.magic_read(infile) ordata,file_type=pmag.magic_read(orfile) if '-exc' in sys.argv: crits,file_type=pmag.magic_read(critfile) for crit in crits: if crit['pmag_criteria_code']=="DE-SITE": SiteCrit=crit break # get to work # PLTS={'geo':1,'strat':2,'taus':3} # make plot dictionary pmagplotlib.plot_init(PLTS['geo'],5,5) pmagplotlib.plot_init(PLTS['strat'],5,5) pmagplotlib.plot_init(PLTS['taus'],5,5) DIDDs= [] # set up list for dec inc dip_direction, dip for rec in data: # read in the data from standard input if eval(rec['site_tilt_correction'])==0: dip,dip_dir=0,-1 Dec=float(rec['site_dec']) Inc=float(rec['site_inc']) for orec in ordata: if orec['er_site_name']==rec['er_site_name']: if orec['sample_bed_dip_direction']!="":dip_dir=float(orec['sample_bed_dip_direction']) if orec['sample_bed_dip']!="":dip=float(orec['sample_bed_dip']) break if dip!=0 and dip_dir!=-1: if '-exc' in sys.argv: keep=1 for key in SiteCrit.keys(): if 'site' in key and SiteCrit[key]!="" and rec[key]!="" and key!='site_alpha95': if float(rec[key])<float(SiteCrit[key]): keep=0 print rec['er_site_name'],key,rec[key] if key=='site_alpha95' and SiteCrit[key]!="" and rec[key]!="": if float(rec[key])>float(SiteCrit[key]): keep=0 if keep==1: DIDDs.append([Dec,Inc,dip_dir,dip]) else: DIDDs.append([Dec,Inc,dip_dir,dip]) pmagplotlib.plotEQ(PLTS['geo'],DIDDs,'Geographic') TCs=[] for k in range(len(DIDDs)): drot,irot=pmag.dotilt(DIDDs[k][0],DIDDs[k][1],DIDDs[k][2],DIDDs[k][3]) TCs.append([drot,irot,1.]) pmagplotlib.plotEQ(PLTS['strat'],TCs,'Stratigraphic') Percs=range(min,max) Cdf,Untilt=[],[] pylab.figure(num=PLTS['taus']) print 'doing ',nb,' iterations...please be patient.....' for n in range(nb): # do bootstrap data sets - plot first 25 as dashed red line if n%50==0:print n Taus=[] # set up lists for taus PDs=pmag.pseudo(DIDDs) for perc in Percs: tilt=0.01*perc TCs=[] for k in range(len(PDs)): drot,irot=pmag.dotilt(PDs[k][0],PDs[k][1],PDs[k][2],tilt*PDs[k][3]) TCs.append([drot,irot,1.]) ppars=pmag.doprinc(TCs) # get principal directions Taus.append(ppars['tau1']) if n<25:pylab.plot(Percs,Taus,'r--') Untilt.append(Percs[Taus.index(numpy.max(Taus))]) # tilt that gives maximum tau Cdf.append(float(n)/float(nb)) pylab.plot(Percs,Taus,'k') pylab.xlabel('% Untilting') pylab.ylabel('tau_1 (red), CDF (green)') Untilt.sort() # now for CDF of tilt of maximum tau pylab.plot(Untilt,Cdf,'g') lower=int(.025*nb) upper=int(.975*nb) pylab.axvline(x=Untilt[lower],ymin=0,ymax=1,linewidth=1,linestyle='--') pylab.axvline(x=Untilt[upper],ymin=0,ymax=1,linewidth=1,linestyle='--') tit= '%i - %i %s'%(Untilt[lower],Untilt[upper],'Percent Unfolding') print tit pylab.title(tit) try: raw_input('Return to save all figures, cntl-d to quit\n') except EOFError: print "Good bye" sys.exit() files={} for key in PLTS.keys(): files[key]=('fold_'+'%s'%(key.strip()[:2])+'.svg') pmagplotlib.saveP(PLTS,files)
def main(): """ NAME foldtest.py DESCRIPTION does a fold test (Tauxe, 2007) on data INPUT FORMAT dec inc dip_direction dip SYNTAX foldtest.py [-h][-i][command line options] OPTIONS -h prints help message and quits -i for interactive parameter entry -f FILE OUTPUT Geographic: is an equal area projection of the input data in original coordinates Stratigraphic: is an equal area projection of the input data in tilt adjusted coordinates % Untilting: The dashed (red) curves are representative plots of maximum eigenvalue (tau_1) as a function of untilting The solid line is the cumulative distribution of the % Untilting required to maximize tau for all the bootstrapped data sets. The dashed vertical lines are 95% confidence bounds on the % untilting that yields the most clustered result (maximum tau_1). Command line: prints out the bootstrapped iterations and finally the confidence bounds on optimum untilting. If the 95% conf bounds include 0, then a pre-tilt magnetization is indicated If the 95% conf bounds include 100, then a post-tilt magnetization is indicated If the 95% conf bounds exclude both 0 and 100, syn-tilt magnetization is possible as is vertical axis rotation or other pathologies """ if '-h' in sys.argv: # check if help is needed print main.__doc__ sys.exit() # graceful quit if '-i' in sys.argv: # ask for filename file=raw_input("Enter file name with dec, inc dip_direction and dip data: ") f=open(file,'rU') data=f.readlines() elif '-f' in sys.argv: ind=sys.argv.index('-f') file=sys.argv[ind+1] f=open(file,'rU') data=f.readlines() else: print main.__doc__ sys.exit() # # get to work # PLTS={'geo':1,'strat':2,'taus':3,'ei':4} # make plot dictionary pmagplotlib.plot_init(PLTS['geo'],5,5) pmagplotlib.plot_init(PLTS['strat'],5,5) pmagplotlib.plot_init(PLTS['taus'],5,5) pmagplotlib.plot_init(PLTS['ei'],5,5) DIDDs= [] # set up list for dec inc dip_direction, dip nb=100 # number of bootstraps for line in data: # read in the data from standard input rec=line.split() # split each line on space to get records DIDDs.append([float(rec[0]),float(rec[1]),float(rec[2]),float(rec[3])]) pmagplotlib.plotEQ(PLTS['geo'],DIDDs,'Geographic') TCs,Ps,Taus,Es,Is=[],[],[],[],[] for k in range(len(DIDDs)): drot,irot=pmag.dotilt(DIDDs[k][0],DIDDs[k][1],DIDDs[k][2],DIDDs[k][3]) TCs.append([drot,irot,1.]) pmagplotlib.plotEQ(PLTS['strat'],TCs,'Stratigraphic') Percs=range(-10,110) for perc in Percs: tilt=0.01*perc TCs=[] for k in range(len(DIDDs)): drot,irot=pmag.dotilt(DIDDs[k][0],DIDDs[k][1],DIDDs[k][2],tilt*DIDDs[k][3]) TCs.append([drot,irot,1.]) ppars=pmag.doprinc(TCs) # get principal directions Taus.append(ppars['tau1']) Es.append(ppars["tau2"]/ppars["tau3"]) Is.append(ppars["inc"]) if int(10*(EI(ppars["inc"])))==int(10*Es[-1]): print EI(ppars["inc"]),Es[-1],perc Ps.append(perc) pylab.figure(num=PLTS['taus']) pylab.plot(Percs,Taus,'b-') pylab.figure(num=PLTS['ei']) pylab.plot(Es,Is,'b-') Is.sort() Eexp=[] for i in Is: Eexp.append(EI(i)) pylab.plot(Eexp,Is,'g-') Cdf,Untilt=[],[] print 'doing ',nb,' iterations...please be patient.....' for n in range(nb): # do bootstrap data sets - plot first 25 as dashed red line Es,Is=[],[] if n%50==0:print n Taus=[] # set up lists for taus PDs=pmag.pseudo(DIDDs) for perc in Percs: tilt=0.01*perc TCs=[] for k in range(len(PDs)): drot,irot=pmag.dotilt(PDs[k][0],PDs[k][1],PDs[k][2],tilt*PDs[k][3]) TCs.append([drot,irot,1.]) ppars=pmag.doprinc(TCs) # get principal directions Taus.append(ppars['tau1']) Es.append(ppars["tau2"]/ppars["tau3"]) Is.append(ppars["inc"]) if int(10*(EI(ppars["inc"])))==int(10*Es[-1]): Ps.append(perc) if n<25: pylab.figure(num=PLTS['taus']) pylab.plot(Percs,Taus,'r--') pylab.figure(num=PLTS['ei']) pylab.plot(Es,Is,'r--') Untilt.append(Percs[Taus.index(pylab.max(Taus))]) # tilt that gives maximum tau Cdf.append(float(n)/float(nb)) pylab.figure(num=PLTS['taus']) pylab.plot(Percs,Taus,'k') pylab.xlabel('% Untilting') pylab.ylabel('tau_1 (red), CDF (green)') Untilt.sort() # now for CDF of tilt of maximum tau Ps.sort() pylab.plot(Untilt,Cdf,'g') lower=int(.025*nb) upper=int(.975*nb) pylab.axvline(x=Untilt[lower],ymin=0,ymax=1,linewidth=1,linestyle='--') pylab.axvline(x=Untilt[upper],ymin=0,ymax=1,linewidth=1,linestyle='--') tit= '%i - %i %s'%(Untilt[lower],Untilt[upper],'Percent Unfolding') pylab.title(tit) print Ps[lower],Ps[upper] pmagplotlib.drawFIGS(PLTS) try: raw_input('Return to save all figures, cntl-d to quit\n') except EOFError: print "Good bye" sys.exit() files={} for key in PLTS.keys(): files[key]=('fold_'+'%s'%(key.strip()[:2])+'.svg') pmagplotlib.saveP(PLTS,files)
def main(): """ NAME foldtest.py DESCRIPTION does a fold test (Tauxe, 2008) on data INPUT FORMAT dec inc dip_direction dip SYNTAX foldtest.py [command line options] OPTIONS -h prints help message and quits -f FILE -u ANGLE (circular standard deviation) for uncertainty on bedding poles -b MIN MAX bounds for quick search of percent untilting [default is -10 to 150%] -n NB number of bootstrap samples [default is 1000] OUTPUT Geographic: is an equal area projection of the input data in original coordinates Stratigraphic: is an equal area projection of the input data in tilt adjusted coordinates % Untilting: The dashed (red) curves are representative plots of maximum eigenvalue (tau_1) as a function of untilting The solid line is the cumulative distribution of the % Untilting required to maximize tau for all the bootstrapped data sets. The dashed vertical lines are 95% confidence bounds on the % untilting that yields the most clustered result (maximum tau_1). Command line: prints out the bootstrapped iterations and finally the confidence bounds on optimum untilting. If the 95% conf bounds include 0, then a pre-tilt magnetization is indicated If the 95% conf bounds include 100, then a post-tilt magnetization is indicated If the 95% conf bounds exclude both 0 and 100, syn-tilt magnetization is possible as is vertical axis rotation or other pathologies """ kappa=0 nb=1000 # number of bootstraps min,max=-10,150 if '-h' in sys.argv: # check if help is needed print main.__doc__ sys.exit() # graceful quit if '-f' in sys.argv: ind=sys.argv.index('-f') file=sys.argv[ind+1] f=open(file,'rU') data=f.readlines() else: print main.__doc__ sys.exit() if '-b' in sys.argv: ind=sys.argv.index('-b') min=float(sys.argv[ind+1]) max=float(sys.argv[ind+2]) if '-n' in sys.argv: ind=sys.argv.index('-n') nb=int(sys.argv[ind+1]) if '-u' in sys.argv: ind=sys.argv.index('-u') csd=float(sys.argv[ind+1]) kappa=(81./csd)**2 # # get to work # PLTS={'geo':1,'strat':2,'taus':3} # make plot dictionary pmagplotlib.plot_init(PLTS['geo'],5,5) pmagplotlib.plot_init(PLTS['strat'],5,5) pmagplotlib.plot_init(PLTS['taus'],5,5) DIDDs= [] # set up list for dec inc dip_direction, dip for line in data: # read in the data from standard input rec=line.split() # split each line on space to get records DIDDs.append([float(rec[0]),float(rec[1]),float(rec[2]),float(rec[3])]) pmagplotlib.plotEQ(PLTS['geo'],DIDDs,'Geographic') TCs=[] for k in range(len(DIDDs)): drot,irot=pmag.dotilt(DIDDs[k][0],DIDDs[k][1],DIDDs[k][2],DIDDs[k][3]) TCs.append([drot,irot,1.]) pmagplotlib.plotEQ(PLTS['strat'],TCs,'Stratigraphic') Percs=range(min,max) Cdf,Untilt=[],[] pylab.figure(num=PLTS['taus']) print 'doing ',nb,' iterations...please be patient.....' for n in range(nb): # do bootstrap data sets - plot first 25 as dashed red line if n%50==0:print n Taus=[] # set up lists for taus PDs=pmag.pseudo(DIDDs) if kappa!=0: for k in range(len(PDs)): d,i=pmag.fshdev(kappa) dipdir,dip=pmag.dodirot(d,i,PDs[k][2],PDs[k][3]) PDs[k][2]=dipdir PDs[k][3]=dip for perc in Percs: tilt=0.01*perc TCs=[] for k in range(len(PDs)): drot,irot=pmag.dotilt(PDs[k][0],PDs[k][1],PDs[k][2],tilt*PDs[k][3]) TCs.append([drot,irot,1.]) ppars=pmag.doprinc(TCs) # get principal directions Taus.append(ppars['tau1']) if n<25:pylab.plot(Percs,Taus,'r--') Untilt.append(Percs[Taus.index(numpy.max(Taus))]) # tilt that gives maximum tau Cdf.append(float(n)/float(nb)) pylab.plot(Percs,Taus,'k') pylab.xlabel('% Untilting') pylab.ylabel('tau_1 (red), CDF (green)') Untilt.sort() # now for CDF of tilt of maximum tau pylab.plot(Untilt,Cdf,'g') lower=int(.025*nb) upper=int(.975*nb) pylab.axvline(x=Untilt[lower],ymin=0,ymax=1,linewidth=1,linestyle='--') pylab.axvline(x=Untilt[upper],ymin=0,ymax=1,linewidth=1,linestyle='--') tit= '%i - %i %s'%(Untilt[lower],Untilt[upper],'Percent Unfolding') print tit print 'range of all bootstrap samples: ', Untilt[0], ' - ', Untilt[-1] pylab.title(tit) try: raw_input('Return to save all figures, cntl-d to quit\n') except: print "Good bye" sys.exit() files={} for key in PLTS.keys(): files[key]=('fold_'+'%s'%(key.strip()[:2])+'.svg') pmagplotlib.saveP(PLTS,files)