BiCEP package#

Subpackages#

Submodules#

BiCEP.conversion module#

BiCEP.conversion.NLTsolver(fields, a, b)#

Makes the non linear TRM correction

BiCEP.conversion.convert_intensity_measurements(measurements)#

Converts a measurements table with only intensity experiments into the internal data format used by the BiCEP method

BiCEP.conversion.generate_arai_plot_table(outputname, wd='./')#

Generates a DataFrame with Thellier Data for a Dataset, stores it as a csv.

Parameters:
  • outputname ((str))

  • extension) (name of file to output (no)

Return type:

None

BiCEP.conversion.sortarai(datablock, s, Zdiff, **kwargs)#

sorts data block in to first_Z, first_I, etc.

Parameters:
  • datablock (Pandas DataFrame with Thellier-Tellier type data)

  • s (specimen name)

  • Zdiff (if True, take difference in Z values instead of vector difference) – NB: this should always be False

  • **kwargs – version : data model. if not 3, assume data model = 2.5

Returns:

  • araiblock ([first_Z, first_I, ptrm_check,) – ptrm_tail, zptrm_check, GammaChecks]

  • field (lab field (in tesla))

BiCEP.criteria module#

BiCEP.criteria.TaubinSVD(x, y)#

Function from PmagPy 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
  1. Taubin, “Estimation Of Planar Curves, Surfaces And Nonplanar

    Space Curves Defined By Implicit Equations, With Applications To Edge And Range Image Segmentation”,

IEEE Trans. PAMI, Vol. 13, pages 1115-1138, (1991)

BiCEP.criteria.auto_interpret(site, mad, dang, drat, mad_type='mad_free')#

Auto-Interpreter for BiCEP. Calculates MAD_coe, DANG and DRAT for every possible interpretation with 4 or more points on the Arai plot. Selects the interpretation that passes the criteria which has the highest FRAC.

Parameters:
  • site (BiCEP specimenCollection object)

  • for (Site/sample to calculate interpretations)

  • mad (float)

  • threshold (DRAT criterion)

  • dang (float)

  • threshold

  • DRAT (float)

  • threshold

Return type:

None

BiCEP.criteria.bestfit_line(ptrm, nrm)#

Returns the slope and intercept of the best fit line to a set of pTRM and NRM data using York Regression

Parameters:
  • ptrm (list or array)

  • data (list of NRM)

  • nrm (list or array)

  • data

Return type:

dictionary of slope and intercept for best fitting line.

BiCEP.criteria.calculate_NLT_correction(IZZI, c)#

Calculates the correction for non linear TRM for a paleointensity interpretation, given the anisotropy and cooling rate corrections

Parameters:
  • IZZI (pandas.DataFrame)

  • and (DataFrame object in BiCEP format of in field)

  • (interpretation). (zero field measurements for a specimen)

  • c (float)

  • correction- (Combined Anisotropy and Cooling Rate)

  • this. (needed because the nonlinearity is applied after)

Returns:

  • c (float)

  • NLT correction factor

BiCEP.criteria.calculate_anisotropy_correction(IZZI)#

Calculates anisotropy correction factor for a paleointensity interpretation, given an s tensor

Parameters:
  • IZZI (pandas.DataFrame)

  • and (DataFrame object in BiCEP format of in field)

  • (interpretation). (zero field measurements for a specimen)

Returns:

  • c (float)

  • Anisotropy correction factor

BiCEP.criteria.get_dang(NRM_trunc_dirs, pca)#

Calculates the Deviation Angle :param NRM_trunc_dirs: :type NRM_trunc_dirs: numpy.ndarray :param Vector directions for zero field measurements for specimen: :param pca: :type pca: scikitlearn.decomposition.PCA object :param pca used to fit the vector direction.:

Returns:

  • dang (float)

  • deviation angle for that intepretation

BiCEP.criteria.get_drat(IZZI, IZZI_trunc, P)#

Calculates the difference ratio (DRAT) of pTRM checks (Selkin and Tauxe, 2000) to check for alteration

Parameters:
  • IZZI (pandas.DataFrame)

  • and (DataFrame object in BiCEP format of all in field)

  • specimen. (zero field measurements for a)

  • IZZI_trunc (pandas.DataFrame)

  • temperatures (DataFrame object- same as IZZI but truncated only for)

  • interpretation (maximum temperature of an)

  • P (pandas.DataFrame)

  • the (DataFrame object containing pTRM checks up to)

  • interpretation

Returns:

  • absdiff (float)

  • maximum DRAT for all pTRM check measurements.

  • returns zero if the interpretation is not valid.

BiCEP.criteria.get_frac(IZZI, IZZI_trunc)#

Calculates the NRM Fraction from VDS (Shaar and Tauxe, 2013)

Parameters:
  • specimen (BiCEP specimen object)

  • from (specimen to obtain FRAC)

Returns:

  • FRAC (float)

  • calculated FRAC

BiCEP.criteria.get_mad(IZZI, pca)#

Calculates the free Maximum Angle of Deviation (MAD) of Kirshvink et al (1980)

Parameters:
  • IZZI (pandas.DataFrame)

  • and (DataFrame object in BiCEP format of in field)

  • (interpretation). (zero field measurements for a specimen)

  • pca (scikitlearn.decomposition.PCA object)

  • direction. (pca used to fit the vector)

Returns:

  • mad (float)

  • maximum angle of deviation for that intepretation

BiCEP.criteria.sufficient_statistics(ptrm, nrm)#

inputs list of ptrm and nrm data and computes sufficent statistcs needed for computations

Parameters:
  • ptrm (list)

  • data (list of nrm)

  • nrm (list)

  • data

Return type:

dict containing mean ptrm and nrm, and covariances in xx, xy and yy.

BiCEP.datamodel module#

class BiCEP.datamodel.Specimen(parentCollection, specimenName)#

Bases: object

Specimen from a given site or sample SpecimenCollection object.

Parameters:
  • parentCollection (SpecimenCollection object)

  • from. (Site/Sample the specimen is derived)

  • specimenName (string)

  • specimen (Name of)

BiCEP_prep()#

Returns the needed data for a paleointensity interpretation to perform the BiCEP method, calculates all corrections for a specimen. Performs scaling on the PTRM and NRM data. It performs the Taubin SVD circle fit to find the maximum likelihood circle fit to initialize the BiCEP method sampler.

Parameters:

None

Returns:

  • minPTRM (float)

  • Minimum scaled pTRM

  • maxNRM (float)

  • Minimum scaled NRM

  • PTRMmax (float)

  • Maximum total pTRM (scaled)

  • k (float)

  • Best fitting k value using Taubin circle fit.

  • phi (float)

  • Best fitting phi value using Taubin circle fit

  • dist_to_edge (float)

  • Best fitting D value using Taubin circle fit.

  • sigma (float)

  • Best fitting sigma value using Taubin circle fit.

  • PTRMS (numpy.ndarray())

  • Scaled and translated pTRM values

  • NRMS (numpy.ndarray())

  • Scaled and translated NRM values.

calc_plotting_temps()#

Uses k-means clustering to find the set of temperatures to plot as text on the Arai/Zijderveld plot, without things overlapping

change_temps(lowerTemp, upperTemp)#

Changes temperature range (interpretation for specimen). Recalculates SPD statistic and PCA for said specimen.

Parameters:
  • lowerTemp (float)

  • interpretation (Upper temperature (inclusive) for)

  • upperTemp (float)

  • interpretation

Return type:

None

plot_arai(ax=None, temps=True)#

Plots data onto the Arai plot.

Parameters:
  • ax (matplotlib axis)

  • to (axis for plot to be plotted on)

  • temps (bool)

  • True (if)

  • plot (plots temperatures on the Arai)

Return type:

None

plot_circ(ax, legend=False, linewidth=2, title=None, tangent=False)#

Plots circle fits sampled from the posterior distribution (using the BiCEP method) to the Arai plot data. Plots tangent to the circle as a slope if tangent=True

Parameters:
  • ax (matplotlib axis)

  • plot. (axis to be used for)

  • legend (bool)

  • legend. (If True plots a)

  • linewidth (float)

  • plot (Title for)

  • title (str)

  • plot

  • tangent (bool)

  • True (If set to)

  • circle. (plots best fitting tangent to)

plot_zijd(ax=None, temps=True)#

Plots data onto the Zijderveld plot. Does not fit a line to this data.

Parameters:
  • ax (matplotlib axis)

  • to (axis for plot to be plotted on)

  • temps (bool)

  • True (if)

  • plot. (plots temperature values as text on)

Return type:

None

save_changes()#

Commits temperature changes for use with the BiCEP method

Parameters:

None

Return type:

None

class BiCEP.datamodel.SpecimenCollection(parentData, collectionName, key)#

Bases: object

Collection of specimens (site or sample, from ThellierData Dataset)

Parameters:
  • parentData (ThellierData object)

  • from (Set of Thellier Data the site/sample is derived)

  • collectionName (string)

  • specimen/site (Name of)

  • key (string)

  • sample (Either 'site' for site or 'sample' for)

BiCEP_fit(n_samples=30000, priorstd=5, model=None, **kwargs)#

Performs the fitting routine using the BiCEP method for a given list of specimens from a single site. :param Specimenlist: :type Specimenlist: iterable of specimen names (strings)

get_specimen_rhats()#

Finds the worst Rhat va; for each specimen and assigns it to that specimen

histplot(ax, **kwargs)#

Plots a histogram of the site level paleointensity estimate.

Parameters:
  • **kwargs

  • plot (arguments to be passed to the histogram)

Return type:

None

regplot(ax, legend=False, title=None)#

Plots B vs k for all specimens in a site given a BiCEP or unpooled fit

Parameters:
  • ax (matplotlib axis)

  • to (axes to plot)

  • legend (plots a)

  • True (If set to)

  • legend

  • title (str)

  • None. (Title for plot. Does not plot title if set to)

save_magic_tables()#

Saves data from the currently displayed site to the GUI

Parameters:

None

Return type:

None

class BiCEP.datamodel.ThellierData(datafile)#

Bases: object

Class which supports several methods using the BiCEP method in pandas. :param datafile: :type datafile: string for file name in BiCEP format

switch_grouping()#

BiCEP.extract module#

BiCEP.extract.extract_values(fit, var)#

Extracts the data for variable in the BiCEP fit to a 1d numpy array

Parameters:
  • InferenceData (fit arviz)

  • object (site level BiCEP fit)

  • str (var)

  • fit (name of variable in)

Returns:

  • values (array)

  • 1d array of values for that variable in the fit

BiCEP.extract.get_sampler_success(site, abs_tol=16, perc_tol=40, acceptSkew=False)#

Checks for a BiCEP site result has a full width of its credible interval <abs_tol μT or perc_tol% of the median. Additionally, checks that the sampler did not fail the rhat criterion (if it does, you may need to rerun this function on the site). The function also outputs a warning if the skewness of the distribution of the site mean intensity is highly skewed, which can be indicative of a result which cannot exclude zero. These results have a higher chance of being inaccurate because the mean is restricted to be greater than zero and so this may artificially reduce the uncertainty in the mean value.

Parameters:
  • site (BiCEP specimenCollection object)

  • success. (site/sample used to check for)

  • abs_tol (float)

  • specimen (absolute maximum percentage tolerance for accurate)

  • perc_tol (float)

  • specimen

  • acceptSkew (bool)

  • False) (Whether we accept A- / B- results (default)

Returns:

  • True/False (bool)

  • Whether the site has a successful result or not (an A or a B)

BiCEP.extract.run_site_fit(site, min_specs=4, save_nc=False, model=None, n_samples=10000, **kwargs)#

Runs a BiCEP fit to a site, automatically choosing specimen level interpretations.

Parameters:
  • site (BiCEP specimenCollection object.)

  • on (site/specimen to run fit)

Return type:

None

BiCEP.gui module#

class BiCEP.gui.GUI#

Bases: object

activate_deactivate(a)#

Function that excludes/includes a specimen depending on activation/deactivation

Parameters:#

a: interact object Has no practical use

rtype:

None

display_sampler_diags(fit)#

Displays the worst R_hat and n_eff, B_anc and Category or Grade for the BiCEP fit

Parameters:
  • fit (StanFit object)

  • site/sample (model fit to)

  • Returns

  • --------

  • None

display_site_plot(fit)#

Displays the site plots for BiCEP GUI

Parameters:
  • fit (StanFit object)

  • site/sample (BiCEP fit for that)

Return type:

None

display_specimen_plots()#

Displays specimen level plots on the BiCEP GUI

Parameters:#

None

Returns:#

None

display_specimen_ring()#

Displays a red circle around the currently selected specimen in the site plot of BiCEP GUI

Parameters:#

None

rtype:

None

enablerun(a)#

Enables running the GUI after choosing a file

Parameters:#

a: Button pressed object Has no practical use

rtype:

None

full_auto_interpreter(a)#
get_sampler_diags(site)#

Returns useful sampler diagnostics for a particular MCMC fit with pystan

Parameters:
  • fit (StanFit object)

  • site/sample (model fit to)

Returns:

  • rhat_worst (float)

  • worst rhat of all parameters

  • n_eff_int_site (float)

  • Effective number of pseudosamples of B_anc

get_site_dist(a)#

Runs the MCMC sampler and updates the GUI

Parameters:#

a: Button pressed object has no practical use.

Returns:#

None

on_change(change)#

Update GUI on changing one of our site, specimen, temperature dropdowns.

Parameters:#

change: Dropdown change object Gives us information about which object was changed (owner), the type of change (name, either value for a value change, or options for all options changed),and the new value (new). Note that these attributes are very important to avoid repeating many operations, as the changing the site widget’s value changes the specimen widgets options, which then changes it’s options. This is the reason for the numerous if statements in this function.

Returns:#

None

run(a)#

Runs the GUI after selecting a file.

Parameters:#

a: Button pressed object Has no practical use

rtype:

None

save_figures(a)#

Saves figures from GUI to file

Parameters:#

a: Button pressed object Has no practical use

rtype:

None

save_magic_tables(a)#

Saves data from the currently displayed site to the GUI

Parameters:#

a: Button pressed object Has no practical use

rtype:

None

save_temps(a)#

Saves changes to specimen temperatures

Parameters:#

a: Button pressed object has no practical use.

Returns:#

None

save_to_netcdf(a)#

Function that saves site fit to netCDF

Parameters:#

a: interact object Has no practical use

rtype:

None

Module contents#