comet.snmr.survey package

Submodules

comet.snmr.survey.survey module

Part of comet/snmr/survey

Enhanced sounding class for SNMR data sets and supporting variables. Sounding class can hold any number of Measurement class instances each representing single FIDs.

class comet.snmr.survey.survey.Earth(incl=60.0, decl=2.0, mag=4.8e-05, rad=False)[source]

Bases: object

Parameters:
  • inclination (float [ 60. ]) – Inclination of the earth magnetic field in rad or degree.
  • declination (float [ 2. ]) – Declination of the earth magnetic field in rad or degree.
  • magnitude (float [48000 * 1e-9]) – Magnitude of the earth magnetic field in Tesla.
  • rad (boolean [ False ]) – Input inclination and declination in rad?

Example

>>> from comet.snmr.survey import Earth
>>> e = Earth(inclination=45, declination=0, magnitude=4.8*1e-5)
>>> print(e)
copy()[source]
field

Static magnetic field vector from earth defined in survey.

larmor
magnitude
class comet.snmr.survey.survey.FID(tx=0, rx=0, pulses=None)[source]

Bases: object

Single SNMR experiment (sounding) using a simple Free Induction Decay (FID).

Attributes to be setted directly:

amperes

Ampere vector [A].

curie

Curie factor for kernel calculation. Read only. Calculated automatically by setting temperature.

deadtime

Effective deadtime (device + half pulse) [s].

filterGates(mint=0.0, maxt=2.0)[source]

Dismiss not desired time gates.

Parameters:
  • mint (float [0.0]) – Cut all data reqired before mint (in seconds). This is done using the gate midpoints including deadtime.
  • maxt (float [2.0]) – Cut all data reqired after maxt (in seconds). This is done using the gate midpoints including deadtime.
  • Append new .gating to restore old gates
  • raw_data remain untouched)
gates

Time gate midpoint vector [s] (including deadtime).

gating(num_gates=42, verbose=False)[source]

(extracted from MRSMatlab, 2017)

y=exp(x) For some interval x(a:b) the exact mean within exp(x(a:b)) yAverage = exp(mean(log(y(a:b)))) t(yAverage) = mean(t(a:b))

Problem: Logarithm is nice for exact average of exponential function. But signals are noise contaminated. 1. Logarithm of gaussian noise changes noise structure from gaussian to lorenzian. Averaging of lorenzian distributed noise is not zero. 2. Since noise can make signal negative a dc shift is added to make signals positive. This deminishes the accurancy of averaging in logspace. For large constant shift averaging in logspace becomes equivalent to average in linspace. However this is nice for noise structure. So we have a tradeoff. Finally, from some amount of intervals on, e.g. 20 within interval [0 1]/s averaging is sufficiently exact in any case.

MMP 18/10/2011

getComplexData()[source]
getRotatedAmplitudes()[source]

Returns Data and Error as real component of the rotated Vecs.

load(savename, df_removed=True)[source]

Load previously saved FID class instance from savename (.npz) (numpy compressed binary data structure).

Usually imported data are cleansed from frequency offsets (df) before saving. However there is no auto detection for that. In rare cases (if you know what youre doing) data are saved without removing df first. Then df_removed has to be set to False. Otherwise the raw data

pulses

Pulse moment vector [As].

rotateAmplitudes(raw_data=False)[source]

One of the three main ways for NMR forward modelling is to use rotated amplitudes, instead of using the amplitudes of the complex data or the complex data itself. If the phase information of the noise free data is known (synthetic data) or fitted (e.g. monoexponential fit) the rotated Amplitudes (also complex, do not confuse) have the advantage of containing all the information in the real part (together with noise), where the imaginary part contians only noise and can therefore be discarded later.

Can be used on gated or ungated data, however this call alters the raw_data!

Parameters:raw_data (boolean [ True ]) – Flag to decide if raw data or gated data are rotated. Default is raw data, however if no raw data are
Returns:
Return type:complex rotated raveled data.
save(savename)[source]

Saves FID class instance under savename. Expect savename with ending .npz (numpy compressed binary data structure).

setDataPhase(data_phase)[source]

Sets variable data_phase. Expect single float value for data phase in rad.

setFrequencyOffset(df)[source]

Sets frequency offset of tx pulse to larmor frequency.

Expect one value per pulse or one single value (used for all pulses). None is treated as zero offset (internal initialization).

setGatedDataErrorAndGates(data, error, gates, rotated=False, phases=None, midpoints=True)[source]

Sets the processed and gated data vector along with the gates (time discretization) and error cube.

