Code Documentation
Contents
Modules
DirichletMagmaMix
A python package for modelling partial mantle melt aggregation using the Dirichlet distribution as described by Rudge et al. (2013).
Developed and maintained by Simon Matthews (simonm@hi.is).
The module requires a set of primary melt compositions to be generated elsewhere. At the present time the module can only important results generated by the pyMelt library (though an older version of the code is compatible with alphaMELTS).
- exception DirichletMagmaMix.InputError(message)[source]
Exception raised for errors in the input.
- Attributes:
expression – input expression in which the error occurred message – explanation of the error
- class DirichletMagmaMix.UnmixedMelts(melts, pressure=None, mass=None, weights=None, isotopes=[], mass_warning=True, lithology_names=[], **kwargs)[source]
Contains all the melts (from all lithologies) and information about how they should be weighted in the mixtures.
- Parameters
melts (pandas.DataFrame) – All of the melts from the melting region. Columns should only be chemical composition.
weighting (str, pandas.Series, or None, default: None) – How to weight the melts in the mixtures (in addition to their mass). In built options: - ‘triangle’, a triangular melting region for a spreading-centre - ‘truncated_triangle’, a triangular melting region missing the
top or bottom. Specify by passing arguments ‘shape_top’ and ‘shape_bottom’ (pressure in GPa).
Alternatively, supply a pandas Series with the numerical weighting values. If None, an equal weighting will be applied.
isotopes (list of dicts, default: []) – For any isotope ratios in the melts DataFrame a dict should be provided with the following keys: - ‘ratio’: the name of the ratio in the DataFrame, e.g., ‘Nd143Nd144’. - ‘element’: the element the isotopes are associated with, e.g., ‘Nd’.
This element must be in the DataFrame.
mass_warning (bool, default: True) – Warn if there is no mass information provided.
lithology_names (list of strings, default: []) – The names of the lithologies contributing to the melting column. Used to preserve tracer variables, for example during fractional crystallisation.
- correlation()[source]
Calculates the correlation coefficient between elements. This is independent of the mixing parameter.
- Returns
DataFrame containing the correlations with elements as the indexes and columns.
- Return type
pandas.DataFrame
- gen_cmc_melts(samples, max_crystallisation, mixing_min, mixing_max, partition_coefficient=None)[source]
Generate melts produced by concurrent mixing and crystallisation, using the model defined in Rudge et. al. (2003).
- Parameters
samples (int) – Number of mixed melts to produce.
max_crystallisation (float) – Maximum fraction of crystallisation. Denoted by Chi in Rudge et. al. (2003)
mixing_min (float or int) – Minimum degree of melt mixing
mixing_max (float or int) – Maximum degree of melt mixing
partition_coefficient (float, pandas.Series or None, default: None) – The partition coefficient for each element during crystallisation. If None, all elements will be treated as being perfectly incompatible.
- Returns
The randomly mixed melts.
- Return type
- gen_dirichlet_parameters(N)[source]
Generate dirichlet parameters given the mixing parameter passed to function, and the weighting variables contained in UnmixedMelts object.
- Parameters
N (float or int) – Mixing parameter. Must be >1.
- Returns
Dirichlet parameters
- Return type
pandas.Series
- gen_mixed_melts(mixing_parameter, samples=1)[source]
Generate mixed melts with mixing parameters randomly selected from the dirichlet distribution defined by the mixing parameter.
- Parameters
mixing_parameter (float or int) – Mixing parameter. Must be >=1.
samples (int, default: 1) – Number of mixed melts to return.
- Returns
The randomly mixed melts.
- Return type
- gen_mixing_weights(alpha)[source]
Generate a random distribution of mixing proportions.
- Parameters
alpha (pandas.Series) – The dirichlet parameters, probably calculated using the gen_alpha method.
- Returns
Mixing weights for one random draw from the dirichlet distribution.
- Return type
pandas.Series
- homogenise(pressure)[source]
Homogenise melts produced below a certain pressure.
- Parameters
pressure (float) – Pressure at which to homogenise melts generated beneath.
- DirichletMagmaMix.import_pyMelt_geoSetting(geoSetting, weights=None, isotopes={}, **kwargs)[source]
Imports a pyMelt geoSetting.
- Parameters
geoSetting (pyMelt.geoSetting) – The geoSetting class containing the melts to be mixed.
weights (pandas.Series, string, or None, default: None) – Specify weighting for the melts (see UnmixedMelts docstring for more information). If None and the geoSetting is a spreadingCentre, a triangular weighting will be applied, otherwise the melts will have equal weighting.
isotopes (dict containing lists of dicts, default: {}) – The isotope ratios to assign to the melts. The keys of the first dictionary should be the lithology names, then the list consists of dictionaries containing: - ratio, e.g., ‘Nd143Nd144’ - element, e.g., ‘Nd’ - value, e.g., 0.51230
- Returns
The UnmixedMelts object created during import
- Return type