예제 #1
0
def tk03(n=100,dec=0,lat=0,rev='no',G2=0,G3=0):
    """
    generates set of vectors drawn from the TK03.gad model of 
    secular variation at given latitude and rotated about vertical 
    axis by given declination 

    Parameters
    ----------
    n number of vectors to determine (default is 100)
    dec mean declination of data set (default is 0)
    lat latitude at which secular variation is simulated (default is 0)
    rev if reversals are to be included this should be 'yes' (default is 'no')
    G2 specify average g_2^0 fraction (default is 0)
    G3 specify average g_3^0 fraction (default is 0)
    """
    tk_03_output=[]
    for k in range(n): 
        gh=pmag.mktk03(8,k,G2,G3) # terms and random seed
        long=random.randint(0,360) # get a random longitude, between 0 and 359
        vec= pmag.getvec(gh,lat,long)  # send field model and lat to getvec
        vec[0]+=dec
        if vec[0]>=360.:
            vec[0]-=360.
        if k%2==0 and rev=='yes':
           vec[0]+=180.
           vec[1]=-vec[1]
        tk_03_output.append([vec[0],vec[1],vec[2]])    
    return tk_03_output
예제 #2
0
파일: tk03.py 프로젝트: headmetal/PmagPy
def main():
    """
    NAME
        tk03.py

    DESCRIPTION
        generates set of vectors drawn from TK03.gad at given lat and
        rotated about vertical axis by given Dec 

    INPUT (COMMAND LINE ENTRY and interactive)
    OUTPUT
        dec,  inc, int   

    SYNTAX
        tk03.py [command line options] [> OutputFileName]

    OPTIONS
        -n N specify N, default is 100
        -d D specify mean Dec, default is 0
        -lat LAT specify latitude, default is 0
        -rev include reversals
        -t INT  truncates  intensities to >INT uT
        -G2 FRAC  specify average g_2^0 fraction (default is 0)
        -G3 FRAC  specify average g_3^0 fraction (default is 0)
    """
    N,L,D,R=100,0.,0.,0
    G2,G3=0.,0.
    cnt=1
    Imax=0
    if len(sys.argv)!=0 and  '-h' in sys.argv:
        print main.__doc__
        sys.exit()
    else:
        if '-n' in sys.argv:
            ind=sys.argv.index('-n')
            N=int(sys.argv[ind+1])
        if '-d' in sys.argv:
            ind=sys.argv.index('-d')
            D=float(sys.argv[ind+1])
        if '-lat' in sys.argv:
            ind=sys.argv.index('-lat')
            L=float(sys.argv[ind+1])
        if '-t' in sys.argv:
            ind=sys.argv.index('-t')
            Imax=1e3*float(sys.argv[ind+1])
        if '-rev' in sys.argv: R=1
        if '-G2' in sys.argv:
            ind=sys.argv.index('-G2')
            G2=float(sys.argv[ind+1])
        if '-G3' in sys.argv:
            ind=sys.argv.index('-G3')
            G3=float(sys.argv[ind+1])
    for k in range(N): 
        gh=pmag.mktk03(8,k,G2,G3) # terms and random seed
        long=random.randint(0,359) # get a random longitude, between 0 and 359
        vec= pmag.getvec(gh,L,long)  # send field model and lat to getvec
        if vec[2]>=Imax:
            vec[0]+=D
            if k%2==0 and R==1:
               vec[0]+=180.
               vec[1]=-vec[1]
            if vec[0]>=360.:vec[0]-=360.
            print'%7.1f %7.1f %8.2f ' % (vec[0],vec[1],vec[2])