Esempio n. 1
0
def main():
    """
    NAME
       revtest.py

    DESCRIPTION
       calculates bootstrap statistics to test for antipodality

    INPUT FORMAT
       takes dec/inc as first two columns in space delimited file
   
    SYNTAX
       revtest.py [-h] [command line options]
    
    OPTION
       -h prints help message and quits
       -f FILE, sets input filename on command line
       -fmt [svg,png,jpg], sets format for image output
       -sav saves the figures silently and quits
               

    """
    fmt,plot='svg',0
    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]
        data=numpy.loadtxt(file).transpose()
        D=numpy.array([data[0],data[1]]).transpose()
    else: 
        print('-f is a required switch')
        print(main.__doc__)
        print(sys.exit())
    if '-fmt' in sys.argv:
        ind=sys.argv.index('-fmt')
        fmt=sys.argv[ind+1]
    if '-sav' in sys.argv:plot=1
# set up plots
    d=""
    CDF={'X':1,'Y':2,'Z':3}
    pmagplotlib.plot_init(CDF['X'],5,5)
    pmagplotlib.plot_init(CDF['Y'],5,5)
    pmagplotlib.plot_init(CDF['Z'],5,5)
#
# flip reverse mode
#
    D1,D2=pmag.flip(D)
    counter,NumSims=0,500
#
# get bootstrapped means for each data set
#
    print('doing first mode, be patient')
    BDI1=pmag.di_boot(D1)
    print('doing second mode, be patient')
    BDI2=pmag.di_boot(D2)
    pmagplotlib.plotCOM(CDF,BDI1,BDI2,[""])
    files={}
    for key in list(CDF.keys()):
        files[key]='REV'+'_'+key+'.'+fmt 
    if plot==0:
        pmagplotlib.drawFIGS(CDF)
        ans=  input("s[a]ve plots, [q]uit: ")
        if ans=='a':
            pmagplotlib.saveP(CDF,files)
        print('good bye')
        sys.exit()
    else:
        pmagplotlib.saveP(CDF,files)
Esempio n. 2
0
def main():
    """
    NAME
       revtest_magic.py

    DESCRIPTION
       calculates bootstrap statistics to test for antipodality

    INPUT FORMAT
       takes dec/inc data from pmag_sites table 
   
    SYNTAX
       revtest_magic.py [command line options]
    
    OPTION
       -h prints help message and quits
       -f FILE, sets pmag_sites filename on command line
       -crd [s,g,t], set coordinate system, default is geographic
       -exc use pmag_criteria.txt to set acceptance criteria
       -fmt [svg,png,jpg], sets format for image output
       -sav saves plot and quits               

    """
    D, fmt, plot = [], 'svg', 0
    coord = '0'
    infile = 'pmag_sites.txt'
    critfile = 'pmag_criteria.txt'
    dir_path = '.'
    if '-h' in sys.argv:  # check if help is needed
        print main.__doc__
        sys.exit()  # graceful quit
    if '-WD' in sys.argv:
        ind = sys.argv.index('-WD')
        dir_path = sys.argv[ind + 1]
    if '-sav' in sys.argv: plot = 1
    if '-f' in sys.argv:
        ind = sys.argv.index('-f')
        infile = sys.argv[ind + 1]
    if '-crd' in sys.argv:
        ind = sys.argv.index('-crd')
        coord = sys.argv[ind + 1]
        if coord == 's': coord = '-1'
        if coord == 'g': coord = '0'
        if coord == 't': coord = '100'
    if '-fmt' in sys.argv:
        ind = sys.argv.index('-fmt')
        fmt = sys.argv[ind + 1]
#
    infile = dir_path + '/' + infile
    critfile = dir_path + '/' + critfile
    Accept = ['site_k', 'site_alpha95', 'site_n', 'site_n_lines']
    data, file_type = pmag.magic_read(infile)
    if file_type != 'pmag_sites':
        print "Error opening file"
        sys.exit()
#    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
    for rec in data:
        if rec['site_tilt_correction'] == coord:
            Dec = float(rec['site_dec'])
            Inc = float(rec['site_inc'])
            if '-exc' in sys.argv:
                for key in Accept:
                    if SiteCrit[key] != "":
                        if float(rec[key]) <= float(SiteCrit[key]):
                            D.append([Dec, Inc, 1.])
            else:
                D.append([Dec, Inc, 1.])


