lib_dd package

Submodules

lib_dd.Jacobian module

Copyright 2014-2017 Maximilian Weigand

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Jacobian implementation for a Debye-Decomposition style function Resistivity formulation

lib_dd.Jacobian.Jacobian(omega, pars, s, partials)[source]

Calculate the Jacobian matrix for a given set of parameters m and relaxation times s (s = log_{10}(\tau)).

Parameters
  • omega (Angular frequencies 2 \cdot \pi \cdot f) –

  • pars (\rho_0 and m_i values in the parmeterisation) – (linear,log10) of the provided partials

  • s (\tau values in log10) –

  • partials (List of the four partial derivative functions) – \frac{\partial Re}{\partial \rho0}, \frac{\partial
Re}{\partial m_i}, \frac{\partial -Im}{\partial \rho0},
\frac{\partial -Im}{\partial m_i}

Returns

  • The derivatives of d Re(rho)/d g_i and d -Im(rho)d g_i in form of a

  • 2*K x P matrix (K = number of frequencies), (P = number of model

  • parameters)

lib_dd.base_class module

Copyright 2014-2017 Maximilian Weigand

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

lib_dd.base_class.determine_tau_range(settings)[source]

Return the tau values depending on the settings ‘Nd’, ‘tau_values’ and ‘tau_sel’ in the dict ‘settings’

Tau values can be set by using one of the following strings in

self.settings[‘tausel’]:

data data_ext factor_left,factor_right ,factor_right factor_left,

Missing values are replaced by one (i.e. the data frequency limits are

used).

lib_dd.base_class.get_tau_values_for_data(frequencies, Nd, factor_left=1, factor_right=1)[source]

Return the \tau values corresponding to the frequency range of the data set.

Parameters
  • Nd (number of \tau values per decade) –

  • factor_left (factor to divide to the lower limit by) –

  • factor_right (factor to multiply to the upper limit) –

Returns

Return type

tau,s with s = log_{10}(\tau)

class lib_dd.base_class.integrated_parameters[source]

Bases: object

Computation of integrated paramters. This class is not meant to be used alone, it is meant to be inherited by ‘dd_resistivity_skeleton’

compute_par_stats(pars)[source]

For a given parameter set (i.e. a fit result), compute relevant statistical values such das m_{tot}, m_{tot}^n, \tau_{50}, \tau_{mean}, \tau_{peak}

Returns

  • stat_pars (dict containing the computed parameters)

  • Also store stat_pars in self.stat_pars

class lib_dd.base_class.starting_pars_3(re, mim, frequencies, taus)[source]

Bases: object

Heuristic nr 3 for determining useful starting values for the fit.

This function is aware if the conductivity or resistivity formulation is used.

estimate(obj)[source]

Determine a starting model by creating frequency-decade wise mean values of mim and then computing a fixed chargeability value for each frequency decade.

get_bins()[source]
get_sec_data()[source]

lib_dd.int_pars module

Copyright 2014-2017 Maximilian Weigand

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Integrated parameters

pars: linear representation of parameters

lib_dd.int_pars.U_tau(pars, tau, s)[source]

compute uniformity parameter similar to Nordsiek and Weller, 2008: U_{\tau} = \frac{\tau_{60}}{\tau_{10}}

lib_dd.int_pars.decade_loadings(pars, tau, s)[source]

Compute the chargeability sum for each frequency decade. Store in linear scale.

lib_dd.int_pars.m_data(pars, tau, s)[source]
lib_dd.int_pars.m_tot(pars, tau, s)[source]
lib_dd.int_pars.m_tot_n(pars, tau, s)[source]
lib_dd.int_pars.rho0(pars, tau, s)[source]
lib_dd.int_pars.tau_50(pars, tau, s)[source]
lib_dd.int_pars.tau_arithmetic(pars, tau, s)[source]
lib_dd.int_pars.tau_geometric(pars, tau, s)[source]
lib_dd.int_pars.tau_max(pars, tau, s)[source]
lib_dd.int_pars.tau_mean(pars, tau, s)[source]
lib_dd.int_pars.tau_peaks(pars, tau, s)[source]
lib_dd.int_pars.tau_x(pars, tau, s)[source]

Arbitrary cumultative \tau_x values can be computed using the environment variable DD_TAU_X: The string separates the requested percentages as fractions with ‘;’ characters.

Example

DD_TAU_X=”0.2;0.35;0.6”

lib_dd.interface module

Copyright 2014-2017 Maximilian Weigand

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Functions common to the Cole-Cole decomposition implementations ccd_single, ccd_time.