Parameters:
  • data (np.ndarray) – Data vector of shape (number of pulses, number of gates). Expect complex valued vector.
  • error (np.ndarray) – Error vector of the same shape as the data vector.
  • gates (np.ndarray) – Simple time vector in seconds with shape matching the dimension 1 of the data and error vector. Expect gates without deadtime.
  • rotated (boolean [ False ]) – Define whether the data are already rotated or not. thee is no autodetect for that.
  • phases (np.ndarray [ None ]) – Define phases as simple vector containing phases in rad. Expect one value per pulse.
  • midpoints (boolean [ True ]) – If True (default) the given times in the gates vector are interpreted as midpoint of gates. However if False the vector is interpreted as outer limits of the gates, so gate 1 would be defined between time 1 and time 2 and gate 2 between time 2 and 3 and so on.
  • Sets
  • —-
  • This functionality fills the following attributes
  • *data_gated*, *gates*, *error_gated*, *rotated*
  • and optionally
  • *phi* (phases)
setGates(gates, midpoints=True)[source]

Define time gates.

Parameters:
  • gates (np.ndarray) – Define gates midpoints. Expect array with float in [s]. See midpoints for definition of how the input array is interpreted.
  • midpoints (boolean [ True ]) – If True (default) the given times in the gates vector are interpreted as midpoint of gates. However if False the vector is interpreted as outer limits of the gates, so gate 1 would be defined between time 1 and time 2 and gate 2 between timne 2 and 3 and so on.
  • Sets
  • —-gates and _gates_thk if not the midpoints are given
setPhases(phi)[source]

Sets variable phi. No check for length if vector is done. See setGatedDataErrorAndGates or setRawDataErrorAndTimes for more details.

setPulseDuration(taup, deadtime_device=0.005)[source]

Sets pulse duration [s] and internal deadtime from the device.

Parameters:
  • taup (float) – Pulse duration in seconds.
  • deadtime_device (float [ 0.005 ]) – Internal deadtime of the measurement device in seconds. 0.005 seconds are default for synthetic studies.
  • Sets
  • —-
  • *taup1*,
  • *deadtime_device*,
  • *deadtime* (half pulse + deadtime_device)
setPulses(pulses)[source]

Set pulse moment vector. Expect array with float in [As].

pulses

setRawDataErrorAndTimes(data, error, times, rotated=False, phases=None, remove_df=True, omit_regating=False)[source]

Sets the raw (processed but ungated) data vector along with the time discretization and errorvector.

Parameters:
  • data (np.ndarray) – Data vector of shape (number of pulses, times). Expect complex valued vector.
  • error (np.ndarray) – Error vector of the same shape as the data vector.
  • times (np.ndarray) – Simple time vector in seconds with shape matching the dimension 1 of the data and error vector, expect times without deadtime!
  • rotated (boolean [ False ]) – Define whether the data are already rotated or not. There is no autodetect for that.
  • phases (np.ndarray [ None ]) – Define phases as simple vector containing phases in rad. Expect one value per pulse.
  • remove_df (boolean [ True ]) – Removes the frequency offset in the given data stored in the attribute df [Hz].
  • omit_regating (boolean [ False ]) – When setting the raw data, the gated data need to be recalculated. By default this is done via regating with the original settings for the gating.
  • Sets
  • —-
  • This functionality fills the following attributes
  • *data_raw*, *times*, *error_raw*, *raw_rotated*
  • and optionally
  • *phi* (phases)
setResponse(array)[source]

Sets a respinse array with the same shape as the data e.g. from an inversion instance. For plotting only.

setRotated(rotated, raw_data=False)[source]

Sets rotation of data. True = rotatedAmplitudes, False = complex.

setRx(index, turns=None)[source]

Define index of receiver loop and turns.

setTx(index, turns=None)[source]

Define index of transmitter loop and turns.

temperature

Middle temperature [K]. Default = 281 K (8°C or 46.4°F).

times

Time vector [s] of raw data (including deadtime).

class comet.snmr.survey.survey.Survey(earth=None, loops=None)[source]

Bases: object

Survey class for containment and handling of SNMR datasets (FIDS).

addLoop(loop)[source]

Appends a given loop instance to the loops in survey and returns id

addSounding(fid)[source]

Appends a given sounding instance to the sounds in survey and returns id

createKernel(fid=0, dimension=1)[source]

Returns a initialized kernel instance for the chosen sounding.

Parameters:
  • sound_index (integer) – Index of the sounding the kernelclass is calcualting the kernel for. In order to calculate the kernel, pulses, tx and rx are taken as references from the sounding.
  • Note (createKernel does not set or change any values in survey nor in)
  • the corresponding sounding. However when calculating, the kernel class
  • will override the frequency in the given loops (tx and rx) and set it
  • to the larmor frequency calculated from the earth magnetic fields
  • magnitude. Use the *setEarth* method before or after you generate the
  • kernel instances, but obviously before calculation.
createMRS(fid=0, kernel=None, mtype='smooth', dtype='complex', nlay=3, lam=1000, dimension=2, **kwargs)[source]
createSounding(tx=0, rx=0, check_double=True)[source]

Creates a new sounding based on the given ids for tx and rx.

