_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q11600
fshdev
train
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 -------...
python
{ "resource": "" }
q11601
lowes
train
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 """ lmax = data[-1][0] Ls = list(range(1, lmax+1))...
python
{ "resource": "" }
q11602
magnetic_lat
train
def magnetic_lat(inc): """ returns magnetic latitude from inclination """ rad = old_div(np.pi, 180.) paleo_lat = old_div(np.arctan(0.5 * np.tan(inc * rad)), rad) return paleo_lat
python
{ "resource": "" }
q11603
Dir_anis_corr
train
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 """ Dir = np.zeros((3), 'f') Dir[0] = InDir[0] Dir[1] = InDir[1] Dir[2] = 1. chi, chi_inv = check_F(AniSpec) if ch...
python
{ "resource": "" }
q11604
doaniscorr
train
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 """ AniSpecRec = {} for key in list(PmagSpecRec.keys()): AniSpecRec[key] = PmagSpecRec[key] Dir = np.zeros(...
python
{ "resource": "" }
q11605
watsonsV
train
def watsonsV(Dir1, Dir2): """ calculates Watson's V statistic for two sets of directions """ 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 # ...
python
{ "resource": "" }
q11606
dimap
train
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] ...
python
{ "resource": "" }
q11607
dimap_V
train
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 """ # GET CARTESIAN COMPONENTS OF INPUT DIRECTION DI = np.array([D, I]).transpose() X = dir2cart(DI).transpose() # CALCULATE THE X,Y C...
python
{ "resource": "" }
q11608
getmeths
train
def getmeths(method_type): """ returns MagIC method codes available for a given type """ 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') ...
python
{ "resource": "" }
q11609
first_up
train
def first_up(ofile, Rec, file_type): """ writes the header for a MagIC template file """ 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 ...
python
{ "resource": "" }
q11610
get_age
train
def get_age(Rec, sitekey, keybase, Ages, DefaultAge): """ finds the age record for a given site """ 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"] != "":...
python
{ "resource": "" }
q11611
adjust_ages
train
def adjust_ages(AgesIn): """ Function to adjust ages to a common age_unit """ # 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]) ...
python
{ "resource": "" }
q11612
doseigs
train
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...
python
{ "resource": "" }
q11613
sbar
train
def sbar(Ss): """ calculate average s,sigma from list of "s"s. """ 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(...
python
{ "resource": "" }
q11614
design
train
def design(npos): """ make a design matrix for an anisotropy experiment """ 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, ....
python
{ "resource": "" }
q11615
cross
train
def cross(v, w): """ cross product of two vectors """ 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]
python
{ "resource": "" }
q11616
dostilt
train
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 ""...
python
{ "resource": "" }
q11617
apseudo
train
def apseudo(Ss, ipar, sigma): """ draw a bootstrap sample of Ss """ # 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...
python
{ "resource": "" }
q11618
s_boot
train
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 Vme...
python
{ "resource": "" }
q11619
designAARM
train
def designAARM(npos): # """ calculates B matrix for AARM calculations. """ 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....
python
{ "resource": "" }
q11620
domagicmag
train
def domagicmag(file, Recs): """ converts a magic record back into the SIO mag format """ 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: ty...
python
{ "resource": "" }
q11621
cleanup
train
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 """ cont = 0 Nmin = len(first_I) if len(first_Z) < Nmin: Nmin = len(first_Z) for kk in range(Nmin): if ...
python
{ "resource": "" }
q11622
unpack
train
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],...] """ data = [] k, l = 0, 1 while k + 1 < len(gh): for m in range(l + 1): ...
python
{ "resource": "" }
q11623
parse_site
train
def parse_site(sample, convention, Z): """ parse the site name from the sample name using the specified convention """ 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 conv...
python
{ "resource": "" }
q11624
get_samp_con
train
def get_samp_con(): """ get sample naming convention """ # samp_con, Z = "", "" while samp_con == "": samp_con = input(""" Sample naming convention: [1] XXXXY: where XXXX is an arbitrary length site designation and Y is the single character sample design...
python
{ "resource": "" }
q11625
set_priorities
train
def set_priorities(SO_methods, ask): """ figure out which sample_azimuth to use, if multiple orientation methods """ # 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'...
python
{ "resource": "" }
q11626
getvec
train
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, ...
python
{ "resource": "" }
q11627
mktk03
train
def mktk03(terms, seed, G2, G3): """ generates a list of gauss coefficients drawn from the TK03 distribution """ # 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...
python
{ "resource": "" }
q11628
pseudo
train
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 (de...
python
{ "resource": "" }
q11629
dir_df_boot
train
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...
python
{ "resource": "" }
q11630
dir_df_fisher_mean
train
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 ...
python
{ "resource": "" }
q11631
pseudosample
train
def pseudosample(x): """ draw a bootstrap sample of x """ # BXs = [] for k in range(len(x)): ind = random.randint(0, len(x) - 1) BXs.append(x[ind]) return BXs
python
{ "resource": "" }
q11632
bc02
train
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 ---------- """...
python
{ "resource": "" }
q11633
linreg
train
def linreg(x, y): """ does a linear regression """ 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]...
python
{ "resource": "" }
q11634
add_flag
train
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. """ if var: var = flag + " " + str(var) else: var = "" return var
python
{ "resource": "" }
q11635
get_named_arg
train
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 ...
python
{ "resource": "" }
q11636
separate_directions
train
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 """ ppars = doprinc(di_block) ...
python
{ "resource": "" }
q11637
import_basemap
train
def import_basemap(): """ Try to import Basemap and print out a useful help message if Basemap is either not installed or is missing required environment variables. Returns --------- has_basemap : bool Basemap : Basemap package if possible else None """ Basemap = None has_b...
python
{ "resource": "" }
q11638
import_cartopy
train
def import_cartopy(): """ Try to import cartopy and print out a help message if it is not installed Returns --------- has_cartopy : bool cartopy : cartopy package if available else None """ cartopy = None has_cartopy = True try: import cartopy WARNINGS['has_c...
python
{ "resource": "" }
q11639
method_codes_to_geomagia
train
def method_codes_to_geomagia(magic_method_codes,geomagia_table): """ Looks at the MagIC method code list and returns the correct GEOMAGIA code number depending on the method code list and the GEOMAGIA table specified. Returns O, GEOMAGIA's "Not specified" value, if no match. When mutiple codes are mat...
python
{ "resource": "" }
q11640
do_walk
train
def do_walk(data_path): """ Walk through data_files and list all in dict format """ data_files = {} def cond(File, prefix): """ Return True for useful files Return False for non-useful files """ file_path = path.join(prefix, 'data_files', File) return ...
python
{ "resource": "" }
q11641
main
train
def main(): """ NAME change_case_magic.py DESCRIPTION picks out key and converts to upper or lower case SYNTAX change_case_magic.py [command line options] OPTIONS -h prints help message and quits -f FILE: specify input magic format file -F FILE: s...
python
{ "resource": "" }
q11642
main
train
def main(): """ NAME download_magic.py DESCRIPTION unpacks a magic formatted smartbook .txt file from the MagIC database into the tab delimited MagIC format txt files for use with the MagIC-Py programs. SYNTAX download_magic.py command line options] INPUT ta...
python
{ "resource": "" }
q11643
smooth
train
def smooth(x,window_len,window='bartlett'): """smooth the data using a sliding window with requested size. This method is based on the convolution of a scaled window with the signal. The signal is prepared by padding the beginning and the end of the signal with average of the first (last) ten values of...
python
{ "resource": "" }
q11644
deriv1
train
def deriv1(x,y,i,n): """ alternative way to smooth the derivative of a noisy signal using least square fit. x=array of x axis y=array of y axis n=smoothing factor i= position in this method the slope in position i is calculated by least square fit of n points before and after positi...
python
{ "resource": "" }
q11645
main
train
def main(): """ NAME extract_methods.py DESCRIPTION reads in a magic table and creates a file with method codes SYNTAX extract_methods.py [command line options] OPTIONS -h: prints the help message and quits. -f FILE: specify magic format input file, defaul...
python
{ "resource": "" }
q11646
main
train
def main(): """ NAME gofish.py DESCRIPTION calculates fisher parameters from dec inc data INPUT FORMAT takes dec/inc as first two columns in space delimited file SYNTAX gofish.py [options] [< filename] OPTIONS -h prints help message and quits -i f...
python
{ "resource": "" }
q11647
main
train
def main(): """ NAME huji_sample_magic.py DESCRIPTION takes tab delimited Hebrew University sample file and converts to MagIC formatted tables SYNTAX huji_sample_magic.py [command line options] OPTIONS -f FILE: specify input file -Fsa FILE: specify sample o...
python
{ "resource": "" }
q11648
main
train
def main(): """ NAME vector_mean.py DESCRIPTION calculates vector mean of vector data INPUT FORMAT takes dec, inc, int from an input file SYNTAX vector_mean.py [command line options] [< filename] OPTIONS -h prints help message and quits -f FILE, s...
python
{ "resource": "" }
q11649
array_map
train
def array_map(f, ar): "Apply an ordinary function to all values in an array." flat_ar = ravel(ar) out = zeros(len(flat_ar), flat_ar.typecode()) for i in range(len(flat_ar)): out[i] = f(flat_ar[i]) out.shape = ar.shape return out
python
{ "resource": "" }
q11650
VGP_Dialog.on_plot_select
train
def on_plot_select(self,event): """ Select data point if cursor is in range of a data point @param: event -> the wx Mouseevent for that click """ if not self.xdata or not self.ydata: return pos=event.GetPosition() width, height = self.canvas.get_width_height() ...
python
{ "resource": "" }
q11651
user_input.get_values
train
def get_values(self): """ Applies parsing functions to each input as specified in init before returning a tuple with first entry being a boolean which specifies if the user entered all values and a second entry which is a dictionary of input names to parsed values. """ return_dict = {} ...
python
{ "resource": "" }
q11652
main
train
def main(): """ NAME upload_magic.py DESCRIPTION This program will prepare your MagIC text files for uploading to the MagIC database it will check for all the MagIC text files and skip the missing ones SYNTAX upload_magic.py INPUT MagIC txt files OPTI...
python
{ "resource": "" }
q11653
split_lines
train
def split_lines(lines): """ split a MagIC upload format file into lists. the lists are split by the '>>>' lines between file_types. """ container = [] new_list = [] for line in lines: if '>>>' in line: container.append(new_list) new_list = [] else: ...
python
{ "resource": "" }
q11654
fisher_angular_deviation
train
def fisher_angular_deviation(dec=None, inc=None, di_block=None, confidence=95): ''' The angle from the true mean within which a chosen percentage of directions lie can be calculated from the Fisher distribution. This function uses the calculated Fisher concentration parameter to estimate this angle from...
python
{ "resource": "" }
q11655
print_direction_mean
train
def print_direction_mean(mean_dictionary): """ Does a pretty job printing a Fisher mean and associated statistics for directional data. Parameters ---------- mean_dictionary: output dictionary of pmag.fisher_mean Examples -------- Generate a Fisher mean using ``ipmag.fisher_mean`` ...
python
{ "resource": "" }
q11656
print_pole_mean
train
def print_pole_mean(mean_dictionary): """ Does a pretty job printing a Fisher mean and associated statistics for mean paleomagnetic poles. Parameters ---------- mean_dictionary: output dictionary of pmag.fisher_mean Examples -------- Generate a Fisher mean using ``ipmag.fisher_mean...
python
{ "resource": "" }
q11657
fishrot
train
def fishrot(k=20, n=100, dec=0, inc=90, di_block=True): """ Generates Fisher distributed unit vectors from a specified distribution using the pmag.py fshdev and dodirot functions. Parameters ---------- k : kappa precision parameter (default is 20) n : number of vectors to determine (default...
python
{ "resource": "" }
q11658
lat_from_inc
train
def lat_from_inc(inc, a95=None): """ Calculate paleolatitude from inclination using the dipole equation Required Parameter ---------- inc: (paleo)magnetic inclination in degrees Optional Parameter ---------- a95: 95% confidence interval from Fisher mean Returns ---------- ...
python
{ "resource": "" }
q11659
lat_from_pole
train
def lat_from_pole(ref_loc_lon, ref_loc_lat, pole_plon, pole_plat): """ Calculate paleolatitude for a reference location based on a paleomagnetic pole Required Parameters ---------- ref_loc_lon: longitude of reference location in degrees ref_loc_lat: latitude of reference location pole_plon:...
python
{ "resource": "" }
q11660
inc_from_lat
train
def inc_from_lat(lat): """ Calculate inclination predicted from latitude using the dipole equation Parameter ---------- lat : latitude in degrees Returns ------- inc : inclination calculated using the dipole equation """ rad = old_div(np.pi, 180.) inc = old_div(np.arctan(2 ...
python
{ "resource": "" }
q11661
plot_net
train
def plot_net(fignum): """ Draws circle and tick marks for equal area projection. """ # make the perimeter plt.figure(num=fignum,) plt.clf() plt.axis("off") Dcirc = np.arange(0, 361.) Icirc = np.zeros(361, 'f') Xcirc, Ycirc = [], [] for k in range(361): XY = pmag.dimap(Dc...
python
{ "resource": "" }
q11662
plot_di
train
def plot_di(dec=None, inc=None, di_block=None, color='k', marker='o', markersize=20, legend='no', label='', title='', edge='',alpha=1): """ Plot declination, inclination data on an equal area plot. Before this function is called a plot needs to be initialized with code that looks something like: >f...
python
{ "resource": "" }
q11663
make_orthographic_map
train
def make_orthographic_map(central_longitude=0, central_latitude=0, figsize=(8, 8), add_land=True, land_color='tan', add_ocean=False, ocean_color='lightblue', grid_lines=True, lat_grid=[-80., -60., -30., 0., 30., 60., 80.], ...
python
{ "resource": "" }
q11664
plot_pole
train
def plot_pole(map_axis, plon, plat, A95, label='', color='k', edgecolor='k', marker='o', markersize=20, legend='no'): """ This function plots a paleomagnetic pole and A95 error ellipse on a cartopy map axis. Before this function is called, a plot needs to be initialized with code such as that in the ma...
python
{ "resource": "" }
q11665
plot_poles
train
def plot_poles(map_axis, plon, plat, A95, label='', color='k', edgecolor='k', marker='o', markersize=20, legend='no'): """ This function plots paleomagnetic poles and A95 error ellipses on a cartopy map axis. Before this function is called, a plot needs to be initialized with code such as that in the m...
python
{ "resource": "" }
q11666
plot_poles_colorbar
train
def plot_poles_colorbar(map_axis, plons, plats, A95s, colorvalues, vmin, vmax, colormap='viridis', edgecolor='k', marker='o', markersize='20', alpha=1.0, colorbar=True, colorbar_label='pole age (Ma)'): """ This function plots multiple paleomagnetic pole and A95 er...
python
{ "resource": "" }
q11667
plot_vgp
train
def plot_vgp(map_axis, vgp_lon=None, vgp_lat=None, di_block=None, label='', color='k', marker='o', edge='black', markersize=20, legend=False): """ This function plots a paleomagnetic pole position on a cartopy map axis. Before this function is called, a plot needs to be initialized with code ...
python
{ "resource": "" }
q11668
plot_dmag
train
def plot_dmag(data="", title="", fignum=1, norm=1,dmag_key='treat_ac_field',intensity='', quality=False): """ plots demagenetization data versus step for all specimens in pandas dataframe datablock Parameters ______________ data : Pandas dataframe with MagIC data model 3 columns: ...
python
{ "resource": "" }
q11669
eigs_s
train
def eigs_s(infile="", dir_path='.'): """ Converts eigenparamters format data to s format Parameters ___________________ Input: file : input file name with eigenvalues (tau) and eigenvectors (V) with format: tau_1 V1_dec V1_inc tau_2 V2_dec V2_inc tau_3 V3_dec V3_inc Output ...
python
{ "resource": "" }
q11670
specimens_extract
train
def specimens_extract(spec_file='specimens.txt', output_file='specimens.xls', landscape=False, longtable=False, output_dir_path='.', input_dir_path='', latex=False): """ Extracts specimen results from a MagIC 3.0 format specimens.txt file. Default output format is an Excel file. t...
python
{ "resource": "" }
q11671
criteria_extract
train
def criteria_extract(crit_file='criteria.txt', output_file='criteria.xls', output_dir_path='.', input_dir_path='', latex=False): """ Extracts criteria from a MagIC 3.0 format criteria.txt file. Default output format is an Excel file. typeset with latex on your own computer. Pa...
python
{ "resource": "" }
q11672
Site.parse_fits
train
def parse_fits(self, fit_name): '''USE PARSE_ALL_FITS unless otherwise necessary Isolate fits by the name of the fit; we also set 'specimen_tilt_correction' to zero in order to only include data in geographic coordinates - THIS NEEDS TO BE GENERALIZED ''' fits = self.fits.loc[sel...
python
{ "resource": "" }
q11673
MagICMenu.on_show_mainframe
train
def on_show_mainframe(self, event): """ Show mainframe window """ self.parent.Enable() self.parent.Show() self.parent.Raise()
python
{ "resource": "" }
q11674
get_PD_direction
train
def get_PD_direction(X1_prime, X2_prime, X3_prime, PD): """takes arrays of X1_prime, X2_prime, X3_prime, and the PD. checks that the PD vector direction is correct""" n = len(X1_prime) - 1 X1 = X1_prime[0] - X1_prime[n] X2 = X2_prime[0] - X2_prime[n] X3 = X3_prime[0] - X3_prime[n] R= numpy...
python
{ "resource": "" }
q11675
dir2cart
train
def dir2cart(d): # from pmag.py """converts list or array of vector directions, in degrees, to array of cartesian coordinates, in x,y,z form """ ints = numpy.ones(len(d)).transpose() # get an array of ones to plug into dec,inc pairs d = numpy.array(d) rad = old_div(numpy.pi, 180.) if le...
python
{ "resource": "" }
q11676
pmag_angle
train
def pmag_angle(D1,D2): # use this """ finds the angle between lists of two directions D1,D2 """ D1 = numpy.array(D1) if len(D1.shape) > 1: D1 = D1[:,0:2] # strip off intensity else: D1 = D1[:2] D2 = numpy.array(D2) if len(D2.shape) > 1: D2 = D2[:,0:2] # strip o...
python
{ "resource": "" }
q11677
new_get_angle_diff
train
def new_get_angle_diff(v1,v2): """returns angular difference in degrees between two vectors. may be more precise in certain cases. see SPD""" v1 = numpy.array(v1) v2 = numpy.array(v2) angle = numpy.arctan2(numpy.linalg.norm(numpy.cross(v1, v2)), numpy.dot(v1, v2)) return math.degrees(angle)
python
{ "resource": "" }
q11678
get_angle_difference
train
def get_angle_difference(v1, v2): """returns angular difference in degrees between two vectors. takes in cartesian coordinates.""" v1 = numpy.array(v1) v2 = numpy.array(v2) angle=numpy.arccos(old_div((numpy.dot(v1, v2) ), (numpy.sqrt(math.fsum(v1**2)) * numpy.sqrt(math.fsum(v2**2))))) return ma...
python
{ "resource": "" }
q11679
get_ptrms_angle
train
def get_ptrms_angle(ptrms_best_fit_vector, B_lab_vector): """ gives angle between principal direction of the ptrm data and the b_lab vector. this is NOT in SPD, but taken from Ron Shaar's old thellier_gui.py code. see PmagPy on github """ ptrms_angle = math.degrees(math.acos(old_div(numpy.dot(ptrms_be...
python
{ "resource": "" }
q11680
main
train
def main(): """ Take out dos problem characters from any file """ filename = pmag.get_named_arg('-f') if not filename: return with open(filename, 'rb+') as f: content = f.read() f.seek(0) f.write(content.replace(b'\r', b'')) f.truncate()
python
{ "resource": "" }
q11681
main
train
def main(): """ NAME kly4s_magic.py DESCRIPTION converts files generated by SIO kly4S labview program to MagIC formated files for use with PmagPy plotting software SYNTAX kly4s_magic.py -h [command line options] OPTIONS -h: prints the help message and quits...
python
{ "resource": "" }
q11682
main
train
def main(): """ NAME sort_specimens.py DESCRIPTION Reads in a pmag_specimen formatted file and separates it into different components (A,B...etc.) SYNTAX sort_specimens.py [-h] [command line options] INPUT takes pmag_specimens.txt formatted input file OPTIONS...
python
{ "resource": "" }
q11683
ErMagicCheckFrame3.InitLocCheck
train
def InitLocCheck(self): """ make an interactive grid in which users can edit locations """ # if there is a location without a name, name it 'unknown' self.contribution.rename_item('locations', 'nan', 'unknown') # propagate lat/lon values from sites table self.cont...
python
{ "resource": "" }
q11684
ErMagicCheckFrame3.validate
train
def validate(self, grid): """ Using the MagIC data model, generate validation errors on a MagicGrid. Parameters ---------- grid : dialogs.magic_grid3.MagicGrid The MagicGrid to be validated Returns --------- warnings: dict ...
python
{ "resource": "" }
q11685
ErMagicCheckFrame3.on_saveButton
train
def on_saveButton(self, event, grid): """saves any editing of the grid but does not continue to the next window""" wait = wx.BusyInfo("Please wait, working...") wx.SafeYield() if self.grid_frame.drop_down_menu: # unhighlight selected columns, etc. self.grid_frame.drop_down_...
python
{ "resource": "" }
q11686
ErMagicCheckFrame.onMouseOver
train
def onMouseOver(self, event, grid): """ Displays a tooltip over any cell in a certain column """ x, y = grid.CalcUnscrolledPosition(event.GetX(), event.GetY()) coords = grid.XYToCell(x, y) col = coords[1] row = coords[0] # creates tooltip message for cell...
python
{ "resource": "" }
q11687
ErMagicCheckFrame.on_helpButton
train
def on_helpButton(self, event, page=None): """shows html help page""" # for use on the command line: path = find_pmag_dir.get_pmag_dir() # for use with pyinstaller #path = self.main_frame.resource_dir help_page = os.path.join(path, 'dialogs', 'help_files', page) #...
python
{ "resource": "" }
q11688
ErMagicCheckFrame.onDeleteRow
train
def onDeleteRow(self, event, data_type): """ On button click, remove relevant object from both the data model and the grid. """ ancestry = self.er_magic_data.ancestry child_type = ancestry[ancestry.index(data_type) - 1] names = [self.grid.GetCellValue(row, 0) for row in s...
python
{ "resource": "" }
q11689
ErMagicCheckFrame.onSelectRow
train
def onSelectRow(self, event): """ Highlight or unhighlight a row for possible deletion. """ grid = self.grid row = event.Row default = (255, 255, 255, 255) highlight = (191, 216, 216, 255) cell_color = grid.GetCellBackgroundColour(row, 0) attr = wx...
python
{ "resource": "" }
q11690
ErMagicCheckFrame.update_grid
train
def update_grid(self, grid): """ takes in wxPython grid and ErMagic data object to be updated """ data_methods = {'specimen': self.er_magic_data.change_specimen, 'sample': self.er_magic_data.change_sample, 'site': self.er_magic_data.change_...
python
{ "resource": "" }
q11691
main
train
def main(): """ NAME update_measurements.py DESCRIPTION update the magic_measurements table with new orientation info SYNTAX update_measurements.py [command line options] OPTIONS -h prints help message and quits -f MFILE, specify magic_measurements file; ...
python
{ "resource": "" }
q11692
main
train
def main(): """ NAME angle.py DESCRIPTION calculates angle between two input directions D1,D2 INPUT (COMMAND LINE ENTRY) D1_dec D1_inc D1_dec D2_inc OUTPUT angle SYNTAX angle.py [-h][-i] [command line options] [< filename] OPTIONS -h pr...
python
{ "resource": "" }
q11693
main
train
def main(): """ NAME fishrot.py DESCRIPTION generates set of Fisher distributed data from specified distribution SYNTAX fishrot.py [-h][-i][command line options] OPTIONS -h prints help message and quits -i for interactive entry -k kappa specify ka...
python
{ "resource": "" }
q11694
Arai_GUI.cart2dir
train
def cart2dir(self,cart): """ converts a direction to cartesian coordinates """ # print "calling cart2dir(), not in anything" cart=numpy.array(cart) rad=old_div(numpy.pi,180.) # constant to convert degrees to radians if len(cart.shape)>1: Xs,Ys,Zs=cart[:...
python
{ "resource": "" }
q11695
Arai_GUI.magic_read
train
def magic_read(self,infile): """ reads a Magic template file, puts data in a list of dictionaries """ # print "calling magic_read(self, infile)", infile hold,magic_data,magic_record,magic_keys=[],[],{},[] try: f=open(infile,"r") except: ret...
python
{ "resource": "" }
q11696
Arai_GUI.get_specs
train
def get_specs(self,data): """ takes a magic format file and returns a list of unique specimen names """ # sort the specimen names # # print "calling get_specs()" speclist=[] for rec in data: spec=rec["er_specimen_name"] if spec not in speclist:...
python
{ "resource": "" }
q11697
main
train
def main(): """ NAME orientation_magic.py DESCRIPTION takes tab delimited field notebook information and converts to MagIC formatted tables SYNTAX orientation_magic.py [command line options] OPTIONS -f FILE: specify input file, default is: orient.txt -Fsa F...
python
{ "resource": "" }
q11698
MagicGrid.add_row
train
def add_row(self, label='', item=''): """ Add a row to the grid """ self.AppendRows(1) last_row = self.GetNumberRows() - 1 self.SetCellValue(last_row, 0, str(label)) self.row_labels.append(label) self.row_items.append(item)
python
{ "resource": "" }
q11699
MagicGrid.remove_row
train
def remove_row(self, row_num=None): """ Remove a row from the grid """ #DeleteRows(self, pos, numRows, updateLabel if not row_num and row_num != 0: row_num = self.GetNumberRows() - 1 label = self.GetCellValue(row_num, 0) self.DeleteRows(pos=row_num, nu...
python
{ "resource": "" }