code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
if not self.user_warning("This feature is in ALPHA and still in development and testing. It is subject to bugs and will often create a LOT of new interpretations. This feature should only be used to get a general idea of the trend of the data before actually mannuely interpreting the data and the outpu...
def autointerpret(self, event, step_size=None, calculation_type="DE-BFL")
Clears current interpretations and adds interpretations to every specimen of type = calculation_type by attempting fits of size = step size and type = calculation_type and testing the mad or a95 then finding peaks in these to note areas of maximum error then fits between these peaks excl...
7.210937
6.809047
1.059023
if self.COORDINATE_SYSTEM == 'geographic': block = self.Data[specimen]['zijdblock_geo'] elif self.COORDINATE_SYSTEM == 'tilt-corrected': block = self.Data[specimen]['zijdblock_tilt'] else: block = self.Data[specimen]['zijdblock'] if step_size ...
def autointerpret_specimen(self, specimen, step_size, calculation_type)
In Dev
3.002048
3.001964
1.000028
elements_list = self.Data_hierarchy[high_level_type][high_level_name][elements_type] pars_for_mean = {} pars_for_mean["All"] = [] for element in elements_list: if elements_type == 'specimens' and element in self.pmag_results_data['specimens']: for f...
def get_high_level_mean_pars(self, high_level_type, high_level_name, calculation_type, elements_type, mean_fit, dirtype)
Gets the Parameters of a mean of lower level data such as a Site level Fisher mean of Specimen interpretations Parameters ---------- high_level_type : 'samples','sites','locations','study' high_level_name : sample, site, location, or study whose data to which to appl...
2.94434
2.894614
1.017179
if len(pars_for_mean) == 0: return({}) elif len(pars_for_mean) == 1: return ({"dec": float(pars_for_mean[0]['dec']), "inc": float(pars_for_mean[0]['inc']), "calculation_type": calculation_type, "n": 1}) # elif calculation_type =='Bingham': # data=[] ...
def calculate_mean(self, pars_for_mean, calculation_type)
Uses pmag.dolnp or pmag.fisher_by_pol to do a fisher mean or fisher mean by polarity on the list of dictionaries in pars for mean Parameters ---------- pars_for_mean : list of dictionaries with all data to average calculation_type : type of mean to take (options: Fisher, ...
3.740124
2.576951
1.451376
high_level_type = str(self.level_box.GetValue()) if high_level_type == 'sample': high_level_type = 'samples' if high_level_type == 'site': high_level_type = 'sites' if high_level_type == 'location': high_level_type = 'locations' high_l...
def calculate_high_levels_data(self)
calculates high level mean data for the high level mean plot using information in level_box, level_names, mean_type_box, and mean_fit_box also updates the information in the ie to match high level mean data in main GUI.
3.696377
2.799165
1.320529
new_Data_info = self.get_data_info() new_Data, new_Data_hierarchy = self.get_data() if not new_Data: print("Data read in failed when reseting, aborting reset") return else: self.Data, self.Data_hierarchy, self.Data_info = new_Data, new_Data_h...
def quiet_reset_backend(self, reset_interps=True)
Doesn't update plots or logger or any visable data but resets all measurement data, hierarchy data, and optionally resets intepretations. Parameters ---------- reset_interps : bool to tell the function to reset fits or not.
2.764244
2.76741
0.998856
if warn_user and not self.data_loss_warning(): return False # reset backend, including get_data(), get_data_info() self.quiet_reset_backend(reset_interps=reset_interps) # reset specimens box self.specimens_box.SetItems(self.specimens) self.specimens...
def reset_backend(self, warn_user=True, reset_interps=True)
Resets GUI data and updates GUI displays such as plots, boxes, and logger Parameters ---------- warn_user : bool which decides if a warning dialog is displayed to the user to ask about reseting data reset_interps : bool which decides if interpretations are read in ...
4.837227
4.876748
0.991896
self.initialize_CART_rot(self.s) if str(self.s) in self.pmag_results_data['specimens']: for fit in self.pmag_results_data['specimens'][self.s]: if fit.get('specimen') and 'calculation_type' in fit.get('specimen'): fit.put(self.s, 'specimen', self....
def recalculate_current_specimen_interpreatations(self)
recalculates all interpretations on all specimens for all coordinate systems. Does not display recalcuated data.
2.69428
2.652231
1.015854
if specimen not in self.Data: print( ("no measurement data found loaded for specimen %s and will be ignored" % (specimen))) return (None, None) if self.Data[specimen]['measurement_step_unit'] == "C": if float(tmin0) == 0 or float(tmin0) == 273...
def parse_bound_data(self, tmin0, tmax0, specimen)
converts Kelvin/Tesla temperature/AF data from the MagIC/Redo format to that of Celsius/milliTesla which is used by the GUI as it is often more intuitive Parameters ---------- tmin0 : the input temperature/AF lower bound value to convert tmax0 : the input temperature/AF ...
1.774879
1.710535
1.037616
recs = {} recs = deepcopy(old_recs) headers = [] for rec in recs: for key in list(rec.keys()): if key not in headers: headers.append(key) for rec in recs: for header in headers: if header not in ...
def merge_pmag_recs(self, old_recs)
Takes in a list of dictionaries old_recs and returns a list of dictionaries where every dictionary in the returned list has the same keys as all the others. Parameters ---------- old_recs : list of dictionaries to fix Returns ------- recs : list of dicti...
2.210908
2.250975
0.9822
try: fit_index = self.pmag_results_data['specimens'][self.s].index( self.current_fit) except KeyError: fit_index = None except ValueError: fit_index = None # sets self.s to specimen calculates params etc. self.initializ...
def select_specimen(self, specimen)
Goes through the calculations necessary to plot measurement data for specimen and sets specimen as current GUI specimen, also attempts to handle changing current fit.
4.126829
3.8148
1.081794
if self.total_num_of_interpertations() == 0: print("There are no interpretations") return True if message == None: message = "All interpretations will be deleted all unsaved data will be irretrievable, continue?" dlg = wx.MessageDialog(self, caption=...
def clear_interpretations(self, message=None)
Clears all specimen interpretations Parameters ---------- message : message to display when warning the user that all fits will be deleted. If None default message is used (None is default)
5.609351
5.310627
1.05625
meas_index, ind_data = 0, [] for i, meas_data in enumerate(self.mag_meas_data): if meas_data['er_specimen_name'] == self.s: ind_data.append(i) meas_index = ind_data[g_index] self.Data[self.s]['measurement_flag'][g_index] = 'g' if len(self.Dat...
def mark_meas_good(self, g_index)
Marks the g_index'th measuremnt of current specimen good Parameters ---------- g_index : int that gives the index of the measurement to mark good, indexed from 0
2.422352
2.427228
0.997991
if spec == None: for spec, fits in list(self.pmag_results_data['specimens'].items()): if fit in fits: break samp = self.Data_hierarchy['sample_of_specimen'][spec] if 'sample_orientation_flag' not in self.Data_info['er_samples'][samp]: ...
def mark_fit_good(self, fit, spec=None)
Marks fit good so it is used in high level means Parameters ---------- fit : fit to mark good spec : specimen of fit to mark good (optional though runtime will increase if not provided)
5.010081
5.042799
0.993512
if fit not in self.bad_fits: self.bad_fits.append(fit) return True else: return False
def mark_fit_bad(self, fit)
Marks fit bad so it is excluded from high level means Parameters ---------- fit : fit to mark bad
2.581602
2.970734
0.869012
if "specimen" not in self.spec_data.columns or \ "meas_step_min" not in self.spec_data.columns or \ "meas_step_max" not in self.spec_data.columns or \ "meas_step_unit" not in self.spec_data.columns or \ "method_codes" not in self.spec_data.columns: ...
def get_interpretations3(self)
Used instead of update_pmag_tables in data model 3.0 to fetch interpretations from contribution objects
2.308936
2.229665
1.035553
# default preferences = {} preferences['gui_resolution'] = 100. preferences['show_Zij_treatments'] = True preferences['show_Zij_treatments_steps'] = 2. preferences['show_eqarea_treatments'] = False preferences['auto_save'] = True # preferences['sh...
def get_preferences(self)
Gets preferences for certain display variables from zeq_gui_preferences.
6.469159
6.245807
1.03576
DATA = {} try: with open(path, 'r') as finput: lines = list(finput.readlines()[1:]) except FileNotFoundError: return [] # fin=open(path,'r') # fin.readline() line = lines[0] header = line.strip('\n').split('\t') ...
def read_magic_file(self, path, sort_by_this_name)
reads a magic formated data file from path and sorts the keys according to sort_by_this_name Parameters ---------- path : path to file to read sort_by_this_name : variable to sort data by
2.541956
2.559273
0.993234
cont = self.user_warning( "LSQ import only works if all measurements are present and not averaged during import from magnetometer files to magic format. Do you wish to continue reading interpretations?") if not cont: return self.clear_interpretations( ...
def read_from_LSQ(self, LSQ_file)
Clears all current interpretations and replaces them with interpretations read from LSQ file. Parameters ---------- LSQ_file : path to LSQ file to read in
4.682825
4.623401
1.012853
if not self.clear_interpretations(): return print("-I- read redo file and processing new bounds") fin = open(redo_file, 'r') new_s = "" for Line in fin.read().splitlines(): line = Line.split('\t') specimen = line[0] if spe...
def read_redo_file(self, redo_file)
Reads a .redo formated file and replaces all current interpretations with interpretations taken from the .redo file Parameters ---------- redo_file : path to .redo file to read
3.913979
3.929784
0.995978
new_WD = os.path.abspath(new_WD) if not os.path.isdir(new_WD): return self.WD = new_WD if not meas_file: if self.data_model == None: if os.path.isfile(os.path.join(self.WD, "measurements.txt")) and os.path.isfile(os.path.join(self.WD, "mag...
def change_WD(self, new_WD, meas_file="")
Changes Demag GUI's current WD to new_WD if possible Parameters ---------- new_WD : WD to change to current GUI's WD
2.726296
2.744209
0.993472
# redirect terminal output self.old_stdout = sys.stdout sys.stdout = open(os.path.join(self.WD, "demag_gui.log"), 'w+')
def init_log_file(self)
redirects stdout to a log file to prevent printing to a hanging terminal when dealing with the compiled binary.
6.857419
6.265401
1.09449
crit_list = list(self.acceptance_criteria.keys()) crit_list.sort() rec = {} rec['pmag_criteria_code'] = "ACCEPT" # rec['criteria_definition']="" rec['criteria_definition'] = "acceptance criteria for study" rec['er_citation_names'] = "This study" ...
def write_acceptance_criteria_to_file(self)
Writes current GUI acceptance criteria to criteria.txt or pmag_criteria.txt depending on data model
2.383583
2.281608
1.044694
if not self.test_mode: dlg.Center() return dlg.ShowModal() else: return dlg.GetAffirmativeId()
def show_dlg(self, dlg)
Abstraction function that is to be used instead of dlg.ShowModal Parameters ---------- dlg : dialog to ShowModal if possible
4.740394
5.055752
0.937624
dlg = wx.DirDialog(self, "Choose a directory:", defaultPath=self.currentDirectory, style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON | wx.DD_CHANGE_DIR) ok = self.show_dlg(dlg) if ok == wx.ID_OK: new_WD = dlg.GetPath() dlg.Destroy() ...
def get_DIR(self)
Dialog that allows user to choose a working directory
2.572845
2.354439
1.092764
dlg = wx.FileDialog( self, message="Please choose a measurement file", defaultDir=self.WD, defaultFile="measurements.txt", wildcard="measurement files (*.magic,*.txt)|*.magic;*.txt", style=wx.FD_OPEN | wx.FD_CHANGE_DIR ) if sel...
def choose_meas_file(self, event=None)
Opens a dialog allowing the user to pick a measurement file
3.049778
2.966636
1.028026
dlg = wx.MessageDialog(self, caption=caption, message=message, style=wx.OK) result = self.show_dlg(dlg) dlg.Destroy()
def saved_dlg(self, message, caption='Saved:')
Shows a dialog that tells the user that a file has been saved Parameters ---------- message : message to display to user caption : title for dialog (default: "Saved:")
3.170097
4.269722
0.74246
dlg = wx.MessageDialog(self, message, caption, wx.OK | wx.CANCEL | wx.ICON_WARNING) if self.show_dlg(dlg) == wx.ID_OK: continue_bool = True else: continue_bool = False dlg.Destroy() return continue_bool
def user_warning(self, message, caption='Warning!')
Shows a dialog that warns the user about some action Parameters ---------- message : message to display to user caption : title for dialog (default: "Warning!") Returns ------- continue_bool : True or False
2.495261
2.224019
1.12196
window_list_specimens = [ 'specimen_n', 'specimen_mad', 'specimen_dang', 'specimen_alpha95'] window_list_samples = ['sample_n', 'sample_n_lines', 'sample_n_planes', 'sample_k', 'sample_r', 'sample_alpha95'] window_list_sites = ['site_n', 'site_...
def on_close_criteria_box(self, dia)
Function called on close of change acceptance criteria dialog that writes new criteria to the hardrive and sets new criteria as GUI's current criteria. Parameters ---------- dia : closed change criteria dialog
3.407257
3.388718
1.005471
dlg = wx.MessageDialog( self, caption="Error:", message="not a vaild value for statistic %s\n ignoring value" % crit, style=wx.OK) result = self.show_dlg(dlg) if result == wx.ID_OK: dlg.Destroy()
def show_crit_window_err_messege(self, crit)
error message if a valid naumber is not entered to criteria dialog boxes
6.067196
5.987052
1.013386
self.clear_boxes() # commented out to allow propogation of higher level viewing state self.clear_high_level_pars() if self.UPPER_LEVEL_SHOW != "specimens": self.mean_type_box.SetValue("None") # -------------------------- # check if the coordinate s...
def update_selection(self)
Convenience function update display (figures, text boxes and statistics windows) with a new selection of specimen
3.522596
3.446462
1.02209
self.warning_box.Clear() if self.warning_text == "": self.warning_box.AppendText("No Problems") else: self.warning_box.AppendText(self.warning_text)
def update_warning_box(self)
updates the warning box with whatever the warning_text variable contains for this specimen
2.749197
2.353881
1.167942
self.update_fit_bounds_and_statistics() self.draw_interpretations() self.calculate_high_levels_data() self.plot_high_levels_data()
def update_GUI_with_new_interpretation(self)
update statistics boxes and figures with a new interpretatiom when selecting new temperature bound
9.716073
7.7774
1.24927
self.clear_high_level_pars() dirtype = str(self.coordinates_box.GetValue()) if dirtype == 'specimen': dirtype = 'DA-DIR' elif dirtype == 'geographic': dirtype = 'DA-DIR-GEO' elif dirtype == 'tilt-corrected': dirtype = 'DA-DIR-TILT' ...
def update_high_level_stats(self)
updates high level statistics in bottom left of GUI.
2.608974
2.587101
1.008455
if self.s not in list(self.Data.keys()): self.select_specimen(list(self.Data.keys())[0]) self.T_list = self.Data[self.s]['zijdblock_steps'] if self.current_fit: self.tmin_box.SetItems(self.T_list) self.tmax_box.SetItems(self.T_list) if typ...
def update_bounds_boxes(self)
updates bounds boxes with bounds of current specimen and fit
3.173556
2.936481
1.080734
if self.s in list(self.pmag_results_data['specimens'].keys()): if self.current_fit: tmin = self.current_fit.tmin tmax = self.current_fit.tmax calculation_type = self.current_fit.PCA_type else: calculation_type = se...
def update_PCA_box(self)
updates PCA box with current fit's PCA type
3.892303
3.750348
1.037851
# update the fit box self.update_fit_box(new_fit) # select new fit self.on_select_fit(None) # update the high level fits box self.update_mean_fit_box()
def update_fit_boxes(self, new_fit=False)
alters fit_box and mean_fit_box lists to match with changes in specimen or new/removed interpretations Parameters ---------- new_fit : boolean representing if there is a new fit Alters ------ fit_box selection, tmin_box selection, tmax_box selection, mea...
5.896425
5.586118
1.05555
# get new fit data if self.s in list(self.pmag_results_data['specimens'].keys()): self.fit_list = list( [x.name for x in self.pmag_results_data['specimens'][self.s]]) else: self.fit_list = [] # find new index to set fit_box to if n...
def update_fit_box(self, new_fit=False)
alters fit_box lists to match with changes in specimen or new/ removed interpretations Parameters ---------- new_fit : boolean representing if there is a new fit Alters ------ fit_box selection and choices, current_fit
2.641599
2.7052
0.976489
self.mean_fit_box.Clear() # update high level mean fit box fit_index = None if self.mean_fit in self.all_fits_list: fit_index = self.all_fits_list.index(self.mean_fit) self.all_fits_list = [] for specimen in self.specimens: if specimen in ...
def update_mean_fit_box(self)
alters mean_fit_box list to match with changes in specimen or new/ removed interpretations Alters ------ mean_fit_box selection and choices, mean_types_box string selection
2.268753
2.165225
1.047814
FONT_WEIGHT = self.GUI_RESOLUTION+(self.GUI_RESOLUTION-1)*5 font2 = wx.Font(12+min(1, FONT_WEIGHT), wx.SWISS, wx.NORMAL, wx.NORMAL, False, self.font_type) if self.mean_type_box.GetValue() != "None" and self.mean_fit_box.GetValue() != "None" and mpars: ...
def show_high_levels_pars(self, mpars)
shows in the high level mean display area in the bottom left of the GUI the data in mpars.
2.786693
2.742781
1.01601
self.tmin_box.Clear() self.tmin_box.SetStringSelection("") if self.current_fit: self.tmin_box.SetItems(self.T_list) self.tmin_box.SetSelection(-1) self.tmax_box.Clear() self.tmax_box.SetStringSelection("") if self.current_fit: ...
def clear_boxes(self)
Clear all boxes
2.949156
2.926047
1.007898
for val in ['mean_type', 'dec', 'inc', 'alpha95', 'K', 'R', 'n_lines', 'n_planes']: COMMAND = % (val) exec(COMMAND) if self.ie_open: for val in ['mean_type', 'dec', 'inc', 'alpha95', 'K', 'R', 'n_lines', 'n_planes']: COMMAND = % (val) ...
def clear_high_level_pars(self)
clears all high level pars display boxes
5.819535
5.512957
1.05561
# use new measurement file and corresponding WD meas_file = self.choose_meas_file() WD = os.path.split(meas_file)[0] self.WD = WD self.magic_file = meas_file # reset backend with new files self.reset_backend()
def on_menu_import_meas_file(self, event)
Open measurement file, reset self.magic_file and self.WD, and reset everything.
6.585809
4.139573
1.590939
if self.data_model == 3: default_file = "criteria.txt" else: default_file = "pmag_criteria.txt" read_sucsess = False dlg = wx.FileDialog( self, message="choose pmag criteria file", defaultDir=self.WD, defaultFile=defaul...
def on_menu_criteria_file(self, event)
read pmag_criteria.txt file and open changecriteria dialog
2.913476
2.66693
1.092446
if event.LeftIsDown() or event.ButtonDClick(): return elif self.zijderveld_setting == "Zoom": self.zijderveld_setting = "Pan" try: self.toolbar1.pan('off') except TypeError: pass elif self.zijderveld_setting...
def right_click_zijderveld(self, event)
toggles between zoom and pan effects for the zijderveld on right click Parameters ---------- event : the wx.MouseEvent that triggered the call of this function Alters ------ zijderveld_setting, toolbar1 setting
2.887792
2.247282
1.285015
if not array(self.CART_rot).any(): return pos = event.GetPosition() width, height = self.canvas1.get_width_height() pos[1] = height - pos[1] xpick_data, ypick_data = pos xdata_org = list(self.CART_rot[:, 0]) + list(self.CART_rot[:, 0]) ydata_o...
def on_change_zijd_mouse_cursor(self, event)
If mouse is over data point making it selectable change the shape of the cursor Parameters ---------- event : the wx Mouseevent for that click
3.130604
3.208063
0.975855
if not array(self.CART_rot_good).any(): return pos = event.GetPosition() width, height = self.canvas1.get_width_height() pos[1] = height - pos[1] xpick_data, ypick_data = pos xdata_org = list( self.CART_rot_good[:, 0]) + list(self.CART_rot...
def on_zijd_select(self, event)
Get mouse position on double click find the nearest interpretation to the mouse position then select that interpretation Parameters ---------- event : the wx Mouseevent for that click Alters ------ current_fit
4.230834
4.215012
1.003754
if not array(self.CART_rot).any(): return pos = event.GetPosition() width, height = self.canvas1.get_width_height() pos[1] = height - pos[1] xpick_data, ypick_data = pos xdata_org = list(self.CART_rot[:, 0]) + list(self.CART_rot[:, 0]) ydata_o...
def on_zijd_mark(self, event)
Get mouse position on double right click find the interpretation in range of mouse position then mark that interpretation bad or good Parameters ---------- event : the wx Mouseevent for that click Alters ------ current_fit
4.331367
4.182798
1.035519
if event.LeftIsDown() or event.ButtonDClick(): return elif self.specimen_EA_setting == "Zoom": self.specimen_EA_setting = "Pan" try: self.toolbar2.pan('off') except TypeError: pass elif self.specimen_EA_sett...
def right_click_specimen_equalarea(self, event)
toggles between zoom and pan effects for the specimen equal area on right click Parameters ---------- event : the wx.MouseEvent that triggered the call of this function Alters ------ specimen_EA_setting, toolbar2 setting
3.296185
2.364549
1.394002
if not self.specimen_EA_xdata or not self.specimen_EA_ydata: return pos = event.GetPosition() width, height = self.canvas2.get_width_height() pos[1] = height - pos[1] xpick_data, ypick_data = pos xdata_org = self.specimen_EA_xdata ydata_org = ...
def on_change_specimen_mouse_cursor(self, event)
If mouse is over data point making it selectable change the shape of the cursor Parameters ---------- event : the wx Mouseevent for that click
2.919144
2.911278
1.002702
if not self.specimen_EA_xdata or not self.specimen_EA_ydata: return pos = event.GetPosition() width, height = self.canvas2.get_width_height() pos[1] = height - pos[1] xpick_data, ypick_data = pos xdata_org = self.specimen_EA_xdata ydata_org = ...
def on_equalarea_specimen_select(self, event)
Get mouse position on double click find the nearest interpretation to the mouse position then select that interpretation Parameters ---------- event : the wx Mouseevent for that click Alters ------ current_fit
3.432068
3.461814
0.991407
if event.LeftIsDown(): return elif self.high_EA_setting == "Zoom": self.high_EA_setting = "Pan" try: self.toolbar4.pan('off') except TypeError: pass elif self.high_EA_setting == "Pan": self.high_...
def right_click_high_equalarea(self, event)
toggles between zoom and pan effects for the high equal area on right click Parameters ---------- event : the wx.MouseEvent that triggered the call of this function Alters ------ high_EA_setting, toolbar4 setting
3.573699
2.355994
1.516854
if self.ie_open and self.ie.show_box.GetValue() != "specimens": return pos = event.GetPosition() width, height = self.canvas4.get_width_height() pos[1] = height - pos[1] xpick_data, ypick_data = pos xdata_org = self.high_EA_xdata ydata_org = s...
def on_change_high_mouse_cursor(self, event)
If mouse is over data point making it selectable change the shape of the cursor Parameters ---------- event : the wx Mouseevent for that click
3.591825
3.557468
1.009658
if self.ie_open and self.ie.show_box.GetValue() != "specimens": return if not self.high_EA_xdata or not self.high_EA_ydata: return if fig == None: fig = self.high_level_eqarea if canvas == None: canvas = self.canvas4 pos = ...
def on_equalarea_high_select(self, event, fig=None, canvas=None)
Get mouse position on double click find the nearest interpretation to the mouse position then select that interpretation Parameters ---------- event : the wx Mouseevent for that click Alters ------ current_fit, s, mean_fit, fit_box selection, mean_fit_box select...
3.175258
3.113331
1.019891
self.selected_meas = [] if self.COORDINATE_SYSTEM == 'geographic': zijdblock = self.Data[self.s]['zijdblock_geo'] elif self.COORDINATE_SYSTEM == 'tilt-corrected': zijdblock = self.Data[self.s]['zijdblock_tilt'] else: zijdblock = self.Data[self...
def Add_text(self)
Add measurement data lines to the text window.
2.496396
2.438685
1.023665
tmin_index, tmax_index = "", "" if str(self.tmin_box.GetValue()) != "": tmin_index = self.tmin_box.GetSelection() if str(self.tmax_box.GetValue()) != "": tmax_index = self.tmax_box.GetSelection() if self.list_bound_loc != 0: if self.list_boun...
def select_bounds_in_logger(self, index)
sets index as the upper or lower bound of a fit based on what the other bound is and selects it in the logger. Requires 2 calls to completely update a interpretation. NOTE: Requires an interpretation to exist before it is called. Parameters ---------- index : index of th...
1.932477
1.946723
0.992682
g_index = event.GetIndex() if self.Data[self.s]['measurement_flag'][g_index] == 'g': self.mark_meas_bad(g_index) else: self.mark_meas_good(g_index) if self.data_model == 3.0: self.con.tables['measurements'].write_magic_file(dir_path=self.WD)...
def on_right_click_listctrl(self, event)
right click on the listctrl toggles measurement bad
7.090694
6.212803
1.141303
self.selected_meas = [] self.select_specimen(str(self.specimens_box.GetValue())) if self.ie_open: self.ie.change_selected(self.current_fit) self.update_selection()
def onSelect_specimen(self, event)
update figures and text when a new specimen is selected
7.70979
7.205476
1.06999
new_specimen = self.specimens_box.GetValue() if new_specimen not in self.specimens: self.user_warning( "%s is not a valid specimen with measurement data, aborting" % (new_specimen)) self.specimens_box.SetValue(self.s) return self.selec...
def on_enter_specimen(self, event)
upon enter on the specimen box it makes that specimen the current specimen
4.638671
4.471255
1.037443
tmin = str(self.tmin_box.GetValue()) tmax = str(self.tmax_box.GetValue()) if tmin == "" or tmax == "": return if tmin in self.T_list and tmax in self.T_list and \ (self.T_list.index(tmax) <= self.T_list.index(tmin)): return PCA_type ...
def get_new_PCA_parameters(self, event)
calculate statistics when temperatures are selected or PCA type is changed
3.502592
3.362661
1.041613
fit_val = self.fit_box.GetValue() if self.s not in self.pmag_results_data['specimens'] or not self.pmag_results_data['specimens'][self.s] or fit_val == 'None': self.clear_boxes() self.current_fit = None self.fit_box.SetStringSelection('None') self...
def on_select_fit(self, event)
Picks out the fit selected in the fit combobox and sets it to the current fit of the GUI then calls the select function of the fit to set the GUI's bounds boxes and alter other such parameters Parameters ---------- event : the wx.ComboBoxEvent that triggers this function ...
3.323043
3.109566
1.068652
if self.current_fit == None: self.on_btn_add_fit(event) value = self.fit_box.GetValue() if ':' in value: name, color = value.split(':') else: name, color = value, None if name in [x.name for x in self.pmag_results_data['specimens'][sel...
def on_enter_fit_name(self, event)
Allows the entering of new fit names in the fit combobox Parameters ---------- event : the wx.ComboBoxEvent that triggers this function Alters ------ current_fit.name
3.903219
3.899111
1.001054
if self.current_fit: self.current_fit.saved = True calculation_type = self.current_fit.get(self.COORDINATE_SYSTEM)[ 'calculation_type'] tmin = str(self.tmin_box.GetValue()) tmax = str(self.tmax_box.GetValue()) self.current_fi...
def on_save_interpretation_button(self, event)
on the save button the interpretation is saved to pmag_results_table data in all coordinate systems
3.156344
2.934453
1.075616
if self.auto_save.GetValue(): self.current_fit = self.add_fit(self.s, None, None, None, saved=True) else: self.current_fit = self.add_fit(self.s, None, None, None, saved=False) self.generate_warning_text() self.update_warning_box() if self.ie_ope...
def on_btn_add_fit(self, event)
add a new interpretation to the current specimen Parameters ---------- event : the wx.ButtonEvent that triggered this function Alters ------ pmag_results_data
6.468585
6.444594
1.003723
self.delete_fit(self.current_fit, specimen=self.s)
def on_btn_delete_fit(self, event)
removes the current interpretation Parameters ---------- event : the wx.ButtonEvent that triggered this function
13.0864
15.325476
0.853898
if not self.auto_save.GetValue(): if self.current_fit: if not self.current_fit.saved: self.delete_fit(self.current_fit, specimen=self.s)
def do_auto_save(self)
Delete current fit if auto_save==False, unless current fit has explicitly been saved.
6.58018
4.866964
1.352009
self.do_auto_save() self.selected_meas = [] index = self.specimens.index(self.s) try: fit_index = self.pmag_results_data['specimens'][self.s].index( self.current_fit) except KeyError: fit_index = None except ValueError: ...
def on_next_button(self, event)
update figures and text when a next button is selected
3.886039
3.782025
1.027502
if "-h" in sys.argv: print(main.__doc__) return infile = pmag.get_named_arg("-f", "measurements.txt") dir_path = pmag.get_named_arg("-WD", ".") infile = pmag.resolve_file_name(infile, dir_path) fmt = pmag.get_named_arg("-fmt", "svg") save_plots = False interactive = True...
def main()
NAME chi_magic.py DESCRIPTION plots magnetic susceptibility as a function of frequency and temperature and AC field SYNTAX chi_magic.py [command line options] OPTIONS -h prints help message and quits -f FILE, specify measurements format file, default "measurements....
3.342486
2.557777
1.306793
D,D1,D2=[],[],[] Flip=0 if '-h' in sys.argv: # check if help is needed print(main.__doc__) sys.exit() # graceful quit if '-ant' in sys.argv: Flip=1 if '-f' in sys.argv: ind=sys.argv.index('-f') file1=sys.argv[ind+1] if '-f2' in sys.argv: ind=sys.argv...
def main()
NAME watsons_f.py DESCRIPTION calculates Watson's F statistic from input files INPUT FORMAT takes dec/inc as first two columns in two space delimited files SYNTAX watsons_f.py [command line options] OPTIONS -h prints help message and quits -f FILE (with...
3.01921
2.717876
1.110871
vector_diffs = [] for k in range(len(zdata)-1): # gets diff between two vectors vector_diffs.append(numpy.sqrt(sum((numpy.array(zdata[k+1]) - numpy.array(zdata[k]))**2) )) last_vector = numpy.linalg.norm(zdata[-1]) vector_diffs.append(last_vector) vds = sum(vector_diffs) f_vds = abs...
def get_vds(zdata, delta_y_prime, start, end)
takes zdata array: [[1, 2, 3], [3, 4, 5]], delta_y_prime: 1, start value, and end value. gets vds and f_vds, etc.
3.373563
3.231963
1.043812
# if beta_threshold is -999, that means null if beta_threshold == -999: beta_threshold = .1 slope_err_threshold = abs(slope) * beta_threshold x, y = x_mean, y_mean # get lines that pass through mass center, with opposite slope slope1 = slope + (2* slope_err_threshold) line1_y_i...
def get_SCAT_box(slope, x_mean, y_mean, beta_threshold = .1)
takes in data and returns information about SCAT box: the largest possible x_value, the largest possible y_value, and functions for the two bounding lines of the box
2.224866
2.189515
1.016145
passing = True upper_limit = high_bound(x) lower_limit = low_bound(x) if x > x_max or y > y_max: passing = False if x < 0 or y < 0: passing = False if y > upper_limit: passing = False if y < lower_limit: passing = False return passing
def in_SCAT_box(x, y, low_bound, high_bound, x_max, y_max)
determines if a particular point falls within a box
2.254458
2.478075
0.909762
points = [] points_arai = [] points_ptrm = [] points_tail = [] for i in range(len(x_Arai_segment)): # uses only the best_fit segment, so no need for further selection x = x_Arai_segment[i] y = y_Arai_segment[i] points.append((x, y)) points_arai.append((x,y)) ...
def get_SCAT_points(x_Arai_segment, y_Arai_segment, tmin, tmax, ptrm_checks_temperatures, ptrm_checks_starting_temperatures, x_ptrm_check, y_ptrm_check, tail_checks_temperatures, tail_checks_starting_temperatures, x_tail_check, y_tail_check)
returns relevant points for a SCAT test
2.25241
2.241683
1.004786
# iterate through all relevant points and see if any of them fall outside of your SCAT box SCAT = True for point in points: result = in_SCAT_box(point[0], point[1], low_bound, high_bound, x_max, y_max) if result == False: # print "SCAT TEST FAILED" SCAT = False ...
def get_SCAT(points, low_bound, high_bound, x_max, y_max)
runs SCAT test and returns boolean
4.462074
4.254678
1.048745
# iterate through all relevant points and see if any of them fall outside of your SCAT box # {'points_arai': [(x,y),(x,y)], 'points_ptrm': [(x,y),(x,y)], ...} SCAT = 'Pass' SCATs = {'SCAT_arai': 'Pass', 'SCAT_ptrm': 'Pass', 'SCAT_tail': 'Pass'} for point_type in points: #print 'point_ty...
def fancy_SCAT(points, low_bound, high_bound, x_max, y_max)
runs SCAT test and returns 'Pass' or 'Fail'
4.499412
4.167097
1.079747
for num in vector_diffs_segment: if num < 0: raise ValueError('vector diffs should not be negative') if vds == 0: raise ValueError('attempting to divide by zero. vds should be a positive number') FRAC = old_div(sum(vector_diffs_segment), vds) return FRAC
def get_FRAC(vds, vector_diffs_segment)
input: vds, vector_diffs_segment output: FRAC
3.836953
3.775029
1.016404
def get_R_corr2(x_avg, y_avg, x_segment, y_segment): # xd = x_segment - x_avg # detrend x_segment yd = y_segment - y_avg # detrend y_segment if sum(xd**2) * sum(yd**2) == 0: # prevent divide by zero error return float('nan') rcorr = old_div(sum((xd * yd))**2, (sum(xd**2) * sum(yd**2))) ...
input: x_avg, y_avg, x_segment, y_segment output: R_corr2
null
null
null
numerator = sum((numpy.array(y_segment) - numpy.array(y_prime))**2) denominator = sum((numpy.array(y_segment) - y_avg)**2) if denominator: # prevent divide by zero error R_det2 = 1 - (old_div(numerator, denominator)) return R_det2 else: return float('nan')
def get_R_det2(y_segment, y_avg, y_prime)
takes in an array of y values, the mean of those values, and the array of y prime values. returns R_det2
2.769619
2.820405
0.981993
if x == 0: b_wiggle = 0 else: b_wiggle = old_div((y_int - y), x) return b_wiggle
def get_b_wiggle(x, y, y_int)
returns instantaneous slope from the ratio of NRM lost to TRM gained at the ith step
2.544989
2.394455
1.062868
Z = 0 first_time = True for num, x in enumerate(x_segment): b_wiggle = get_b_wiggle(x, y_segment[num], y_int) z = old_div((x * abs(b_wiggle - abs(slope)) ), abs(x_int)) Z += z first_time = False return Z
def get_Z(x_segment, y_segment, x_int, y_int, slope)
input: x_segment, y_segment, x_int, y_int, slope output: Z (Arai plot zigzag parameter)
4.447175
4.487487
0.991017
total = 0 first_time = True for num, x in enumerate(x_segment): b_wiggle = get_b_wiggle(x, y_segment[num], y_int) result = 100 * ( old_div((x * abs(b_wiggle - abs(slope)) ), abs(y_int)) ) total += result first_time = False Zstar = (old_div(1., (n - 1.))) * total ...
def get_Zstar(x_segment, y_segment, x_int, y_int, slope, n)
input: x_segment, y_segment, x_int, y_int, slope, n output: Z* (Arai plot zigzag parameter (alternate))
4.704333
4.591464
1.024582
def get_normed_points(point_array, norm): # good to go norm = float(norm) #floated_array = [] #for p in point_array: # need to make sure each point is a float #floated_array.append(float(p)) points = old_div(numpy.array(point_array), norm) return points
input: point_array, norm output: normed array
null
null
null
xy_array = [] for num, x in enumerate(x_segment): xy_array.append((x, y_segment[num])) return xy_array
def get_xy_array(x_segment, y_segment)
input: x_segment, y_segment output: xy_segment, ( format: [(x[0], y[0]), (x[1], y[1])]
2.563184
2.639132
0.971222
if '-h' in sys.argv: print(main.__doc__) sys.exit() if '-i' in sys.argv: file=input("Enter file name: ") f=open(file,'r') elif '-f' in sys.argv: ind=sys.argv.index('-f') file=sys.argv[ind+1] f=open(file,'r') else: f=sys.stdin ofile...
def main()
NAME stats.py DEFINITION calculates Gauss statistics for input data SYNTAX stats [command line options][< filename] INPUT single column of numbers OPTIONS -h prints help message and quits -i interactive entry of file name -f input file name ...
3.016075
2.644711
1.140418
dir_path = "." flag = '' if '-WD' in sys.argv: ind = sys.argv.index('-WD') dir_path = sys.argv[ind+1] if '-h' in sys.argv: print(main.__doc__) sys.exit() if '-f' in sys.argv: ind = sys.argv.index('-f') magic_file = dir_path+'/'+sys.argv[ind+1] ...
def main()
NAME magic_select.py DESCRIPTION picks out records and dictitem options saves to magic_special file SYNTAX magic_select.py [command line optins] OPTIONS -h prints help message and quits -f FILE: specify input magic format file -F FILE: specify output magic ...
2.703352
2.24294
1.205272
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_geo.py DESCRIPTION rotates specimen coordinate dec, inc data to geographic coordinates using the azimuth and plunge of the X direction INPUT FORMAT declination inclination azimuth plunge SYNTAX di_geo.py [-h][-i][-f FILE] [< filename ] OPTIONS -h p...
3.241581
2.791282
1.161323
out="" UP=0 if '-h' in sys.argv: print(main.__doc__) sys.exit() if '-f' in sys.argv: ind=sys.argv.index('-f') file=sys.argv[ind+1] DI=numpy.loadtxt(file,dtype=numpy.float) else: DI = numpy.loadtxt(sys.stdin,dtype=numpy.float) # read from standa...
def main()
NAME di_eq.py DESCRIPTION converts dec, inc pairs to x,y pairs using equal area projection NB: do only upper or lower hemisphere at a time: does not distinguish between up and down. SYNTAX di_eq.py [command line options] [< filename] OPTIONS -h prints he...
3.840178
3.584687
1.071273
sp = Spline(x1, y1) return sp(x2)
def spline_interpolate(x1, y1, x2)
Given a function at a set of points (x1, y1), interpolate to evaluate it at points x2.
4.949915
4.503877
1.099034
sp = Spline(log(x1), log(y1)) return exp(sp(log(x2)))
def logspline_interpolate(x1, y1, x2)
Given a function at a set of points (x1, y1), interpolate to evaluate it at points x2.
4.607142
4.773898
0.965069
li = LinInt(x1, y1) return li(x2)
def linear_interpolate(x1, y1, x2)
Given a function at a set of points (x1, y1), interpolate to evaluate it at points x2.
10.799295
8.910544
1.211968
# if out of range, return endpoint if x <= self.x_vals[0]: return self.y_vals[0] if x >= self.x_vals[-1]: return self.y_vals[-1] pos = numpy.searchsorted(self.x_vals, x) h = self.x_vals[pos]-self.x_vals[pos-1] if h == 0.0: raise ...
def call(self, x)
Evaluate the interpolant, assuming x is a scalar.
2.575765
2.489247
1.034757
# initialize some parameters args = sys.argv if "-h" in args: print(main.__doc__) sys.exit() #meas_file = "aarm_measurements.txt" #rmag_anis = "arm_anisotropy.txt" #rmag_res = "aarm_results.txt" # # get name of file from command line # data_model_num = int(...
def main()
NAME aarm_magic.py DESCRIPTION Converts AARM data to best-fit tensor (6 elements plus sigma) Original program ARMcrunch written to accomodate ARM anisotropy data collected from 6 axial directions (+X,+Y,+Z,-X,-Y,-Z) using the off-axis remanence terms to construct the t...
3.479231
2.475604
1.405407
args = sys.argv if "-h" in args: print(main.__doc__) sys.exit() # initialize some stuff methcode = "LP-NO" demag = "N" # # get command line arguments # data_model_num = int(float(pmag.get_named_arg("-DM", 3))) user = pmag.get_named_arg("-usr", "") dir_path = pmag.get_na...
def main()
NAME mini_magic.py DESCRIPTION converts the Yale minispin format to magic_measurements format files SYNTAX mini_magic.py [command line options] OPTIONS -h: prints the help message and quits. -usr USER: identify user, default is "" -f FILE: specify input f...
3.55212
2.752818
1.290358
infile,critout="","pmag_criteria.txt" # parse command line options if '-h' in sys.argv: print(main.__doc__) sys.exit() if '-f' in sys.argv: ind=sys.argv.index('-f') infile=sys.argv[ind+1] crit_data,file_type=pmag.magic_read(infile) if file_type!='pmag_cr...
def main()
NAME customize_criteria.py NB: This program has been deprecated - use demag_gui or thellier_gui to customize acceptance criteria - OR pandas from within a jupyter notebook DESCRIPTION Allows user to specify acceptance criteria, saves them in pmag_criteria.txt SYNTAX ...
3.727334
3.446703
1.08142
if "-WD" in sys.argv and FIRST_RUN: ind = sys.argv.index('-WD') self.WD = sys.argv[ind + 1] elif not WD: # if no arg was passed in for WD, make a dialog to choose one dialog = wx.DirDialog(None, "Choose a directory:", defaultPath=self.currentDirectory, ...
def get_DIR(self, WD=None)
open dialog box for choosing a working directory
2.963221
2.816449
1.052112
if "specimen_int_uT" not in self.Data[self.s]['pars']: return if 'deleted' in self.Data[self.s]['pars']: self.Data[self.s]['pars'].pop('deleted') self.Data[self.s]['pars']['saved'] = True # collect all interpretation by sample sample = self.Data_...
def on_save_interpretation_button(self, event)
save the current interpretation temporarily (not to a file)
2.707129
2.710548
0.998739
del self.Data[self.s]['pars'] self.Data[self.s]['pars'] = {} self.Data[self.s]['pars']['deleted'] = True self.Data[self.s]['pars']['lab_dc_field'] = self.Data[self.s]['lab_dc_field'] self.Data[self.s]['pars']['er_specimen_name'] = self.Data[self.s]['er_specimen_name'] ...
def on_delete_interpretation_button(self, event)
delete the current interpretation temporarily (not to a file)
2.537848
2.532061
1.002286
self.ignore_parameters, value = {}, '' for crit_short_name in self.preferences['show_statistics_on_gui']: crit = "specimen_" + crit_short_name if self.acceptance_criteria[crit]['value'] == -999: self.threshold_windows[crit_short_name].SetValue("") ...
def write_acceptance_criteria_to_boxes(self)
Update paleointensity statistics in acceptance criteria boxes. (after changing temperature bounds or changing specimen)
2.593892
2.533627
1.023786
tmin_index, tmax_index = "", "" if str(self.tmin_box.GetValue()) != "": tmin_index = self.tmin_box.GetSelection() if str(self.tmax_box.GetValue()) != "": tmax_index = self.tmax_box.GetSelection() # if there is no prior interpretation, assume first click i...
def select_bounds_in_logger(self, index)
sets index as the upper or lower bound of a fit based on what the other bound is and selects it in the logger. Requires 2 calls to completely update a interpretation. NOTE: Requires an interpretation to exist before it is called. @param: index - index of the step to select in the logger
2.763357
2.726321
1.013585
# clear all boxes self.clear_boxes() self.draw_figure(self.s) # update temperature list if self.Data[self.s]['T_or_MW'] == "T": self.temperatures = np.array(self.Data[self.s]['t_Arai']) - 273. else: self.temperatures = np.array(self.Data...
def update_selection(self)
update figures and statistics windows with a new selection of specimen
4.353745
4.112885
1.058562