Parameters:
  • tx (integer [ 0 ]) – Index of the transmitter loop in loops.
  • rx (integer [ 0 ]) – Index of the receiver loop in loops. Same number than tx indicates a coincident measurement.
  • check_double (boolean [ True ]) – If True, omits creating another instance of the same fid (tx/rx combination). Instead the index of the original fid is returned. If False new fid is created and its index is returned.
  • Note (tx and rx indices can be setted regardless if there is an actual)
  • loop in loops or just a *None* placeholder. In other words you can
  • create your soundings and loops in arbitrary order.
data

Complex data cube (pulses * gates) from soundings.

data_phases

Single data phases of the FIDs.

error

Complex error cube (pulses * gates) from soundings.

gates

Time gates gathered from soundings.

load(savename, load_meshes=True, load_loops=True)[source]
loadLoopMesh(savename, indices=None, dipolename=None)[source]

Loads mesh and distribute reference to given indices.

loadMRSD(filename, remove_df=True, build_loops=False, x_offsets=None, segments=80, max_length=None, tx=None, rx=None, fids=None, debug=False)[source]
Parameters:
  • filename (string) – Path to .mrsd file to be imported.
  • build_loops (boolean [ True ]) – If True, the saved config in the mrsd file is used to construct loops for transmitter and receiver. However, the information in the mrsd fiel is not complete. There are some defaults we assume in autogenerating the loops, especially when it comes to figure-of-eight loops. Feel free to replace the loops with custom created loops of the pyhed library. Or switch this off if you only want to see the data or define all the loops yourself.
  • x_offsets (list or None [ None ]) – One information that is missing in mrsd files, is the relative position of the loops to each other. Here one can fill in this information giving a simple list of offsets in positive x direction (all loops (midpoints) are placed at y=0 and z=0). Expect one float per used loop by the data file or raises an error. Ignored if None and multiple loops are found (in this case no loops are build at all). Coincident measurements do not require this, x is set to 0 by default.
  • segments (integer [ 80 ]) – Number of dipoles used to auto build the loops. Ignored if build_loops is False or not given any x_offsets.
  • max_length (float [ None ]) – Maximum length of a dipole when auto generating the loops. Overrides segments. Ignored if build_loops is False or not given any x_offsets.
loadMRSD_h5(filename, remove_df=True, build_loops=False, x_offsets=None, segments=80, max_length=None, tx=None, rx=None, fids=None, debug=False)[source]

See loadMRSD instead.

loadMRSD_mat(filename, remove_df=True, build_loops=False, x_offsets=None, segments=80, max_length=None, tx=None, rx=None, fids=None, debug=False)[source]

See loadMRSD instead.

loadMRSK(filename, tx=None, rx=None, fid=None, set_earth=True, distribute_loop_config=False, x_offsets=None, segments=80, max_length=None, deadtime_device=0.005, min_thk=0, verbose=True, set_df=False)[source]
pulses

Pulse moment vectors gathered from soundings.

response

Complex data cube (pulses * gates) from soundings.

rx_indices

Indices of the used receiver of each sounding.

save(savename, save_loops=True, use_original_loop_names=False)[source]
set1DModel(thk=[], res=[1000.0])[source]

Modifies loop config in terms of primary field resistivity.

setCustemConfig(config, update_loop_configs=True)[source]
setEarth(earth=None, incl=60.0, decl=2.0, mag=4.8e-05, rad=False)[source]

Defines the Earth in terms of inclination, declination and mag.

Parameters:
  • earth (comet.snmr.survey.Earth [ None ]) – Already initialized earth class will be setted. Or created through the other optional arguments.
  • inclination (float [ 60. ]) – Inclination of the earth magnetic field in rad or degree.
  • declination (float [ 2. ]) – Declination of the earth magnetic field in rad or degree.
  • magnitude (float [48000 * 1e-9]) – Magnitude of the earth magnetic field in Tesla.
  • rad (boolean [ False ]) – Input inclination and declination in rad?
setLoopConfig(config, update_loop_configs=True)[source]

Loop config in terms of primary field resistivity and frequency.

setLoops(loops)[source]
setResponse(array)[source]

Set a response array from e.g. an inversion as data set for plotting.

tx_indices

Indices of the used transitter of each sounding.

used_loops
comet.snmr.survey.survey.createLoopFromMRS(looptype, length, xoff, segments=80, max_length=None, turns=1)[source]

Returns a loop class object out of input found in a mrsd or mrsk file.

Parameters:
  • looptype (integer) – Integer in [1, 2, 3, 4], in this range representing circular, square, circular eight, and square eight loop source types. Error for looptype < 1 and > 4.
  • length – Length [m] of one side of the loop, or loop diameter for cicular type.
  • xoff (float) – Offset [m] for loop midpoint in positive x direction.
  • segments (integer [ 80 ]) – Number of segments used for discretization of the loop wire.
  • max_length (integer [ None ]) – If given, replaces the segments with a number suited to ensure each dipole represents this distance [m] at maximum.

Module contents

Module comet/snmr/survey