code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
new_s = self.specimens_box.GetValue() if self.select_specimen(new_s): self.update_selection() else: self.specimens_box.SetValue(self.s) self.user_warning( "no specimen %s reverting to old specimen %s" % (new_s, self.s))
def onSelect_specimen(self, event)
update figures and text when a new specimen is selected
4.490066
4.417257
1.016483
def on_close(event, wind): wind.Close() wind.Destroy() event.Skip() wind = wx.PopupTransientWindow(self, wx.RAISED_BORDER) if self.auto_save.GetValue(): info = "'auto-save' is currently selected. Temperature bounds will be saved when you click...
def on_info_click(self, event)
Show popup info window when user clicks "?"
3.060084
2.943279
1.039685
if 'saved' not in self.Data[self.s]['pars'] or self.Data[self.s]['pars']['saved'] != True: # check preferences if self.auto_save.GetValue(): self.on_save_interpretation_button(None) else: del self.Data[self.s]['pars'] s...
def on_prev_button(self, event)
update figures and text when a previous button is selected
2.573492
2.567863
1.002192
self.tmin_box.Clear() self.tmin_box.SetItems(self.T_list) self.tmin_box.SetSelection(-1) self.tmax_box.Clear() self.tmax_box.SetItems(self.T_list) self.tmax_box.SetSelection(-1) self.Blab_window.SetValue("") self.Banc_window.SetValue("") ...
def clear_boxes(self)
Clear all boxes
3.339829
3.319988
1.005976
user_data_dir = find_pmag_dir.find_user_data_dir("thellier_gui") if not user_data_dir: return {} if os.path.exists(user_data_dir): pref_file = os.path.join(user_data_dir, "thellier_gui_preferences.json") if os.path.exists(pref_file): w...
def read_preferences_file(self)
If json preferences file exists, read it in.
2.864276
2.790879
1.026299
user_data_dir = find_pmag_dir.find_user_data_dir("thellier_gui") if not os.path.exists(user_data_dir): find_pmag_dir.make_user_data_dir(user_data_dir) pref_file = os.path.join(user_data_dir, "thellier_gui_preferences.json") with open(pref_file, "w+") as pfile: ...
def write_preferences_file(self)
Write json preferences file to (platform specific) user data directory, or PmagPy directory if appdirs module is missing.
3.244171
2.93858
1.103993
if self.close_warning: TEXT = "Data is not saved to a file yet!\nTo properly save your data:\n1) Analysis --> Save current interpretations to a redo file.\nor\n1) File --> Save MagIC tables.\n\n Press OK to exit without saving." dlg1 = wx.MessageDialog( None, cap...
def on_menu_exit(self, event)
Runs whenever Thellier GUI exits
4.319815
4.251365
1.016101
save_current_specimen = self.s dlg = wx.FileDialog( self, message="choose a file in a pmagpy redo format", defaultDir=self.WD, defaultFile="thellier_GUI.redo", wildcard="*.redo", style=wx.FD_OPEN | wx.FD_CHANGE_DIR ) if...
def on_menu_previous_interpretation(self, event)
Create and show the Open FileDialog for upload previous interpretation input should be a valid "redo file": [specimen name] [tmin(kelvin)] [tmax(kelvin)]
4.062302
3.620765
1.121946
dia = thellier_gui_dialogs.Criteria_Dialog( None, self.acceptance_criteria, self.preferences, title='Set Acceptance Criteria') dia.Center() result = self.show_dlg(dia) if result == wx.ID_OK: # Until the user clicks OK, show the message self.On_close_cr...
def on_menu_criteria(self, event)
Change acceptance criteria and save it to the criteria file (data_model=2: pmag_criteria.txt; data_model=3: criteria.txt)
9.423625
8.224225
1.145837
criteria_list = list(self.acceptance_criteria.keys()) criteria_list.sort() #--------------------------------------- # check if averaging by sample or by site # and intialize sample/site criteria #--------------------------------------- avg_by = dia.set_a...
def On_close_criteria_box(self, dia)
after criteria dialog window is closed. Take the acceptance criteria values and update self.acceptance_criteria
3.760449
3.683677
1.020841
''' update self.Data[specimen]['pars'] for all specimens. ''' gframe = wx.BusyInfo( "Re-calculating statistics for all specimens\n Please wait..", self) for specimen in list(self.Data.keys()): if 'pars' not in list(self.Data[specimen].keys()): ...
def recalculate_satistics(self)
update self.Data[specimen]['pars'] for all specimens.
3.717183
3.127777
1.188442
''' read criteria file. initialize self.acceptance_criteria try to guess if averaging by sample or by site. ''' if self.data_model == 3: self.acceptance_criteria = pmag.initialize_acceptance_criteria( data_model=self.data_model) sel...
def read_criteria_file(self, criteria_file)
read criteria file. initialize self.acceptance_criteria try to guess if averaging by sample or by site.
4.232895
3.836937
1.103196
''' save interpretations to a redo file ''' thellier_gui_redo_file = open( os.path.join(self.WD, "thellier_GUI.redo"), 'w') #-------------------------------------------------- # write interpretations to thellier_GUI.redo #---------------------------...
def on_menu_save_interpretation(self, event)
save interpretations to a redo file
3.813371
3.548681
1.074588
''' clear all current interpretations. ''' # delete all previous interpretation for sp in list(self.Data.keys()): del self.Data[sp]['pars'] self.Data[sp]['pars'] = {} self.Data[sp]['pars']['lab_dc_field'] = self.Data[sp]['lab_dc_field'] ...
def on_menu_clear_interpretation(self, event)
clear all current interpretations.
3.980333
3.76505
1.057179
''' read er_ages, sort it by site or sample (the header that is not empty) and convert ages to calendar year ''' DATA = {} fin = open(path, 'r') # ignore first lines for i in range(ignore_lines_n): fin.readline() # header line ...
def read_er_ages_file(self, path, ignore_lines_n, sort_by_these_names)
read er_ages, sort it by site or sample (the header that is not empty) and convert ages to calendar year
3.107933
2.224028
1.397434
''' convert all age units to calendar year ''' if ("age" not in list(er_ages_rec.keys())) or (cb.is_null(er_ages_rec['age'], False)): return(er_ages_rec) if ("age_unit" not in list(er_ages_rec.keys())) or (cb.is_null(er_ages_rec['age_unit'])): return(er_ag...
def convert_ages_to_calendar_year(self, er_ages_rec)
convert all age units to calendar year
1.803456
1.77898
1.013759
# remember the last saved interpretation if "saved" in list(self.pars.keys()): if self.pars['saved']: self.last_saved_pars = {} for key in list(self.pars.keys()): self.last_saved_pars[key] = self.pars[key] self.pars['saved...
def get_new_T_PI_parameters(self, event)
calcualte statisics when temperatures are selected
3.401291
3.298187
1.031261
'''criteria used only in thellier gui these criteria are not written to pmag_criteria.txt ''' category = "thellier_gui" for crit in ['sample_int_n_outlier_check', 'site_int_n_outlier_check']: self.acceptance_criteria[crit] = {} self.acceptance_criteria[cri...
def add_thellier_gui_criteria(self)
criteria used only in thellier gui these criteria are not written to pmag_criteria.txt
2.32166
2.165104
1.072309
ofile="" if '-h' in sys.argv: print(main.__doc__) sys.exit() if '-F' in sys.argv: ind=sys.argv.index('-F') ofile=sys.argv[ind+1] outfile=open(ofile,'w') if '-i' in sys.argv: cont=1 while cont==1: cart=[] try: ...
def main()
NAME cart_dir.py DESCRIPTION converts cartesian coordinates to geomagnetic elements INPUT (COMMAND LINE ENTRY) x1 x2 x3 if only two columns, assumes magnitude of unity OUTPUT declination inclination magnitude SYNTAX cart_dir.py [comman...
2.508028
2.345521
1.069284
save_plots = False if '-sav' in sys.argv: save_plots = True interactive = False if '-h' in sys.argv: print(main.__doc__) sys.exit() fmt = pmag.get_named_arg('-fmt', 'svg') fname = pmag.get_named_arg('-f', '') outfile = pmag.get_named_arg("-F", "") norm =...
def main()
NAME histplot.py DESCRIPTION makes histograms for data OPTIONS -h prints help message and quits -f input file name -b binsize -fmt [svg,png,pdf,eps,jpg] specify format for image, default is svg -sav save figure and quit -F output file name, default is hi...
3.841636
3.06535
1.253245
string = " ".join(argv) string = string.split(' -') program = string[0] arguments = [s.split() for s in string[1:]] return arguments
def extract_args(argv)
take sys.argv that is used to call a command-line script and return a correctly split list of arguments for example, this input: ["eqarea.py", "-f", "infile", "-F", "outfile", "-A"] will return this output: [['f', 'infile'], ['F', 'outfile'], ['A']]
4.747918
4.573614
1.038111
stripped_args = [a[0] for a in arguments] df = data_frame.df # first make sure all args are valid for a in arguments: if a[0] not in df.index: print("-I- ignoring invalid argument: {}".format(a[0])) print("-") # next make sure required arguments are present c...
def check_args(arguments, data_frame)
check arguments against a command_line_dataframe. checks that: all arguments are valid all required arguments are present default values are used where needed
5.286992
5.065573
1.043711
if self.data_type in ['orient', 'ages']: belongs_to = [] else: parent_table_name = self.parent_type + "s" if parent_table_name in self.contribution.tables: belongs_to = sorted(self.contribution.tables[parent_table_name].df.index.unique()) ...
def InitUI(self)
Initialize interface for drop down menu
3.514145
3.424714
1.026113
if col_label.endswith('**') or col_label.endswith('^^'): col_label = col_label[:-2] # add drop-down for experiments if col_label == "experiments": if 'measurements' in self.contribution.tables: meas_table = self.contribution.tables['measurements']...
def add_drop_down(self, col_number, col_label)
Add a correctly formatted drop-down-menu for given col_label, if required or suggested. Otherwise do nothing. Parameters ---------- col_number : int grid position at which to add a drop down menu col_label : str column name
2.696846
2.66526
1.011851
if self.data_type == 'ages': method_list = self.contribution.vocab.age_methods else: method_list = self.contribution.vocab.age_methods.copy() method_list.update(self.contribution.vocab.methods) self.choices[col_number] = (method_list, True)
def add_method_drop_down(self, col_number, col_label)
Add drop-down-menu options for magic_method_codes columns
4.719932
4.565778
1.033763
if '-h' in sys.argv: print(main.__doc__) sys.exit() if '-F' in sys.argv: ind=sys.argv.index('-F') ofile=sys.argv[ind+1] out=open(ofile,'w') print(ofile, ' opened for output') else: ofile="" if '-i' in sys.argv: # interactive flag while 1: ...
def main()
NAME di_tilt.py DESCRIPTION rotates geographic coordinate dec, inc data to stratigraphic coordinates using the dip and dip direction (strike+90, dip if dip to right of strike) INPUT FORMAT declination inclination dip_direction dip SYNTAX di_tilt.py [-h][-i][-f FILE] [...
3.339096
2.860859
1.167165
if '-h' in sys.argv: print(main.__doc__) sys.exit() file=sys.argv[1] f=open(file,'r') Input=f.readlines() f.close() out=open(file,'w') for line in Input: out.write(line) out.close()
def main()
NAME convert2unix.py DESCRIPTION converts mac or dos formatted file to unix file in place SYNTAX convert2unix.py FILE OPTIONS -h prints help and quits
2.800563
2.735354
1.023839
if len(sys.argv) > 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] f=open(file,'r') data=f.readlines() ...
def main()
NAME gokent.py DESCRIPTION calculates Kent parameters from dec inc data INPUT FORMAT takes dec/inc as first two columns in space delimited file SYNTAX gokent.py [options] OPTIONS -h prints help message and quits -i for interactive filename entry -f...
3.192029
2.537621
1.257883
is_win = True if sys.platform in ['win32', 'win64'] else False if not is_win: plt.ion() for fig in list(FIGS.keys()): plt.draw() plt.show() plt.ioff() if is_win: # this style basically works for Windows plt.draw() print("You must m...
def draw_figs(FIGS)
Can only be used if matplotlib backend is set to TKAgg Does not play well with wxPython Parameters _________ FIGS : dictionary of figure names as keys and numbers as values
5.545396
5.205434
1.065309
locs = fig.xaxis.get_ticklocs() nlocs = np.delete(locs, list(range(0, len(locs), 2))) fig.set_xticks(nlocs)
def delticks(fig)
deletes half the x-axis tick marks Parameters ___________ fig : matplotlib figure number
3.875775
4.119704
0.94079
global fig_x_pos, fig_y_pos, plt_num dpi = 80 if isServer: dpi = 240 # plt.ion() plt_num += 1 fig = plt.figure(num=fignum, figsize=(w, h), dpi=dpi) if (not isServer) and (not set_env.IS_NOTEBOOK): plt.get_current_fig_manager().show() # plt.get_current_fig_manager...
def plot_init(fignum, w, h)
initializes plot number fignum with width w and height h Parameters __________ fignum : matplotlib figure number w : width h : height
3.556712
3.695532
0.962436
from mpl_toolkits.mplot3d import Axes3D fig = plt.figure(fignum) ax = fig.add_subplot(111, projection='3d') return ax
def plot3d_init(fignum)
initializes 3D plot
1.554652
1.571612
0.989208
x = old_div((y - ybar), (np.sqrt(2.) * sigma)) t = old_div(1.0, (1.0 + .3275911 * abs(x))) erf = 1.0 - np.exp(-x * x) * t * (.254829592 - t * (.284496736 - t * (1.421413741 - t * (1.453152027 - t * 1.061405429)))) erf = abs(erf) sign = old...
def gaussfunc(y, ybar, sigma)
cumulative normal distribution function of the variable y with mean ybar,standard deviation sigma uses expression 7.1.26 from Abramowitz & Stegun accuracy better than 1.5e-7 absolute Parameters _________ y : input variable ybar : mean sigma : standard deviation
3.057264
3.03014
1.008951
xbar, sigma = pmag.gausspars(X) d, f = 0, 0. for i in range(1, len(X) + 1): b = old_div(float(i), float(len(X))) a = gaussfunc(X[i - 1], xbar, sigma) if abs(f - a) > abs(b - a): delta = abs(f - a) else: delta = abs(b - a) if delta > d: ...
def k_s(X)
Kolmorgorov-Smirnov statistic. Finds the probability that the data are distributed as func - used method of Numerical Recipes (Press et al., 1986)
4.046488
4.131951
0.979317
d = p if d < 0. or d > 1.: print('d not in (1,1) ') sys.exit() x = 0. if (d - 0.5) > 0: d = 1. - d if (d - 0.5) < 0: t2 = -2. * np.log(d) t = np.sqrt(t2) x = t - old_div((2.515517 + .802853 * t + .010328 * t2), (1. + 1.4327...
def qsnorm(p)
rational approximation for x where q(x)=d, q being the cumulative normal distribution function. taken from Abramowitz & Stegun p. 933 |error(x)| < 4.5*10**-4
3.49406
3.52011
0.9926
plt.figure(num=fignum) # if 'poly' in kwargs.keys(): # coeffs=np.polyfit(X,Y,kwargs['poly']) # polynomial=np.poly1d(coeffs) # xs=np.arange(np.min(X),np.max(X)) # ys=polynomial(xs) # plt.plot(xs,ys) # print coefs # print polynomial if 'sym' i...
def plot_xy(fignum, X, Y, **kwargs)
deprecated, used in curie
1.728546
1.723958
1.002661
print('Site mean data: ') print(' dec inc n_lines n_planes kappa R alpha_95 comp coord') print(SiteRec['site_dec'], SiteRec['site_inc'], SiteRec['site_n_lines'], SiteRec['site_n_planes'], SiteRec['site_k'], SiteRec['site_r'], SiteRec['site_alpha95'], SiteRec['site_comp_name'], SiteRec['s...
def plot_site(fignum, SiteRec, data, key)
deprecated (used in ipmag)
6.165533
5.753166
1.071677
plt.figure(num=fignum) if type(Y) == list: Y = np.array(Y) Y = np.sort(Y) # sort the data n = len(Y) d, mean, sigma = k_s(Y) dc = old_div(0.886, np.sqrt(float(n))) X = [] # list for normal quantile for i in range(1, n + 1): p = old_div(float(i), float(n + 1)) ...
def plot_qq_norm(fignum, Y, title)
makes a Quantile-Quantile plot for data Parameters _________ fignum : matplotlib figure number Y : list or array of data title : title string for plot Returns ___________ d,dc : the values for D and Dc (the critical value) if d>dc, likely to be normally distributed (95\% confiden...
2.445369
2.314647
1.056476
if subplot == True: plt.subplot(1, 2, fignum) else: plt.figure(num=fignum) X, Y, dpos, dneg = [], [], 0., 0. if degrees: D = (np.array(D)) % 360 X = D/D.max() X = np.sort(X) n = float(len(D)) i = np.arange(0, len(D)) Y = (i-0.5)/n ds = (i/n)-X dpo...
def plot_qq_unf(fignum, D, title, subplot=False, degrees=True)
plots data against a uniform distribution in 0=>360. Parameters _________ fignum : matplotlib figure number D : data title : title for plot subplot : if True, make this number one of two subplots degrees : if True, assume that these are degrees Return Mu : Mu statistic (Fisher et al...
3.673193
3.471359
1.058143
if subplot == True: plt.subplot(1, 2, fignum) else: plt.figure(num=fignum) X, Y, dpos, dneg = [], [], 0., 0. rad = old_div(np.pi, 180.) xsum = 0 for i in I: theta = (90. - i) * rad X.append(1. - np.cos(theta)) xsum += X[-1] X.sort() n = float(...
def plot_qq_exp(fignum, I, title, subplot=False)
plots data against an exponential distribution in 0=>90. Parameters _________ fignum : matplotlib figure number I : data title : plot title subplot : boolean, if True plot as subplot with 1 row, two columns with fignum the plot number
3.254929
3.315306
0.981788
global globals X_down, X_up, Y_down, Y_up = [], [], [], [] # initialize some variables plt.figure(num=fignum) # # plot the data - separate upper and lower hemispheres # for rec in DIblock: Up, Down = 0, 0 XY = pmag.dimap(rec[0], rec[1]) if rec[1] >= 0: X_down....
def plot_di(fignum, DIblock)
plots directions on equal area net Parameters _________ fignum : matplotlib figure number DIblock : nested list of dec, inc pairs
2.824502
2.980893
0.947536
global globals X_down, X_up, Y_down, Y_up = [], [], [], [] # initialize some variables plt.figure(num=fignum) # # plot the data - separate upper and lower hemispheres # for rec in DIblock: Up, Down = 0, 0 XY = pmag.dimap(rec[0], rec[1]) if rec[1] >= 0: X_down....
def plot_di_sym(fignum, DIblock, sym)
plots directions on equal area net Parameters _________ fignum : matplotlib figure number DIblock : nested list of dec, inc pairs sym : set matplotlib symbol (e.g., 'bo' for blue circles)
2.679223
2.686686
0.997222
plt.figure(num=fignum) D_c, I_c = pmag.circ(pole[0], pole[1], ang) X_c_up, Y_c_up = [], [] X_c_d, Y_c_d = [], [] for k in range(len(D_c)): XY = pmag.dimap(D_c[k], I_c[k]) if I_c[k] < 0: X_c_up.append(XY[0]) Y_c_up.append(XY[1]) else: X...
def plot_circ(fignum, pole, ang, col)
function to put a small circle on an equal area projection plot, fig,fignum Parameters __________ fignum : matplotlib figure number pole : dec,inc of center of circle ang : angle of circle col :
2.188902
2.268562
0.964885
for fignum in list(ZED.keys()): fig = plt.figure(num=ZED[fignum]) plt.clf() if not isServer: plt.figtext(.02, .01, version_num) DIbad, DIgood = [], [] for rec in datablock: if cb.is_null(rec[1],zero_as_null=False): print('-W- You are missing a dec...
def plot_zed(ZED, datablock, angle, s, units)
function to make equal area plot and zijderveld plot Parameters _________ ZED : dictionary with keys for plots eqarea : figure number for equal area projection zijd : figure number for zijderveld plot demag : figure number for magnetization against demag step datablock :...
3.858377
3.359087
1.148639
global globals first_Z, first_I, ptrm_check, ptrm_tail = indata[0], indata[1], indata[2], indata[3] plt.figure(num=fignum) plt.clf() if not isServer: plt.figtext(.02, .01, version_num) X, Y, recnum = [], [], 0 # for rec in first_Z: if units == "K": if rec[0] ...
def plot_np(fignum, indata, s, units)
makes plot of de(re)magnetization data for Thellier-Thellier type experiment Parameters __________ fignum : matplotlib figure number indata : araiblock from, e.g., pmag.sortarai() s : specimen name units : [K, J, ""] (kelvin, joules, unknown) Effect _______ Makes a plot
3.043601
3.089247
0.985224
angle = zijdblock[0][1] norm = 1 if units == "U": norm = 0 plot_arai(ZED['arai'], araiblock, s, units) plot_teq(ZED['eqarea'], araiblock, s, "") plot_zij(ZED['zijd'], zijdblock, angle, s, norm) plot_np(ZED['deremag'], araiblock, s, units) return ZED
def plot_arai_zij(ZED, araiblock, zijdblock, s, units)
calls the four plotting programs for Thellier-Thellier experiments Parameters __________ ZED : dictionary with plotting figure keys: deremag : figure for de (re) magnezation plots arai : figure for the Arai diagram eqarea : equal area projection of data, color coded by r...
5.006914
2.97594
1.682465
# make the stereonet plt.figure(num=fignum) plot_net(fignum) s = SiteRec['er_site_name'] # # plot on the data # coord = SiteRec['site_tilt_correction'] title = '' if coord == '-1': title = s + ": specimen coordinates" if coord == '0': title = s + ": geographic coordina...
def plot_slnp(fignum, SiteRec, datablock, key)
plots lines and planes on a great circle with alpha 95 and mean deprecated (used in pmagplotlib)
3.623951
3.335131
1.086599
# make the stereonet plot_net(fignum) # # plot on the data # dec_key, inc_key, tilt_key = 'dec', 'inc', 'tilt_correction' if 'dir_dec' in datablock[0].keys(): # this is data model 3.0 dec_key, inc_key, tilt_key = 'dir_dec', 'dir_inc', 'dir_tilt_correction' coord = datablock[0][tilt_key] ...
def plot_lnp(fignum, s, datablock, fpars, direction_type_key)
plots lines and planes on a great circle with alpha 95 and mean Parameters _________ fignum : number of plt.figure() object datablock : nested list of dictionaries with keys in 3.0 or 2.5 format 3.0 keys: dir_dec, dir_inc, dir_tilt_correction = [-1,0,100], direction_type_key =['p','l'] ...
3.434572
2.973796
1.154945
# make the stereonet plt.figure(num=fignum) if len(DIblock) < 1: return # plt.clf() if not isServer: plt.figtext(.02, .01, version_num) plot_net(fignum) # # put on the directions # plot_di(fignum, DIblock) # plot directions plt.axis("equal") plt.text(-1.1, 1.15, s...
def plot_eq(fignum, DIblock, s)
plots directions on eqarea projection Parameters __________ fignum : matplotlib figure number DIblock : nested list of dec/inc pairs s : specimen name
6.419535
6.239197
1.028904
# make the stereonet plt.figure(num=fignum) if len(DIblock) < 1: return # plt.clf() if not isServer: plt.figtext(.02, .01, version_num) plot_net(fignum) # # put on the directions # plot_di_sym(fignum, DIblock, sym) # plot directions with symbols in sym plt.axis("equal...
def plot_eq_sym(fignum, DIblock, s, sym)
plots directions with specified symbol Parameters __________ fignum : matplotlib figure number DIblock : nested list of dec/inc pairs s : specimen name sym : matplotlib symbol (e.g., 'bo' for blue circle)
6.96787
6.889377
1.011393
first_Z, first_I = araiblock[0], araiblock[1] # make the stereonet plt.figure(num=fignum) plt.clf() ZIblock, IZblock, pTblock = [], [], [] for zrec in first_Z: # sort out the zerofield steps if zrec[4] == 1: # this is a ZI step ZIblock.append([zrec[1], zrec[2]]) el...
def plot_teq(fignum, araiblock, s, pars)
plots directions of pTRM steps and zero field steps Parameters __________ fignum : figure number for matplotlib object araiblock : nested list of data from pmag.sortarai() s : specimen name pars : default is "", otherwise is dictionary with keys: 'measurement_step_min' and 'mea...
3.340593
2.672311
1.250076
saved = [] for key in list(Figs.keys()): try: plt.figure(num=Figs[key]) fname = filenames[key] if set_env.IS_WIN: # always truncate filenames if on Windows fname = os.path.split(fname)[1] if not isServer: # remove illegal ':' charact...
def save_plots(Figs, filenames, **kwargs)
Parameters ---------- Figs : dict dictionary of plots, e.g. {'eqarea': 1, ...} filenames : dict dictionary of filenames, e.g. {'eqarea': 'mc01a_eqarea.svg', ...} dict keys should correspond with Figs
3.778818
4.067344
0.929063
# plt.figure(num=fignum) plt.text(-1.1, 1.15, title) # plot V1s as squares, V2s as triangles and V3s as circles symb, symkey = ['s', 'v', 'o'], 0 col = ['r', 'b', 'k'] # plot V1s rec, V2s blue, V3s black for VEC in range(3): X, Y = [], [] for Vdirs in Vs: # ...
def plot_evec(fignum, Vs, symsize, title)
plots eigenvector directions of S vectors Paramters ________ fignum : matplotlib figure number Vs : nested list of eigenvectors symsize : size in pts for symbol title : title for plot
4.948416
4.968727
0.995912
vertical_plot_init(fignum, 10, 3) xlab, ylab, title = labels[0], labels[1], labels[2] X, Y = [], [] for rec in data: X.append(rec[0]) Y.append(rec[1]) plt.plot(X, Y) plt.plot(X, Y, 'ro') plt.xlabel(xlab) plt.ylabel(ylab) plt.title(title)
def plot_strat(fignum, data, labels)
plots a time/depth series Parameters _________ fignum : matplotlib figure number data : nested list of [X,Y] pairs labels : [xlabel, ylabel, title]
2.497602
2.712602
0.92074
# #if len(sym)==1:sym=sym+'-' fig = plt.figure(num=fignum) # sdata=np.array(data).sort() sdata = [] for d in data: sdata.append(d) # have to copy the data to avoid overwriting it! sdata.sort() X, Y = [], [] color = "" for j in range(len(sdata)): Y.append(old_div...
def plot_cdf(fignum, data, xlab, sym, title, **kwargs)
Makes a plot of the cumulative distribution function. Parameters __________ fignum : matplotlib figure number data : list of data to be plotted - doesn't need to be sorted sym : matplotlib symbol for plotting, e.g., 'r--' for a red dashed line **kwargs : optional dictionary with {'color': color...
3.084618
2.891106
1.066933
fig = plt.figure(num=fignum) for yv in Ys: bounds = plt.axis() plt.axhline(y=yv, xmin=0, xmax=1, linewidth=1, color=c, linestyle=ls)
def plot_hs(fignum, Ys, c, ls)
plots horizontal lines at Ys values Parameters _________ fignum : matplotlib figure number Ys : list of Y values for lines c : color for lines ls : linestyle for lines
3.186734
3.263655
0.976431
fig = plt.figure(num=fignum) for xv in Xs: bounds = plt.axis() plt.axvline( x=xv, ymin=bounds[2], ymax=bounds[3], linewidth=1, color=c, linestyle=ls)
def plot_vs(fignum, Xs, c, ls)
plots vertical lines at Xs values Parameters _________ fignum : matplotlib figure number Xs : list of X values for lines c : color for lines ls : linestyle for lines
3.183945
3.157213
1.008467
vertical_plot_init(fignum, 10, 3) TS, Chrons = pmag.get_ts(ts) p = 1 X, Y = [], [] for d in TS: if d <= dates[1]: if d >= dates[0]: if len(X) == 0: ind = TS.index(d) X.append(TS[ind - 1]) Y.append(p ...
def plot_ts(fignum, dates, ts)
plot the geomagnetic polarity time scale Parameters __________ fignum : matplotlib figure number dates : bounding dates for plot ts : time scale ck95, gts04, or gts12
4.241539
4.359239
0.973
plt.figure(num=fignum) plt.clf() if not isServer: plt.figtext(.02, .01, version_num) plt.plot(B, DM, 'b') plt.xlabel('B (T)') plt.ylabel('Delta M') linex = [0, Bcr, Bcr] liney = [old_div(DM[0], 2.), old_div(DM[0], 2.), 0] plt.plot(linex, liney, 'r') plt.title(s)
def plot_delta_m(fignum, B, DM, Bcr, s)
function to plot Delta M curves Parameters __________ fignum : matplotlib figure number B : array of field values DM : array of difference between top and bottom curves in hysteresis loop Bcr : coercivity of remanence s : specimen name
3.181018
3.17708
1.001239
plt.figure(num=fignum) plt.clf() if not isServer: plt.figtext(.02, .01, version_num) start = len(Bdm) - len(DdeltaM) plt.plot(Bdm[start:], DdeltaM, 'b') plt.xlabel('B (T)') plt.ylabel('d (Delta M)/dB') plt.title(s)
def plot_d_delta_m(fignum, Bdm, DdeltaM, s)
function to plot d (Delta M)/dB curves Parameters __________ fignum : matplotlib figure number Bdm : change in field Ddelta M : change in delta M s : specimen name
4.166682
3.614629
1.152728
plt.figure(num=fignum) plt.clf() if not isServer: plt.figtext(.02, .01, version_num) plt.plot(Bimag, Mimag, 'r') plt.xlabel('B (T)') plt.ylabel('M/Ms') plt.axvline(0, color='k') plt.title(s)
def plot_imag(fignum, Bimag, Mimag, s)
function to plot d (Delta M)/dB curves
3.694815
3.787439
0.975544
hpars, deltaM, Bdm = plot_hys( HDD['hyst'], B, M, s) # Moff is the "fixed" loop data DdeltaM = [] Mhalf = "" for k in range(2, len(Bdm)): # differnential DdeltaM.append( old_div(abs(deltaM[k] - deltaM[k - 2]), (Bdm[k] - Bdm[k - 2]))) for k in range(len(delta...
def plot_hdd(HDD, B, M, s)
Function to make hysteresis, deltaM and DdeltaM plots Parameters: _______________ Input HDD : dictionary with figure numbers for the keys: 'hyst' : hysteresis plot normalized to maximum value 'deltaM' : Delta M plot 'DdeltaM' : differential of Delta M plot ...
4.436451
3.922061
1.131153
plt.figure(num=fignum) plt.plot(BcrBc, S, sym) plt.axhline(0, color='k') plt.axhline(.05, color='k') plt.axhline(.5, color='k') plt.axvline(1, color='k') plt.axvline(4, color='k') plt.xlabel('Bcr/Bc') plt.ylabel('Mr/Ms') plt.title('Day Plot') plt.xlim(0, 6) #bounds= ...
def plot_day(fignum, BcrBc, S, sym, **kwargs)
function to plot Day plots Parameters _________ fignum : matplotlib figure number BcrBc : list or array ratio of coercivity of remenance to coercivity S : list or array ratio of saturation remanence to saturation magnetization (squareness) sym : matplotlib symbol (e.g., 'rs' for red squares) ...
3.672791
3.55058
1.03442
plt.figure(num=fignum) plt.plot(Bc, S, sym) plt.xlabel('Bc') plt.ylabel('Mr/Ms') plt.title('Squareness-Coercivity Plot') bounds = plt.axis() plt.axis([0, bounds[1], 0, 1])
def plot_s_bc(fignum, Bc, S, sym)
function to plot Squareness,Coercivity Parameters __________ fignum : matplotlib figure number Bc : list or array coercivity values S : list or array of ratio of saturation remanence to saturation sym : matplotlib symbol (e.g., 'g^' for green triangles)
4.340255
3.063436
1.416793
plt.figure(num=fignum) plt.plot(Bcr, S, sym) plt.xlabel('Bcr') plt.ylabel('Mr/Ms') plt.title('Squareness-Bcr Plot') bounds = plt.axis() plt.axis([0, bounds[1], 0, 1])
def plot_s_bcr(fignum, Bcr, S, sym)
function to plot Squareness,Coercivity of remanence Parameters __________ fignum : matplotlib figure number Bcr : list or array coercivity of remenence values S : list or array of ratio of saturation remanence to saturation sym : matplotlib symbol (e.g., 'g^' for green triangles)
3.752566
3.316596
1.131451
plt.figure(num=fignum) plt.plot(Bcr1, Bcr2, 'ro') plt.xlabel('Bcr1') plt.ylabel('Bcr2') plt.title('Compare coercivity of remanence')
def plot_bcr(fignum, Bcr1, Bcr2)
function to plot two estimates of Bcr against each other
3.501506
3.408567
1.027266
plt.figure(num=HDD['hyst']) X, Y = [], [] X.append(0) Y.append(old_div(float(hpars['hysteresis_mr_moment']), float( hpars['hysteresis_ms_moment']))) X.append(float(hpars['hysteresis_bc'])) Y.append(0) plt.plot(X, Y, sym) bounds = plt.axis() n4 = 'Ms: ' + '%8.2e' % (float...
def plot_hpars(HDD, hpars, sym)
function to plot hysteresis parameters deprecated (used in hysteresis_magic)
2.36584
2.306731
1.025625
rpars = {} Mnorm = [] backfield = 0 X, Y = [], [] for k in range(len(B)): if M[k] < 0: break if k <= 5: kmin = 0 else: kmin = k - 5 for k in range(kmin, k + 1): X.append(B[k]) if B[k] < 0: backfield = 1 Y.append...
def plot_irm(fignum, B, M, title)
function to plot IRM backfield curves Parameters _________ fignum : matplotlib figure number B : list or array of field values M : list or array of magnetizations title : string title for plot
3.13213
3.12559
1.002093
plt.figure(num=fignum) plt.xlabel('Temperature (K)') plt.ylabel('Susceptibility (m^3/kg)') k = 0 Flab = [] for freq in XTF: T, X = [], [] for xt in freq: X.append(xt[0]) T.append(xt[1]) plt.plot(T, X) plt.text(T[-1], X[-1], str(int(Fs[...
def plot_xtf(fignum, XTF, Fs, e, b)
function to plot series of chi measurements as a function of temperature, holding field constant and varying frequency
3.63775
3.42593
1.061829
plt.figure(num=fignum) plt.xlabel('Temperature (K)') plt.ylabel('Susceptibility (m^3/kg)') k = 0 Blab = [] for field in XTB: T, X = [], [] for xt in field: X.append(xt[0]) T.append(xt[1]) plt.plot(T, X) plt.text(T[-1], X[-1], '%8.2e' %...
def plot_xtb(fignum, XTB, Bs, e, f)
function to plot series of chi measurements as a function of temperature, holding frequency constant and varying B
3.894216
3.693744
1.054273
plt.figure(num=fignum) plt.clf() if not isServer: plt.figtext(.02, .01, version_num) plt.xlabel('Frequency (Hz)') plt.ylabel('Susceptibility (m^3/kg)') k = 0 F, X = [], [] for xf in XF: X.append(xf[0]) F.append(xf[1]) plt.plot(F, X) plt.semilogx() ...
def plot_xft(fignum, XF, T, e, b)
function to plot series of chi measurements as a function of temperature, holding field constant and varying frequency
4.412078
4.288207
1.028887
plt.figure(num=fignum) plt.clf() if not isServer: plt.figtext(.02, .01, version_num) plt.xlabel('Field (T)') plt.ylabel('Susceptibility (m^3/kg)') k = 0 B, X = [], [] for xb in XB: X.append(xb[0]) B.append(xb[1]) plt.plot(B, X) plt.legend(['%i' % (int...
def plot_xbt(fignum, XB, T, e, b)
function to plot series of chi measurements as a function of temperature, holding field constant and varying frequency
4.158126
3.883226
1.070792
leglist, init = [], 0 if len(LTC_CM) > 2: if init == 0: plot_init(1, 5, 5) plt.plot(LTC_CT, LTC_CM, 'b') leglist.append('RT SIRM, measured while cooling') init = 1 if len(LTC_WM) > 2: if init == 0: plot_init(1, 5, 5) plt.plot(LTC_W...
def plot_ltc(LTC_CM, LTC_CT, LTC_WM, LTC_WT, e)
function to plot low temperature cycling experiments
2.641211
2.613533
1.01059
# make the stereonet if new == 1: plot_net(fignum) # # plot the data # DIblock = [] for plotrec in datablock: DIblock.append((float(plotrec["dec"]), float(plotrec["inc"]))) if len(DIblock) > 0: plot_di(fignum, DIblock) # plot directed lines # # put on the mean direction #...
def plot_conf(fignum, s, datablock, pars, new)
plots directions and confidence ellipses
3.884861
3.736116
1.039813
def split_title(s): s_list = s.split(",") lines = [] tot = 0 line = [] for i in s_list: tot += len(i) if tot < 30: line.append(i + ",") else: lines.append(" ".join(line)) line =...
def add_borders(Figs, titles, border_color='#000000', text_color='#800080', con_id="")
Formatting for generating plots on the server Default border color: black Default text color: purple
2.934691
2.932965
1.000588
if not has_basemap: print('-W- Basemap must be installed to run plot_mag_map_basemap') return from matplotlib import cm # matplotlib's color map module lincr = 1 if type(date) != str: date = str(date) fig = plt.figure(fignum) m = Basemap(projection='hammer', lon_0=l...
def plot_mag_map_basemap(fignum, element, lons, lats, element_type, cmap='RdYlBu', lon_0=0, date="")
makes a color contour map of geomagnetic field element Parameters ____________ fignum : matplotlib figure number element : field element array from pmag.do_mag_map for plotting lons : longitude array from pmag.do_mag_map for plotting lats : latitude array from pmag.do_mag_map for plotting e...
2.072617
1.973885
1.050019
ax.set_title(timescale.upper()) ax.axis([-.25, 1.5, agemax, agemin]) ax.axes.get_xaxis().set_visible(False) # get dates and chron names for timescale TS, Chrons = pmag.get_ts(timescale) X, Y, Y2 = [0, 1], [], [] cnt = 0 if agemin < TS[1]: # in the Brunhes Y = [agemin, agemi...
def plot_ts(ax, agemin, agemax, timescale='gts12', ylabel="Age (Ma)")
Make a time scale plot between specified ages. Parameters: ------------ ax : figure object agemin : Minimum age for timescale agemax : Maximum age for timescale timescale : Time Scale [ default is Gradstein et al., (2012)] for other options see pmag.get_ts() ylabel : if set, plot as ...
3.359207
3.311104
1.014528
alpha=p[0] beta=p[1] dev=0 for i in range(len(x)): dev=dev+((y[i]-(alpha*math.tanh(beta*x[i])))**2) rms=math.sqrt(old_div(dev,float(len(y)))) return rms
def funk(p, x, y)
Function misfit evaluation for best-fit tanh curve f(x[:]) = alpha*tanh(beta*x[:]) alpha = params[0] beta = params[1] funk(params) = sqrt(sum((y[:] - f(x[:]))**2)/len(y[:])) Output is RMS misfit x=xx[0][:] y=xx[1][:]q
3.439156
2.917957
1.178618
s=0 for i in range(len(a)): s=s+abs(a[i]-b[i]) return s
def compare(a, b)
Compare items in 2 arrays. Returns sum(abs(a(i)-b(i)))
2.510305
2.019953
1.242754
m = float(a) * math.tanh(float(b) * float(f)) return float(m)
def TRM(f,a,b)
Calculate TRM using tanh relationship TRM(f)=a*math.tanh(b*f)
5.662018
4.146589
1.365464
WARN = True # Warn, rather than stop if I encounter a NaN... if float(a)==0: print('ERROR: TRMinv: a==0.') if not WARN : sys.exit() if float(b)==0: print('ERROR: TRMinv: b==0.') if not WARN : sys.exit() x = (old_div(float(m), float(a))) if (1-x)<=0: p...
def TRMinv(m,a,b)
Calculate applied field from TRM using tanh relationship TRMinv(m)=(1/b)*atanh(m/a)
4.656066
4.891677
0.951834
WARN = True # Warn, rather than stop if I encounter a NaN... if float(f)==0: print('ERROR: NRM: f==0.') if not WARN : sys.exit() m = (old_div(float(best),float(f))) * TRM(f,a,b) return float(m)
def NRM(f,a,b,best)
Calculate NRM expected lab field and estimated ancient field NRM(blab,best)= (best/blab)*TRM(blab)
13.125024
12.431874
1.055756
self.fit_list = [] self.search_choices = [] for specimen in self.specimens_list: if specimen not in self.parent.pmag_results_data['specimens']: continue self.fit_list += [(fit,specimen) for fit in self.parent.pmag_results_data['specimens'][specimen]] se...
def update_editor(self)
updates the logger and plot on the interpretation editor window
5.435047
4.57331
1.188427
if len(self.fit_list)==0: return if self.search_query and self.parent.current_fit not in [x[0] for x in self.fit_list]: return if self.current_fit_index == None: if not self.parent.current_fit: return for i,(fit,specimen) in enumerate(self.fit_list): ...
def change_selected(self,new_fit)
updates passed in fit or index as current fit for the editor (does not affect parent), if no parameters are passed in it sets first fit as current @param: new_fit -> fit object to highlight as selected
2.449597
2.389126
1.025311
if self.logger.GetItemCount()-1 > i+focus_shift: i += focus_shift else: i = self.logger.GetItemCount()-1 self.logger.Focus(i)
def logger_focus(self,i,focus_shift=16)
focuses the logger on an index 12 entries below i @param: i -> index to focus on
3.471251
3.780576
0.91818
i = event.GetIndex() if self.parent.current_fit == self.fit_list[i][0]: return self.parent.initialize_CART_rot(self.fit_list[i][1]) si = self.parent.specimens.index(self.fit_list[i][1]) self.parent.specimens_box.SetSelection(si) self.parent.select_specimen(self.f...
def OnClick_listctrl(self, event)
Edits the logger and the Zeq_GUI parent object to select the fit that was newly selected by a double click @param: event -> wx.ListCtrlEvent that triggered this function
4.066854
3.972847
1.023663
i = event.GetIndex() fit,spec = self.fit_list[i][0],self.fit_list[i][1] if fit in self.parent.bad_fits: if not self.parent.mark_fit_good(fit,spec=spec): return if i == self.current_fit_index: self.logger.SetItemBackgroundColour(i,"LIGHT BLUE") ...
def OnRightClickListctrl(self, event)
Edits the logger and the Zeq_GUI parent object so that the selected interpretation is now marked as bad @param: event -> wx.ListCtrlEvent that triggered this function
3.500022
3.079378
1.1366
self.parent.UPPER_LEVEL_SHOW=self.show_box.GetValue() self.parent.calculate_high_levels_data() self.parent.plot_high_levels_data()
def on_select_show_box(self,event)
Changes the type of mean shown on the high levels mean plot so that single dots represent one of whatever the value of this box is. @param: event -> the wx.COMBOBOXEVENT that triggered this function
7.172154
5.333875
1.344642
UPPER_LEVEL=self.level_box.GetValue() if UPPER_LEVEL=='sample': self.level_names.SetItems(self.parent.samples) self.level_names.SetStringSelection(self.parent.Data_hierarchy['sample_of_specimen'][self.parent.s]) if UPPER_LEVEL=='site': self.level_na...
def on_select_high_level(self,event,called_by_parent=False)
alters the possible entries in level_names combobox to give the user selections for which specimen interpretations to display in the logger @param: event -> the wx.COMBOBOXEVENT that triggered this function
2.4516
2.309491
1.061532
high_level_name=str(self.level_names.GetValue()) if self.level_box.GetValue()=='sample': self.specimens_list=self.parent.Data_hierarchy['samples'][high_level_name]['specimens'] elif self.level_box.GetValue()=='site': self.specimens_list=self.parent.Data_hierarch...
def on_select_level_name(self,event,called_by_parent=False)
change this objects specimens_list to control which specimen interpretatoins are displayed in this objects logger @param: event -> the wx.ComboBoxEvent that triggered this function
2.499676
2.493646
1.002418
new_mean_type = self.mean_type_box.GetValue() if new_mean_type == "None": self.parent.clear_high_level_pars() self.parent.mean_type_box.SetStringSelection(new_mean_type) self.parent.onSelect_mean_type_box(event)
def on_select_mean_type_box(self, event)
set parent Zeq_GUI to reflect change in this box and change the @param: event -> the wx.ComboBoxEvent that triggered this function
3.441218
3.276595
1.050242
new_mean_fit = self.mean_fit_box.GetValue() self.parent.mean_fit_box.SetStringSelection(new_mean_fit) self.parent.onSelect_mean_fit_box(event)
def on_select_mean_fit_box(self, event)
set parent Zeq_GUI to reflect the change in this box then replot the high level means plot @param: event -> the wx.COMBOBOXEVENT that triggered this function
3.186801
2.898237
1.099565
specimens = [] next_i = self.logger.GetNextSelected(-1) if next_i == -1: return while next_i != -1: fit,specimen = self.fit_list[next_i] if specimen in specimens: next_i = self.logger.GetNextSelected(next_i) continue ...
def add_highlighted_fits(self, evnet)
adds a new interpretation to each specimen highlighted in logger if multiple interpretations are highlighted of the same specimen only one new interpretation is added @param: event -> the wx.ButtonEvent that triggered this function
3.072921
2.806568
1.094903
next_i = -1 deleted_items = [] while True: next_i = self.logger.GetNextSelected(next_i) if next_i == -1: break deleted_items.append(next_i) deleted_items.sort(reverse=True) for item in deleted_items: self.d...
def delete_highlighted_fits(self, event)
iterates through all highlighted fits in the logger of this object and removes them from the logger and the Zeq_GUI parent object @param: event -> the wx.ButtonEvent that triggered this function
3.839249
3.490382
1.099951
if type(index) == int and not fit: fit,specimen = self.fit_list[index] if fit and type(index) == int: for i, (f,s) in enumerate(self.fit_list): if fit == f: index,specimen = i,s break if index == self.curre...
def delete_entry(self, fit = None, index = None)
deletes the single item from the logger of this object that corrisponds to either the passed in fit or index. Note this function mutaits the logger of this object if deleting more than one entry be sure to pass items to delete in from highest index to lowest or else odd things can happen. @param: fit -> Fit obj...
4.28707
4.209414
1.018448
new_name = self.name_box.GetLineText(0) new_color = self.color_box.GetValue() new_tmin = self.tmin_box.GetValue() new_tmax = self.tmax_box.GetValue() next_i = -1 changed_i = [] while True: next_i = self.logger.GetNextSelected(next_i) ...
def apply_changes(self, event)
applies the changes in the various attribute boxes of this object to all highlighted fit objects in the logger, these changes are reflected both in this object and in the Zeq_GUI parent object. @param: event -> the wx.ButtonEvent that triggered this function
2.420719
2.330041
1.038917
if event.LeftIsDown() or event.ButtonDClick(): return elif self.high_EA_setting == "Zoom": self.high_EA_setting = "Pan" try: self.toolbar.pan('off') except TypeError: pass elif self.high_EA_setting == "Pan": self.high_EA_settin...
def pan_zoom_high_equalarea(self,event)
Uses the toolbar for the canvas to change the function from zoom to pan or pan to zoom @param: event -> the wx.MouseEvent that triggered this funciton
2.71629
2.754874
0.985995
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.arg...
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) OUTPUT dec, inc, int SYNTAX tk03.py [command line options] [> OutputFileName] OPTIONS -n N s...
2.712615
2.370049
1.144539
N,mean,sigma=100,0,1. outfile="" if '-h' in sys.argv: print(main.__doc__) sys.exit() else: if '-s' in sys.argv: ind=sys.argv.index('-s') sigma=float(sys.argv[ind+1]) if '-n' in sys.argv: ind=sys.argv.index('-n') N=int(s...
def main()
NAME gaussian.py DESCRIPTION generates set of normally distribed data from specified distribution INPUT (COMMAND LINE ENTRY) OUTPUT x SYNTAX gaussian.py [command line options] OPTIONS -h prints help message and quits -s specify standard deviation ...
2.803825
2.58318
1.085416
fmt,plot='svg',0 if '-h' in sys.argv: # check if help is needed print(main.__doc__) sys.exit() # graceful quit elif '-f' in sys.argv: # ask for filename ind=sys.argv.index('-f') file=sys.argv[ind+1] f=open(file,'r') input=f.readlines() Data=[] for...
def main()
NAME qqunf.py DESCRIPTION makes qq plot from input data against uniform distribution SYNTAX qqunf.py [command line options] OPTIONS -h help message -f FILE, specify file on command line
4.277654
4.08717
1.046605