# set up plots

    d = ""
    CDF = {'X': 1, 'Y': 2, 'Z': 3}
    pmagplotlib.plot_init(CDF['X'], 5, 5)
    pmagplotlib.plot_init(CDF['Y'], 5, 5)
    pmagplotlib.plot_init(CDF['Z'], 5, 5)
    #
    # flip reverse mode
    #
    D1, D2 = pmag.flip(D)
    counter, NumSims = 0, 500
    #
    # get bootstrapped means for each data set
    #
    if len(D1) < 5 or len(D2) < 5:
        print 'not enough data in two different modes for reversals test'
        sys.exit()
    print 'doing first mode, be patient'
    BDI1 = pmag.di_boot(D1)
    print 'doing second mode, be patient'
    BDI2 = pmag.di_boot(D2)
    pmagplotlib.plotCOM(CDF, BDI1, BDI2, [""])
    files = {}
    for key in CDF.keys():
        files[key] = 'REV' + '_' + key + '.' + fmt
    if plot == 0:
        pmagplotlib.drawFIGS(CDF)
        ans = raw_input("s[a]ve plots, [q]uit: ")
        if ans == 'a':
            pmagplotlib.saveP(CDF, files)
    else:
        pmagplotlib.saveP(CDF, files)
        sys.exit()
Esempio n. 3
0
def main():
    """
    NAME
       common_mean.py

    DESCRIPTION
       calculates bootstrap statistics to test for common mean

    INPUT FORMAT
       takes dec/inc as first two columns in two space delimited files
   
    SYNTAX
       common_mean.py [command line options]
    
    OPTIONS
       -h prints help message and quits
       -f FILE, input file 
       -f2 FILE, optional second file to compare with first file
       -dir D I, optional direction to compare with input file
       -fmt [svg,jpg,pnd,pdf] set figure format [default is svg]
    NOTES
       must have either F2 OR dir but not both
     

    """
    d,i,file2="","",""
    fmt,plot='svg',0
    if '-h' in sys.argv: # check if help is needed
        print(main.__doc__)
        sys.exit() # graceful quit
    if '-sav' in sys.argv: plot=1
    if '-fmt'  in sys.argv:
        ind=sys.argv.index('-fmt')
        fmt=sys.argv[ind+1]
    if '-f' in sys.argv:
        ind=sys.argv.index('-f')
        file1=sys.argv[ind+1]
    if '-f2' in sys.argv:
        ind=sys.argv.index('-f2')
        file2=sys.argv[ind+1]
    if '-dir' in sys.argv:
        ind=sys.argv.index('-dir')
        d=float(sys.argv[ind+1])
        i=float(sys.argv[ind+2])
    D1=numpy.loadtxt(file1,dtype=numpy.float)
    if file2!="": D2=numpy.loadtxt(file2,dtype=numpy.float)
#
    counter,NumSims=0,1000
#
# get bootstrapped means for first data set
#
    print("Doing first set of directions, please be patient..")
    BDI1=pmag.di_boot(D1)
#
#   convert to cartesian coordinates X1,X2, Y1,Y2 and Z1, Z2
#
    if d=="": # repeat for second data set
        print("Doing second  set of directions, please be patient..")
        BDI2=pmag.di_boot(D2)
    else:
        BDI2=[]
# set up plots
    CDF={'X':1,'Y':2,'Z':3}
    pmagplotlib.plot_init(CDF['X'],4,4)
    pmagplotlib.plot_init(CDF['Y'],4,4)
    pmagplotlib.plot_init(CDF['Z'],4,4)
# draw the cdfs
    pmagplotlib.plotCOM(CDF,BDI1,BDI2,[d,i])
    files={}
    files['X']='CD_X.'+fmt
    files['Y']='CD_Y.'+fmt
    files['Z']='CD_Z.'+fmt
    if plot==0:
        pmagplotlib.drawFIGS(CDF)
        ans=input("S[a]ve plots, <Return> to quit ")
        if ans=="a":
            pmagplotlib.saveP(CDF,files)
        else:
            sys.exit()
        
    else: 
        pmagplotlib.saveP(CDF,files)
        sys.exit()