lib_dd.interface.aggregate_dicts(iteration_list, dict_name)[source]

For a given list of NDimInv iterations, aggregate the dictionaries with name ‘dict_name’ (Iteration.dict_name) and return one dict containing the values of all iterations as lists.

lib_dd.interface.create_output_dir(options)[source]

Create the output directory

lib_dd.interface.get_command()[source]

Return a string with the full command call, including environment variables.

Environment variables are exported in separate lines

lib_dd.interface.load_frequencies_and_data(options)[source]

Load frequencies and data from options.frequency_file and options.data_file. Apply certain processing steps such as:

  • frequency filtering

  • magnitude normalization

Parameters

options (object as created by optparse (e.g. provided by dd_single.py or) – dd_time.py)

Returns

  • data (data dict)

  • options (the options object can be changed by this function, e.g. when the) – data type is changed.

lib_dd.interface.prepare_stat_values(raw_values, key, norm_factors)[source]

Prepare stat_pars for saving to disc.

This included renormalization or padding for specific keys.

Divide the statistical parameter rho0 by norm_factors and multiply m_tot_n by them.

Parameters
  • raw_values (NxM array, N: number of spectra, M: number of parameters) – values of given parameter

  • key (str) – identifier for the parameter type, e.g. rho0, tau_mean, …

  • norm_factors (numpy.ndarray) – norm factors for the inversions

Returns

values – modified values

Return type

NxM array, N: number of spectra, M: number of parameters

lib_dd.interface.save_rms_values(rms_list, rms_names)[source]

Save the RMS values to the corresponding filenames

lib_dd.interface.save_stat_pars(stat_pars, norm_factors=None)[source]

Saves to current working directy.

lib_dd.plot module

Copyright 2014-2017 Maximilian Weigand

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

class lib_dd.plot.plot_iteration[source]

Bases: object

This class defines an override function for the default plot function of the Iteration class. The new plot function is aware of the Cole-Cole Decomposition approach and will plot more information (i.e. the RTD)

In addition, it will renormalize data if necessary.

create_figure()[source]
finalize_fig()[source]
plot(it, norm_factors=None)[source]

lib_dd.plot_stats module

lib_dd.starting_parameters module

class lib_dd.starting_parameters.starting_parameters[source]

Bases: object

estimate_starting_parameters(spectrum)[source]
estimate_starting_parameters_1(re, mim)[source]

Heuristic 1 to generate a suitable starting distribution for a fit

TODO: Florsch et al. 2014 has a name for this kind of heuristic…

estimate_starting_parameters_2(re, mim)[source]

Try to find good starting parameters using a Gaussian m-distribution.

This should only work well if we have only one peak in the data (imaginary/phase)

estimate_starting_parameters_3(re, mim)[source]

lib_dd.test_functions module

Copyright 2014-2017 Maximilian Weigand

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

lib_dd.test_functions.assert_single_t_rms_pos_change(rms_old_result, rms_new_result, allowed_percentage)[source]

Wrap assertTrue statements around the function

lib_dd.test_functions.single_t_rms_pos_change(rms_old_result, rms_new_result, allowed_percentage)[source]

Process one spectrum as described in the documentation of t_rms_pos_change

Parameters
  • rms_old_result (list/array with 3 entries containing the RMS-values from) – the last recorded dd fit: Overall RMS, Real part RMS, Imaginary part RMS

  • rms_new_result (list/array with 3 entries containing the RMS-values from) – the test dd fit: Overall RMS, Real part RMS, Imaginary part RMS

  • allowed_percentage (one percentage value for the allowed change) – between old and new result.

Returns

rms_within_limit – allow percentage change, False for a larger deviation

Return type

list with 3 bool entries; True for values within the

lib_dd.test_functions.t_rms_pos_change(old_result, new_result, allowed_percentage)[source]

Test for positive rms changes

Parameters
  • old_result (dd directory containing the old run) –

  • new_rusult (dd directory containing the new run) –

  • allowed_percentage (percentage threshold for positive changes.) – If this variable is a list of length three the values will be treated as rms, rms_re, rms_im thresholds

class lib_dd.test_functions.tcolors[source]

Bases: object

ENDC = '\x1b[0m'
FAIL = '\x1b[91m'
GRAY = '\x1b[37m'
HEADER = '\x1b[95m'
OKBLUE = '\x1b]94m'
OKGREEN = '\x1b[92m'
WARNING = '\x1b[93m'

lib_dd.version module

Copyright 2014-2017 Maximilian Weigand

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Module contents

Overview lib_dd package