Error Propagation Functions

Thermobar.noise_averaging.add_noise_sample_1phase(phase_comp, phase_err=None, phase_err_type='Abs', variable=None, variable_err=None, variable_err_type=None, duplicates=10, noise_percent=None, err_dist='normal', positive=True, filter_q=None, append=False)[source]

This function generates N duplicates containing random noise from the compositions in the dataframe specified by phase_comp.

  • Comps (Phase) – Pandas dataframe of phase compositions. This can be generated from the import_excel function, or any dataframe with the headings _Liq for liquids, _Cpx for clinopyroxenes etc.

  • error (Options for adding different types of) –

  • variable (1) If you want to specifying an error for >1) –

    phase_err: pandas dataframe

    Pandas dataframe with headings for the error of the oxide in each phase (e.g., SiO2_Liq_Err, or SiO2_Cpx_Err). This dataframe can be generated from a user-inputted spreadsheet with these column headings using the function import_excel_errors. Errors can be absolute, or percentage errors. the default is absolute errors (in wt%), but users can overwrite this using phase_err_Type=”Perc”.

    phase_err_type: “Abs” (default) or “Perc”

    Determins if specified errors are absolute (Abs) or percentage errors.

  1. If you want to specify error for a single variable:

    variable: str

    Name of column you wish to add error to (e.g. “Na2O” for Na2O in Liq)

    variable_err: flt, int

    Specifies how much error to add

  2. If you want to add a fixed percent of noise to all variables.

    noise_percent: flt, int

    Adds a fixed noise percent to all input variables.

duplicates: flt, int (Default: 10)

Number of new synthetic samples generated per sample in the original dataframe. E.g., if the user enteres 7 samples, and duplicates=1000, the function returns 7000 compositions by default. If append=True, the original dataframe is appended onto the end of the returned dataframe

err_dist: “normal” (default) or “uniform”

determins whether added error is normally distributed with 1 sigma = entered value. Or uniformly distributed between +noise value and - noise value.

positive: True (default) or False

If True, doesn’t allow negative values of oxide species, temperature or pressure. Can result in a non-normally distributed error distribution. If False, negative values are allowed.

filter_q: str

Filter criteria, e.g. if SiO2_Liq>60, only returns samples with SiO2_Liq>60

append: False (default) or True

If True, appends user-entered dataframe onto the synthetic dataframe once noise has been added.


  • Panda dataframe containing user-inputted samples with noise added.

  • The output is sorted such that the first row in the input * the number

  • of noise samples requested are the first N rows, then the new synthetic

  • compositions for the second row in the input database are next.

  • A heading called “Sample_ID_Liq_Num” is added, with all synthetic samples

  • from the first row in the input dataframe have an index 0, the 2nd row have

  • an index 1. etc.

Thermobar.noise_averaging.av_noise_samples_df(dataframe, calc_heading, ID_heading)[source]

This function calculates the mean, median, standard devation, maximum and minimum value of rows in a datarame with column heading “calc_heading” grouping by values in “ID_heading”. :param dataframe: Panda datframe of inputs you want to average.

Must contain column headings “calc_heading” and “ID_heading”.

  • calc_heading (str) – column heading for the thing you want to average (e.g, P_kbar_calc)

  • ID_heading (str) – column heading for the thing you want to average by (e.g., Sample_ID)


  • Dataframe with headings “Sample”, “Mean_calc”, “Median_calc”,

  • ”St_dev_calc”, “Max_calc”, “Min_calc”

Thermobar.noise_averaging.av_noise_samples_series(calc, sampleID)[source]

This function calculates the mean, median, standard devation, maximum and minimum value of rows specified by “calc” based on values in “Sample ID” where both inputs are panda series.

  • calc (Series) – Panda series of inputs you want to average.

  • SampleID (str) – column heading for the thing you want to average by (e.g., Sample_ID_Cpx)


  • Dataframe with headings “Sample”, “Mean_calc”, “Median_calc”,

  • ”St_dev_calc”, “Max_calc”, “Min_calc”

Thermobar.noise_averaging.calculate_bootstrap_mixes(endmember1, endmember2, num_samples, self_mixing=False)[source]

Specify 2 end-members, generates synthetic liquids from mixing between these end-members

endmember1: pandas.DataFrame

Panda DataFrame of liquid compositions for end-member 1, with column headings SiO2_Liq etc.

endmember2: pandas.DataFrame

Panda DataFrame of liquid compositions for end-member 2, with column headings SiO2_Liq etc.

num_samples: float or int

If num_samples is less than the length of the end members, will randomly resample liquids entered to get to sufficient N. If num_samples greater than length of end members, will randomly downsample liquids to N=num_samples.

self_mixing: None, False, True, “Partial”

If None or False, will mix 2 end members in various proportions, but no mixing between end members If True, will mix between samples from a given end member as well as between the 2 end members. If Partial, half of outputted liquids will be generated by mixing within and between end members, and the other half from mixing between end members.

pandas DataFrame

synthetic liquids generated by mixing between end-members with column headings “SiO2_Liq” etc.