repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
PmagPy/PmagPy
programs/mk_redo.py
main
def main(): """ NAME mk_redo.py DESCRIPTION Makes thellier_redo and zeq_redo files from existing pmag_specimens format file SYNTAX mk_redo.py [-h] [command line options] INPUT takes specimens.txt formatted input file OPTIONS -h: prints help message and...
python
def main(): """ NAME mk_redo.py DESCRIPTION Makes thellier_redo and zeq_redo files from existing pmag_specimens format file SYNTAX mk_redo.py [-h] [command line options] INPUT takes specimens.txt formatted input file OPTIONS -h: prints help message and...
[ "def", "main", "(", ")", ":", "if", "'-h'", "in", "sys", ".", "argv", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "zfile", ",", "tfile", "=", "'zeq_redo'", ",", "'thellier_redo'", "zredo", ",", "tredo", "=", "\"\""...
NAME mk_redo.py DESCRIPTION Makes thellier_redo and zeq_redo files from existing pmag_specimens format file SYNTAX mk_redo.py [-h] [command line options] INPUT takes specimens.txt formatted input file OPTIONS -h: prints help message and quits -f FILE: ...
[ "NAME", "mk_redo", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/mk_redo.py#L8-L90
PmagPy/PmagPy
pmagpy/lcc_ticks.py
find_side
def find_side(ls, side): """ Given a shapely LineString which is assumed to be rectangular, return the line corresponding to a given side of the rectangle. """ minx, miny, maxx, maxy = ls.bounds points = {'left': [(minx, miny), (minx, maxy)], 'right': [(maxx, miny), (maxx, max...
python
def find_side(ls, side): """ Given a shapely LineString which is assumed to be rectangular, return the line corresponding to a given side of the rectangle. """ minx, miny, maxx, maxy = ls.bounds points = {'left': [(minx, miny), (minx, maxy)], 'right': [(maxx, miny), (maxx, max...
[ "def", "find_side", "(", "ls", ",", "side", ")", ":", "minx", ",", "miny", ",", "maxx", ",", "maxy", "=", "ls", ".", "bounds", "points", "=", "{", "'left'", ":", "[", "(", "minx", ",", "miny", ")", ",", "(", "minx", ",", "maxy", ")", "]", ","...
Given a shapely LineString which is assumed to be rectangular, return the line corresponding to a given side of the rectangle.
[ "Given", "a", "shapely", "LineString", "which", "is", "assumed", "to", "be", "rectangular", "return", "the", "line", "corresponding", "to", "a", "given", "side", "of", "the", "rectangle", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/lcc_ticks.py#L5-L16
PmagPy/PmagPy
pmagpy/lcc_ticks.py
lambert_xticks
def lambert_xticks(ax, ticks): """Draw ticks on the bottom x-axis of a Lambert Conformal projection.""" te = lambda xy: xy[0] lc = lambda t, n, b: np.vstack((np.zeros(n) + t, np.linspace(b[2], b[3], n))).T xticks, xticklabels = _lambert_ticks(ax, ticks, 'bottom', lc, te) ax.xaxis.tick_bottom() a...
python
def lambert_xticks(ax, ticks): """Draw ticks on the bottom x-axis of a Lambert Conformal projection.""" te = lambda xy: xy[0] lc = lambda t, n, b: np.vstack((np.zeros(n) + t, np.linspace(b[2], b[3], n))).T xticks, xticklabels = _lambert_ticks(ax, ticks, 'bottom', lc, te) ax.xaxis.tick_bottom() a...
[ "def", "lambert_xticks", "(", "ax", ",", "ticks", ")", ":", "te", "=", "lambda", "xy", ":", "xy", "[", "0", "]", "lc", "=", "lambda", "t", ",", "n", ",", "b", ":", "np", ".", "vstack", "(", "(", "np", ".", "zeros", "(", "n", ")", "+", "t", ...
Draw ticks on the bottom x-axis of a Lambert Conformal projection.
[ "Draw", "ticks", "on", "the", "bottom", "x", "-", "axis", "of", "a", "Lambert", "Conformal", "projection", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/lcc_ticks.py#L19-L26
PmagPy/PmagPy
pmagpy/lcc_ticks.py
lambert_yticks
def lambert_yticks(ax, ticks): """Draw ricks on the left y-axis of a Lamber Conformal projection.""" te = lambda xy: xy[1] lc = lambda t, n, b: np.vstack((np.linspace(b[0], b[1], n), np.zeros(n) + t)).T yticks, yticklabels = _lambert_ticks(ax, ticks, 'left', lc, te) ax.yaxis.tick_left() ax.set_y...
python
def lambert_yticks(ax, ticks): """Draw ricks on the left y-axis of a Lamber Conformal projection.""" te = lambda xy: xy[1] lc = lambda t, n, b: np.vstack((np.linspace(b[0], b[1], n), np.zeros(n) + t)).T yticks, yticklabels = _lambert_ticks(ax, ticks, 'left', lc, te) ax.yaxis.tick_left() ax.set_y...
[ "def", "lambert_yticks", "(", "ax", ",", "ticks", ")", ":", "te", "=", "lambda", "xy", ":", "xy", "[", "1", "]", "lc", "=", "lambda", "t", ",", "n", ",", "b", ":", "np", ".", "vstack", "(", "(", "np", ".", "linspace", "(", "b", "[", "0", "]...
Draw ricks on the left y-axis of a Lamber Conformal projection.
[ "Draw", "ricks", "on", "the", "left", "y", "-", "axis", "of", "a", "Lamber", "Conformal", "projection", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/lcc_ticks.py#L29-L36
PmagPy/PmagPy
pmagpy/lcc_ticks.py
_lambert_ticks
def _lambert_ticks(ax, ticks, tick_location, line_constructor, tick_extractor): """Get the tick locations and labels for an axis of a Lambert Conformal projection.""" outline_patch = sgeom.LineString(ax.outline_patch.get_path().vertices.tolist()) axis = find_side(outline_patch, tick_location) n_steps = ...
python
def _lambert_ticks(ax, ticks, tick_location, line_constructor, tick_extractor): """Get the tick locations and labels for an axis of a Lambert Conformal projection.""" outline_patch = sgeom.LineString(ax.outline_patch.get_path().vertices.tolist()) axis = find_side(outline_patch, tick_location) n_steps = ...
[ "def", "_lambert_ticks", "(", "ax", ",", "ticks", ",", "tick_location", ",", "line_constructor", ",", "tick_extractor", ")", ":", "outline_patch", "=", "sgeom", ".", "LineString", "(", "ax", ".", "outline_patch", ".", "get_path", "(", ")", ".", "vertices", "...
Get the tick locations and labels for an axis of a Lambert Conformal projection.
[ "Get", "the", "tick", "locations", "and", "labels", "for", "an", "axis", "of", "a", "Lambert", "Conformal", "projection", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/lcc_ticks.py#L38-L65
PmagPy/PmagPy
programs/deprecated/umich_magic.py
main
def main(): """ NAME umich_magic.py DESCRIPTION converts UMICH .mag format files to magic_measurements format files SYNTAX umich_magic.py [command line options] OPTIONS -h: prints the help message and quits. -usr USER: identify user, default is "" ...
python
def main(): """ NAME umich_magic.py DESCRIPTION converts UMICH .mag format files to magic_measurements format files SYNTAX umich_magic.py [command line options] OPTIONS -h: prints the help message and quits. -usr USER: identify user, default is "" ...
[ "def", "main", "(", ")", ":", "# initialize some stuff", "dir_path", "=", "'.'", "infile_type", "=", "\"mag\"", "noave", "=", "0", "methcode", ",", "inst", "=", "\"\"", ",", "\"\"", "phi", ",", "theta", ",", "peakfield", ",", "labfield", "=", "0", ",", ...
NAME umich_magic.py DESCRIPTION converts UMICH .mag format files to magic_measurements format files SYNTAX umich_magic.py [command line options] OPTIONS -h: prints the help message and quits. -usr USER: identify user, default is "" -f FILE: specify .mag ...
[ "NAME", "umich_magic", ".", "py", "DESCRIPTION", "converts", "UMICH", ".", "mag", "format", "files", "to", "magic_measurements", "format", "files" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/deprecated/umich_magic.py#L7-L244
PmagPy/PmagPy
programs/dmag_magic.py
dmag_magic
def dmag_magic(in_file="measurements.txt", dir_path=".", input_dir_path="", spec_file="specimens.txt", samp_file="samples.txt", site_file="sites.txt", loc_file="locations.txt", plot_by="loc", LT="AF", norm=True, XLP="", save_plots=True, fmt="svg"): """ plots intensity decay ...
python
def dmag_magic(in_file="measurements.txt", dir_path=".", input_dir_path="", spec_file="specimens.txt", samp_file="samples.txt", site_file="sites.txt", loc_file="locations.txt", plot_by="loc", LT="AF", norm=True, XLP="", save_plots=True, fmt="svg"): """ plots intensity decay ...
[ "def", "dmag_magic", "(", "in_file", "=", "\"measurements.txt\"", ",", "dir_path", "=", "\".\"", ",", "input_dir_path", "=", "\"\"", ",", "spec_file", "=", "\"specimens.txt\"", ",", "samp_file", "=", "\"samples.txt\"", ",", "site_file", "=", "\"sites.txt\"", ",", ...
plots intensity decay curves for demagnetization experiments Parameters ---------- in_file : str, default "measurements.txt" dir_path : str output directory, default "." input_dir_path : str input file directory (if different from dir_path), default "" spec_file : str in...
[ "plots", "intensity", "decay", "curves", "for", "demagnetization", "experiments" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/dmag_magic.py#L16-L187
PmagPy/PmagPy
programs/dmag_magic.py
main
def main(): """ NAME dmag_magic.py DESCRIPTION plots intensity decay curves for demagnetization experiments SYNTAX dmag_magic -h [command line options] INPUT takes magic formatted measurements.txt files OPTIONS -h prints help message and quits -f...
python
def main(): """ NAME dmag_magic.py DESCRIPTION plots intensity decay curves for demagnetization experiments SYNTAX dmag_magic -h [command line options] INPUT takes magic formatted measurements.txt files OPTIONS -h prints help message and quits -f...
[ "def", "main", "(", ")", ":", "if", "'-h'", "in", "sys", ".", "argv", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "# initialize variables from command line + defaults", "dir_path", "=", "pmag", ".", "get_named_arg", "(", "...
NAME dmag_magic.py DESCRIPTION plots intensity decay curves for demagnetization experiments SYNTAX dmag_magic -h [command line options] INPUT takes magic formatted measurements.txt files OPTIONS -h prints help message and quits -f FILE: specify input fil...
[ "NAME", "dmag_magic", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/dmag_magic.py#L191-L244
PmagPy/PmagPy
programs/watsons_v.py
main
def main(): """ NAME watsons_v.py DESCRIPTION calculates Watson's V statistic from input files INPUT FORMAT takes dec/inc as first two columns in two space delimited files SYNTAX watsons_v.py [command line options] OPTIONS -h prints help message and quits ...
python
def main(): """ NAME watsons_v.py DESCRIPTION calculates Watson's V statistic from input files INPUT FORMAT takes dec/inc as first two columns in two space delimited files SYNTAX watsons_v.py [command line options] OPTIONS -h prints help message and quits ...
[ "def", "main", "(", ")", ":", "Flip", "=", "0", "show", ",", "plot", "=", "1", ",", "0", "fmt", "=", "'svg'", "file2", "=", "\"\"", "if", "'-h'", "in", "sys", ".", "argv", ":", "# check if help is needed", "print", "(", "main", ".", "__doc__", ")",...
NAME watsons_v.py DESCRIPTION calculates Watson's V statistic from input files INPUT FORMAT takes dec/inc as first two columns in two space delimited files SYNTAX watsons_v.py [command line options] OPTIONS -h prints help message and quits -f FILE (with op...
[ "NAME", "watsons_v", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/watsons_v.py#L15-L158
PmagPy/PmagPy
programs/deprecated/biplot_magic.py
main
def main(): """ NAME biplot_magic.py DESCRIPTION makes a biplot of specified variables from magic_measurements.txt format file SYNTAX biplot_magic.py [-h] [-i] [command line options] INPUT takes magic formated magic_measurments file OPTIONS -h prints h...
python
def main(): """ NAME biplot_magic.py DESCRIPTION makes a biplot of specified variables from magic_measurements.txt format file SYNTAX biplot_magic.py [-h] [-i] [command line options] INPUT takes magic formated magic_measurments file OPTIONS -h prints h...
[ "def", "main", "(", ")", ":", "#", "file", "=", "'magic_measurements.txt'", "methx", ",", "methy", ",", "fmt", "=", "\"\"", ",", "\"\"", ",", "'.svg'", "plot_key", "=", "''", "norm_by", "=", "\"\"", "#plot=0", "no_plot", "=", "pmag", ".", "get_flag_arg_f...
NAME biplot_magic.py DESCRIPTION makes a biplot of specified variables from magic_measurements.txt format file SYNTAX biplot_magic.py [-h] [-i] [command line options] INPUT takes magic formated magic_measurments file OPTIONS -h prints help message and quits ...
[ "NAME", "biplot_magic", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/deprecated/biplot_magic.py#L10-L217
PmagPy/PmagPy
programs/strip_magic.py
main
def main(): """ NAME strip_magic.py DESCRIPTION plots various parameters versus depth or age SYNTAX strip_magic.py [command line optins] OPTIONS -h prints help message and quits -DM NUM: specify data model num, options 2 (legacy) or 3 (default) -f F...
python
def main(): """ NAME strip_magic.py DESCRIPTION plots various parameters versus depth or age SYNTAX strip_magic.py [command line optins] OPTIONS -h prints help message and quits -DM NUM: specify data model num, options 2 (legacy) or 3 (default) -f F...
[ "def", "main", "(", ")", ":", "if", "'-h'", "in", "sys", ".", "argv", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "xaxis", ",", "xplotind", ",", "yplotind", "=", "\"\"", ",", "0", ",", "0", "# (0 for strat pos)", ...
NAME strip_magic.py DESCRIPTION plots various parameters versus depth or age SYNTAX strip_magic.py [command line optins] OPTIONS -h prints help message and quits -DM NUM: specify data model num, options 2 (legacy) or 3 (default) -f FILE: specify input magic...
[ "NAME", "strip_magic", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/strip_magic.py#L11-L375
PmagPy/PmagPy
programs/site_edit_magic.py
main
def main(): """ NAME site_edit_magic.py DESCRIPTION makes equal area projections site by site from pmag_specimens.txt file with Fisher confidence ellipse using McFadden and McElhinny (1988) technique for combining lines and planes allows testing and reject...
python
def main(): """ NAME site_edit_magic.py DESCRIPTION makes equal area projections site by site from pmag_specimens.txt file with Fisher confidence ellipse using McFadden and McElhinny (1988) technique for combining lines and planes allows testing and reject...
[ "def", "main", "(", ")", ":", "dir_path", "=", "'.'", "FIG", "=", "{", "}", "# plot dictionary", "FIG", "[", "'eqarea'", "]", "=", "1", "# eqarea is figure 1", "in_file", "=", "'pmag_specimens.txt'", "sampfile", "=", "'er_samples.txt'", "out_file", "=", "\"\""...
NAME site_edit_magic.py DESCRIPTION makes equal area projections site by site from pmag_specimens.txt file with Fisher confidence ellipse using McFadden and McElhinny (1988) technique for combining lines and planes allows testing and reject specimens for bad orien...
[ "NAME", "site_edit_magic", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/site_edit_magic.py#L11-L235
PmagPy/PmagPy
programs/lowes.py
main
def main(): """ NAME lowes.py DESCRIPTION Plots Lowes spectrum for input IGRF-like file SYNTAX lowes.py [options] OPTIONS: -h prints help message and quits -f FILE specify file name with input data -d date specify desired date -r read desired date...
python
def main(): """ NAME lowes.py DESCRIPTION Plots Lowes spectrum for input IGRF-like file SYNTAX lowes.py [options] OPTIONS: -h prints help message and quits -f FILE specify file name with input data -d date specify desired date -r read desired date...
[ "def", "main", "(", ")", ":", "norm", "=", "0", "if", "'-f'", "in", "sys", ".", "argv", ":", "ind", "=", "sys", ".", "argv", ".", "index", "(", "'-f'", ")", "file", "=", "sys", ".", "argv", "[", "ind", "+", "1", "]", "data", "=", "np", ".",...
NAME lowes.py DESCRIPTION Plots Lowes spectrum for input IGRF-like file SYNTAX lowes.py [options] OPTIONS: -h prints help message and quits -f FILE specify file name with input data -d date specify desired date -r read desired dates from file -n no...
[ "NAME", "lowes", ".", "py", "DESCRIPTION", "Plots", "Lowes", "spectrum", "for", "input", "IGRF", "-", "like", "file", "SYNTAX", "lowes", ".", "py", "[", "options", "]" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/lowes.py#L15-L66
PmagPy/PmagPy
data_files/LearningPython/main.py
main
def main(): """This program prints doubled values!""" import numpy X=arange(.1,10.1,.2) #make a list of numbers Y=myfunc(X) # calls myfunc with argument X for i in range(len(X)): print(X[i],Y[i])
python
def main(): """This program prints doubled values!""" import numpy X=arange(.1,10.1,.2) #make a list of numbers Y=myfunc(X) # calls myfunc with argument X for i in range(len(X)): print(X[i],Y[i])
[ "def", "main", "(", ")", ":", "import", "numpy", "X", "=", "arange", "(", ".1", ",", "10.1", ",", ".2", ")", "#make a list of numbers", "Y", "=", "myfunc", "(", "X", ")", "# calls myfunc with argument X", "for", "i", "in", "range", "(", "len", "(", "X"...
This program prints doubled values!
[ "This", "program", "prints", "doubled", "values!" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/data_files/LearningPython/main.py#L11-L17
PmagPy/PmagPy
programs/common_mean.py
main
def main(): """ NAME common_mean.py DESCRIPTION calculates bootstrap statistics to test for common mean INPUT FORMAT takes dec/inc as first two columns in two space delimited files SYNTAX common_mean.py [command line options] OPTIONS -h prints help m...
python
def main(): """ NAME common_mean.py DESCRIPTION calculates bootstrap statistics to test for common mean INPUT FORMAT takes dec/inc as first two columns in two space delimited files SYNTAX common_mean.py [command line options] OPTIONS -h prints help m...
[ "def", "main", "(", ")", ":", "d", ",", "i", ",", "file2", "=", "\"\"", ",", "\"\"", ",", "\"\"", "fmt", ",", "plot", "=", "'svg'", ",", "0", "if", "'-h'", "in", "sys", ".", "argv", ":", "# check if help is needed", "print", "(", "main", ".", "__...
NAME common_mean.py DESCRIPTION calculates bootstrap statistics to test for common mean INPUT FORMAT takes dec/inc as first two columns in two space delimited files SYNTAX common_mean.py [command line options] OPTIONS -h prints help message and quits ...
[ "NAME", "common_mean", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/common_mean.py#L12-L94
PmagPy/PmagPy
SPD/lib/lib_curvature.py
AraiCurvature
def AraiCurvature(x=x,y=y): """ input: list of x points, list of y points output: k, a, b, SSE. curvature, circle center, and SSE Function for calculating the radius of the best fit circle to a set of x-y coordinates. Paterson, G. A., (2011), A simple test for the presence of multidomain b...
python
def AraiCurvature(x=x,y=y): """ input: list of x points, list of y points output: k, a, b, SSE. curvature, circle center, and SSE Function for calculating the radius of the best fit circle to a set of x-y coordinates. Paterson, G. A., (2011), A simple test for the presence of multidomain b...
[ "def", "AraiCurvature", "(", "x", "=", "x", ",", "y", "=", "y", ")", ":", "# makes sure all values are floats, then norms them by largest value", "X", "=", "numpy", ".", "array", "(", "list", "(", "map", "(", "float", ",", "x", ")", ")", ")", "X", "=", "...
input: list of x points, list of y points output: k, a, b, SSE. curvature, circle center, and SSE Function for calculating the radius of the best fit circle to a set of x-y coordinates. Paterson, G. A., (2011), A simple test for the presence of multidomain behaviour during paleointensity experimen...
[ "input", ":", "list", "of", "x", "points", "list", "of", "y", "points", "output", ":", "k", "a", "b", "SSE", ".", "curvature", "circle", "center", "and", "SSE", "Function", "for", "calculating", "the", "radius", "of", "the", "best", "fit", "circle", "t...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_curvature.py#L19-L55
PmagPy/PmagPy
SPD/lib/lib_curvature.py
TaubinSVD
def TaubinSVD(XY): """ algebraic circle fit input: list [[x_1, y_1], [x_2, y_2], ....] output: a, b, r. a and b are the center of the fitting circle, and r is the radius Algebraic circle fit by Taubin G. Taubin, "Estimation Of Planar Curves, Surfaces And Nonplanar Space Cu...
python
def TaubinSVD(XY): """ algebraic circle fit input: list [[x_1, y_1], [x_2, y_2], ....] output: a, b, r. a and b are the center of the fitting circle, and r is the radius Algebraic circle fit by Taubin G. Taubin, "Estimation Of Planar Curves, Surfaces And Nonplanar Space Cu...
[ "def", "TaubinSVD", "(", "XY", ")", ":", "XY", "=", "numpy", ".", "array", "(", "XY", ")", "X", "=", "XY", "[", ":", ",", "0", "]", "-", "numpy", ".", "mean", "(", "XY", "[", ":", ",", "0", "]", ")", "# norming points by x avg", "Y", "=", "XY...
algebraic circle fit input: list [[x_1, y_1], [x_2, y_2], ....] output: a, b, r. a and b are the center of the fitting circle, and r is the radius Algebraic circle fit by Taubin G. Taubin, "Estimation Of Planar Curves, Surfaces And Nonplanar Space Curves Defined By Implicit Equati...
[ "algebraic", "circle", "fit", "input", ":", "list", "[[", "x_1", "y_1", "]", "[", "x_2", "y_2", "]", "....", "]", "output", ":", "a", "b", "r", ".", "a", "and", "b", "are", "the", "center", "of", "the", "fitting", "circle", "and", "r", "is", "the...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_curvature.py#L58-L85
PmagPy/PmagPy
SPD/lib/lib_curvature.py
VarCircle
def VarCircle(XY, Par): # must have at least 4 sets of xy points or else division by zero occurs """ computing the sample variance of distances from data points (XY) to the circle Par = [a b R] """ if type(XY) != numpy.ndarray: XY = numpy.array(XY) n = len(XY) if n < 4: raise Wa...
python
def VarCircle(XY, Par): # must have at least 4 sets of xy points or else division by zero occurs """ computing the sample variance of distances from data points (XY) to the circle Par = [a b R] """ if type(XY) != numpy.ndarray: XY = numpy.array(XY) n = len(XY) if n < 4: raise Wa...
[ "def", "VarCircle", "(", "XY", ",", "Par", ")", ":", "# must have at least 4 sets of xy points or else division by zero occurs", "if", "type", "(", "XY", ")", "!=", "numpy", ".", "ndarray", ":", "XY", "=", "numpy", ".", "array", "(", "XY", ")", "n", "=", "le...
computing the sample variance of distances from data points (XY) to the circle Par = [a b R]
[ "computing", "the", "sample", "variance", "of", "distances", "from", "data", "points", "(", "XY", ")", "to", "the", "circle", "Par", "=", "[", "a", "b", "R", "]" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_curvature.py#L88-L101
PmagPy/PmagPy
SPD/lib/lib_curvature.py
LMA
def LMA(XY,ParIni): """ input: list of x and y values [[x_1, y_1], [x_2, y_2], ....], and a tuple containing an initial guess (a, b, r) which is acquired by using an algebraic circle fit (TaubinSVD) output: a, b, r. a and b are the center of the fitting circle, and r is the radius % Geom...
python
def LMA(XY,ParIni): """ input: list of x and y values [[x_1, y_1], [x_2, y_2], ....], and a tuple containing an initial guess (a, b, r) which is acquired by using an algebraic circle fit (TaubinSVD) output: a, b, r. a and b are the center of the fitting circle, and r is the radius % Geom...
[ "def", "LMA", "(", "XY", ",", "ParIni", ")", ":", "factorUp", "=", "10", "factorDown", "=", "0.04", "lambda0", "=", "0.01", "epsilon", "=", "0.000001", "IterMAX", "=", "50", "AdjustMax", "=", "20", "Xshift", "=", "0", "Yshift", "=", "0", "dX", "=", ...
input: list of x and y values [[x_1, y_1], [x_2, y_2], ....], and a tuple containing an initial guess (a, b, r) which is acquired by using an algebraic circle fit (TaubinSVD) output: a, b, r. a and b are the center of the fitting circle, and r is the radius % Geometric circle fit (minimizing ort...
[ "input", ":", "list", "of", "x", "and", "y", "values", "[[", "x_1", "y_1", "]", "[", "x_2", "y_2", "]", "....", "]", "and", "a", "tuple", "containing", "an", "initial", "guess", "(", "a", "b", "r", ")", "which", "is", "acquired", "by", "using", "...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_curvature.py#L104-L293
PmagPy/PmagPy
SPD/lib/lib_curvature.py
get_SSE
def get_SSE(a,b,r,x,y): """ input: a, b, r, x, y. circle center, radius, xpts, ypts output: SSE """ SSE = 0 X = numpy.array(x) Y = numpy.array(y) for i in range(len(X)): x = X[i] y = Y[i] v = (numpy.sqrt( (x -a)**2 + (y - b)**2 ) - r )**2 SSE += v ret...
python
def get_SSE(a,b,r,x,y): """ input: a, b, r, x, y. circle center, radius, xpts, ypts output: SSE """ SSE = 0 X = numpy.array(x) Y = numpy.array(y) for i in range(len(X)): x = X[i] y = Y[i] v = (numpy.sqrt( (x -a)**2 + (y - b)**2 ) - r )**2 SSE += v ret...
[ "def", "get_SSE", "(", "a", ",", "b", ",", "r", ",", "x", ",", "y", ")", ":", "SSE", "=", "0", "X", "=", "numpy", ".", "array", "(", "x", ")", "Y", "=", "numpy", ".", "array", "(", "y", ")", "for", "i", "in", "range", "(", "len", "(", "...
input: a, b, r, x, y. circle center, radius, xpts, ypts output: SSE
[ "input", ":", "a", "b", "r", "x", "y", ".", "circle", "center", "radius", "xpts", "ypts", "output", ":", "SSE" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_curvature.py#L297-L310
PmagPy/PmagPy
programs/sundec.py
main
def main(): """ NAME sundec.py DESCRIPTION calculates calculates declination from sun compass measurements INPUT FORMAT GMT_offset, lat,long,year,month,day,hours,minutes,shadow_angle where GMT_offset is the hours to subtract from local time for GMT. SYNTAX sun...
python
def main(): """ NAME sundec.py DESCRIPTION calculates calculates declination from sun compass measurements INPUT FORMAT GMT_offset, lat,long,year,month,day,hours,minutes,shadow_angle where GMT_offset is the hours to subtract from local time for GMT. SYNTAX sun...
[ "def", "main", "(", ")", ":", "if", "'-h'", "in", "sys", ".", "argv", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "if", "'-f'", "in", "sys", ".", "argv", ":", "ind", "=", "sys", ".", "argv", ".", "index", "("...
NAME sundec.py DESCRIPTION calculates calculates declination from sun compass measurements INPUT FORMAT GMT_offset, lat,long,year,month,day,hours,minutes,shadow_angle where GMT_offset is the hours to subtract from local time for GMT. SYNTAX sundec.py [-i][-f FILE] [< ...
[ "NAME", "sundec", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/sundec.py#L23-L79
PmagPy/PmagPy
programs/deprecated/sites_locations.py
main
def main(): """ NAME sites_locations.py DESCRIPTION reads in er_sites.txt file and finds all locations and bounds of locations outputs er_locations.txt file SYNTAX sites_locations.py [command line options] OPTIONS -h prints help message and quits -f...
python
def main(): """ NAME sites_locations.py DESCRIPTION reads in er_sites.txt file and finds all locations and bounds of locations outputs er_locations.txt file SYNTAX sites_locations.py [command line options] OPTIONS -h prints help message and quits -f...
[ "def", "main", "(", ")", ":", "# set defaults", "site_file", "=", "\"er_sites.txt\"", "loc_file", "=", "\"er_locations.txt\"", "Names", ",", "user", "=", "[", "]", ",", "\"unknown\"", "Done", "=", "[", "]", "version_num", "=", "pmag", ".", "get_version", "("...
NAME sites_locations.py DESCRIPTION reads in er_sites.txt file and finds all locations and bounds of locations outputs er_locations.txt file SYNTAX sites_locations.py [command line options] OPTIONS -h prints help message and quits -f: specimen input er_site...
[ "NAME", "sites_locations", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/deprecated/sites_locations.py#L7-L70
PmagPy/PmagPy
programs/zeq_magic2.py
main
def main(): """ NAME zeq_magic.py DESCRIPTION reads in magic_measurements formatted file, makes plots of remanence decay during demagnetization experiments. Reads in prior interpretations saved in a pmag_specimens formatted file and allows re-interpretations of best-fit l...
python
def main(): """ NAME zeq_magic.py DESCRIPTION reads in magic_measurements formatted file, makes plots of remanence decay during demagnetization experiments. Reads in prior interpretations saved in a pmag_specimens formatted file and allows re-interpretations of best-fit l...
[ "def", "main", "(", ")", ":", "# initialize some variables", "doave", ",", "e", ",", "b", "=", "1", ",", "0", ",", "0", "# average replicates, initial end and beginning step", "plots", ",", "coord", "=", "0", ",", "'s'", "noorient", "=", "0", "version_num", ...
NAME zeq_magic.py DESCRIPTION reads in magic_measurements formatted file, makes plots of remanence decay during demagnetization experiments. Reads in prior interpretations saved in a pmag_specimens formatted file and allows re-interpretations of best-fit lines and planes ...
[ "NAME", "zeq_magic", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/zeq_magic2.py#L17-L729
PmagPy/PmagPy
pmagpy/controlled_vocabularies2.py
Vocabulary.get_one_meth_type
def get_one_meth_type(self, mtype, method_list): """ Get all codes of one type (i.e., 'anisotropy_estimation') """ cond = method_list['dtype'] == mtype codes = method_list[cond] return codes
python
def get_one_meth_type(self, mtype, method_list): """ Get all codes of one type (i.e., 'anisotropy_estimation') """ cond = method_list['dtype'] == mtype codes = method_list[cond] return codes
[ "def", "get_one_meth_type", "(", "self", ",", "mtype", ",", "method_list", ")", ":", "cond", "=", "method_list", "[", "'dtype'", "]", "==", "mtype", "codes", "=", "method_list", "[", "cond", "]", "return", "codes" ]
Get all codes of one type (i.e., 'anisotropy_estimation')
[ "Get", "all", "codes", "of", "one", "type", "(", "i", ".", "e", ".", "anisotropy_estimation", ")" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/controlled_vocabularies2.py#L29-L35
PmagPy/PmagPy
pmagpy/controlled_vocabularies2.py
Vocabulary.get_one_meth_category
def get_one_meth_category(self, category, all_codes, code_types): """ Get all codes in one category (i.e., all pmag codes). This can include multiple method types (i.e., 'anisotropy_estimation', 'sample_prepartion', etc.) """ categories = Series(code_types[code_types[category] ==...
python
def get_one_meth_category(self, category, all_codes, code_types): """ Get all codes in one category (i.e., all pmag codes). This can include multiple method types (i.e., 'anisotropy_estimation', 'sample_prepartion', etc.) """ categories = Series(code_types[code_types[category] ==...
[ "def", "get_one_meth_category", "(", "self", ",", "category", ",", "all_codes", ",", "code_types", ")", ":", "categories", "=", "Series", "(", "code_types", "[", "code_types", "[", "category", "]", "==", "True", "]", ".", "index", ")", "cond", "=", "all_co...
Get all codes in one category (i.e., all pmag codes). This can include multiple method types (i.e., 'anisotropy_estimation', 'sample_prepartion', etc.)
[ "Get", "all", "codes", "in", "one", "category", "(", "i", ".", "e", ".", "all", "pmag", "codes", ")", ".", "This", "can", "include", "multiple", "method", "types", "(", "i", ".", "e", ".", "anisotropy_estimation", "sample_prepartion", "etc", ".", ")" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/controlled_vocabularies2.py#L37-L45
PmagPy/PmagPy
programs/azdip_magic.py
main
def main(): """ NAME azdip_magic.py DESCRIPTION takes space delimited AzDip file and converts to MagIC formatted tables SYNTAX azdip_magic.py [command line options] OPTIONS -f FILE: specify input file -Fsa FILE: specify output file, default is: er_samples.t...
python
def main(): """ NAME azdip_magic.py DESCRIPTION takes space delimited AzDip file and converts to MagIC formatted tables SYNTAX azdip_magic.py [command line options] OPTIONS -f FILE: specify input file -Fsa FILE: specify output file, default is: er_samples.t...
[ "def", "main", "(", ")", ":", "args", "=", "sys", ".", "argv", "if", "\"-h\"", "in", "args", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "dataframe", "=", "extractor", ".", "command_line_dataframe", "(", "[", "[", ...
NAME azdip_magic.py DESCRIPTION takes space delimited AzDip file and converts to MagIC formatted tables SYNTAX azdip_magic.py [command line options] OPTIONS -f FILE: specify input file -Fsa FILE: specify output file, default is: er_samples.txt/samples.txt -...
[ "NAME", "azdip_magic", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/azdip_magic.py#L10-L79
PmagPy/PmagPy
programs/plot_geomagia.py
main
def main(): """ NAME plot_geomagia.py DESCRIPTION makes a map and VADM plot of geomagia download file SYNTAX plot_geomagia.py [command line options] OPTIONS -h prints help message and quits -f FILE, specify geomagia download file -res [c,l,i,h] s...
python
def main(): """ NAME plot_geomagia.py DESCRIPTION makes a map and VADM plot of geomagia download file SYNTAX plot_geomagia.py [command line options] OPTIONS -h prints help message and quits -f FILE, specify geomagia download file -res [c,l,i,h] s...
[ "def", "main", "(", ")", ":", "dir_path", "=", "'.'", "names", ",", "res", ",", "proj", ",", "locs", ",", "padlon", ",", "padlat", ",", "fancy", ",", "gridspace", ",", "details", "=", "[", "]", ",", "'l'", ",", "'lcc'", ",", "''", ",", "0", ","...
NAME plot_geomagia.py DESCRIPTION makes a map and VADM plot of geomagia download file SYNTAX plot_geomagia.py [command line options] OPTIONS -h prints help message and quits -f FILE, specify geomagia download file -res [c,l,i,h] specify resolution (crude...
[ "NAME", "plot_geomagia", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/plot_geomagia.py#L15-L124
PmagPy/PmagPy
programs/conversion_scripts/k15_magic.py
main
def main(): """ NAME k15_magic.py DESCRIPTION converts .k15 format data to magic_measurements format. assums Jelinek Kappabridge measurement scheme SYNTAX k15_magic.py [-h] [command line options] OPTIONS -h prints help message and quits -DM DATA_MO...
python
def main(): """ NAME k15_magic.py DESCRIPTION converts .k15 format data to magic_measurements format. assums Jelinek Kappabridge measurement scheme SYNTAX k15_magic.py [-h] [command line options] OPTIONS -h prints help message and quits -DM DATA_MO...
[ "def", "main", "(", ")", ":", "args", "=", "sys", ".", "argv", "if", "'-h'", "in", "args", ":", "print", "(", "do_help", "(", ")", ")", "sys", ".", "exit", "(", ")", "# def k15_magic(k15file, specnum=0, sample_naming_con='1', er_location_name=\"unknown\", measfile...
NAME k15_magic.py DESCRIPTION converts .k15 format data to magic_measurements format. assums Jelinek Kappabridge measurement scheme SYNTAX k15_magic.py [-h] [command line options] OPTIONS -h prints help message and quits -DM DATA_MODEL: specify data model ...
[ "NAME", "k15_magic", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/conversion_scripts/k15_magic.py#L8-L67
PmagPy/PmagPy
programs/conversion_scripts2/cit_magic2.py
main
def main(command_line=True, **kwargs): """ NAME cit_magic.py DESCRIPTION converts CIT and .sam format files to magic_measurements format files SYNTAX cit_magic.py [command line options] OPTIONS -h: prints the help message and quits. -usr USER: identify u...
python
def main(command_line=True, **kwargs): """ NAME cit_magic.py DESCRIPTION converts CIT and .sam format files to magic_measurements format files SYNTAX cit_magic.py [command line options] OPTIONS -h: prints the help message and quits. -usr USER: identify u...
[ "def", "main", "(", "command_line", "=", "True", ",", "*", "*", "kwargs", ")", ":", "#", "# NB: use PHI, THETA = -1 -1 to signal that it changes, i.e. in anisotropy experiment", "# -ac B : peak AF field (in mT) for ARM acquisition, default is none", "#", "#initial...
NAME cit_magic.py DESCRIPTION converts CIT and .sam format files to magic_measurements format files SYNTAX cit_magic.py [command line options] OPTIONS -h: prints the help message and quits. -usr USER: identify user, default is "" -f FILE: specify .sam fo...
[ "NAME", "cit_magic", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/conversion_scripts2/cit_magic2.py#L11-L419
PmagPy/PmagPy
programs/zeq.py
main
def main(): """ NAME zeq.py DESCRIPTION plots demagnetization data. The equal area projection has the X direction (usually North in geographic coordinates) to the top. The red line is the X axis of the Zijderveld diagram. Solid symbols are lower hemisphere. The solid ...
python
def main(): """ NAME zeq.py DESCRIPTION plots demagnetization data. The equal area projection has the X direction (usually North in geographic coordinates) to the top. The red line is the X axis of the Zijderveld diagram. Solid symbols are lower hemisphere. The solid ...
[ "def", "main", "(", ")", ":", "files", ",", "fmt", ",", "plot", "=", "{", "}", ",", "'svg'", ",", "0", "end_pca", ",", "beg_pca", "=", "\"\"", ",", "\"\"", "calculation_type", "=", "'DE-BFL'", "if", "'-h'", "in", "sys", ".", "argv", ":", "# check i...
NAME zeq.py DESCRIPTION plots demagnetization data. The equal area projection has the X direction (usually North in geographic coordinates) to the top. The red line is the X axis of the Zijderveld diagram. Solid symbols are lower hemisphere. The solid (open) symbols in the Zi...
[ "NAME", "zeq", ".", "py", "DESCRIPTION", "plots", "demagnetization", "data", ".", "The", "equal", "area", "projection", "has", "the", "X", "direction", "(", "usually", "North", "in", "geographic", "coordinates", ")", "to", "the", "top", ".", "The", "red", ...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/zeq.py#L13-L186
PmagPy/PmagPy
programs/make_magic_plots.py
check_for_reqd_cols
def check_for_reqd_cols(data, reqd_cols): """ Check data (PmagPy list of dicts) for required columns """ missing = [] for col in reqd_cols: if col not in data[0]: missing.append(col) return missing
python
def check_for_reqd_cols(data, reqd_cols): """ Check data (PmagPy list of dicts) for required columns """ missing = [] for col in reqd_cols: if col not in data[0]: missing.append(col) return missing
[ "def", "check_for_reqd_cols", "(", "data", ",", "reqd_cols", ")", ":", "missing", "=", "[", "]", "for", "col", "in", "reqd_cols", ":", "if", "col", "not", "in", "data", "[", "0", "]", ":", "missing", ".", "append", "(", "col", ")", "return", "missing...
Check data (PmagPy list of dicts) for required columns
[ "Check", "data", "(", "PmagPy", "list", "of", "dicts", ")", "for", "required", "columns" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/make_magic_plots.py#L26-L34
PmagPy/PmagPy
programs/make_magic_plots.py
main
def main(): """ NAME make_magic_plots.py DESCRIPTION inspects magic directory for available data and makes plots SYNTAX make_magic_plots.py [command line options] INPUT magic files OPTIONS -h prints help message and quits -f FILE specifies inpu...
python
def main(): """ NAME make_magic_plots.py DESCRIPTION inspects magic directory for available data and makes plots SYNTAX make_magic_plots.py [command line options] INPUT magic files OPTIONS -h prints help message and quits -f FILE specifies inpu...
[ "def", "main", "(", ")", ":", "if", "'-h'", "in", "sys", ".", "argv", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "# reset log files", "for", "fname", "in", "[", "'log.txt'", ",", "'errors.txt'", "]", ":", "f", "="...
NAME make_magic_plots.py DESCRIPTION inspects magic directory for available data and makes plots SYNTAX make_magic_plots.py [command line options] INPUT magic files OPTIONS -h prints help message and quits -f FILE specifies input file name -fmt...
[ "NAME", "make_magic_plots", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/make_magic_plots.py#L37-L464
PmagPy/PmagPy
programs/core_depthplot.py
main
def main(): """ NAME core_depthplot.py DESCRIPTION plots various measurements versus core_depth or age. plots data flagged as 'FS-SS-C' as discrete samples. SYNTAX core_depthplot.py [command line options] # or, for Anaconda users: core_depthplot_anaconda [comma...
python
def main(): """ NAME core_depthplot.py DESCRIPTION plots various measurements versus core_depth or age. plots data flagged as 'FS-SS-C' as discrete samples. SYNTAX core_depthplot.py [command line options] # or, for Anaconda users: core_depthplot_anaconda [comma...
[ "def", "main", "(", ")", ":", "args", "=", "sys", ".", "argv", "if", "'-h'", "in", "args", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "dataframe", "=", "extractor", ".", "command_line_dataframe", "(", "[", "[", "'...
NAME core_depthplot.py DESCRIPTION plots various measurements versus core_depth or age. plots data flagged as 'FS-SS-C' as discrete samples. SYNTAX core_depthplot.py [command line options] # or, for Anaconda users: core_depthplot_anaconda [command line options] OP...
[ "NAME", "core_depthplot", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/core_depthplot.py#L19-L193
PmagPy/PmagPy
programs/pca.py
main
def main(): """ NAME pca.py DESCRIPTION calculates best-fit line/plane through demagnetization data INPUT FORMAT takes specimen_name treatment intensity declination inclination in space delimited file SYNTAX pca.py [command line options][< filename] OPTIONS ...
python
def main(): """ NAME pca.py DESCRIPTION calculates best-fit line/plane through demagnetization data INPUT FORMAT takes specimen_name treatment intensity declination inclination in space delimited file SYNTAX pca.py [command line options][< filename] OPTIONS ...
[ "def", "main", "(", ")", ":", "if", "'-h'", "in", "sys", ".", "argv", ":", "# check if help is needed", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "# graceful quit", "if", "'-f'", "in", "sys", ".", "argv", ":", "ind", "=...
NAME pca.py DESCRIPTION calculates best-fit line/plane through demagnetization data INPUT FORMAT takes specimen_name treatment intensity declination inclination in space delimited file SYNTAX pca.py [command line options][< filename] OPTIONS -h prints help and qu...
[ "NAME", "pca", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/pca.py#L6-L72
PmagPy/PmagPy
programs/pt_rot.py
main
def main(): """ NAME pt_rot.py DESCRIPTION rotates pt according to specified age and plate SYNTAX pt_rot.py [command line options] OPTIONS -h prints help and quits -f file with lon lat plate age Dplate as space delimited input Dplate is the de...
python
def main(): """ NAME pt_rot.py DESCRIPTION rotates pt according to specified age and plate SYNTAX pt_rot.py [command line options] OPTIONS -h prints help and quits -f file with lon lat plate age Dplate as space delimited input Dplate is the de...
[ "def", "main", "(", ")", ":", "dir_path", "=", "'.'", "PTS", "=", "[", "]", "ResRecs", "=", "[", "]", "ofile", "=", "\"\"", "data_model", "=", "3", "Dplates", "=", "[", "'nwaf'", ",", "'neaf'", ",", "'saf'", ",", "'aus'", ",", "'eur'", ",", "'ind...
NAME pt_rot.py DESCRIPTION rotates pt according to specified age and plate SYNTAX pt_rot.py [command line options] OPTIONS -h prints help and quits -f file with lon lat plate age Dplate as space delimited input Dplate is the destination plate coordina...
[ "NAME", "pt_rot", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/pt_rot.py#L12-L146
PmagPy/PmagPy
pmagpy/validate_upload3.py
requiredUnless
def requiredUnless(col_name, arg, dm, df, *args): """ Arg is a string in the format "str1, str2, ..." Each string will be a column name. Col_name is required in df unless each column from arg is present. """ # if column name is present, no need to check if it is required if col_name in df.co...
python
def requiredUnless(col_name, arg, dm, df, *args): """ Arg is a string in the format "str1, str2, ..." Each string will be a column name. Col_name is required in df unless each column from arg is present. """ # if column name is present, no need to check if it is required if col_name in df.co...
[ "def", "requiredUnless", "(", "col_name", ",", "arg", ",", "dm", ",", "df", ",", "*", "args", ")", ":", "# if column name is present, no need to check if it is required", "if", "col_name", "in", "df", ".", "columns", ":", "return", "None", "arg_list", "=", "arg"...
Arg is a string in the format "str1, str2, ..." Each string will be a column name. Col_name is required in df unless each column from arg is present.
[ "Arg", "is", "a", "string", "in", "the", "format", "str1", "str2", "...", "Each", "string", "will", "be", "a", "column", "name", ".", "Col_name", "is", "required", "in", "df", "unless", "each", "column", "from", "arg", "is", "present", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L15-L37
PmagPy/PmagPy
pmagpy/validate_upload3.py
requiredUnlessTable
def requiredUnlessTable(col_name, arg, dm, df, con=None): """ Col_name must be present in df unless arg (table_name) is present in contribution """ table_name = arg if col_name in df.columns: return None elif not con: return None elif table_name in con.tables: ret...
python
def requiredUnlessTable(col_name, arg, dm, df, con=None): """ Col_name must be present in df unless arg (table_name) is present in contribution """ table_name = arg if col_name in df.columns: return None elif not con: return None elif table_name in con.tables: ret...
[ "def", "requiredUnlessTable", "(", "col_name", ",", "arg", ",", "dm", ",", "df", ",", "con", "=", "None", ")", ":", "table_name", "=", "arg", "if", "col_name", "in", "df", ".", "columns", ":", "return", "None", "elif", "not", "con", ":", "return", "N...
Col_name must be present in df unless arg (table_name) is present in contribution
[ "Col_name", "must", "be", "present", "in", "df", "unless", "arg", "(", "table_name", ")", "is", "present", "in", "contribution" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L40-L53
PmagPy/PmagPy
pmagpy/validate_upload3.py
requiredIfGroup
def requiredIfGroup(col_name, arg, dm, df, *args): """ Col_name is required if other columns of the group arg are present. """ group_name = arg groups = set() columns = df.columns for col in columns: if col not in dm.index: continue group = dm.loc[col]['group'...
python
def requiredIfGroup(col_name, arg, dm, df, *args): """ Col_name is required if other columns of the group arg are present. """ group_name = arg groups = set() columns = df.columns for col in columns: if col not in dm.index: continue group = dm.loc[col]['group'...
[ "def", "requiredIfGroup", "(", "col_name", ",", "arg", ",", "dm", ",", "df", ",", "*", "args", ")", ":", "group_name", "=", "arg", "groups", "=", "set", "(", ")", "columns", "=", "df", ".", "columns", "for", "col", "in", "columns", ":", "if", "col"...
Col_name is required if other columns of the group arg are present.
[ "Col_name", "is", "required", "if", "other", "columns", "of", "the", "group", "arg", "are", "present", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L56-L74
PmagPy/PmagPy
pmagpy/validate_upload3.py
required
def required(col_name, arg, dm, df, *args): """ Col_name is required in df.columns. Return error message if not. """ if col_name in df.columns: return None else: return '"{}" column is required'.format(col_name)
python
def required(col_name, arg, dm, df, *args): """ Col_name is required in df.columns. Return error message if not. """ if col_name in df.columns: return None else: return '"{}" column is required'.format(col_name)
[ "def", "required", "(", "col_name", ",", "arg", ",", "dm", ",", "df", ",", "*", "args", ")", ":", "if", "col_name", "in", "df", ".", "columns", ":", "return", "None", "else", ":", "return", "'\"{}\" column is required'", ".", "format", "(", "col_name", ...
Col_name is required in df.columns. Return error message if not.
[ "Col_name", "is", "required", "in", "df", ".", "columns", ".", "Return", "error", "message", "if", "not", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L77-L85
PmagPy/PmagPy
pmagpy/validate_upload3.py
isIn
def isIn(row, col_name, arg, dm, df, con=None): """ row[col_name] must contain a value from another column. If not, return error message. """ #grade = df.apply(func, args=(validation_name, arg, dm), axis=1) cell_value = row[col_name] cell_value = str(cell_value) if not cell_value: ...
python
def isIn(row, col_name, arg, dm, df, con=None): """ row[col_name] must contain a value from another column. If not, return error message. """ #grade = df.apply(func, args=(validation_name, arg, dm), axis=1) cell_value = row[col_name] cell_value = str(cell_value) if not cell_value: ...
[ "def", "isIn", "(", "row", ",", "col_name", ",", "arg", ",", "dm", ",", "df", ",", "con", "=", "None", ")", ":", "#grade = df.apply(func, args=(validation_name, arg, dm), axis=1)", "cell_value", "=", "row", "[", "col_name", "]", "cell_value", "=", "str", "(", ...
row[col_name] must contain a value from another column. If not, return error message.
[ "row", "[", "col_name", "]", "must", "contain", "a", "value", "from", "another", "column", ".", "If", "not", "return", "error", "message", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L87-L130
PmagPy/PmagPy
pmagpy/validate_upload3.py
checkMax
def checkMax(row, col_name, arg, *args): """ row[col_name] must be less than or equal to arg. else, return error message. """ cell_value = row[col_name] if not cell_value: return None elif isinstance(cell_value, float): if np.isnan(cell_value): return None try...
python
def checkMax(row, col_name, arg, *args): """ row[col_name] must be less than or equal to arg. else, return error message. """ cell_value = row[col_name] if not cell_value: return None elif isinstance(cell_value, float): if np.isnan(cell_value): return None try...
[ "def", "checkMax", "(", "row", ",", "col_name", ",", "arg", ",", "*", "args", ")", ":", "cell_value", "=", "row", "[", "col_name", "]", "if", "not", "cell_value", ":", "return", "None", "elif", "isinstance", "(", "cell_value", ",", "float", ")", ":", ...
row[col_name] must be less than or equal to arg. else, return error message.
[ "row", "[", "col_name", "]", "must", "be", "less", "than", "or", "equal", "to", "arg", ".", "else", "return", "error", "message", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L132-L160
PmagPy/PmagPy
pmagpy/validate_upload3.py
cv
def cv(row, col_name, arg, current_data_model, df, con): """ row[col_name] must contain only values from the appropriate controlled vocabulary """ vocabulary = con.vocab.vocabularies cell_value = str(row[col_name]) if not cell_value: return None elif cell_value == "None": ret...
python
def cv(row, col_name, arg, current_data_model, df, con): """ row[col_name] must contain only values from the appropriate controlled vocabulary """ vocabulary = con.vocab.vocabularies cell_value = str(row[col_name]) if not cell_value: return None elif cell_value == "None": ret...
[ "def", "cv", "(", "row", ",", "col_name", ",", "arg", ",", "current_data_model", ",", "df", ",", "con", ")", ":", "vocabulary", "=", "con", ".", "vocab", ".", "vocabularies", "cell_value", "=", "str", "(", "row", "[", "col_name", "]", ")", "if", "not...
row[col_name] must contain only values from the appropriate controlled vocabulary
[ "row", "[", "col_name", "]", "must", "contain", "only", "values", "from", "the", "appropriate", "controlled", "vocabulary" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L191-L225
PmagPy/PmagPy
pmagpy/validate_upload3.py
requiredOneInGroup
def requiredOneInGroup(col_name, group, dm, df, *args): """ If col_name is present in df, the group validation is satisfied. If not, it still may be satisfied, but not by THIS col_name. If col_name is missing, return col_name, else return None. Later, we will validate to see if there is at least one...
python
def requiredOneInGroup(col_name, group, dm, df, *args): """ If col_name is present in df, the group validation is satisfied. If not, it still may be satisfied, but not by THIS col_name. If col_name is missing, return col_name, else return None. Later, we will validate to see if there is at least one...
[ "def", "requiredOneInGroup", "(", "col_name", ",", "group", ",", "dm", ",", "df", ",", "*", "args", ")", ":", "if", "col_name", "in", "df", ".", "columns", ":", "# if the column name is present, return nothing", "return", "None", "else", ":", "# if the column na...
If col_name is present in df, the group validation is satisfied. If not, it still may be satisfied, but not by THIS col_name. If col_name is missing, return col_name, else return None. Later, we will validate to see if there is at least one None (non-missing) value for this group.
[ "If", "col_name", "is", "present", "in", "df", "the", "group", "validation", "is", "satisfied", ".", "If", "not", "it", "still", "may", "be", "satisfied", "but", "not", "by", "THIS", "col_name", ".", "If", "col_name", "is", "missing", "return", "col_name",...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L228-L241
PmagPy/PmagPy
pmagpy/validate_upload3.py
validate_df
def validate_df(df, dm, con=None): """ Take in a DataFrame and corresponding data model. Run all validations for that DataFrame. Output is the original DataFrame with some new columns that contain the validation output. Validation columns start with: presence_pass_ (checking that req'd colum...
python
def validate_df(df, dm, con=None): """ Take in a DataFrame and corresponding data model. Run all validations for that DataFrame. Output is the original DataFrame with some new columns that contain the validation output. Validation columns start with: presence_pass_ (checking that req'd colum...
[ "def", "validate_df", "(", "df", ",", "dm", ",", "con", "=", "None", ")", ":", "# check column validity", "required_one", "=", "{", "}", "# keep track of req'd one in group validations here", "cols", "=", "df", ".", "columns", "invalid_cols", "=", "[", "col", "f...
Take in a DataFrame and corresponding data model. Run all validations for that DataFrame. Output is the original DataFrame with some new columns that contain the validation output. Validation columns start with: presence_pass_ (checking that req'd columns are present) type_pass_ (checking that ...
[ "Take", "in", "a", "DataFrame", "and", "corresponding", "data", "model", ".", "Run", "all", "validations", "for", "that", "DataFrame", ".", "Output", "is", "the", "original", "DataFrame", "with", "some", "new", "columns", "that", "contain", "the", "validation"...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L298-L369
PmagPy/PmagPy
pmagpy/validate_upload3.py
get_validation_col_names
def get_validation_col_names(df): """ Input: validated pandas DataFrame (using validate_df) Output: names of all value validation columns, names of all presence validation columns, names of all type validation columns, names of all missing group columns, names...
python
def get_validation_col_names(df): """ Input: validated pandas DataFrame (using validate_df) Output: names of all value validation columns, names of all presence validation columns, names of all type validation columns, names of all missing group columns, names...
[ "def", "get_validation_col_names", "(", "df", ")", ":", "value_cols", "=", "df", ".", "columns", ".", "str", ".", "match", "(", "\"^value_pass_\"", ")", "present_cols", "=", "df", ".", "columns", ".", "str", ".", "match", "(", "\"^presence_pass\"", ")", "t...
Input: validated pandas DataFrame (using validate_df) Output: names of all value validation columns, names of all presence validation columns, names of all type validation columns, names of all missing group columns, names of all validation columns (excluding groups).
[ "Input", ":", "validated", "pandas", "DataFrame", "(", "using", "validate_df", ")", "Output", ":", "names", "of", "all", "value", "validation", "columns", "names", "of", "all", "presence", "validation", "columns", "names", "of", "all", "type", "validation", "c...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L374-L397
PmagPy/PmagPy
pmagpy/validate_upload3.py
print_row_failures
def print_row_failures(failing_items, verbose=False, outfile_name=None): """ Take output from get_row_failures (DataFrame), and output it to stdout, an outfile, or both. """ if outfile_name: outfile = open(outfile_name, "w") outfile.write("\t".join(["name", "row_number", "problem_typ...
python
def print_row_failures(failing_items, verbose=False, outfile_name=None): """ Take output from get_row_failures (DataFrame), and output it to stdout, an outfile, or both. """ if outfile_name: outfile = open(outfile_name, "w") outfile.write("\t".join(["name", "row_number", "problem_typ...
[ "def", "print_row_failures", "(", "failing_items", ",", "verbose", "=", "False", ",", "outfile_name", "=", "None", ")", ":", "if", "outfile_name", ":", "outfile", "=", "open", "(", "outfile_name", ",", "\"w\"", ")", "outfile", ".", "write", "(", "\"\\t\"", ...
Take output from get_row_failures (DataFrame), and output it to stdout, an outfile, or both.
[ "Take", "output", "from", "get_row_failures", "(", "DataFrame", ")", "and", "output", "it", "to", "stdout", "an", "outfile", "or", "both", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L400-L429
PmagPy/PmagPy
pmagpy/validate_upload3.py
get_row_failures
def get_row_failures(df, value_cols, type_cols, verbose=False, outfile=None): """ Input: already validated DataFrame, value & type column names, and output options. Get details on each detected issue, row by row. Output: DataFrame with type & value validation columns, plus an "issues" column wit...
python
def get_row_failures(df, value_cols, type_cols, verbose=False, outfile=None): """ Input: already validated DataFrame, value & type column names, and output options. Get details on each detected issue, row by row. Output: DataFrame with type & value validation columns, plus an "issues" column wit...
[ "def", "get_row_failures", "(", "df", ",", "value_cols", ",", "type_cols", ",", "verbose", "=", "False", ",", "outfile", "=", "None", ")", ":", "# set temporary numeric index", "df", "[", "\"num\"", "]", "=", "list", "(", "range", "(", "len", "(", "df", ...
Input: already validated DataFrame, value & type column names, and output options. Get details on each detected issue, row by row. Output: DataFrame with type & value validation columns, plus an "issues" column with a dictionary of every problem for that row.
[ "Input", ":", "already", "validated", "DataFrame", "value", "&", "type", "column", "names", "and", "output", "options", ".", "Get", "details", "on", "each", "detected", "issue", "row", "by", "row", ".", "Output", ":", "DataFrame", "with", "type", "&", "val...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L432-L461
PmagPy/PmagPy
pmagpy/validate_upload3.py
get_bad_rows_and_cols
def get_bad_rows_and_cols(df, validation_names, type_col_names, value_col_names, verbose=False): """ Input: validated DataFrame, all validation names, names of the type columns, names of the value columns, verbose (True or False). Output: list of rows with bad values, list of c...
python
def get_bad_rows_and_cols(df, validation_names, type_col_names, value_col_names, verbose=False): """ Input: validated DataFrame, all validation names, names of the type columns, names of the value columns, verbose (True or False). Output: list of rows with bad values, list of c...
[ "def", "get_bad_rows_and_cols", "(", "df", ",", "validation_names", ",", "type_col_names", ",", "value_col_names", ",", "verbose", "=", "False", ")", ":", "df", "[", "\"num\"", "]", "=", "list", "(", "range", "(", "len", "(", "df", ")", ")", ")", "proble...
Input: validated DataFrame, all validation names, names of the type columns, names of the value columns, verbose (True or False). Output: list of rows with bad values, list of columns with bad values, list of missing (but required) columns.
[ "Input", ":", "validated", "DataFrame", "all", "validation", "names", "names", "of", "the", "type", "columns", "names", "of", "the", "value", "columns", "verbose", "(", "True", "or", "False", ")", ".", "Output", ":", "list", "of", "rows", "with", "bad", ...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L464-L513
PmagPy/PmagPy
pmagpy/validate_upload3.py
validate_table
def validate_table(the_con, dtype, verbose=False, output_dir="."): """ Return name of bad table, or False if no errors found. Calls validate_df then parses its output. """ print("-I- Validating {}".format(dtype)) # grab dataframe current_df = the_con.tables[dtype].df # grab data model ...
python
def validate_table(the_con, dtype, verbose=False, output_dir="."): """ Return name of bad table, or False if no errors found. Calls validate_df then parses its output. """ print("-I- Validating {}".format(dtype)) # grab dataframe current_df = the_con.tables[dtype].df # grab data model ...
[ "def", "validate_table", "(", "the_con", ",", "dtype", ",", "verbose", "=", "False", ",", "output_dir", "=", "\".\"", ")", ":", "print", "(", "\"-I- Validating {}\"", ".", "format", "(", "dtype", ")", ")", "# grab dataframe", "current_df", "=", "the_con", "....
Return name of bad table, or False if no errors found. Calls validate_df then parses its output.
[ "Return", "name", "of", "bad", "table", "or", "False", "if", "no", "errors", "found", ".", "Calls", "validate_df", "then", "parses", "its", "output", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L518-L557
PmagPy/PmagPy
pmagpy/validate_upload3.py
validate_contribution
def validate_contribution(the_con): """ Go through a Contribution and validate each table """ passing = True for dtype in list(the_con.tables.keys()): print("validating {}".format(dtype)) fail = validate_table(the_con, dtype) if fail: passing = False print...
python
def validate_contribution(the_con): """ Go through a Contribution and validate each table """ passing = True for dtype in list(the_con.tables.keys()): print("validating {}".format(dtype)) fail = validate_table(the_con, dtype) if fail: passing = False print...
[ "def", "validate_contribution", "(", "the_con", ")", ":", "passing", "=", "True", "for", "dtype", "in", "list", "(", "the_con", ".", "tables", ".", "keys", "(", ")", ")", ":", "print", "(", "\"validating {}\"", ".", "format", "(", "dtype", ")", ")", "f...
Go through a Contribution and validate each table
[ "Go", "through", "a", "Contribution", "and", "validate", "each", "table" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L562-L572
PmagPy/PmagPy
pmagpy/validate_upload3.py
split_func
def split_func(string): """ Take a string like 'requiredIf("arg_name")' return the function name and the argument: (requiredIf, arg_name) """ ind = string.index("(") return string[:ind], string[ind+1:-1].strip('"')
python
def split_func(string): """ Take a string like 'requiredIf("arg_name")' return the function name and the argument: (requiredIf, arg_name) """ ind = string.index("(") return string[:ind], string[ind+1:-1].strip('"')
[ "def", "split_func", "(", "string", ")", ":", "ind", "=", "string", ".", "index", "(", "\"(\"", ")", "return", "string", "[", ":", "ind", "]", ",", "string", "[", "ind", "+", "1", ":", "-", "1", "]", ".", "strip", "(", "'\"'", ")" ]
Take a string like 'requiredIf("arg_name")' return the function name and the argument: (requiredIf, arg_name)
[ "Take", "a", "string", "like", "requiredIf", "(", "arg_name", ")", "return", "the", "function", "name", "and", "the", "argument", ":", "(", "requiredIf", "arg_name", ")" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L578-L585
PmagPy/PmagPy
pmagpy/validate_upload3.py
get_degree_cols
def get_degree_cols(df): """ Take in a pandas DataFrame, and return a list of columns that are in that DataFrame AND should be between 0 - 360 degrees. """ vals = ['lon_w', 'lon_e', 'lat_lon_precision', 'pole_lon', 'paleolon', 'paleolon_sigma', 'lon', 'lon_sigma', 'vgp_lon', ...
python
def get_degree_cols(df): """ Take in a pandas DataFrame, and return a list of columns that are in that DataFrame AND should be between 0 - 360 degrees. """ vals = ['lon_w', 'lon_e', 'lat_lon_precision', 'pole_lon', 'paleolon', 'paleolon_sigma', 'lon', 'lon_sigma', 'vgp_lon', ...
[ "def", "get_degree_cols", "(", "df", ")", ":", "vals", "=", "[", "'lon_w'", ",", "'lon_e'", ",", "'lat_lon_precision'", ",", "'pole_lon'", ",", "'paleolon'", ",", "'paleolon_sigma'", ",", "'lon'", ",", "'lon_sigma'", ",", "'vgp_lon'", ",", "'paleo_lon'", ",", ...
Take in a pandas DataFrame, and return a list of columns that are in that DataFrame AND should be between 0 - 360 degrees.
[ "Take", "in", "a", "pandas", "DataFrame", "and", "return", "a", "list", "of", "columns", "that", "are", "in", "that", "DataFrame", "AND", "should", "be", "between", "0", "-", "360", "degrees", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L588-L599
PmagPy/PmagPy
pmagpy/validate_upload3.py
extract_col_name
def extract_col_name(string): """ Take a string and split it. String will be a format like "presence_pass_azimuth", where "azimuth" is the MagIC column name and "presence_pass" is the validation. Return "presence", "azimuth". """ prefixes = ["presence_pass_", "value_pass_", "type_pass_"]...
python
def extract_col_name(string): """ Take a string and split it. String will be a format like "presence_pass_azimuth", where "azimuth" is the MagIC column name and "presence_pass" is the validation. Return "presence", "azimuth". """ prefixes = ["presence_pass_", "value_pass_", "type_pass_"]...
[ "def", "extract_col_name", "(", "string", ")", ":", "prefixes", "=", "[", "\"presence_pass_\"", ",", "\"value_pass_\"", ",", "\"type_pass_\"", "]", "end", "=", "string", ".", "rfind", "(", "\"_\"", ")", "for", "prefix", "in", "prefixes", ":", "if", "string",...
Take a string and split it. String will be a format like "presence_pass_azimuth", where "azimuth" is the MagIC column name and "presence_pass" is the validation. Return "presence", "azimuth".
[ "Take", "a", "string", "and", "split", "it", ".", "String", "will", "be", "a", "format", "like", "presence_pass_azimuth", "where", "azimuth", "is", "the", "MagIC", "column", "name", "and", "presence_pass", "is", "the", "validation", ".", "Return", "presence", ...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L602-L615
PmagPy/PmagPy
pmagpy/validate_upload3.py
make_row_dict
def make_row_dict(row): """ Takes in a DataFrame row (Series), and return a dictionary with the row's index as key, and the row's values as values. {col1_name: col1_value, col2_name: col2_value} """ ind = row[row.notnull()].index values = row[row.notnull()].values # to transformation...
python
def make_row_dict(row): """ Takes in a DataFrame row (Series), and return a dictionary with the row's index as key, and the row's values as values. {col1_name: col1_value, col2_name: col2_value} """ ind = row[row.notnull()].index values = row[row.notnull()].values # to transformation...
[ "def", "make_row_dict", "(", "row", ")", ":", "ind", "=", "row", "[", "row", ".", "notnull", "(", ")", "]", ".", "index", "values", "=", "row", "[", "row", ".", "notnull", "(", ")", "]", ".", "values", "# to transformation with extract_col_name here???", ...
Takes in a DataFrame row (Series), and return a dictionary with the row's index as key, and the row's values as values. {col1_name: col1_value, col2_name: col2_value}
[ "Takes", "in", "a", "DataFrame", "row", "(", "Series", ")", "and", "return", "a", "dictionary", "with", "the", "row", "s", "index", "as", "key", "and", "the", "row", "s", "values", "as", "values", ".", "{", "col1_name", ":", "col1_value", "col2_name", ...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/validate_upload3.py#L618-L628
PmagPy/PmagPy
programs/eq_di.py
main
def main(): """ NAME eq_di.py DESCRIPTION converts x,y pairs digitized from equal area projection to dec inc data SYNTAX eq_di.py [command line options] [< filename] OPTIONS -f FILE, input file -F FILE, specifies output file name -up if d...
python
def main(): """ NAME eq_di.py DESCRIPTION converts x,y pairs digitized from equal area projection to dec inc data SYNTAX eq_di.py [command line options] [< filename] OPTIONS -f FILE, input file -F FILE, specifies output file name -up if d...
[ "def", "main", "(", ")", ":", "out", "=", "\"\"", "UP", "=", "0", "if", "'-h'", "in", "sys", ".", "argv", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "if", "'-f'", "in", "sys", ".", "argv", ":", "dat", "=", ...
NAME eq_di.py DESCRIPTION converts x,y pairs digitized from equal area projection to dec inc data SYNTAX eq_di.py [command line options] [< filename] OPTIONS -f FILE, input file -F FILE, specifies output file name -up if data are upper hemisphere
[ "NAME", "eq_di", ".", "py", "DESCRIPTION", "converts", "x", "y", "pairs", "digitized", "from", "equal", "area", "projection", "to", "dec", "inc", "data", "SYNTAX", "eq_di", ".", "py", "[", "command", "line", "options", "]", "[", "<", "filename", "]", "OP...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/eq_di.py#L9-L69
PmagPy/PmagPy
programs/chartmaker.py
main
def main(): """ Welcome to the thellier-thellier experiment automatic chart maker. Please select desired step interval and upper bound for which it is valid. e.g., 50 500 10 600 a blank entry signals the end of data entry. which would generate steps with 50 degree in...
python
def main(): """ Welcome to the thellier-thellier experiment automatic chart maker. Please select desired step interval and upper bound for which it is valid. e.g., 50 500 10 600 a blank entry signals the end of data entry. which would generate steps with 50 degree in...
[ "def", "main", "(", ")", ":", "print", "(", "main", ".", "__doc__", ")", "if", "'-h'", "in", "sys", ".", "argv", ":", "sys", ".", "exit", "(", ")", "cont", ",", "Int", ",", "Top", "=", "1", ",", "[", "]", ",", "[", "]", "while", "cont", "==...
Welcome to the thellier-thellier experiment automatic chart maker. Please select desired step interval and upper bound for which it is valid. e.g., 50 500 10 600 a blank entry signals the end of data entry. which would generate steps with 50 degree intervals up to 500, follo...
[ "Welcome", "to", "the", "thellier", "-", "thellier", "experiment", "automatic", "chart", "maker", ".", "Please", "select", "desired", "step", "interval", "and", "upper", "bound", "for", "which", "it", "is", "valid", ".", "e", ".", "g", ".", "50", "500", ...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/chartmaker.py#L9-L33
PmagPy/PmagPy
programs/conversion_scripts/s_magic.py
main
def main(): """ NAME s_magic.py DESCRIPTION converts .s format data to measurements format. SYNTAX s_magic.py [command line options] OPTIONS -h prints help message and quits -DM DATA_MODEL_NUM data model number (default is 3) -f SFILE specifies the...
python
def main(): """ NAME s_magic.py DESCRIPTION converts .s format data to measurements format. SYNTAX s_magic.py [command line options] OPTIONS -h prints help message and quits -DM DATA_MODEL_NUM data model number (default is 3) -f SFILE specifies the...
[ "def", "main", "(", ")", ":", "if", "'-h'", "in", "sys", ".", "argv", ":", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "data_model_num", "=", "pmag", ".", "get_named_arg", "(", "\"-DM\"", ",", "3", ")", "data_model_num", ...
NAME s_magic.py DESCRIPTION converts .s format data to measurements format. SYNTAX s_magic.py [command line options] OPTIONS -h prints help message and quits -DM DATA_MODEL_NUM data model number (default is 3) -f SFILE specifies the .s file name -s...
[ "NAME", "s_magic", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/conversion_scripts/s_magic.py#L8-L92
PmagPy/PmagPy
programs/deprecated/basemap_magic.py
main
def main(): """ NAME basemap_magic.py NB: this program no longer maintained - use plot_map_pts.py for greater functionality DESCRIPTION makes a map of locations in er_sites.txt SYNTAX basemap_magic.py [command line options] OPTIONS -h prints help message ...
python
def main(): """ NAME basemap_magic.py NB: this program no longer maintained - use plot_map_pts.py for greater functionality DESCRIPTION makes a map of locations in er_sites.txt SYNTAX basemap_magic.py [command line options] OPTIONS -h prints help message ...
[ "def", "main", "(", ")", ":", "dir_path", "=", "'.'", "sites_file", "=", "'er_sites.txt'", "ocean", "=", "0", "res", "=", "'i'", "proj", "=", "'merc'", "prn_name", "=", "0", "prn_loc", "=", "0", "fancy", "=", "0", "rivers", ",", "boundaries", "=", "0...
NAME basemap_magic.py NB: this program no longer maintained - use plot_map_pts.py for greater functionality DESCRIPTION makes a map of locations in er_sites.txt SYNTAX basemap_magic.py [command line options] OPTIONS -h prints help message and quits -f SFI...
[ "NAME", "basemap_magic", ".", "py", "NB", ":", "this", "program", "no", "longer", "maintained", "-", "use", "plot_map_pts", ".", "py", "for", "greater", "functionality" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/deprecated/basemap_magic.py#L17-L169
PmagPy/PmagPy
programs/incfish.py
main
def main(): """ NAME incfish.py DESCRIPTION calculates fisher parameters from inc only data INPUT FORMAT takes inc data SYNTAX incfish.py [options] [< filename] OPTIONS -h prints help message and quits -i for interactive filename entry -f...
python
def main(): """ NAME incfish.py DESCRIPTION calculates fisher parameters from inc only data INPUT FORMAT takes inc data SYNTAX incfish.py [options] [< filename] OPTIONS -h prints help message and quits -i for interactive filename entry -f...
[ "def", "main", "(", ")", ":", "inc", "=", "[", "]", "if", "'-h'", "in", "sys", ".", "argv", ":", "# check if help is needed", "print", "(", "main", ".", "__doc__", ")", "sys", ".", "exit", "(", ")", "# graceful quit", "if", "'-i'", "in", "sys", ".", ...
NAME incfish.py DESCRIPTION calculates fisher parameters from inc only data INPUT FORMAT takes inc data SYNTAX incfish.py [options] [< filename] OPTIONS -h prints help message and quits -i for interactive filename entry -f FILE, specify input fil...
[ "NAME", "incfish", ".", "py" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/incfish.py#L8-L63
PmagPy/PmagPy
pmagpy/pmag.py
sort_diclist
def sort_diclist(undecorated, sort_on): """ Sort a list of dictionaries by the value in each dictionary for the sorting key Parameters ---------- undecorated : list of dicts sort_on : str, numeric key that is present in all dicts to sort on Returns --------- ordered lis...
python
def sort_diclist(undecorated, sort_on): """ Sort a list of dictionaries by the value in each dictionary for the sorting key Parameters ---------- undecorated : list of dicts sort_on : str, numeric key that is present in all dicts to sort on Returns --------- ordered lis...
[ "def", "sort_diclist", "(", "undecorated", ",", "sort_on", ")", ":", "decorated", "=", "[", "(", "len", "(", "dict_", "[", "sort_on", "]", ")", "if", "hasattr", "(", "dict_", "[", "sort_on", "]", ",", "'__len__'", ")", "else", "dict_", "[", "sort_on", ...
Sort a list of dictionaries by the value in each dictionary for the sorting key Parameters ---------- undecorated : list of dicts sort_on : str, numeric key that is present in all dicts to sort on Returns --------- ordered list of dicts Examples --------- >>> lst =...
[ "Sort", "a", "list", "of", "dictionaries", "by", "the", "value", "in", "each", "dictionary", "for", "the", "sorting", "key" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L32-L58
PmagPy/PmagPy
pmagpy/pmag.py
get_dictitem
def get_dictitem(In, k, v, flag, float_to_int=False): """ returns a list of dictionaries from list In with key,k = value, v . CASE INSENSITIVE # allowed keywords: requires that the value of k in the dictionaries contained in In be castable to string and requires that v be castable to a string if flag is T,...
python
def get_dictitem(In, k, v, flag, float_to_int=False): """ returns a list of dictionaries from list In with key,k = value, v . CASE INSENSITIVE # allowed keywords: requires that the value of k in the dictionaries contained in In be castable to string and requires that v be castable to a string if flag is T,...
[ "def", "get_dictitem", "(", "In", ",", "k", ",", "v", ",", "flag", ",", "float_to_int", "=", "False", ")", ":", "if", "float_to_int", ":", "try", ":", "v", "=", "str", "(", "math", ".", "trunc", "(", "float", "(", "v", ")", ")", ")", "except", ...
returns a list of dictionaries from list In with key,k = value, v . CASE INSENSITIVE # allowed keywords: requires that the value of k in the dictionaries contained in In be castable to string and requires that v be castable to a string if flag is T,F ,has or not and requires they be castable to float i...
[ "returns", "a", "list", "of", "dictionaries", "from", "list", "In", "with", "key", "k", "=", "value", "v", ".", "CASE", "INSENSITIVE", "#", "allowed", "keywords", ":", "requires", "that", "the", "value", "of", "k", "in", "the", "dictionaries", "contained",...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L61-L127
PmagPy/PmagPy
pmagpy/pmag.py
get_dictkey
def get_dictkey(In, k, dtype): """ returns list of given key (k) from input list of dictionaries (In) in data type dtype. uses command: get_dictkey(In,k,dtype). If dtype =="", data are strings; if "int", data are integers; if "f", data are floats. """ Out = [] for d in In: if...
python
def get_dictkey(In, k, dtype): """ returns list of given key (k) from input list of dictionaries (In) in data type dtype. uses command: get_dictkey(In,k,dtype). If dtype =="", data are strings; if "int", data are integers; if "f", data are floats. """ Out = [] for d in In: if...
[ "def", "get_dictkey", "(", "In", ",", "k", ",", "dtype", ")", ":", "Out", "=", "[", "]", "for", "d", "in", "In", ":", "if", "dtype", "==", "''", ":", "Out", ".", "append", "(", "d", "[", "k", "]", ")", "if", "dtype", "==", "'f'", ":", "if",...
returns list of given key (k) from input list of dictionaries (In) in data type dtype. uses command: get_dictkey(In,k,dtype). If dtype =="", data are strings; if "int", data are integers; if "f", data are floats.
[ "returns", "list", "of", "given", "key", "(", "k", ")", "from", "input", "list", "of", "dictionaries", "(", "In", ")", "in", "data", "type", "dtype", ".", "uses", "command", ":", "get_dictkey", "(", "In", "k", "dtype", ")", ".", "If", "dtype", "==", ...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L130-L154
PmagPy/PmagPy
pmagpy/pmag.py
get_orient
def get_orient(samp_data, er_sample_name, **kwargs): """ samp_data : PmagPy list of dicts or pandas DataFrame er_sample_name : sample name """ if isinstance(samp_data, pd.DataFrame): samp_data = (samp_data.T.apply(dict)) # set orientation priorities EX = ["SO-ASC", "SO-POM"] samp...
python
def get_orient(samp_data, er_sample_name, **kwargs): """ samp_data : PmagPy list of dicts or pandas DataFrame er_sample_name : sample name """ if isinstance(samp_data, pd.DataFrame): samp_data = (samp_data.T.apply(dict)) # set orientation priorities EX = ["SO-ASC", "SO-POM"] samp...
[ "def", "get_orient", "(", "samp_data", ",", "er_sample_name", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "samp_data", ",", "pd", ".", "DataFrame", ")", ":", "samp_data", "=", "(", "samp_data", ".", "T", ".", "apply", "(", "dict", ")", ...
samp_data : PmagPy list of dicts or pandas DataFrame er_sample_name : sample name
[ "samp_data", ":", "PmagPy", "list", "of", "dicts", "or", "pandas", "DataFrame", "er_sample_name", ":", "sample", "name" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L164-L214
PmagPy/PmagPy
pmagpy/pmag.py
EI
def EI(inc): """ Given a mean inclination value of a distribution of directions, this function calculates the expected elongation of this distribution using a best-fit polynomial of the TK03 GAD secular variation model (Tauxe and Kent, 2004). Parameters ---------- inc : inclination in d...
python
def EI(inc): """ Given a mean inclination value of a distribution of directions, this function calculates the expected elongation of this distribution using a best-fit polynomial of the TK03 GAD secular variation model (Tauxe and Kent, 2004). Parameters ---------- inc : inclination in d...
[ "def", "EI", "(", "inc", ")", ":", "poly_tk03", "=", "[", "3.15976125e-06", ",", "-", "3.52459817e-04", ",", "-", "1.46641090e-02", ",", "2.89538539e+00", "]", "return", "poly_tk03", "[", "0", "]", "*", "inc", "**", "3", "+", "poly_tk03", "[", "1", "]"...
Given a mean inclination value of a distribution of directions, this function calculates the expected elongation of this distribution using a best-fit polynomial of the TK03 GAD secular variation model (Tauxe and Kent, 2004). Parameters ---------- inc : inclination in degrees (int or float) ...
[ "Given", "a", "mean", "inclination", "value", "of", "a", "distribution", "of", "directions", "this", "function", "calculates", "the", "expected", "elongation", "of", "this", "distribution", "using", "a", "best", "-", "fit", "polynomial", "of", "the", "TK03", "...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L217-L241
PmagPy/PmagPy
pmagpy/pmag.py
find_f
def find_f(data): """ Given a distribution of directions, this function determines parameters (elongation, inclination, flattening factor, and elongation direction) that are consistent with the TK03 secular variation model. Parameters ---------- data : array of declination, inclination pair...
python
def find_f(data): """ Given a distribution of directions, this function determines parameters (elongation, inclination, flattening factor, and elongation direction) that are consistent with the TK03 secular variation model. Parameters ---------- data : array of declination, inclination pair...
[ "def", "find_f", "(", "data", ")", ":", "rad", "=", "np", ".", "pi", "/", "180.", "Es", ",", "Is", ",", "Fs", ",", "V2s", "=", "[", "]", ",", "[", "]", ",", "[", "]", ",", "[", "]", "ppars", "=", "doprinc", "(", "data", ")", "D", "=", "...
Given a distribution of directions, this function determines parameters (elongation, inclination, flattening factor, and elongation direction) that are consistent with the TK03 secular variation model. Parameters ---------- data : array of declination, inclination pairs (e.g. np.array([[140...
[ "Given", "a", "distribution", "of", "directions", "this", "function", "determines", "parameters", "(", "elongation", "inclination", "flattening", "factor", "and", "elongation", "direction", ")", "that", "are", "consistent", "with", "the", "TK03", "secular", "variati...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L244-L305
PmagPy/PmagPy
pmagpy/pmag.py
convert_lat
def convert_lat(Recs): """ uses lat, for age<5Ma, model_lat if present, else tries to use average_inc to estimate plat. """ New = [] for rec in Recs: if 'model_lat' in list(rec.keys()) and rec['model_lat'] != "": New.append(rec) elif 'average_age' in list(rec.keys()) and ...
python
def convert_lat(Recs): """ uses lat, for age<5Ma, model_lat if present, else tries to use average_inc to estimate plat. """ New = [] for rec in Recs: if 'model_lat' in list(rec.keys()) and rec['model_lat'] != "": New.append(rec) elif 'average_age' in list(rec.keys()) and ...
[ "def", "convert_lat", "(", "Recs", ")", ":", "New", "=", "[", "]", "for", "rec", "in", "Recs", ":", "if", "'model_lat'", "in", "list", "(", "rec", ".", "keys", "(", ")", ")", "and", "rec", "[", "'model_lat'", "]", "!=", "\"\"", ":", "New", ".", ...
uses lat, for age<5Ma, model_lat if present, else tries to use average_inc to estimate plat.
[ "uses", "lat", "for", "age<5Ma", "model_lat", "if", "present", "else", "tries", "to", "use", "average_inc", "to", "estimate", "plat", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L332-L347
PmagPy/PmagPy
pmagpy/pmag.py
convert_ages
def convert_ages(Recs, data_model=3): """ converts ages to Ma Parameters _________ Recs : list of dictionaries in data model by data_model data_model : MagIC data model (default is 3) """ if data_model == 3: site_key = 'site' agekey = "age" keybase = "" else: ...
python
def convert_ages(Recs, data_model=3): """ converts ages to Ma Parameters _________ Recs : list of dictionaries in data model by data_model data_model : MagIC data model (default is 3) """ if data_model == 3: site_key = 'site' agekey = "age" keybase = "" else: ...
[ "def", "convert_ages", "(", "Recs", ",", "data_model", "=", "3", ")", ":", "if", "data_model", "==", "3", ":", "site_key", "=", "'site'", "agekey", "=", "\"age\"", "keybase", "=", "\"\"", "else", ":", "site_key", "=", "'er_site_names'", "agekey", "=", "f...
converts ages to Ma Parameters _________ Recs : list of dictionaries in data model by data_model data_model : MagIC data model (default is 3)
[ "converts", "ages", "to", "Ma", "Parameters", "_________", "Recs", ":", "list", "of", "dictionaries", "in", "data", "model", "by", "data_model", "data_model", ":", "MagIC", "data", "model", "(", "default", "is", "3", ")" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L350-L399
PmagPy/PmagPy
pmagpy/pmag.py
convert_items
def convert_items(data, mapping): """ Input: list of dicts (each dict a record for one item), mapping with column names to swap into the records. Output: updated list of dicts. """ new_recs = [] for rec in data: new_rec = map_magic.mapping(rec, mapping) new_recs.append(new_re...
python
def convert_items(data, mapping): """ Input: list of dicts (each dict a record for one item), mapping with column names to swap into the records. Output: updated list of dicts. """ new_recs = [] for rec in data: new_rec = map_magic.mapping(rec, mapping) new_recs.append(new_re...
[ "def", "convert_items", "(", "data", ",", "mapping", ")", ":", "new_recs", "=", "[", "]", "for", "rec", "in", "data", ":", "new_rec", "=", "map_magic", ".", "mapping", "(", "rec", ",", "mapping", ")", "new_recs", ".", "append", "(", "new_rec", ")", "...
Input: list of dicts (each dict a record for one item), mapping with column names to swap into the records. Output: updated list of dicts.
[ "Input", ":", "list", "of", "dicts", "(", "each", "dict", "a", "record", "for", "one", "item", ")", "mapping", "with", "column", "names", "to", "swap", "into", "the", "records", ".", "Output", ":", "updated", "list", "of", "dicts", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L412-L422
PmagPy/PmagPy
pmagpy/pmag.py
convert_directory_2_to_3
def convert_directory_2_to_3(meas_fname="magic_measurements.txt", input_dir=".", output_dir=".", meas_only=False, data_model=None): """ Convert 2.0 measurements file into 3.0 measurements file. Merge and convert specimen, sample, site, and location data. Also translates crit...
python
def convert_directory_2_to_3(meas_fname="magic_measurements.txt", input_dir=".", output_dir=".", meas_only=False, data_model=None): """ Convert 2.0 measurements file into 3.0 measurements file. Merge and convert specimen, sample, site, and location data. Also translates crit...
[ "def", "convert_directory_2_to_3", "(", "meas_fname", "=", "\"magic_measurements.txt\"", ",", "input_dir", "=", "\".\"", ",", "output_dir", "=", "\".\"", ",", "meas_only", "=", "False", ",", "data_model", "=", "None", ")", ":", "convert", "=", "{", "'specimens'"...
Convert 2.0 measurements file into 3.0 measurements file. Merge and convert specimen, sample, site, and location data. Also translates criteria data. Parameters ---------- meas_name : name of measurement file (do not include full path, default is "magic_measurements.txt") input_dir : na...
[ "Convert", "2", ".", "0", "measurements", "file", "into", "3", ".", "0", "measurements", "file", ".", "Merge", "and", "convert", "specimen", "sample", "site", "and", "location", "data", ".", "Also", "translates", "criteria", "data", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L425-L499
PmagPy/PmagPy
pmagpy/pmag.py
convert_and_combine_2_to_3
def convert_and_combine_2_to_3(dtype, map_dict, input_dir=".", output_dir=".", data_model=None): """ Read in er_*.txt file and pmag_*.txt file in working directory. Combine the data, then translate headers from 2.5 --> 3.0. Last, write out the data in 3.0. Parameters ---------- dtype : stri...
python
def convert_and_combine_2_to_3(dtype, map_dict, input_dir=".", output_dir=".", data_model=None): """ Read in er_*.txt file and pmag_*.txt file in working directory. Combine the data, then translate headers from 2.5 --> 3.0. Last, write out the data in 3.0. Parameters ---------- dtype : stri...
[ "def", "convert_and_combine_2_to_3", "(", "dtype", ",", "map_dict", ",", "input_dir", "=", "\".\"", ",", "output_dir", "=", "\".\"", ",", "data_model", "=", "None", ")", ":", "# read in er_ data & make DataFrame", "er_file", "=", "os", ".", "path", ".", "join", ...
Read in er_*.txt file and pmag_*.txt file in working directory. Combine the data, then translate headers from 2.5 --> 3.0. Last, write out the data in 3.0. Parameters ---------- dtype : string for input type (specimens, samples, sites, etc.) map_dict : dictionary with format {header2_format: he...
[ "Read", "in", "er_", "*", ".", "txt", "file", "and", "pmag_", "*", ".", "txt", "file", "in", "working", "directory", ".", "Combine", "the", "data", "then", "translate", "headers", "from", "2", ".", "5", "--", ">", "3", ".", "0", ".", "Last", "write...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L502-L561
PmagPy/PmagPy
pmagpy/pmag.py
convert_criteria_file_2_to_3
def convert_criteria_file_2_to_3(fname="pmag_criteria.txt", input_dir=".", output_dir=".", data_model=None): """ Convert a criteria file from 2.5 to 3.0 format and write it out to file Parameters ---------- fname : string of filename (default "pmag_criteria.txt") ...
python
def convert_criteria_file_2_to_3(fname="pmag_criteria.txt", input_dir=".", output_dir=".", data_model=None): """ Convert a criteria file from 2.5 to 3.0 format and write it out to file Parameters ---------- fname : string of filename (default "pmag_criteria.txt") ...
[ "def", "convert_criteria_file_2_to_3", "(", "fname", "=", "\"pmag_criteria.txt\"", ",", "input_dir", "=", "\".\"", ",", "output_dir", "=", "\".\"", ",", "data_model", "=", "None", ")", ":", "# get criteria from infile", "fname", "=", "os", ".", "path", ".", "joi...
Convert a criteria file from 2.5 to 3.0 format and write it out to file Parameters ---------- fname : string of filename (default "pmag_criteria.txt") input_dir : string of input directory (default ".") output_dir : string of output directory (default ".") data_model : data_model.DataModel obje...
[ "Convert", "a", "criteria", "file", "from", "2", ".", "5", "to", "3", ".", "0", "format", "and", "write", "it", "out", "to", "file" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L564-L626
PmagPy/PmagPy
pmagpy/pmag.py
orient
def orient(mag_azimuth, field_dip, or_con): """ uses specified orientation convention to convert user supplied orientations to laboratory azimuth and plunge """ or_con = str(or_con) if mag_azimuth == -999: return "", "" if or_con == "1": # lab_mag_az=mag_az; sample_dip = -dip ...
python
def orient(mag_azimuth, field_dip, or_con): """ uses specified orientation convention to convert user supplied orientations to laboratory azimuth and plunge """ or_con = str(or_con) if mag_azimuth == -999: return "", "" if or_con == "1": # lab_mag_az=mag_az; sample_dip = -dip ...
[ "def", "orient", "(", "mag_azimuth", ",", "field_dip", ",", "or_con", ")", ":", "or_con", "=", "str", "(", "or_con", ")", "if", "mag_azimuth", "==", "-", "999", ":", "return", "\"\"", ",", "\"\"", "if", "or_con", "==", "\"1\"", ":", "# lab_mag_az=mag_az;...
uses specified orientation convention to convert user supplied orientations to laboratory azimuth and plunge
[ "uses", "specified", "orientation", "convention", "to", "convert", "user", "supplied", "orientations", "to", "laboratory", "azimuth", "and", "plunge" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L918-L940
PmagPy/PmagPy
pmagpy/pmag.py
get_Sb
def get_Sb(data): """ returns vgp scatter for data set """ Sb, N = 0., 0. for rec in data: delta = 90. - abs(rec['vgp_lat']) if rec['average_k'] != 0: k = rec['average_k'] L = rec['average_lat'] * np.pi / 180. # latitude in radians Nsi = rec['aver...
python
def get_Sb(data): """ returns vgp scatter for data set """ Sb, N = 0., 0. for rec in data: delta = 90. - abs(rec['vgp_lat']) if rec['average_k'] != 0: k = rec['average_k'] L = rec['average_lat'] * np.pi / 180. # latitude in radians Nsi = rec['aver...
[ "def", "get_Sb", "(", "data", ")", ":", "Sb", ",", "N", "=", "0.", ",", "0.", "for", "rec", "in", "data", ":", "delta", "=", "90.", "-", "abs", "(", "rec", "[", "'vgp_lat'", "]", ")", "if", "rec", "[", "'average_k'", "]", "!=", "0", ":", "k",...
returns vgp scatter for data set
[ "returns", "vgp", "scatter", "for", "data", "set" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L943-L961
PmagPy/PmagPy
pmagpy/pmag.py
get_sb_df
def get_sb_df(df, mm97=False): """ Calculates Sf for a dataframe with VGP Lat., and optional Fisher's k, site latitude and N information can be used to correct for within site scatter (McElhinny & McFadden, 1997) Parameters _________ df : Pandas Dataframe with columns REQUIRED: vgp_...
python
def get_sb_df(df, mm97=False): """ Calculates Sf for a dataframe with VGP Lat., and optional Fisher's k, site latitude and N information can be used to correct for within site scatter (McElhinny & McFadden, 1997) Parameters _________ df : Pandas Dataframe with columns REQUIRED: vgp_...
[ "def", "get_sb_df", "(", "df", ",", "mm97", "=", "False", ")", ":", "df", "[", "'delta'", "]", "=", "90.", "-", "df", ".", "vgp_lat", "Sp2", "=", "np", ".", "sum", "(", "df", ".", "delta", "**", "2", ")", "/", "(", "df", ".", "shape", "[", ...
Calculates Sf for a dataframe with VGP Lat., and optional Fisher's k, site latitude and N information can be used to correct for within site scatter (McElhinny & McFadden, 1997) Parameters _________ df : Pandas Dataframe with columns REQUIRED: vgp_lat : VGP latitude ONLY REQUIRED f...
[ "Calculates", "Sf", "for", "a", "dataframe", "with", "VGP", "Lat", ".", "and", "optional", "Fisher", "s", "k", "site", "latitude", "and", "N", "information", "can", "be", "used", "to", "correct", "for", "within", "site", "scatter", "(", "McElhinny", "&", ...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L964-L994
PmagPy/PmagPy
pmagpy/pmag.py
grade
def grade(PmagRec, ACCEPT, type, data_model=2.5): """ Finds the 'grade' (pass/fail; A/F) of a record (specimen,sample,site) given the acceptance criteria """ GREATERTHAN = ['specimen_q', 'site_k', 'site_n', 'site_n_lines', 'site_int_n', 'measurement_step_min', 'specimen_int_ptrm_n', 'specimen_fvds', 'sp...
python
def grade(PmagRec, ACCEPT, type, data_model=2.5): """ Finds the 'grade' (pass/fail; A/F) of a record (specimen,sample,site) given the acceptance criteria """ GREATERTHAN = ['specimen_q', 'site_k', 'site_n', 'site_n_lines', 'site_int_n', 'measurement_step_min', 'specimen_int_ptrm_n', 'specimen_fvds', 'sp...
[ "def", "grade", "(", "PmagRec", ",", "ACCEPT", ",", "type", ",", "data_model", "=", "2.5", ")", ":", "GREATERTHAN", "=", "[", "'specimen_q'", ",", "'site_k'", ",", "'site_n'", ",", "'site_n_lines'", ",", "'site_int_n'", ",", "'measurement_step_min'", ",", "'...
Finds the 'grade' (pass/fail; A/F) of a record (specimen,sample,site) given the acceptance criteria
[ "Finds", "the", "grade", "(", "pass", "/", "fail", ";", "A", "/", "F", ")", "of", "a", "record", "(", "specimen", "sample", "site", ")", "given", "the", "acceptance", "criteria" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1031-L1110
PmagPy/PmagPy
pmagpy/pmag.py
flip
def flip(di_block, combine=False): """ determines 'normal' direction along the principle eigenvector, then flips the antipodes of the reverse mode to the antipode Parameters ___________ di_block : nested list of directions Return D1 : normal mode D2 : flipped reverse mode as two DI ...
python
def flip(di_block, combine=False): """ determines 'normal' direction along the principle eigenvector, then flips the antipodes of the reverse mode to the antipode Parameters ___________ di_block : nested list of directions Return D1 : normal mode D2 : flipped reverse mode as two DI ...
[ "def", "flip", "(", "di_block", ",", "combine", "=", "False", ")", ":", "ppars", "=", "doprinc", "(", "di_block", ")", "# get principle direction", "if", "combine", ":", "D3", "=", "[", "]", "D1", ",", "D2", "=", "[", "]", ",", "[", "]", "for", "re...
determines 'normal' direction along the principle eigenvector, then flips the antipodes of the reverse mode to the antipode Parameters ___________ di_block : nested list of directions Return D1 : normal mode D2 : flipped reverse mode as two DI blocks combine : if True return combined D1...
[ "determines", "normal", "direction", "along", "the", "principle", "eigenvector", "then", "flips", "the", "antipodes", "of", "the", "reverse", "mode", "to", "the", "antipode" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1115-L1146
PmagPy/PmagPy
pmagpy/pmag.py
dia_vgp
def dia_vgp(*args): # new function interface by J.Holmes, SIO, 6/1/2011 """ Converts directional data (declination, inclination, alpha95) at a given location (Site latitude, Site longitude) to pole position (pole longitude, pole latitude, dp, dm) Parameters ---------- Takes input as (Dec, ...
python
def dia_vgp(*args): # new function interface by J.Holmes, SIO, 6/1/2011 """ Converts directional data (declination, inclination, alpha95) at a given location (Site latitude, Site longitude) to pole position (pole longitude, pole latitude, dp, dm) Parameters ---------- Takes input as (Dec, ...
[ "def", "dia_vgp", "(", "*", "args", ")", ":", "# new function interface by J.Holmes, SIO, 6/1/2011", "# test whether arguments are one 2-D list or 5 floats", "if", "len", "(", "args", ")", "==", "1", ":", "# args comes in as a tuple of multi-dim lists.", "largs", "=", "list",...
Converts directional data (declination, inclination, alpha95) at a given location (Site latitude, Site longitude) to pole position (pole longitude, pole latitude, dp, dm) Parameters ---------- Takes input as (Dec, Inc, a95, Site latitude, Site longitude) Input can be as individual values (5 par...
[ "Converts", "directional", "data", "(", "declination", "inclination", "alpha95", ")", "at", "a", "given", "location", "(", "Site", "latitude", "Site", "longitude", ")", "to", "pole", "position", "(", "pole", "longitude", "pole", "latitude", "dp", "dm", ")" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1150-L1245
PmagPy/PmagPy
pmagpy/pmag.py
int_pars
def int_pars(x, y, vds, **kwargs): """ calculates York regression and Coe parameters (with Tauxe Fvds) """ # first do linear regression a la York # do Data Model 3 way: if 'version' in list(kwargs.keys()) and kwargs['version'] == 3: n_key = 'int_n_measurements' b_key = 'int_b' ...
python
def int_pars(x, y, vds, **kwargs): """ calculates York regression and Coe parameters (with Tauxe Fvds) """ # first do linear regression a la York # do Data Model 3 way: if 'version' in list(kwargs.keys()) and kwargs['version'] == 3: n_key = 'int_n_measurements' b_key = 'int_b' ...
[ "def", "int_pars", "(", "x", ",", "y", ",", "vds", ",", "*", "*", "kwargs", ")", ":", "# first do linear regression a la York", "# do Data Model 3 way:", "if", "'version'", "in", "list", "(", "kwargs", ".", "keys", "(", ")", ")", "and", "kwargs", "[", "'ve...
calculates York regression and Coe parameters (with Tauxe Fvds)
[ "calculates", "York", "regression", "and", "Coe", "parameters", "(", "with", "Tauxe", "Fvds", ")" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1248-L1324
PmagPy/PmagPy
pmagpy/pmag.py
dovds
def dovds(data): """ calculates vector difference sum for demagnetization data """ vds, X = 0, [] for rec in data: X.append(dir2cart(rec)) for k in range(len(X) - 1): xdif = X[k + 1][0] - X[k][0] ydif = X[k + 1][1] - X[k][1] zdif = X[k + 1][2] - X[k][2] v...
python
def dovds(data): """ calculates vector difference sum for demagnetization data """ vds, X = 0, [] for rec in data: X.append(dir2cart(rec)) for k in range(len(X) - 1): xdif = X[k + 1][0] - X[k][0] ydif = X[k + 1][1] - X[k][1] zdif = X[k + 1][2] - X[k][2] v...
[ "def", "dovds", "(", "data", ")", ":", "vds", ",", "X", "=", "0", ",", "[", "]", "for", "rec", "in", "data", ":", "X", ".", "append", "(", "dir2cart", "(", "rec", ")", ")", "for", "k", "in", "range", "(", "len", "(", "X", ")", "-", "1", "...
calculates vector difference sum for demagnetization data
[ "calculates", "vector", "difference", "sum", "for", "demagnetization", "data" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1327-L1340
PmagPy/PmagPy
pmagpy/pmag.py
vspec_magic
def vspec_magic(data): """ Takes average vector of replicate measurements """ vdata, Dirdata, step_meth = [], [], "" if len(data) == 0: return vdata treat_init = ["treatment_temp", "treatment_temp_decay_rate", "treatment_temp_dc_on", "treatment_temp_dc_off", "treatment_ac_field", "treatm...
python
def vspec_magic(data): """ Takes average vector of replicate measurements """ vdata, Dirdata, step_meth = [], [], "" if len(data) == 0: return vdata treat_init = ["treatment_temp", "treatment_temp_decay_rate", "treatment_temp_dc_on", "treatment_temp_dc_off", "treatment_ac_field", "treatm...
[ "def", "vspec_magic", "(", "data", ")", ":", "vdata", ",", "Dirdata", ",", "step_meth", "=", "[", "]", ",", "[", "]", ",", "\"\"", "if", "len", "(", "data", ")", "==", "0", ":", "return", "vdata", "treat_init", "=", "[", "\"treatment_temp\"", ",", ...
Takes average vector of replicate measurements
[ "Takes", "average", "vector", "of", "replicate", "measurements" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1343-L1416
PmagPy/PmagPy
pmagpy/pmag.py
get_specs
def get_specs(data): """ Takes a magic format file and returns a list of unique specimen names """ # sort the specimen names speclist = [] for rec in data: try: spec = rec["er_specimen_name"] except KeyError as e: spec = rec["specimen"] if spec not...
python
def get_specs(data): """ Takes a magic format file and returns a list of unique specimen names """ # sort the specimen names speclist = [] for rec in data: try: spec = rec["er_specimen_name"] except KeyError as e: spec = rec["specimen"] if spec not...
[ "def", "get_specs", "(", "data", ")", ":", "# sort the specimen names", "speclist", "=", "[", "]", "for", "rec", "in", "data", ":", "try", ":", "spec", "=", "rec", "[", "\"er_specimen_name\"", "]", "except", "KeyError", "as", "e", ":", "spec", "=", "rec"...
Takes a magic format file and returns a list of unique specimen names
[ "Takes", "a", "magic", "format", "file", "and", "returns", "a", "list", "of", "unique", "specimen", "names" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1496-L1510
PmagPy/PmagPy
pmagpy/pmag.py
vector_mean
def vector_mean(data): """ calculates the vector mean of a given set of vectors Parameters __________ data : nested array of [dec,inc,intensity] Returns _______ dir : array of [dec, inc, 1] R : resultant vector length """ Xbar = np.zeros((3)) X = dir2cart(data).transpo...
python
def vector_mean(data): """ calculates the vector mean of a given set of vectors Parameters __________ data : nested array of [dec,inc,intensity] Returns _______ dir : array of [dec, inc, 1] R : resultant vector length """ Xbar = np.zeros((3)) X = dir2cart(data).transpo...
[ "def", "vector_mean", "(", "data", ")", ":", "Xbar", "=", "np", ".", "zeros", "(", "(", "3", ")", ")", "X", "=", "dir2cart", "(", "data", ")", ".", "transpose", "(", ")", "for", "i", "in", "range", "(", "3", ")", ":", "Xbar", "[", "i", "]", ...
calculates the vector mean of a given set of vectors Parameters __________ data : nested array of [dec,inc,intensity] Returns _______ dir : array of [dec, inc, 1] R : resultant vector length
[ "calculates", "the", "vector", "mean", "of", "a", "given", "set", "of", "vectors", "Parameters", "__________", "data", ":", "nested", "array", "of", "[", "dec", "inc", "intensity", "]" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1513-L1533
PmagPy/PmagPy
pmagpy/pmag.py
mark_dmag_rec
def mark_dmag_rec(s, ind, data): """ Edits demagnetization data to mark "bad" points with measurement_flag """ datablock = [] for rec in data: if rec['er_specimen_name'] == s: meths = rec['magic_method_codes'].split(':') if 'LT-NO' in meths or 'LT-AF-Z' in meths or 'L...
python
def mark_dmag_rec(s, ind, data): """ Edits demagnetization data to mark "bad" points with measurement_flag """ datablock = [] for rec in data: if rec['er_specimen_name'] == s: meths = rec['magic_method_codes'].split(':') if 'LT-NO' in meths or 'LT-AF-Z' in meths or 'L...
[ "def", "mark_dmag_rec", "(", "s", ",", "ind", ",", "data", ")", ":", "datablock", "=", "[", "]", "for", "rec", "in", "data", ":", "if", "rec", "[", "'er_specimen_name'", "]", "==", "s", ":", "meths", "=", "rec", "[", "'magic_method_codes'", "]", ".",...
Edits demagnetization data to mark "bad" points with measurement_flag
[ "Edits", "demagnetization", "data", "to", "mark", "bad", "points", "with", "measurement_flag" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1536-L1559
PmagPy/PmagPy
pmagpy/pmag.py
find_dmag_rec
def find_dmag_rec(s, data, **kwargs): """ Returns demagnetization data for specimen s from the data. Excludes other kinds of experiments and "bad" measurements Parameters __________ s : specimen name data : DataFrame with measurement data **kwargs : version : if not 3, assume da...
python
def find_dmag_rec(s, data, **kwargs): """ Returns demagnetization data for specimen s from the data. Excludes other kinds of experiments and "bad" measurements Parameters __________ s : specimen name data : DataFrame with measurement data **kwargs : version : if not 3, assume da...
[ "def", "find_dmag_rec", "(", "s", ",", "data", ",", "*", "*", "kwargs", ")", ":", "if", "'version'", "in", "list", "(", "kwargs", ".", "keys", "(", ")", ")", "and", "kwargs", "[", "'version'", "]", "==", "3", ":", "# convert dataframe to list of dictiona...
Returns demagnetization data for specimen s from the data. Excludes other kinds of experiments and "bad" measurements Parameters __________ s : specimen name data : DataFrame with measurement data **kwargs : version : if not 3, assume data model = 2.5 Returns ________ databl...
[ "Returns", "demagnetization", "data", "for", "specimen", "s", "from", "the", "data", ".", "Excludes", "other", "kinds", "of", "experiments", "and", "bad", "measurements" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1567-L1686
PmagPy/PmagPy
pmagpy/pmag.py
open_file
def open_file(infile, verbose=True): """ Open file and return a list of the file's lines. Try to use utf-8 encoding, and if that fails use Latin-1. Parameters ---------- infile : str full path to file Returns ---------- data: list all lines in the file """ t...
python
def open_file(infile, verbose=True): """ Open file and return a list of the file's lines. Try to use utf-8 encoding, and if that fails use Latin-1. Parameters ---------- infile : str full path to file Returns ---------- data: list all lines in the file """ t...
[ "def", "open_file", "(", "infile", ",", "verbose", "=", "True", ")", ":", "try", ":", "with", "codecs", ".", "open", "(", "infile", ",", "\"r\"", ",", "\"utf-8\"", ")", "as", "f", ":", "lines", "=", "list", "(", "f", ".", "readlines", "(", ")", "...
Open file and return a list of the file's lines. Try to use utf-8 encoding, and if that fails use Latin-1. Parameters ---------- infile : str full path to file Returns ---------- data: list all lines in the file
[ "Open", "file", "and", "return", "a", "list", "of", "the", "file", "s", "lines", ".", "Try", "to", "use", "utf", "-", "8", "encoding", "and", "if", "that", "fails", "use", "Latin", "-", "1", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1689-L1735
PmagPy/PmagPy
pmagpy/pmag.py
magic_read
def magic_read(infile, data=None, return_keys=False, verbose=False): """ Reads a Magic template file, returns data in a list of dictionaries. Parameters ___________ Required: infile : the MagIC formatted tab delimited data file first line contains 'tab' in the firs...
python
def magic_read(infile, data=None, return_keys=False, verbose=False): """ Reads a Magic template file, returns data in a list of dictionaries. Parameters ___________ Required: infile : the MagIC formatted tab delimited data file first line contains 'tab' in the firs...
[ "def", "magic_read", "(", "infile", ",", "data", "=", "None", ",", "return_keys", "=", "False", ",", "verbose", "=", "False", ")", ":", "if", "infile", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "infile", ")", ":", "if", "return_keys", ...
Reads a Magic template file, returns data in a list of dictionaries. Parameters ___________ Required: infile : the MagIC formatted tab delimited data file first line contains 'tab' in the first column and the data file type in the second (e.g., measurements, specimen, samp...
[ "Reads", "a", "Magic", "template", "file", "returns", "data", "in", "a", "list", "of", "dictionaries", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1738-L1853
PmagPy/PmagPy
pmagpy/pmag.py
magic_read_dict
def magic_read_dict(path, data=None, sort_by_this_name=None, return_keys=False): """ Read a magic-formatted tab-delimited file and return a dictionary of dictionaries, with this format: {'Z35.5a': {'specimen_weight': '1.000e-03', 'er_citation_names': 'This study', 'specimen_volume': '', 'er_location_nam...
python
def magic_read_dict(path, data=None, sort_by_this_name=None, return_keys=False): """ Read a magic-formatted tab-delimited file and return a dictionary of dictionaries, with this format: {'Z35.5a': {'specimen_weight': '1.000e-03', 'er_citation_names': 'This study', 'specimen_volume': '', 'er_location_nam...
[ "def", "magic_read_dict", "(", "path", ",", "data", "=", "None", ",", "sort_by_this_name", "=", "None", ",", "return_keys", "=", "False", ")", ":", "DATA", "=", "{", "}", "#fin = open(path, 'r')", "#first_line = fin.readline()", "lines", "=", "open_file", "(", ...
Read a magic-formatted tab-delimited file and return a dictionary of dictionaries, with this format: {'Z35.5a': {'specimen_weight': '1.000e-03', 'er_citation_names': 'This study', 'specimen_volume': '', 'er_location_name': '', 'er_site_name': 'Z35.', 'er_sample_name': 'Z35.5', 'specimen_class': '', 'er_specimen...
[ "Read", "a", "magic", "-", "formatted", "tab", "-", "delimited", "file", "and", "return", "a", "dictionary", "of", "dictionaries", "with", "this", "format", ":", "{", "Z35", ".", "5a", ":", "{", "specimen_weight", ":", "1", ".", "000e", "-", "03", "er_...
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1856-L1914
PmagPy/PmagPy
pmagpy/pmag.py
sort_magic_data
def sort_magic_data(magic_data, sort_name): ''' Sort magic_data by header (like er_specimen_name for example) ''' magic_data_sorted = {} for rec in magic_data: name = rec[sort_name] if name not in list(magic_data_sorted.keys()): magic_data_sorted[name] = [] magic_...
python
def sort_magic_data(magic_data, sort_name): ''' Sort magic_data by header (like er_specimen_name for example) ''' magic_data_sorted = {} for rec in magic_data: name = rec[sort_name] if name not in list(magic_data_sorted.keys()): magic_data_sorted[name] = [] magic_...
[ "def", "sort_magic_data", "(", "magic_data", ",", "sort_name", ")", ":", "magic_data_sorted", "=", "{", "}", "for", "rec", "in", "magic_data", ":", "name", "=", "rec", "[", "sort_name", "]", "if", "name", "not", "in", "list", "(", "magic_data_sorted", ".",...
Sort magic_data by header (like er_specimen_name for example)
[ "Sort", "magic_data", "by", "header", "(", "like", "er_specimen_name", "for", "example", ")" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1917-L1927
PmagPy/PmagPy
pmagpy/pmag.py
upload_read
def upload_read(infile, table): """ Reads a table from a MagIC upload (or downloaded) txt file, puts data in a list of dictionaries """ delim = 'tab' hold, magic_data, magic_record, magic_keys = [], [], {}, [] f = open(infile, "r") # # look for right table # line = f.readline()[:-1] ...
python
def upload_read(infile, table): """ Reads a table from a MagIC upload (or downloaded) txt file, puts data in a list of dictionaries """ delim = 'tab' hold, magic_data, magic_record, magic_keys = [], [], {}, [] f = open(infile, "r") # # look for right table # line = f.readline()[:-1] ...
[ "def", "upload_read", "(", "infile", ",", "table", ")", ":", "delim", "=", "'tab'", "hold", ",", "magic_data", ",", "magic_record", ",", "magic_keys", "=", "[", "]", ",", "[", "]", ",", "{", "}", ",", "[", "]", "f", "=", "open", "(", "infile", ",...
Reads a table from a MagIC upload (or downloaded) txt file, puts data in a list of dictionaries
[ "Reads", "a", "table", "from", "a", "MagIC", "upload", "(", "or", "downloaded", ")", "txt", "file", "puts", "data", "in", "a", "list", "of", "dictionaries" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1930-L1974
PmagPy/PmagPy
pmagpy/pmag.py
putout
def putout(ofile, keylist, Rec): """ writes out a magic format record to ofile """ pmag_out = open(ofile, 'a') outstring = "" for key in keylist: try: outstring = outstring + '\t' + str(Rec[key]).strip() except: print(key, Rec[key]) # raw_input...
python
def putout(ofile, keylist, Rec): """ writes out a magic format record to ofile """ pmag_out = open(ofile, 'a') outstring = "" for key in keylist: try: outstring = outstring + '\t' + str(Rec[key]).strip() except: print(key, Rec[key]) # raw_input...
[ "def", "putout", "(", "ofile", ",", "keylist", ",", "Rec", ")", ":", "pmag_out", "=", "open", "(", "ofile", ",", "'a'", ")", "outstring", "=", "\"\"", "for", "key", "in", "keylist", ":", "try", ":", "outstring", "=", "outstring", "+", "'\\t'", "+", ...
writes out a magic format record to ofile
[ "writes", "out", "a", "magic", "format", "record", "to", "ofile" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1977-L1991
PmagPy/PmagPy
pmagpy/pmag.py
first_rec
def first_rec(ofile, Rec, file_type): """ opens the file ofile as a magic template file with headers as the keys to Rec """ keylist = [] opened = False # sometimes Windows needs a little extra time to open a file # or else it throws an error while not opened: try: pma...
python
def first_rec(ofile, Rec, file_type): """ opens the file ofile as a magic template file with headers as the keys to Rec """ keylist = [] opened = False # sometimes Windows needs a little extra time to open a file # or else it throws an error while not opened: try: pma...
[ "def", "first_rec", "(", "ofile", ",", "Rec", ",", "file_type", ")", ":", "keylist", "=", "[", "]", "opened", "=", "False", "# sometimes Windows needs a little extra time to open a file", "# or else it throws an error", "while", "not", "opened", ":", "try", ":", "pm...
opens the file ofile as a magic template file with headers as the keys to Rec
[ "opens", "the", "file", "ofile", "as", "a", "magic", "template", "file", "with", "headers", "as", "the", "keys", "to", "Rec" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L1994-L2017
PmagPy/PmagPy
pmagpy/pmag.py
magic_write_old
def magic_write_old(ofile, Recs, file_type): """ writes out a magic format list of dictionaries to ofile Parameters _________ ofile : path to output file Recs : list of dictionaries in MagIC format file_type : MagIC table type (e.g., specimens) Effects : writes a MagIC formatte...
python
def magic_write_old(ofile, Recs, file_type): """ writes out a magic format list of dictionaries to ofile Parameters _________ ofile : path to output file Recs : list of dictionaries in MagIC format file_type : MagIC table type (e.g., specimens) Effects : writes a MagIC formatte...
[ "def", "magic_write_old", "(", "ofile", ",", "Recs", ",", "file_type", ")", ":", "if", "len", "(", "Recs", ")", "<", "1", ":", "print", "(", "'nothing to write'", ")", "return", "pmag_out", "=", "open", "(", "ofile", ",", "'w'", ")", "outstring", "=", ...
writes out a magic format list of dictionaries to ofile Parameters _________ ofile : path to output file Recs : list of dictionaries in MagIC format file_type : MagIC table type (e.g., specimens) Effects : writes a MagIC formatted file from Recs
[ "writes", "out", "a", "magic", "format", "list", "of", "dictionaries", "to", "ofile" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2020-L2062
PmagPy/PmagPy
pmagpy/pmag.py
magic_write
def magic_write(ofile, Recs, file_type): """ Parameters _________ ofile : path to output file Recs : list of dictionaries in MagIC format file_type : MagIC table type (e.g., specimens) Return : [True,False] : True if successful ofile : same as input Effects : writes a M...
python
def magic_write(ofile, Recs, file_type): """ Parameters _________ ofile : path to output file Recs : list of dictionaries in MagIC format file_type : MagIC table type (e.g., specimens) Return : [True,False] : True if successful ofile : same as input Effects : writes a M...
[ "def", "magic_write", "(", "ofile", ",", "Recs", ",", "file_type", ")", ":", "if", "len", "(", "Recs", ")", "<", "1", ":", "print", "(", "'No records to write to file {}'", ".", "format", "(", "ofile", ")", ")", "return", "False", ",", "\"\"", "if", "o...
Parameters _________ ofile : path to output file Recs : list of dictionaries in MagIC format file_type : MagIC table type (e.g., specimens) Return : [True,False] : True if successful ofile : same as input Effects : writes a MagIC formatted file from Recs
[ "Parameters", "_________", "ofile", ":", "path", "to", "output", "file", "Recs", ":", "list", "of", "dictionaries", "in", "MagIC", "format", "file_type", ":", "MagIC", "table", "type", "(", "e", ".", "g", ".", "specimens", ")" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2065-L2120
PmagPy/PmagPy
pmagpy/pmag.py
dotilt
def dotilt(dec, inc, bed_az, bed_dip): """ Does a tilt correction on a direction (dec,inc) using bedding dip direction and bedding dip. Parameters ---------- dec : declination directions in degrees inc : inclination direction in degrees bed_az : bedding dip direction bed_dip : beddi...
python
def dotilt(dec, inc, bed_az, bed_dip): """ Does a tilt correction on a direction (dec,inc) using bedding dip direction and bedding dip. Parameters ---------- dec : declination directions in degrees inc : inclination direction in degrees bed_az : bedding dip direction bed_dip : beddi...
[ "def", "dotilt", "(", "dec", ",", "inc", ",", "bed_az", ",", "bed_dip", ")", ":", "rad", "=", "old_div", "(", "np", ".", "pi", ",", "180.", ")", "# converts from degrees to radians", "X", "=", "dir2cart", "(", "[", "dec", ",", "inc", ",", "1.", "]", ...
Does a tilt correction on a direction (dec,inc) using bedding dip direction and bedding dip. Parameters ---------- dec : declination directions in degrees inc : inclination direction in degrees bed_az : bedding dip direction bed_dip : bedding dip Returns ------- dec,inc : a tup...
[ "Does", "a", "tilt", "correction", "on", "a", "direction", "(", "dec", "inc", ")", "using", "bedding", "dip", "direction", "and", "bedding", "dip", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2123-L2158
PmagPy/PmagPy
pmagpy/pmag.py
dotilt_V
def dotilt_V(indat): """ Does a tilt correction on an array with rows of dec,inc bedding dip direction and dip. Parameters ---------- input : declination, inclination, bedding dip direction and bedding dip nested array of [[dec1, inc1, bed_az1, bed_dip1],[dec2,inc2,bed_az2,bed_dip2]...] Re...
python
def dotilt_V(indat): """ Does a tilt correction on an array with rows of dec,inc bedding dip direction and dip. Parameters ---------- input : declination, inclination, bedding dip direction and bedding dip nested array of [[dec1, inc1, bed_az1, bed_dip1],[dec2,inc2,bed_az2,bed_dip2]...] Re...
[ "def", "dotilt_V", "(", "indat", ")", ":", "indat", "=", "indat", ".", "transpose", "(", ")", "# unpack input array into separate arrays", "dec", ",", "inc", ",", "bed_az", ",", "bed_dip", "=", "indat", "[", "0", "]", ",", "indat", "[", "1", "]", ",", ...
Does a tilt correction on an array with rows of dec,inc bedding dip direction and dip. Parameters ---------- input : declination, inclination, bedding dip direction and bedding dip nested array of [[dec1, inc1, bed_az1, bed_dip1],[dec2,inc2,bed_az2,bed_dip2]...] Returns ------- dec,inc : a...
[ "Does", "a", "tilt", "correction", "on", "an", "array", "with", "rows", "of", "dec", "inc", "bedding", "dip", "direction", "and", "dip", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2161-L2195
PmagPy/PmagPy
pmagpy/pmag.py
dogeo
def dogeo(dec, inc, az, pl): """ Rotates declination and inclination into geographic coordinates using the azimuth and plunge of the X direction (lab arrow) of a specimen. Parameters ---------- dec : declination in specimen coordinates inc : inclination in specimen coordinates Returns ...
python
def dogeo(dec, inc, az, pl): """ Rotates declination and inclination into geographic coordinates using the azimuth and plunge of the X direction (lab arrow) of a specimen. Parameters ---------- dec : declination in specimen coordinates inc : inclination in specimen coordinates Returns ...
[ "def", "dogeo", "(", "dec", ",", "inc", ",", "az", ",", "pl", ")", ":", "A1", ",", "A2", ",", "A3", "=", "[", "]", ",", "[", "]", ",", "[", "]", "# set up lists for rotation vector", "# put dec inc in direction list and set length to unity", "Dir", "=", "...
Rotates declination and inclination into geographic coordinates using the azimuth and plunge of the X direction (lab arrow) of a specimen. Parameters ---------- dec : declination in specimen coordinates inc : inclination in specimen coordinates Returns ------- rotated_direction : tuple...
[ "Rotates", "declination", "and", "inclination", "into", "geographic", "coordinates", "using", "the", "azimuth", "and", "plunge", "of", "the", "X", "direction", "(", "lab", "arrow", ")", "of", "a", "specimen", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2198-L2237
PmagPy/PmagPy
pmagpy/pmag.py
dogeo_V
def dogeo_V(indat): """ Rotates declination and inclination into geographic coordinates using the azimuth and plunge of the X direction (lab arrow) of a specimen. Parameters ---------- indat: nested list of [dec, inc, az, pl] data Returns ------- rotated_directions : arrays of Decl...
python
def dogeo_V(indat): """ Rotates declination and inclination into geographic coordinates using the azimuth and plunge of the X direction (lab arrow) of a specimen. Parameters ---------- indat: nested list of [dec, inc, az, pl] data Returns ------- rotated_directions : arrays of Decl...
[ "def", "dogeo_V", "(", "indat", ")", ":", "indat", "=", "indat", ".", "transpose", "(", ")", "# unpack input array into separate arrays", "dec", ",", "inc", ",", "az", ",", "pl", "=", "indat", "[", "0", "]", ",", "indat", "[", "1", "]", ",", "indat", ...
Rotates declination and inclination into geographic coordinates using the azimuth and plunge of the X direction (lab arrow) of a specimen. Parameters ---------- indat: nested list of [dec, inc, az, pl] data Returns ------- rotated_directions : arrays of Declinations and Inclinations
[ "Rotates", "declination", "and", "inclination", "into", "geographic", "coordinates", "using", "the", "azimuth", "and", "plunge", "of", "the", "X", "direction", "(", "lab", "arrow", ")", "of", "a", "specimen", "." ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2240-L2278
PmagPy/PmagPy
pmagpy/pmag.py
dodirot
def dodirot(D, I, Dbar, Ibar): """ Rotate a direction (declination, inclination) by the difference between dec=0 and inc = 90 and the provided desired mean direction Parameters ---------- D : declination to be rotated I : inclination to be rotated Dbar : declination of desired mean ...
python
def dodirot(D, I, Dbar, Ibar): """ Rotate a direction (declination, inclination) by the difference between dec=0 and inc = 90 and the provided desired mean direction Parameters ---------- D : declination to be rotated I : inclination to be rotated Dbar : declination of desired mean ...
[ "def", "dodirot", "(", "D", ",", "I", ",", "Dbar", ",", "Ibar", ")", ":", "d", ",", "irot", "=", "dogeo", "(", "D", ",", "I", ",", "Dbar", ",", "90.", "-", "Ibar", ")", "drot", "=", "d", "-", "180.", "if", "drot", "<", "360.", ":", "drot", ...
Rotate a direction (declination, inclination) by the difference between dec=0 and inc = 90 and the provided desired mean direction Parameters ---------- D : declination to be rotated I : inclination to be rotated Dbar : declination of desired mean Ibar : inclination of desired mean Ret...
[ "Rotate", "a", "direction", "(", "declination", "inclination", ")", "by", "the", "difference", "between", "dec", "=", "0", "and", "inc", "=", "90", "and", "the", "provided", "desired", "mean", "direction" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2281-L2303
PmagPy/PmagPy
pmagpy/pmag.py
dodirot_V
def dodirot_V(di_block, Dbar, Ibar): """ Rotate an array of dec/inc pairs to coordinate system with Dec,Inc as 0,90 Parameters ___________________ di_block : array of [[Dec1,Inc1],[Dec2,Inc2],....] Dbar : declination of desired center Ibar : inclination of desired center Returns __...
python
def dodirot_V(di_block, Dbar, Ibar): """ Rotate an array of dec/inc pairs to coordinate system with Dec,Inc as 0,90 Parameters ___________________ di_block : array of [[Dec1,Inc1],[Dec2,Inc2],....] Dbar : declination of desired center Ibar : inclination of desired center Returns __...
[ "def", "dodirot_V", "(", "di_block", ",", "Dbar", ",", "Ibar", ")", ":", "N", "=", "di_block", ".", "shape", "[", "0", "]", "DipDir", ",", "Dip", "=", "np", ".", "ones", "(", "N", ",", "dtype", "=", "np", ".", "float", ")", ".", "transpose", "(...
Rotate an array of dec/inc pairs to coordinate system with Dec,Inc as 0,90 Parameters ___________________ di_block : array of [[Dec1,Inc1],[Dec2,Inc2],....] Dbar : declination of desired center Ibar : inclination of desired center Returns __________ array of rotated decs and incs: [[ro...
[ "Rotate", "an", "array", "of", "dec", "/", "inc", "pairs", "to", "coordinate", "system", "with", "Dec", "Inc", "as", "0", "90" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2306-L2327
PmagPy/PmagPy
pmagpy/pmag.py
find_samp_rec
def find_samp_rec(s, data, az_type): """ find the orientation info for samp s """ datablock, or_error, bed_error = [], 0, 0 orient = {} orient["sample_dip"] = "" orient["sample_azimuth"] = "" orient['sample_description'] = "" for rec in data: if rec["er_sample_name"].lower() ...
python
def find_samp_rec(s, data, az_type): """ find the orientation info for samp s """ datablock, or_error, bed_error = [], 0, 0 orient = {} orient["sample_dip"] = "" orient["sample_azimuth"] = "" orient['sample_description'] = "" for rec in data: if rec["er_sample_name"].lower() ...
[ "def", "find_samp_rec", "(", "s", ",", "data", ",", "az_type", ")", ":", "datablock", ",", "or_error", ",", "bed_error", "=", "[", "]", ",", "0", ",", "0", "orient", "=", "{", "}", "orient", "[", "\"sample_dip\"", "]", "=", "\"\"", "orient", "[", "...
find the orientation info for samp s
[ "find", "the", "orientation", "info", "for", "samp", "s" ]
train
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L2330-L2369