Esempio n. 4
0
def main():
    """
    NAME
       revtest.py

    DESCRIPTION
       calculates bootstrap statistics to test for antipodality

    INPUT FORMAT
       takes dec/inc as first two columns in space delimited file
   
    SYNTAX
       revtest.py [-h] [command line options]
    
    OPTION
       -h prints help message and quits
       -f FILE, sets input filename on command line
       -fmt [svg,png,jpg], sets format for image output
       -sav saves the figures silently and quits
               

    """
    fmt, plot = 'svg', 0
    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]
        data = numpy.loadtxt(file).transpose()
        D = numpy.array([data[0], data[1]]).transpose()
    else:
        print '-f is a required switch'
        print main.__doc__
        print sys.exit()
    if '-fmt' in sys.argv:
        ind = sys.argv.index('-fmt')
        fmt = sys.argv[ind + 1]
    if '-sav' in sys.argv: plot = 1
    # set up plots
    d = ""
    CDF = {'X': 1, 'Y': 2, 'Z': 3}
    pmagplotlib.plot_init(CDF['X'], 5, 5)
    pmagplotlib.plot_init(CDF['Y'], 5, 5)
    pmagplotlib.plot_init(CDF['Z'], 5, 5)
    #
    # flip reverse mode
    #
    D1, D2 = pmag.flip(D)
    counter, NumSims = 0, 500
    #
    # get bootstrapped means for each data set
    #
    print 'doing first mode, be patient'
    BDI1 = pmag.di_boot(D1)
    print 'doing second mode, be patient'
    BDI2 = pmag.di_boot(D2)
    pmagplotlib.plotCOM(CDF, BDI1, BDI2, [""])
    files = {}
    for key in CDF.keys():
        files[key] = 'REV' + '_' + key + '.' + fmt
    if plot == 0:
        pmagplotlib.drawFIGS(CDF)
        ans = raw_input("s[a]ve plots, [q]uit: ")
        if ans == 'a':
            pmagplotlib.saveP(CDF, files)
        print 'good bye'
        sys.exit()
    else:
        pmagplotlib.saveP(CDF, files)
Esempio n. 5
0
def main():
    """
    NAME
       revtest_magic.py

    DESCRIPTION
       calculates bootstrap statistics to test for antipodality

    INPUT FORMAT
       takes dec/inc data from pmag_sites table 
   
    SYNTAX
       revtest_magic.py [command line options]
    
    OPTION
       -h prints help message and quits
       -f FILE, sets pmag_sites filename on command line
       -crd [s,g,t], set coordinate system, default is geographic
       -exc use pmag_criteria.txt to set acceptance criteria
       -fmt [svg,png,jpg], sets format for image output
       -sav saves plot and quits               

    """
    D,fmt,plot=[],'svg',0
    coord='0'
    infile='pmag_sites.txt'
    critfile='pmag_criteria.txt'
    dir_path='.'
    if '-h' in sys.argv: # check if help is needed
        print main.__doc__
        sys.exit() # graceful quit
    if '-WD' in sys.argv:
        ind=sys.argv.index('-WD')
        dir_path=sys.argv[ind+1]
    if '-sav' in sys.argv:plot=1
    if '-f' in sys.argv:
        ind=sys.argv.index('-f')
        infile=sys.argv[ind+1]
    if '-crd' in sys.argv:
        ind=sys.argv.index('-crd')
        coord=sys.argv[ind+1]
        if coord=='s':coord='-1'
        if coord=='g':coord='0'
        if coord=='t':coord='100'
    if '-fmt' in sys.argv:
        ind=sys.argv.index('-fmt')
        fmt=sys.argv[ind+1]
#
    infile=dir_path+'/'+infile
    critfile=dir_path+'/'+critfile
    Accept=['site_k','site_alpha95','site_n','site_n_lines']
    data,file_type=pmag.magic_read(infile)
    if file_type!='pmag_sites':
        print "Error opening file"
        sys.exit()
#    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
    for rec in data:
        if rec['site_tilt_correction']==coord:
            Dec=float(rec['site_dec'])
            Inc=float(rec['site_inc'])
            if  '-exc' in  sys.argv:
                for key in Accept:
                    if SiteCrit[key]!="":
                        if float(rec[key])<=float(SiteCrit[key]):     
                            D.append([Dec,Inc,1.])
            else:
                            D.append([Dec,Inc,1.])
# set up plots
    
    d=""
    CDF={'X':1,'Y':2,'Z':3}
    pmagplotlib.plot_init(CDF['X'],5,5)
    pmagplotlib.plot_init(CDF['Y'],5,5)
    pmagplotlib.plot_init(CDF['Z'],5,5)
#
# flip reverse mode
#
    D1,D2=pmag.flip(D)
    counter,NumSims=0,500
#
# get bootstrapped means for each data set
#
    if len(D1) < 5 or len(D2) < 5:
        print 'not enough data in two different modes for reversals test'
        sys.exit()
    print 'doing first mode, be patient'
    BDI1=pmag.di_boot(D1)
    print 'doing second mode, be patient'
    BDI2=pmag.di_boot(D2)
    pmagplotlib.plotCOM(CDF,BDI1,BDI2,[""])
    files={}
    for key in CDF.keys(): files[key]='REV'+'_'+key+'.'+fmt 
    if plot==0:
        pmagplotlib.drawFIGS(CDF)
        ans=  raw_input("s[a]ve plots, [q]uit: ")
        if ans=='a':
            pmagplotlib.saveP(CDF,files)
    else:
        pmagplotlib.saveP(CDF,files)
        sys.exit()