code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
A1, A2, A3 = [], [], [] # set up lists for rotation vector # put dec inc in direction list and set length to unity Dir = [dec, inc, 1.] X = dir2cart(Dir) # get cartesian coordinates # # set up rotation matrix # A1 = dir2cart([az, pl, 1.]) A2 = dir2cart([az + 90., 0, 1.]) A3 = dir2c...
def dogeo(dec, inc, az, pl)
Rotates declination and inclination into geographic coordinates using the azimuth and plunge of the X direction (lab arrow) of a specimen. Parameters ---------- dec : declination in specimen coordinates inc : inclination in specimen coordinates Returns ------- rotated_direction : tuple...
2.999594
3.0034
0.998733
indat = indat.transpose() # unpack input array into separate arrays dec, inc, az, pl = indat[0], indat[1], indat[2], indat[3] Dir = np.array([dec, inc]).transpose() X = dir2cart(Dir).transpose() # get cartesian coordinates N = np.size(dec) A1 = dir2cart(np.array([az, pl, np.ones(N)]).t...
def dogeo_V(indat)
Rotates declination and inclination into geographic coordinates using the azimuth and plunge of the X direction (lab arrow) of a specimen. Parameters ---------- indat: nested list of [dec, inc, az, pl] data Returns ------- rotated_directions : arrays of Declinations and Inclinations
2.568809
2.412502
1.06479
d, irot = dogeo(D, I, Dbar, 90. - Ibar) drot = d - 180. if drot < 360.: drot = drot + 360. if drot > 360.: drot = drot - 360. return drot, irot
def dodirot(D, I, Dbar, Ibar)
Rotate a direction (declination, inclination) by the difference between dec=0 and inc = 90 and the provided desired mean direction Parameters ---------- D : declination to be rotated I : inclination to be rotated Dbar : declination of desired mean Ibar : inclination of desired mean Ret...
3.193925
3.591453
0.889313
N = di_block.shape[0] DipDir, Dip = np.ones(N, dtype=np.float).transpose( )*(Dbar-180.), np.ones(N, dtype=np.float).transpose()*(90.-Ibar) di_block = di_block.transpose() data = np.array([di_block[0], di_block[1], DipDir, Dip]).transpose() drot, irot = dotilt_V(data) drot = (drot-180.) ...
def dodirot_V(di_block, Dbar, Ibar)
Rotate an array of dec/inc pairs to coordinate system with Dec,Inc as 0,90 Parameters ___________________ di_block : array of [[Dec1,Inc1],[Dec2,Inc2],....] Dbar : declination of desired center Ibar : inclination of desired center Returns __________ array of rotated decs and incs: [[ro...
4.275125
4.198705
1.018201
datablock, or_error, bed_error = [], 0, 0 orient = {} orient["sample_dip"] = "" orient["sample_azimuth"] = "" orient['sample_description'] = "" for rec in data: if rec["er_sample_name"].lower() == s.lower(): if 'sample_orientation_flag' in list(rec.keys()) and rec['sampl...
def find_samp_rec(s, data, az_type)
find the orientation info for samp s
1.826866
1.79985
1.01501
vdata, Dirdata, step_meth = [], [], [] tr0 = data[0][0] # set beginning treatment data.append("Stop") k, R = 1, 0 for i in range(k, len(data)): Dirdata = [] if data[i][0] != tr0: if i == k: # sample is unique vdata.append(data[i - 1]) ...
def vspec(data)
Takes the vector mean of replicate measurements at a given step
5.04625
4.711691
1.071006
A = dir2cart([D1[0], D1[1], 1.]) B = dir2cart([D2[0], D2[1], 1.]) C = [] for i in range(3): C.append(A[i] - B[i]) return cart2dir(C)
def Vdiff(D1, D2)
finds the vector difference between two directions D1,D2
2.426866
2.187819
1.109262
cart = np.array(cart) rad = old_div(np.pi, 180.) # constant to convert degrees to radians if len(cart.shape) > 1: Xs, Ys, Zs = cart[:, 0], cart[:, 1], cart[:, 2] else: # single vector Xs, Ys, Zs = cart[0], cart[1], cart[2] if np.iscomplexobj(Xs): Xs = Xs.real if np...
def cart2dir(cart)
Converts a direction in cartesian coordinates into declination, inclinations Parameters ---------- cart : input list of [x,y,z] or list of lists [[x1,y1,z1],[x2,y2,z2]...] Returns ------- direction_array : returns an array of [declination, inclination, intensity] Examples -------- ...
2.956664
3.040677
0.97237
T = [[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]] for row in X: for k in range(3): for l in range(3): T[k][l] += row[k] * row[l] return T
def Tmatrix(X)
gets the orientation matrix (T) from data in X
1.93683
1.962065
0.987139
ints = np.ones(len(d)).transpose( ) # get an array of ones to plug into dec,inc pairs d = np.array(d) rad = np.pi/180. if len(d.shape) > 1: # array of vectors decs, incs = d[:, 0] * rad, d[:, 1] * rad if d.shape[1] == 3: ints = d[:, 2] # take the given lengths ...
def dir2cart(d)
Converts a list or array of vector directions in degrees (declination, inclination) to an array of the direction in cartesian coordinates (x,y,z) Parameters ---------- d : list or array of [dec,inc] or [dec,inc,intensity] Returns ------- cart : array of [x,y,z] Examples -------- ...
2.813031
2.851522
0.986502
datablock = [] for rec in data: if s == rec[0]: datablock.append([rec[1], rec[2], rec[3], rec[4]]) return datablock
def findrec(s, data)
finds all the records belonging to s in data
3.099131
2.744668
1.129146
rad = old_div(np.pi, 180.) D_out, I_out = [], [] dec, dip, alpha = dec * rad, dip * rad, alpha * rad dec1 = dec + old_div(np.pi, 2.) isign = 1 if dip != 0: isign = (old_div(abs(dip), dip)) dip1 = (dip - isign * (old_div(np.pi, 2.))) t = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] ...
def circ(dec, dip, alpha)
function to calculate points on an circle about dec,dip with angle alpha
2.030206
2.023068
1.003528
namestring = "" addmore = 1 while addmore: scientist = input("Enter name - <Return> when done ") if scientist != "": namestring = namestring + ":" + scientist else: namestring = namestring[1:] addmore = 0 return namestring
def getnames()
get mail names
5.207733
5.37372
0.969111
iday = 0 timedate = sundata["date"] timedate = timedate.split(":") year = int(timedate[0]) mon = int(timedate[1]) day = int(timedate[2]) hours = float(timedate[3]) min = float(timedate[4]) du = int(sundata["delta_u"]) hrs = hours - du if hrs > 24: day += 1 ...
def dosundec(sundata)
returns the declination for a given set of suncompass data Parameters __________ sundata : dictionary with these keys: date: time string with the format 'yyyy:mm:dd:hr:min' delta_u: time to SUBTRACT from local time for Universal time lat: latitude of location (negative for so...
2.947732
2.718802
1.084203
rad = old_div(np.pi, 180.) d = julian_day - 2451545.0 + f L = 280.460 + 0.9856474 * d g = 357.528 + 0.9856003 * d L = L % 360. g = g % 360. # ecliptic longitude lamb = L + 1.915 * np.sin(g * rad) + .02 * np.sin(2 * g * rad) # obliquity of ecliptic epsilon = 23.439 - 0.0000004 * d # ...
def gha(julian_day, f)
returns greenwich hour angle
3.257622
3.219088
1.011971
ig = 15 + 31 * (10 + 12 * 1582) if year == 0: print("Julian no can do") return if year < 0: year = year + 1 if mon > 2: julian_year = year julian_month = mon + 1 else: julian_year = year - 1 julian_month = mon + 13 j1 = int(365.25 * ju...
def julian(mon, day, year)
returns julian day
2.871113
2.796533
1.026669
keylist, OutRecs = [], [] for rec in Recs: for key in list(rec.keys()): if key not in keylist: keylist.append(key) for rec in Recs: for key in keylist: if key not in list(rec.keys()): rec[key] = "" OutRecs.append(rec) r...
def fillkeys(Recs)
reconciles keys of dictionaries within Recs.
2.032717
1.935994
1.049961
R, Xbar, X, fpars = 0, [0, 0, 0], [], {} N = len(data) if N < 2: return fpars X = dir2cart(data) for i in range(len(X)): for c in range(3): Xbar[c] += X[i][c] for c in range(3): R += Xbar[c]**2 R = np.sqrt(R) for c in range(3): Xbar[c] = X...
def fisher_mean(data)
Calculates the Fisher mean and associated parameter from a di_block Parameters ---------- di_block : a nested list of [dec,inc] or [dec,inc,intensity] Returns ------- fpars : dictionary containing the Fisher mean and statistics dec : mean declination inc : mean inclination ...
3.430279
3.005524
1.141324
N, mean, d = len(data), 0., 0. if N < 1: return "", "" if N == 1: return data[0], 0 for j in range(N): mean += old_div(data[j], float(N)) for j in range(N): d += (data[j] - mean)**2 stdev = np.sqrt(d * (1./(float(N - 1)))) return mean, stdev
def gausspars(data)
calculates gaussian statistics for data
3.260012
3.123548
1.043689
W, N, mean, d = 0, len(data), 0, 0 if N < 1: return "", "" if N == 1: return data[0][0], 0 for x in data: W += x[1] # sum of the weights for x in data: mean += old_div((float(x[1]) * float(x[0])), float(W)) for x in data: d += (old_div(float(x[1]), f...
def weighted_mean(data)
calculates weighted mean of data
3.154175
3.065279
1.029001
FisherByPoles = {} DIblock, nameblock, locblock = [], [], [] for rec in data: if 'dec' in list(rec.keys()) and 'inc' in list(rec.keys()): # collect data for fisher calculation DIblock.append([float(rec["dec"]), float(rec["inc"])]) else: continue ...
def fisher_by_pol(data)
input: as in dolnp (list of dictionaries with 'dec' and 'inc') description: do fisher mean after splitting data into two polarity domains. output: three dictionaries: 'A'= polarity 'A' 'B = polarity 'B' 'ALL'= switching polarity of 'B' directions, and calculate fisher mean of all data...
2.21313
2.133712
1.03722
if len(Data) == 0: print("This function requires input Data have at least 1 entry") return {} if len(Data) == 1: ReturnData = {} ReturnData["dec"] = Data[0]['dir_dec'] ReturnData["inc"] = Data[0]['dir_inc'] ReturnData["n_total"] = '1' if "DE-BFP" in D...
def dolnp3_0(Data)
DEPRECATED!! USE dolnp() Desciption: takes a list of dicts with the controlled vocabulary of 3_0 and calls dolnp on them after reformating for compatibility. Parameters __________ Data : nested list of dictionarys with keys dir_dec dir_inc dir_tilt_correction method_code...
3.214136
2.334038
1.377071
lam, X = 0, [] for k in range(3): lam = lam + V[k] * L[k] beta = np.sqrt(1. - lam**2) for k in range(3): X.append((old_div((V[k] - lam * L[k]), beta))) return X
def vclose(L, V)
gets the closest vector
3.866004
3.647583
1.059881
U, XV = E[:], [] # make a copy of E to prevent mutation for pole in L: XV.append(vclose(pole, V)) # get some points on the great circle for c in range(3): U[c] = U[c] + XV[-1][c] # iterate to find best agreement angle_tol = 1. while angle_tol > 0.1: angles = [...
def calculate_best_fit_vectors(L, E, V, n_planes)
Calculates the best fit vectors for a set of plane interpretations used in fisher mean calculations @param: L - a list of the "EL, EM, EN" array of MM88 or the cartisian form of dec and inc of the plane interpretation @param: E - the sum of the cartisian coordinates of all the line fits to be used in the mean ...
3.199331
3.290783
0.97221
dec_key, inc_key, meth_key = 'dec', 'inc', 'magic_method_codes' # data model 2.5 if 'dir_dec' in data[0].keys(): # this is data model 3.0 dec_key, inc_key, meth_key = 'dir_dec', 'dir_inc', 'method_codes' n_lines, n_planes = 0, 0 L, fdata = [], [] E = [0, 0, 0] # sort data into ...
def process_data_for_mean(data, direction_type_key)
takes list of dicts with dec and inc as well as direction_type if possible or method_codes and sorts the data into lines and planes and process it for fisher means @param: data - list of dicts with dec inc and some manner of PCA type info @param: direction_type_key - key that indicates the direction type varia...
2.353179
2.111053
1.114694
# changed radius of the earth from 3.367e6 3/12/2010 fact = ((6.371e6)**3) * 1e7 colat = np.radians(90. - lat) return fact * B / (np.sqrt(1 + 3 * (np.cos(colat)**2)))
def b_vdm(B, lat)
Converts a magnetic field value (input in units of tesla) to a virtual dipole moment (VDM) or a virtual axial dipole moment (VADM); output in units of Am^2) Parameters ---------- B: local magnetic field strength in tesla lat: latitude of site in degrees Returns ---------- V(A)DM in...
8.018074
8.976389
0.89324
rad = old_div(np.pi, 180.) # changed radius of the earth from 3.367e6 3/12/2010 fact = ((6.371e6)**3) * 1e7 colat = (90. - lat) * rad return vdm * (np.sqrt(1 + 3 * (np.cos(colat)**2))) / fact
def vdm_b(vdm, lat)
Converts a virtual dipole moment (VDM) or a virtual axial dipole moment (VADM; input in units of Am^2) to a local magnetic field value (output in units of tesla) Parameters ---------- vdm : V(A)DM in units of Am^2 lat: latitude of site in degrees Returns ------- B: local magnetic f...
7.208934
7.402798
0.973812
f = open(file, "w") data.sort() for j in range(len(data)): y = old_div(float(j), float(len(data))) out = str(data[j]) + ' ' + str(y) + '\n' f.write(out) f.close()
def cdfout(data, file)
spits out the cdf for data to file
2.627252
2.609379
1.00685
control, X, bpars = [], [], {} N = len(di_block) if N < 2: return bpars # # get cartesian coordinates # for rec in di_block: X.append(dir2cart([rec[0], rec[1], 1.])) # # put in T matrix # T = np.array(Tmatrix(X)) t, V = tauV(T) w1, w2, w3 = t[2], t[1], t[0] k1, k2...
def dobingham(di_block)
Calculates the Bingham mean and associated statistical parameters from directions that are input as a di_block Parameters ---------- di_block : a nested list of [dec,inc] or [dec,inc,intensity] Returns ------- bpars : dictionary containing the Bingham mean and associated statistics dic...
3.769891
3.217934
1.171525
if inc < 0: inc = -inc dec = (dec + 180.) % 360. return dec, inc
def doflip(dec, inc)
flips lower hemisphere data to upper hemisphere
3.816916
2.982413
1.279808
rad, SCOi, SSOi = old_div(np.pi, 180.), 0., 0. # some definitions abinc = [] for i in inc: abinc.append(abs(i)) MI, std = gausspars(abinc) # get mean inc and standard deviation fpars = {} N = len(inc) # number of data fpars['n'] = N fpars['ginc'] = MI if MI < 30: ...
def doincfish(inc)
gets fisher mean inc from inc only data input: list of inclination values output: dictionary of 'n' : number of inclination values supplied 'ginc' : gaussian mean of inclinations 'inc' : estimated Fisher mean 'r' : estimated Fisher R value 'k' : estimated Fisher kappa ...
4.481412
3.964477
1.130392
ppars = {} rad = old_div(np.pi, 180.) X = dir2cart(data) # for rec in data: # dir=[] # for c in rec: dir.append(c) # cart= (dir2cart(dir)) # X.append(cart) # put in T matrix # T = np.array(Tmatrix(X)) # # get sorted evals/evects # t, V = tauV(T) Pdir = ca...
def doprinc(data)
Gets principal components from data in form of a list of [dec,inc] data. Parameters ---------- data : nested list of dec, inc directions Returns ------- ppars : dictionary with the principal components dec : principal directiion declination inc : principal direction inclination...
3.681247
2.924759
1.258649
# gets user input of Rotation pole lat,long, omega for plate and converts # to radians E = dir2cart([EP[1], EP[0], 1.]) # EP is pole lat,lon omega omega = EP[2] * np.pi / 180. # convert to radians RLats, RLons = [], [] for k in range(len(Lats)): if Lats[k] <= 90.: # peel off delimiters ...
def pt_rot(EP, Lats, Lons)
Rotates points on a globe by an Euler pole rotation using method of Cox and Hart 1986, box 7-3. Parameters ---------- EP : Euler pole list [lat,lon,angle] Lats : list of latitudes of points to be rotated Lons : list of longitudes of points to be rotated Returns _________ RLats : ro...
2.037578
2.020707
1.008349
data = [] f = open(infile, "r") for line in f.readlines(): tmp = line.split() rec = (tmp[0], float(tmp[cols[0]]), float(tmp[cols[1]]), float(tmp[cols[2]]), float(tmp[cols[3]])) data.append(rec) f.close() return data
def dread(infile, cols)
reads in specimen, tr, dec, inc int into data[]. position of tr, dec, inc, int determined by cols[]
2.110231
2.034539
1.037203
k = np.array(k) if len(k.shape) != 0: n = k.shape[0] else: n = 1 R1 = random.random(size=n) R2 = random.random(size=n) L = np.exp(-2 * k) a = R1 * (1 - L) + L fac = np.sqrt(-np.log(a)/(2 * k)) inc = 90. - np.degrees(2 * np.arcsin(fac)) dec = np.degrees(2 * np...
def fshdev(k)
Generate a random draw from a Fisher distribution with mean declination of 0 and inclination of 90 with a specified kappa. Parameters ---------- k : kappa (precision parameter) of the distribution k can be a single number or an array of values Returns ---------- dec, inc : declinat...
3.529949
3.268561
1.079971
lmax = data[-1][0] Ls = list(range(1, lmax+1)) Rs = [] recno = 0 for l in Ls: pow = 0 for m in range(0, l + 1): pow += (l + 1) * ((1e-3 * data[recno][2]) ** 2 + (1e-3 * data[recno][3])**2) recno += 1 Rs.append(pow) ...
def lowes(data)
gets Lowe's power spectrum from gauss coefficients Parameters _________ data : nested list of [[l,m,g,h],...] as from pmag.unpack() Returns _______ Ls : list of degrees (l) Rs : power at degree l
4.097456
3.29888
1.242075
rad = old_div(np.pi, 180.) paleo_lat = old_div(np.arctan(0.5 * np.tan(inc * rad)), rad) return paleo_lat
def magnetic_lat(inc)
returns magnetic latitude from inclination
3.565226
3.433955
1.038228
Dir = np.zeros((3), 'f') Dir[0] = InDir[0] Dir[1] = InDir[1] Dir[2] = 1. chi, chi_inv = check_F(AniSpec) if chi[0][0] == 1.: return Dir # isotropic X = dir2cart(Dir) M = np.array(X) H = np.dot(M, chi_inv) return cart2dir(H)
def Dir_anis_corr(InDir, AniSpec)
takes the 6 element 's' vector and the Dec,Inc 'InDir' data, performs simple anisotropy correction. returns corrected Dec, Inc
4.832476
5.310118
0.910051
AniSpecRec = {} for key in list(PmagSpecRec.keys()): AniSpecRec[key] = PmagSpecRec[key] Dir = np.zeros((3), 'f') Dir[0] = float(PmagSpecRec["specimen_dec"]) Dir[1] = float(PmagSpecRec["specimen_inc"]) Dir[2] = float(PmagSpecRec["specimen_int"]) # check if F test passes! if anisotro...
def doaniscorr(PmagSpecRec, AniSpec)
takes the 6 element 's' vector and the Dec,Inc, Int 'Dir' data, performs simple anisotropy correction. returns corrected Dec, Inc, Int
3.290152
3.225772
1.019958
cart_1 = dir2cart([pars_1["dec"], pars_1["inc"], pars_1["r"]]) cart_2 = dir2cart([pars_2['dec'], pars_2['inc'], pars_2["r"]]) Sw = pars_1['k'] * pars_1['r'] + pars_2['k'] * pars_2['r'] # k1*r1+k2*r2 xhat_1 = pars_1['k'] * cart_1[0] + pars_2['k'] * cart_2[0] # k1*x1+k2*x2 xhat_2 = pars_1['k'] ...
def vfunc(pars_1, pars_2)
Calculate the Watson Vw test statistic. Calculated as 2*(Sw-Rw) Parameters ---------- pars_1 : dictionary of Fisher statistics from population 1 pars_2 : dictionary of Fisher statistics from population 2 Returns ------- Vw : Watson's Vw statistic
1.857441
1.809016
1.026769
plong = plong % 360 slong = slong % 360 signdec = 1. delphi = abs(plong - slong) if delphi != 0: signdec = (plong - slong) / delphi if slat == 90.: slat = 89.99 thetaS = np.radians(90. - slat) thetaP = np.radians(90. - plat) delphi = np.radians(delphi) cosp =...
def vgp_di(plat, plong, slat, slong)
Converts a pole position (pole latitude, pole longitude) to a direction (declination, inclination) at a given location (slat, slong) assuming a dipolar field. Parameters ---------- plat : latitude of pole (vgp latitude) plong : longitude of pole (vgp longitude) slat : latitude of site s...
2.741046
2.719748
1.007831
counter, NumSims = 0, 500 # # first calculate the fisher means and cartesian coordinates of each set of Directions # pars_1 = fisher_mean(Dir1) pars_2 = fisher_mean(Dir2) # # get V statistic for these # V = vfunc(pars_1, pars_2) # # do monte carlo simulation of datasets with same kappas, but common...
def watsonsV(Dir1, Dir2)
calculates Watson's V statistic for two sets of directions
4.750677
4.539102
1.046612
try: D = float(D) I = float(I) except TypeError: # is an array return dimap_V(D, I) # DEFINE FUNCTION VARIABLES # initialize equal area projection x,y XY = [0., 0.] # GET CARTESIAN COMPONENTS OF INPUT DIRECTION X = dir2cart([D, I, 1.]) # CHECK IF Z = 1 AND ABORT i...
def dimap(D, I)
Function to map directions to x,y pairs in equal area projection Parameters ---------- D : list or array of declinations (as float) I : list or array or inclinations (as float) Returns ------- XY : x, y values of directions for equal area projection [x,y]
5.522252
5.226068
1.056674
# GET CARTESIAN COMPONENTS OF INPUT DIRECTION DI = np.array([D, I]).transpose() X = dir2cart(DI).transpose() # CALCULATE THE X,Y COORDINATES FOR THE EQUAL AREA PROJECTION # from Collinson 1983 R = np.sqrt(1. - abs(X[2]))/(np.sqrt(X[0]**2 + X[1]**2)) XY = np.array([X[1] * R, X[0] * R]).transpose...
def dimap_V(D, I)
FUNCTION TO MAP DECLINATION, INCLINATIONS INTO EQUAL AREA PROJECTION, X,Y Usage: dimap_V(D, I) D and I are both numpy arrays
6.337451
5.774812
1.09743
meths = [] if method_type == 'GM': meths.append('GM-PMAG-APWP') meths.append('GM-ARAR') meths.append('GM-ARAR-AP') meths.append('GM-ARAR-II') meths.append('GM-ARAR-NI') meths.append('GM-ARAR-TF') meths.append('GM-CC-ARCH') meths.append('GM-CC-...
def getmeths(method_type)
returns MagIC method codes available for a given type
3.052929
2.875016
1.061882
keylist = [] pmag_out = open(ofile, 'a') outstring = "tab \t" + file_type + "\n" pmag_out.write(outstring) keystring = "" for key in list(Rec.keys()): keystring = keystring + '\t' + key keylist.append(key) keystring = keystring + '\n' pmag_out.write(keystring[1:]) ...
def first_up(ofile, Rec, file_type)
writes the header for a MagIC template file
2.924918
2.884522
1.014004
site = Rec[sitekey] gotone = 0 if len(Ages) > 0: for agerec in Ages: if agerec["er_site_name"] == site: if "age" in list(agerec.keys()) and agerec["age"] != "": Rec[keybase + "age"] = agerec["age"] gotone = 1 if...
def get_age(Rec, sitekey, keybase, Ages, DefaultAge)
finds the age record for a given site
2.052409
2.02967
1.011203
# get a list of age_units first age_units, AgesOut, factors, factor, maxunit, age_unit = [], [], [], 1, 1, "Ma" for agerec in AgesIn: if agerec[1] not in age_units: age_units.append(agerec[1]) if agerec[1] == "Ga": factors.append(1e9) maxunit,...
def adjust_ages(AgesIn)
Function to adjust ages to a common age_unit
2.312335
2.274246
1.016748
# # get uniform directions [dec,inc] z = random.uniform(-1., 1., size=N) t = random.uniform(0., 360., size=N) # decs i = np.arcsin(z) * 180. / np.pi # incs return np.array([t, i]).transpose() # def get_unf(N): #Jeff's way
def get_unf(N=100)
Generates N uniformly distributed directions using the way described in Fisher et al. (1987). Parameters __________ N : number of directions, default is 100 Returns ______ array of nested dec,inc pairs
6.648943
5.965042
1.114652
a = np.zeros((3, 3,), 'f') # make the a matrix for i in range(3): a[i][i] = s[i] a[0][1], a[1][0] = s[3], s[3] a[1][2], a[2][1] = s[4], s[4] a[0][2], a[2][0] = s[5], s[5] return a
def s2a(s)
convert 6 element "s" list to 3,3 a matrix (see Tauxe 1998)
2.263308
2.028619
1.115689
s = np.zeros((6,), 'f') # make the a matrix for i in range(3): s[i] = a[i][i] s[3] = a[0][1] s[4] = a[1][2] s[5] = a[0][2] return s
def a2s(a)
convert 3,3 a matrix to 6 element "s" list (see Tauxe 1998)
3.254892
2.649601
1.228446
# A = s2a(s) # convert s to a (see Tauxe 1998) tau, V = tauV(A) # convert to eigenvalues (t), eigenvectors (V) Vdirs = [] for v in V: # convert from cartesian to direction Vdir = cart2dir(v) if Vdir[1] < 0: Vdir[1] = -Vdir[1] Vdir[0] = (Vdir[0] + 180.) % 3...
def doseigs(s)
convert s format for eigenvalues and eigenvectors Parameters __________ s=[x11,x22,x33,x12,x23,x13] : the six tensor elements Return __________ tau : [t1,t2,t3] tau is an list of eigenvalues in decreasing order: V : [[V1_dec,V1_inc],[V2_dec,V2_inc],[V3_dec,V3_inc]] ...
4.6252
4.123529
1.121661
t = np.zeros((3, 3,), 'f') # initialize the tau diagonal matrix V = [] for j in range(3): t[j][j] = tau[j] # diagonalize tau for k in range(3): V.append(dir2cart([Vdirs[k][0], Vdirs[k][1], 1.0])) V = np.transpose(V) tmp = np.dot(V, t) chi = np.dot(tmp, np.transpose(V))...
def doeigs_s(tau, Vdirs)
get elements of s from eigenvaulues - note that this is very unstable Input: tau,V: tau is an list of eigenvalues in decreasing order: [t1,t2,t3] V is an list of the eigenvector directions [[V1_dec,V1_inc],[V2_dec,V2_inc],[V3_dec,V3_inc]] Output: ...
4.117332
4.061491
1.013749
if type(Ss) == list: Ss = np.array(Ss) npts = Ss.shape[0] Ss = Ss.transpose() avd, avs = [], [] # D=np.array([Ss[0],Ss[1],Ss[2],Ss[3]+0.5*(Ss[0]+Ss[1]),Ss[4]+0.5*(Ss[1]+Ss[2]),Ss[5]+0.5*(Ss[0]+Ss[2])]).transpose() D = np.array([Ss[0], Ss[1], Ss[2], Ss[3] + 0.5 * (Ss[0] + Ss[1]), ...
def sbar(Ss)
calculate average s,sigma from list of "s"s.
2.414395
2.342783
1.030567
if npos == 15: # # rotatable design of Jelinek for kappabridge (see Tauxe, 1998) # A = np.array([[.5, .5, 0, -1., 0, 0], [.5, .5, 0, 1., 0, 0], [1, .0, 0, 0, 0, 0], [.5, .5, 0, -1., 0, 0], [.5, .5, 0, 1., 0, 0], [0, .5, .5, 0, -1., 0], [0, .5, .5, 0, 1., 0], [0, 1., 0, 0, 0, 0],...
def design(npos)
make a design matrix for an anisotropy experiment
2.137051
2.111054
1.012315
# A, B = design(15) # get design matrix for 15 measurements sbar = np.dot(B, k15) # get mean s t = (sbar[0] + sbar[1] + sbar[2]) # trace bulk = old_div(t, 3.) # bulk susceptibility Kbar = np.dot(A, sbar) # get best fit values for K dels = k15 - Kbar # get deltas dels, sbar = old_d...
def dok15_s(k15)
calculates least-squares matrix for 15 measurements from Jelinek [1976]
5.855499
5.225193
1.120628
x = v[1] * w[2] - v[2] * w[1] y = v[2] * w[0] - v[0] * w[2] z = v[0] * w[1] - v[1] * w[0] return [x, y, z]
def cross(v, w)
cross product of two vectors
1.39067
1.322088
1.051875
# a = s2a(s) # convert to 3,3 matrix # first get three orthogonal axes X1 = dir2cart((az, pl, 1.)) X2 = dir2cart((az + 90, 0., 1.)) X3 = cross(X1, X2) A = np.transpose([X1, X2, X3]) b = np.zeros((3, 3,), 'f') # initiale the b matrix for i in range(3): for j in range(3): ...
def dosgeo(s, az, pl)
rotates matrix a to az,pl returns s Parameters __________ s : [x11,x22,x33,x12,x23,x13] - the six tensor elements az : the azimuth of the specimen X direction pl : the plunge (inclination) of the specimen X direction Return s_rot : [x11,x22,x33,x12,x23,x13] - after rotation
4.225716
3.735666
1.131181
tau, Vdirs = doseigs(s) Vrot = [] for evec in Vdirs: d, i = dotilt(evec[0], evec[1], bed_az, bed_dip) Vrot.append([d, i]) s_rot = doeigs_s(tau, Vrot) return s_rot
def dostilt(s, bed_az, bed_dip)
Rotates "s" tensor to stratigraphic coordinates Parameters __________ s : [x11,x22,x33,x12,x23,x13] - the six tensor elements bed_az : bedding dip direction bed_dip : bedding dip Return s_rot : [x11,x22,x33,x12,x23,x13] - after rotation
7.284803
8.200815
0.888302
# Is = random.randint(0, len(Ss) - 1, size=len(Ss)) # draw N random integers #Ss = np.array(Ss) if not ipar: # ipar == 0: BSs = Ss[Is] else: # need to recreate measurement - then do the parametric stuffr A, B = design(6) # get the design matrix for 6 measurementsa K, BSs ...
def apseudo(Ss, ipar, sigma)
draw a bootstrap sample of Ss
6.151206
5.549274
1.10847
# Tau1s, Tau2s, Tau3s = [], [], [] V1s, V2s, V3s = [], [], [] nb = len(Taus) bpars = {} for k in range(nb): Tau1s.append(Taus[k][0]) Tau2s.append(Taus[k][1]) Tau3s.append(Taus[k][2]) V1s.append(Vs[k][0]) V2s.append(Vs[k][1]) V3s.append(Vs[k][2]) ...
def sbootpars(Taus, Vs)
get bootstrap parameters for s data
1.494519
1.490942
1.002399
#npts = len(Ss) Ss = np.array(Ss) npts = Ss.shape[0] # get average s for whole dataset nf, Sigma, avs = sbar(Ss) Tmean, Vmean = doseigs(avs) # get eigenvectors of mean tensor # # now do bootstrap to collect Vs and taus of bootstrap means # Taus, Vs = [], [] # number of bootstraps, list of...
def s_boot(Ss, ipar=0, nb=1000)
Returns bootstrap parameters for S data Parameters __________ Ss : nested array of [[x11 x22 x33 x12 x23 x13],....] data ipar : if True, do a parametric bootstrap nb : number of bootstraps Returns ________ Tmean : average eigenvalues Vmean : average eigvectors Taus : bootstrapp...
8.144463
6.861835
1.186922
# if npos != 9: print('Sorry - only 9 positions available') return Dec = [315., 225., 180., 135., 45., 90., 270., 270., 270., 90., 0., 0., 0., 180., 180.] Dip = [0., 0., 0., 0., 0., -45., -45., 0., 45., 45., 45., -45., -90., -45., 45.] index9 = [0, 1, 2, 5,...
def designAARM(npos)
calculates B matrix for AARM calculations.
2.683684
2.62509
1.022321
for rec in Recs: type = ".0" meths = [] tmp = rec["magic_method_codes"].split(':') for meth in tmp: meths.append(meth.strip()) if 'LT-T-I' in meths: type = ".1" if 'LT-PTRM-I' in meths: type = ".2" if 'LT-PTRM-MD' in me...
def domagicmag(file, Recs)
converts a magic record back into the SIO mag format
3.800001
3.6713
1.035056
cont = 0 Nmin = len(first_I) if len(first_Z) < Nmin: Nmin = len(first_Z) for kk in range(Nmin): if first_I[kk][0] != first_Z[kk][0]: print("\n WARNING: ") if first_I[kk] < first_Z[kk]: del first_I[kk] else: del firs...
def cleanup(first_I, first_Z)
cleans up unbalanced steps failure can be from unbalanced final step, or from missing steps, this takes care of missing steps
3.269574
3.171232
1.031011
model, date, itype = 0, 0, 1 sv = np.zeros(len(gh)) colat = 90. - lat x, y, z, f = magsyn(gh, sv, model, date, itype, alt, colat, lon) return x, y, z, f
def docustom(lon, lat, alt, gh)
Passes the coefficients to the Malin and Barraclough routine (function pmag.magsyn) to calculate the field from the coefficients. Parameters: ----------- lon = east longitude in degrees (0 to 360 or -180 to 180) lat = latitude in degrees (-90 to 90) alt = height above mean sea level in km ...
6.389973
5.951783
1.073623
data = [] k, l = 0, 1 while k + 1 < len(gh): for m in range(l + 1): if m == 0: data.append([l, m, gh[k], 0]) k += 1 else: data.append([l, m, gh[k], gh[k + 1]]) k += 2 l += 1 return data
def unpack(gh)
unpacks gh list into l m g h type list Parameters _________ gh : list of gauss coefficients (as returned by, e.g., doigrf) Returns data : nested list of [[l,m,g,h],...]
2.6608
2.244617
1.185414
convention = str(convention) site = sample # default is that site = sample # # # Sample is final letter on site designation eg: TG001a (used by SIO lab # in San Diego) if convention == "1": return sample[:-1] # peel off terminal character # # Site-Sample format eg: BG94-1 (used by PGL lab ...
def parse_site(sample, convention, Z)
parse the site name from the sample name using the specified convention
6.215631
6.151229
1.01047
# samp_con, Z = "", "" while samp_con == "": samp_con = input() # if samp_con == "" or samp_con == "1": samp_con, Z = "1", 1 if "4" in samp_con: if "-" not in samp_con: print("option [4] must be in form 4-Z where Z is an integer") ...
def get_samp_con()
get sample naming convention
2.493801
2.420304
1.030367
# strike is horizontal line equidistant from two input directions SCart = [0, 0, 0] # cartesian coordites of Strike SCart[2] = 0. # by definition # cartesian coordites of Geographic D GCart = dir2cart([dec_geo, inc_geo, 1.]) TCart = dir2cart([dec_tilt, inc_tilt, 1.]) # cartesian coordites of...
def get_tilt(dec_geo, inc_geo, dec_tilt, inc_tilt)
Function to return the dip direction and dip that would yield the tilt corrected direction if applied to the uncorrected direction (geographic coordinates) Parameters ---------- dec_geo : declination in geographic coordinates inc_geo : inclination in geographic coordinates dec_tilt : declin...
4.627479
4.458997
1.037785
TOL = 1e-4 rad = old_div(np.pi, 180.) Xp = dir2cart([gdec, ginc, 1.]) X = dir2cart([cdec, cinc, 1.]) # find plunge first az, pl, zdif, ang = 0., -90., 1., 360. while zdif > TOL and pl < 180.: znew = X[0] * np.sin(pl * rad) + X[2] * np.cos(pl * rad) zdif = abs(Xp[2] - zne...
def get_azpl(cdec, cinc, gdec, ginc)
gets azimuth and pl from specimen dec inc (cdec,cinc) and gdec,ginc (geographic) coordinates
4.394217
4.383326
1.002485
# if ask set to 1, then can change priorities SO_methods = [meth.strip() for meth in SO_methods] SO_defaults = ['SO-SUN', 'SO-GPS-DIFF', 'SO-SUN-SIGHT', 'SO-SIGHT', 'SO-SIGHT-BS', 'SO-CMD-NORTH', 'SO-MAG', 'SO-SM', 'SO-REC', 'SO-V', 'SO-CORE', 'SO-NO'] SO_priorities, prior_list =...
def set_priorities(SO_methods, ask)
figure out which sample_azimuth to use, if multiple orientation methods
3.776379
3.76483
1.003067
f = open(file, 'r') firstline = f.read(350) EOL = "" for k in range(350): if firstline[k:k + 2] == "\r\n": print(file, ' appears to be a dos file') EOL = '\r\n' break if EOL == "": for k in range(350): if firstline[k] == "\r": ...
def get_EOL(file)
find EOL of input file (whether mac,PC or unix format)
2.517591
2.392587
1.052246
for rec in datablock: methcodes = rec["magic_method_codes"].split(":") step = float(rec["treatment_ac_field"]) str = float(rec["measurement_magn_moment"]) if "LT-NO" in methcodes: NRM.append([0, str]) if "LT-T-I" in methcodes: TRM.append([0, str])...
def sortshaw(s, datablock)
sorts data block in to ARM1,ARM2 NRM,TRM,ARM1,ARM2=[],[],[],[] stick first zero field stuff into first_Z
3.291854
3.134727
1.050124
sv = [] pad = 120 - len(gh) for x in range(pad): gh.append(0.) for x in range(len(gh)): sv.append(0.) #! convert to colatitude for MB routine itype = 1 colat = 90. - lat date, alt = 2000., 0. # use a dummy date and altitude x, y, z, f = magsyn(gh, sv, date, date, it...
def getvec(gh, lat, lon)
Evaluates the vector at a given latitude and longitude for a specified set of coefficients Parameters ---------- gh : a list of gauss coefficients lat : latitude of location long : longitude of location Returns ------- vec : direction in [dec, inc, intensity]
7.374694
7.235608
1.019222
a2 = alpha**2 c_a = 0.547 s_l = np.sqrt(old_div(((c_a**(2. * l)) * a2), ((l + 1.) * (2. * l + 1.)))) return s_l
def s_l(l, alpha)
get sigma as a function of degree l from Constable and Parker (1988)
5.501237
5.10847
1.076885
# random.seed(n) p = 0 n = seed gh = [] g10, sfact, afact = -18e3, 3.8, 2.4 g20 = G2 * g10 g30 = G3 * g10 alpha = g10/afact s1 = s_l(1, alpha) s10 = sfact * s1 gnew = random.normal(g10, s10) if p == 1: print(1, 0, gnew, 0) gh.append(gnew) gh.append(random...
def mktk03(terms, seed, G2, G3)
generates a list of gauss coefficients drawn from the TK03 distribution
3.152534
3.082566
1.022698
tanl = np.tan(np.radians(lat)) inc = np.arctan(2. * tanl) return np.degrees(inc)
def pinc(lat)
calculate paleoinclination from latitude using dipole formula: tan(I) = 2tan(lat) Parameters ________________ lat : either a single value or an array of latitudes Returns ------- array of inclinations
4.065423
5.431014
0.748557
tani = np.tan(np.radians(inc)) lat = np.arctan(tani/2.) return np.degrees(lat)
def plat(inc)
calculate paleolatitude from inclination using dipole formula: tan(I) = 2tan(lat) Parameters ________________ inc : either a single value or an array of inclinations Returns ------- array of latitudes
5.372387
6.154035
0.872986
if random_seed != None: np.random.seed(random_seed) Inds = np.random.randint(len(DIs), size=len(DIs)) D = np.array(DIs) return D[Inds]
def pseudo(DIs, random_seed=None)
Draw a bootstrap sample of directions returning as many bootstrapped samples as in the input directions Parameters ---------- DIs : nested list of dec, inc lists (known as a di_block) random_seed : set random seed for reproducible number generation (default is None) Returns ------- Boo...
2.62509
3.574944
0.734302
# # now do bootstrap to collect BDIs bootstrap means # BDIs = [] # number of bootstraps, list of bootstrap directions # for k in range(nb): # repeat nb times # if k%50==0:print k,' out of ',nb pDIs = pseudo(DIs) # get a pseudosample bfpars = fisher_mean(pDIs) # get boot...
def di_boot(DIs, nb=5000)
returns bootstrap means for Directional data Parameters _________________ DIs : nested list of Dec,Inc pairs nb : number of bootstrap pseudosamples Returns ------- BDIs: nested list of bootstrapped mean Dec,Inc pairs
11.075277
8.28019
1.337563
N = dir_df.dir_dec.values.shape[0] # number of data points BDIs = [] for k in range(nb): pdir_df = dir_df.sample(n=N, replace=True) # bootstrap pseudosample pdir_df.reset_index(inplace=True) # reset the index if par: # do a parametric bootstrap for i in pdir_df.i...
def dir_df_boot(dir_df, nb=5000, par=False)
Performs a bootstrap for direction DataFrame with optional parametric bootstrap Parameters _________ dir_df : Pandas DataFrame with columns: dir_dec : mean declination dir_inc : mean inclination Required for parametric bootstrap dir_n : number of data points in mean di...
4.496456
3.746019
1.200329
N = dir_df.dir_dec.values.shape[0] # number of data points fpars = {} if N < 2: return fpars dirs = dir_df[['dir_dec', 'dir_inc']].values X = dir2cart(dirs).transpose() Xbar = np.array([X[0].sum(), X[1].sum(), X[2].sum()]) R = np.sqrt(Xbar[0]**2+Xbar[1]**2+Xbar[2]**2) Xbar ...
def dir_df_fisher_mean(dir_df)
calculates fisher mean for Pandas data frame Parameters __________ dir_df: pandas data frame with columns: dir_dec : declination dir_inc : inclination Returns ------- fpars : dictionary containing the Fisher mean and statistics dec : mean declination inc : mean i...
3.449702
2.909291
1.185754
# BXs = [] for k in range(len(x)): ind = random.randint(0, len(x) - 1) BXs.append(x[ind]) return BXs
def pseudosample(x)
draw a bootstrap sample of x
3.81487
3.338006
1.142859
plate, site_lat, site_lon, age = data[0], data[1], data[2], data[3] apwp = get_plate_data(plate) recs = apwp.split() # # put it into usable form in plate_data # k, plate_data = 0, [] while k < len(recs) - 3: rec = [float(recs[k]), float(recs[k + 1]), float(recs[k + 2])] ...
def bc02(data)
get APWP from Besse and Courtillot 2002 paper Parameters ---------- Takes input as [plate, site_lat, site_lon, age] plate : string (options: AF, ANT, AU, EU, GL, IN, NA, SA) site_lat : float site_lon : float age : float in Myr Returns ----------
3.25116
2.918527
1.113973
if len(x) != len(y): print('x and y must be same length') return xx, yy, xsum, ysum, xy, n, sum = 0, 0, 0, 0, 0, len(x), 0 linpars = {} for i in range(n): xx += x[i] * x[i] yy += y[i] * y[i] xy += x[i] * y[i] xsum += x[i] ysum += y[i] ...
def linreg(x, y)
does a linear regression
2.081151
2.090228
0.995658
incs = np.radians(incs) I_o = f * np.tan(incs) # multiply tangent by flattening factor return np.degrees(np.arctan(I_o))
def squish(incs, f)
returns 'flattened' inclination, assuming factor, f and King (1955) formula: tan (I_o) = f tan (I_f) Parameters __________ incs : array of inclination (I_f) data to flatten f : flattening factor Returns _______ I_o : inclinations after flattening
6.50906
4.962331
1.311694
namespace = kwargs exec("b = {}".format(st), namespace) return namespace['b']
def execute(st, **kwargs)
Work around for Python3 exec function which doesn't allow changes to the local namespace because of scope. This breaks a lot of the old functionality in the code which was origionally in Python2. So this function runs just like exec except that it returns the output of the input statement to the local namespace...
11.131316
14.362589
0.775022
if var: var = flag + " " + str(var) else: var = "" return var
def add_flag(var, flag)
for use when calling command-line scripts from withing a program. if a variable is present, add its proper command_line flag. return a string.
5.034616
5.003364
1.006246
if name in sys.argv: # if the command line flag is found in sys.argv ind = sys.argv.index(name) return sys.argv[ind + 1] if reqd: # if arg is required but not present raise MissingCommandLineArgException(name) return default_val
def get_named_arg(name, default_val=None, reqd=False)
Extract the value after a command-line flag such as '-f' and return it. If the command-line flag is missing, return default_val. If reqd == True and the command-line flag is missing, throw an error. Parameters ---------- name : str command line flag, e.g. "-f" default_val value ...
3.410543
3.467293
0.983633
''' take a list of recs [rec1,rec2,rec3....], each rec is a dictionary. make sure that all recs have the same headers. ''' headers = [] for rec in recs: keys = list(rec.keys()) for key in keys: if key not in headers: headers.append(key) for rec in ...
def merge_recs_headers(recs)
take a list of recs [rec1,rec2,rec3....], each rec is a dictionary. make sure that all recs have the same headers.
2.584756
1.655707
1.561119
if not fname: return '' file_dir_path, file_name = os.path.split(fname) if (not file_dir_path) or (file_dir_path == '.'): full_file = os.path.join(dir_path, fname) else: full_file = fname return os.path.realpath(full_file)
def resolve_file_name(fname, dir_path='.')
Parse file name information and output full path. Allows input as: fname == /path/to/file.txt or fname == file.txt, dir_path == /path/to Either way, returns /path/to/file.txt. Used in conversion scripts. Parameters ---------- fname : str short filename or full path to file ...
2.477023
2.506266
0.988332
CheckDec = ['_dec', '_lon', '_azimuth', 'dip_direction'] adjust = False for dec_key in CheckDec: if dec_key in key: if key.endswith(dec_key) or key.endswith('_'): adjust = True if not val: return '' elif not adjust: return val elif adjust:...
def adjust_to_360(val, key)
Take in a value and a key. If the key is of the type: declination/longitude/azimuth/direction, adjust it to be within the range 0-360 as required by the MagIC data model
5.39738
4.920387
1.096942
for key in dictionary: dictionary[key] = adjust_to_360(dictionary[key], key) return dictionary
def adjust_all_to_360(dictionary)
Take a dictionary and check each key/value pair. If this key is of type: declination/longitude/azimuth/direction, adjust it to be within 0-360 as required by the MagIC data model
2.413953
3.451761
0.699339
if resolution=='low': incr = 10 # we can vary to the resolution of the model elif resolution=='high': incr = 2 # we can vary to the resolution of the model if lon_0 == 180: lon_0 = 179.99 if lon_0 > 180: lon_0 = lon_0-360. # get some parameters for our arrays o...
def do_mag_map(date, lon_0=0, alt=0, file="", mod="cals10k",resolution='low')
returns lists of declination, inclination and intensities for lat/lon grid for desired model and date. Parameters: _________________ date = Required date in decimal years (Common Era, negative for Before Common Era) Optional Parameters: ______________ mod = model to use ('arch3k','cals3k'...
3.055528
2.893062
1.056157
xp, yp = y, x # need to switch into geographic convention r = np.sqrt(xp**2+yp**2) z = 1.-r**2 t = np.arcsin(z) if UP == 1: t = -t p = np.arctan2(yp, xp) dec, inc = np.degrees(p) % 360, np.degrees(t) return dec, inc
def doeqdi(x, y, UP=False)
Takes digitized x,y, data and returns the dec,inc, assuming an equal area projection Parameters __________________ x : array of digitized x from point on equal area projection y : array of igitized y from point on equal area projection UP : if True, is an upper hemisphere projection...
4.568303
4.418977
1.033792
ppars = doprinc(di_block) di_df = pd.DataFrame(di_block) # turn into a data frame for easy filtering di_df.columns = ['dec', 'inc'] di_df['pdec'] = ppars['dec'] di_df['pinc'] = ppars['inc'] di_df['angle'] = angle(di_df[['dec', 'inc']].values, di_df[['pdec', 'pinc...
def separate_directions(di_block)
Separates set of directions into two modes based on principal direction Parameters _______________ di_block : block of nested dec,inc pairs Return mode_1_block,mode_2_block : two lists of nested dec,inc pairs
2.690039
2.589183
1.038953
vgp_df['delta'] = 90.-vgp_df['vgp_lat'].values ASD = np.sqrt(np.sum(vgp_df.delta**2)/(vgp_df.shape[0]-1)) A = 1.8 * ASD + 5. delta_max = vgp_df.delta.max() while delta_max > A: delta_max = vgp_df.delta.max() if delta_max < A: return vgp_df, A, ASD vgp_df = vg...
def dovandamme(vgp_df)
determine the S_b value for VGPs using the Vandamme (1994) method for determining cutoff value for "outliers". Parameters ___________ vgp_df : pandas DataFrame with required column "vgp_lat" This should be in the desired coordinate system and assumes one polarity Returns _________ ...
2.419556
2.336512
1.035542
vgp_df['delta'] = 90.-vgp_df.vgp_lat.values # filter by cutoff, kappa, and n vgp_df = vgp_df[vgp_df.delta <= cutoff] vgp_df = vgp_df[vgp_df.dir_k >= kappa] vgp_df = vgp_df[vgp_df.dir_n_samples >= n] if spin: # do transformation to pole Pvgps = vgp_df[['vgp_lon', 'vgp_lat']].values ...
def scalc_vgp_df(vgp_df, anti=0, rev=0, cutoff=180., kappa=0, n=0, spin=0, v=0, boot=0, mm97=0, nb=1000)
Calculates Sf for a dataframe with VGP Lat., and optional Fisher's k, site latitude and N information can be used to correct for within site scatter (McElhinny & McFadden, 1997) Parameters _________ df : Pandas Dataframe with columns REQUIRED: vgp_lat : VGP latitude ONLY REQUIRED f...
2.990159
2.81668
1.06159
# first calculate R for the combined data set, then R1 and R2 for each individually. # create a new array from two smaller ones DI = np.concatenate((DI1, DI2), axis=0) fpars = fisher_mean(DI) # re-use our functionfrom problem 1b fpars1 = fisher_mean(DI1) fpars2 = fisher_mean(DI2) N = f...
def watsons_f(DI1, DI2)
calculates Watson's F statistic (equation 11.16 in Essentials text book). Parameters _________ DI1 : nested array of [Dec,Inc] pairs DI2 : nested array of [Dec,Inc] pairs Returns _______ F : Watson's F Fcrit : critical value from F table
6.125679
5.959202
1.027936