custEM.post package

Submodules

custEM.post.interp_tools_fd module

@author: Rochlitz.R

class custEM.post.interp_tools_fd.FrequencyDomainInterpolator(PP, dg_interpolation, self_mode, fs_type=None)[source]

Bases: custEM.post.interpolation_base.InterpolationBase

Interpolator class for interpolating 3D modeling results on arbitrary meshes, which can be generated using this class as well.

There are four ways of interpolation:

  1. Interpolation is conducted in serial and might take some time, because exported solutions need to be imported again in serial for the serial interpolation. Anyway, multi-threading is automatically used to run several interpolation tasks simultaneously.
  2. Parallel interpolation based on a PETSc transfer matrix. Fields are always interpolated on a discontinous Lagrange VectorFunctionSpace as auxiliary step, but do not require parallel export of the solutions on the computation mesh and serial import afterwards. That can save lots of time and disc space if only results on interpolation positions are of interest.
  3. Function data are evaluated at single single locations (not implemented in this class yet).
  4. Automated parallel interpolation using maunally created interpolation-matrices, see InterpolationBase
  • interpolate()
    this function is a wrapper to call the interpolate_in_serial.py file, which calls the FEniCS interpolation routines.
  • interpolate_parallel()
    parallel interpolation between different function spaces and meshes.
  • export_interpolation_data()
    export interpolated data
export_interpolation_data(field_real, field_imag, V_serial, fi, ti, export_name, export_pvd, aux_h5=False, real_serial=None, imag_serial=None)[source]

Export interpolated results as complex numpy arrays and pvd files to be viewed in Paraview. The flag aux_h5 is used to enable a temorary h5 export for the parallelized interpolation, dumping the interpolated, parallelized FEniCS functions to file. This file is read again in serial to export a conform numpy array. Note, this step requires insignificant effort as functions on the interpolation meshes are usually way smaller than functions defined on the original mesh.

interpolate(interp_meshes, EH=['E_t', 'H_t'], interp_p=None, fs_type=None, dg_interpolation=None, export_name=None, export_pvd=True, interp_dir=None, freqs=None)[source]

Customized interpolation function.

  • quantitiy, type str
    Either E_t, H_t, E_s or H_s.
  • interp_mesh, type str
    name of the mesh to interpolate on.
  • mute = False, type bool
    set True, if info-interpolation messages should not be printed.
  • interp_p = 2, type int
    polyonimal order of interpolation mesh FunctionSpaces
  • fs_type = None, type str
    Specify if source functions are defined on Nedelec (“ned”, default) or Lagrange (“cg”) function spaces
  • dg_interpolation = None, type bool
    set True or False to overwrite self.dg_interpolation for manually enabling discontinuous or continuous interpolation
  • export_name = None, type str
    specify a custom export name of the interpolated data if desired.
  • interp_dir, type str
    specify, if a custom interpolation directory is desired, otherwise, the defualt interpolation directory is located in the corresponding results directory
interpolate_parallel(interp_mesh, quantity, mute=True, interp_p=None, fs_type=None, dg_interpolation=None, export_name=None, export_pvd=True, interp_dir=None, fi=0)[source]

Interpolation in parallel between different function spaces and different meshes. Note that a discontinous Lagrange VectorFunctionSpace might be required as auxiliary step to interpolate between Nedelec and Lagrange spaces.

custEM.post.interp_tools_td module

@author: Rochlitz.R

class custEM.post.interp_tools_td.TimeDomainInterpolator(PP, dg_interpolation, self_mode)[source]

Bases: custEM.post.interpolation_base.InterpolationBase

Interpolator class for interpolating 3D modeling results on arbitrary meshes, which can be generated using this class as well.

DOCS TO BE FILLED

eval_at_rx(rx_positions, rx_name, EH='EH', interp_dir=None, mute=True)[source]

will be added if required, so far no reasonable usage

export_interpolation_data(electric, magnetic, V_serial, t_id, export_name, export_pvd, aux_h5=False, E_serial=None, H_serial=None, EH='EH')[source]

Export interpolated results as complex numpy arrays and pvd files to be viewed in Paraview. The flag aux_h5 is used to enable a temorary h5 export for the parallelized interpolation, dumping the interpolated, parallelized FEniCS functions to file. This file is read again in serial to export a conform numpy array. Note, this step requires insignificant effort as functions on the interpolation meshes are usually way smaller than functions defined on the original mesh.

interpolate(interp_meshes, EH=['E', 'H'], interp_p=None, dg_interp=False, export_pvd=True, interp_dir=None)[source]

Customized interpolation function.

  • interp_mesh, type str
    name of the mesh to interpolate on
  • mute = False, type bool
    set True, if info-interpolation messages should not be printed
  • interp_p = 2, type int
    polyonimal order of basis functions on interpolation mesh
  • interp_dir, type str
    specify, if a custom interpolation directory is desired; otherwise, the defualt interpolation directory is located in the corresponding results directory
  • dg_interpolation = None, type bool
    set True or False to overwrite self.dg_interpolation for manually enabling discontinuous or continuous interpolation
interpolate_parallel(interp_mesh, quantity='EH', mute=True, interp_p=None, dg_interp=False, interp_dir=None)[source]

Customized interpolation function.

  • interp_mesh, type str
    name of the mesh to interpolate on.
  • mute = False, type bool
    set True, if info-interpolation messages should not be printed.
  • interp_p = 2, type int
    polyonimal order of interpolation mesh FunctionSpaces
  • interp_dir, type str
    specify, if a custom interpolation directory is desired, otherwise, the defualt interpolation directory is located in the corresponding results directory
  • dg_interpolation = None, type bool
    set True or False to overwrite self.dg_interpolation for manually enabling discontinuous or continuous interpolation

custEM.post.interpolation_base module

@author: Rochlitz.R

class custEM.post.interpolation_base.InterpolationBase(PP, dg_interpolation, self_mode)[source]

Bases: object

Interpolator class for interpolating 3D modeling results on arbitrary meshes, which can be generated using this class as well.

FEniCS does not support interpolation between different meshes in parallel. If not using auto_interpolate during solve_main_problem(), interpolation is conducted in serial and might take some time. Multi-threading is used to run several interpolation tasks simultaneously.

  • update_interpolation_parameters()
    update interpolation parameters such as line or slice information for corresponding mesh generation, if necessary, and interpolation.
  • create_line_mesh()
    create straight line mesh(es) in serial; horizontal lines following topography are supported, which is controlled by the on_topo or on_water_surface flags
  • create_slice_mesh()
    create straight slice mesh(es) in serial, horizontal slices following topography are supported, which is controlled by the on_topo or on_water_surface flags
  • create_path_mesh()
    create path mesh based on list or array of given coordinates in serial; paths following topography are supported, which is controlled by the on_topo or on_water_surface flags
  • create_path_meshes()
    create multiple path meshes at once
  • find_quantity()
    utility function to access field data via strings
  • check_interpolation_meshes()
    check if all interpolation meshes exist before interpolation
  • create_interpolation_matrices()
    create interpolation matrices for auto_interpolate and jacobian computations
  • auto_interpolate_parallel()
    interpolate in parallel on the fly using interpolation matrices
>>> M = MOD('Test_1', 'halfspace_mesh', 'E_t', p=1,
>>>         owerwrite=False, load_existing=False)
>>>
>>> M.IB.create_line_mesh('x', -5e3, 5e3, 400, z=50.)
>>> M.IB.interpolate(
>>>     'E_t', 'x0_-5000.0_x1_5000.0_y_0.0_z_0.0_n_400_topo_line_x')
auto_interpolate_parallel(EH, fi=0)[source]
check_interpolation_meshes(interp_meshes, m_dir, logger)[source]

Utility function to specify interpolation mesh directories and check if every interpolation mesh in the list is valid and exists.

convert_imp_rhoa_tipper(E, H, fi, pi, impedances, rhoa_phase, tipper, npy_files, mat_files, derivatives, ned_coord_system)[source]

Convert E- and H-field to MT quantities.

  • E, H, type numpy array ((2, n_pos, 3))
    Electromagnetic fields for two source polarizations on all receiver positions on the current rx_path
  • fi, type int
    frequency counter
  • pi, type int
    path counter
  • impedances, rhoa_phase, tipper, type bool
    flags to enable or disable corresponding output
  • npy_files, mat_files, type bool
    flags controling output for Python and/or Matlab
convert_mt_data(impedances=True, rhoa_phase=True, tipper=True, npy_files=True, mat_files=False, derivatives=False, ned_coord_system=False)[source]
create_interpolation_matrices(xs, return_mixed=False)[source]
create_line_mesh(axis, start, stop, n_segs, **interp_kwargs)[source]

Create line interpolation meshes. Only lines parallel to the coordinate axes are supported. Topography for horizontal lines is also supported. For arbitrary lines, use the create_path_mesh method.

  • axis, type str
    a string which specifies along which axis a line mesh should be generated, valid values are ‘x’, ‘y’ and ‘z
  • start, stop, type float
    start and stop cooridinates of the line
  • n_segs, type int
    number of equally distributed segments along a line
  • **interp_kwargs,
    see update_interpolation_parameters docs
create_path_mesh(path, suffix=None, rank=None, **interp_kwargs)[source]

Create path interpolation mesh to interpolate on arbitraily distributed points.

  • path, type array of shape (n, 3)
    array containing the 3D points to build the path mesh
  • suffix = ‘’, type str
    exchange the export name ending “path” with something else, e.g., it is useful to name a path mesh like a line mesh for plotting along a coordinate axis later on
  • rank = 0, type int
    use other than root process for multi-threaded serial path mesh generation, e.g., if called from the create_path_meshes method
  • **interp_kwargs,
    see update_interpolation_parameters docs.
create_path_meshes(paths, name=None, names=None, suffix=None, **interp_kwargs)[source]

Create path interpolation mesh to interpolate on arbitraily distributed points.

  • paths, type list
    list containing coordinate arrays to build the path meshes
  • name = None, type str
    specify a single name and use increasing integers ids to name the different path meshes; must be None if names != None
  • names = None, type str
    specify a specific name for each path in the list; must be None if name != None
  • suffix = ‘’, type str
    exchange the export name ending “path” with something else, e.g., it is useful to name a path mesh like a line mesh for plotting along a coordinate axis later on
  • **interp_kwargs,
    see update_interpolation_parameters docs
create_slice_mesh(axis, dim, n_segs, **interp_kwargs)[source]

Create slice interpolation meshes. So far, only slices parallel to the coordinate axes are supported. Topography for z-normal slices is supported as well. Alternatively, use the flexible create_path_mesh method.

  • axis, type str
    a string which specifies along which normal axis a slice mesh should be generated, valid values are ‘x’, ‘y’ and ‘z
  • dim, type float or list of two float
    one float specifies constant dimensions in both slice-parallel directions; a list of two floats specifies different dimensions along the two y/z, x/z or x/y axes for axis=*’x’, *’y’ or ‘z’, respectively.
  • n_segs, type int or list of two int
    one integer specifies an equal number of segments in both slice-parallel directions; a list of two integers specifies a different number of segments along the two y/z, x/z or x/y axes for axis=*’x’, *’y’ or ‘z’, respectively.
  • **interp_kwargs,
    see update_interpolation_parameters docs
export_npy(complex_data, fi, pi, EH, rank=0)[source]
find_quantity(string, fs_type)[source]

Utility function to access dolfin solution functions via a string.

  • string, type str
    Either ‘E_t, ‘E_s’, ‘H_t’ or ‘H_s’.
merge_tx_results(interp_meshes, EH=['E_t', 'H_t'])[source]
update_interpolation_parameters(**interp_kwargs)[source]

update and check given keyword arguments for the Interpolator class.

  • All interpolation parameters can be specified individually when

calling the line - or slice-mesh generation functions. These values are just specified as class attributes to have reasonable default parameters available.

  • x, y, z = 0., type float
    either offset for line interpolation meshes in not-the-axis direction or offset of slice interpolation meshes in slice-normal direction.
  • a_tol = 0.01, type float
    numerical tolerance for cutting the line- or slice interpolation meshes. Does not need to be changed in general.
  • update_print_flag = False, type bool
    define if updated interpolation keyword arguments should be printed or not. By defualt, the latter are not printed when initialzing the class for the first time but afterwards, this flag is set True.
  • self.on_topo = True, type bool
    if the mesh has topography in z-direction, horizontal line or slice interpolation meshes at the surface are automatically adjusted to match the crooked surface or follow the surface with a parallel offset.
  • max_procs = “MPI_SIZE”, type df.MPI.size(df.mpi_comm_world())
    number of parallel processes used during the mpirun call
  • force_create = False,
    if True, overwrite existing interpolation meshes with the same name
  • on_topo = True,
    automatically apply the topography used for the mesh-generation to interpolation meshes following the surface directly or with a constant offset
  • on_water_surface = False,
    if True, ignore bathymetry values (z < 0) when creating interpolation meshes which include a sea domain and use z=0 for corresponding positions instead
  • line_name = None, type str
    specify a custom name for line interpolation meshes
  • slice_name = None, type str
    specify a custom name for slice interpolation meshes
  • path_name = None, type str
    specify a custom name for path interpolation meshes

custEM.post.interpolation_utils module

@author: Rochlitz.R

custEM.post.interpolation_utils.build_line_mesh(IB, axis, start, stop, n_segs, line_name, on_topo)[source]

Generate a 1D line-mesh for interpolation.

see create_line_mesh docs

custEM.post.interpolation_utils.build_path_mesh(IB, points, path_name, on_topo, suffix)[source]

Generate an interpolation mesh for interpolation with an arbitrary list of coordinates.

see create_path_mesh docs

custEM.post.interpolation_utils.build_slice_mesh(IB, axis, dim, n_segs, slice_name, on_topo)[source]

Generate a 2D slice-mesh for interpolation.

see create_slice_mesh docs

custEM.post.plot_tools_fd module

@author: Rochlitz.R

class custEM.post.plot_tools_fd.PlotFD(mod, mesh, approach, **plot_kwargs)[source]

Bases: custEM.post.plot_utils.PlotBase

Plot class for visualization of custEM results.

  • import_line_data()
    load data interpolated on lines.
  • import_slice_data()
    load data interpolated on slices.
  • load_default_line_data()
    import all data interpolated on default coordinate-axes.
  • load_default_slice_data()
    import all data interpolated on default slices orthogonal to the coordinate axes.
  • plot_line_data()
    plot either total or secondary E or H fields component-wise with real and imaginary parts on an observation line.
  • plot_line_errors()
    plot mismatches between two datasets interpolated on the same line or between data and reference solutions component-wise or magnitude with real and imaginary parts on an observation line.
  • plot_slice_data()
    plot either total or secondary E or H fields component-wise with real and imaginary parts on an observation slice.
  • plot_slice_errors()
    plot mismatches between two datasets interpolated on the same slice or between data and reference solutions component-wise or magnitude with real and imaginary parts on an observation slice.
  • add_to_slice_plot()
    plot 2D data in an existing (sub)figure for custom illustrations.
  • add_errors_to_slice_plot()
    plot mismatches of components or field magnitudes of 2D data in an existing (sub)figure for custom illustrations.
  • add_3D_slice_plot()
    adds visulaization of 2D data (e.g., with topography) to an existing (sub)figure as 3D plot.
  • init_main_parameters()
    utility function for the import-functions.
  • init_component_integers()
    utility function for evaulating the correct coordinate directions.
  • calc_pyhed_reference()
    deprecated, might not work anymore, might be re-implemented soon.
  • eval_properties()
    evaluate plot-properties.
  • reduce_slice_data()
    if slice data very interpolated on a grid that is too fine, one could apply a stride (default 1) to reduce the amount of data, otherwise, 2D visualization can become very slow or even crash.
  • print_import_error()
    print warning, if specified data could not be imported
  • get_coords()
    evaluate correct coordinates for 1D or 2D visualization
  • get_coord_names()
    utility function for get_coords()
  • init_cmap()
    initalize colormap (adjust colormap type and range)
  • add_cbar()
    add a proper colorbar to a figure
  • rel_errors(), abs_errors(), ratio()
    calculate relative, absolute errors or ratio between two datasets using the absolute (‘abs’) values of the latter
  • mean_errors(), median_errors()
    calculate **mean* or median of an error distribution using the absolute (‘abs’) values of the latter
  • save_plot()
    save a plot in the save-directory
  • further class-external utility functions are defined at the bottom!
    see description at the bottom
abs_angles(data1, data2, name=None, store=True)[source]

Calculate angles between vectors

abs_errors(data1, data2, name=None, store=True)[source]

Calculate absolute errors / mismatch between two datasets.

add_3D_slice_plot(fig, full_name, slicE, sp_pos=111, fs=12, q_slicE=None, q_name=None, ri='real', cbar=True, EH='E', mesh=None, n_colors=101, q_length=0.2, label=None, c_lim=None, cmap='magma', equal_axis=True, err_type='rel')[source]

Plot 2D EM-data with real 3D geometry (topography) at specified positions in a given figure. In development (there are still some hard coded keyword arguments which need to be made variable!)

  • fig, type matplotlib figure object
    figure to plot in
  • full_name, type str
    full name: a valid key for the dictionary self.slice_data, (characterization via mod or key args. in progress).
  • sliceE, type str
    slice name: a valid key for the dictionary self.slice_coords
  • Most keyword arguments are identical to the ones documented in the plot_line_data(), plot_line_errors(), plot_slice_data() and add_to_slice_plot() functions. Therefore, only new keyword arguments are listed below:
  • q_name = None, type str
    valid key for the dictionary self.slice_data, used to select a dataset for plotting vector arrows with a lower grid/data density than the model specified via full_name for the contour plot.
  • q_sliceE, type str
    valid key for the dictionary self.slice_coord, used to select a dataset for plotting vector arrows with a lower grid/data density than the model specified via slicE for the contour plot.
  • q_length = 0.2, type float
    specify a custom length for all vector arrows.
add_cbar(fig, c_lim, cmap='magma', cmap2=False, pos=[0.9, 0.12, 0.03, 0.75], horizontal=False, pos2=[0.05, 0.12, 0.03, 0.75], diff=0.05, n_colors=101, fs=12, symlog=False, label=None, label_pos=[0.0, 1.02], additional=0, where='left')[source]

Add colorbar to a 2D / 3D data plot at a custom position with custom style options.

add_errors_to_slice_plot(ax, pos, err_key=None, key=None, key2=None, comp='mag', mask=None, ri='real', EH='E', mesh=None, n_colors=101, label=None, fs=12, e_lim=[0.1, 100.0], tcolor='#002C72', cmap=None, equal_axis=True, err_type='rel')[source]

Add a selected dataset, i.e., a specific component, real or imag part, to a subplot specified by a given figure axes object and position. In development (quiver option needs to get variable and no hard coded keyword arguments!)

ax, type matplotlib figure axes object
axes object of a matplotlib figure which might be separated into numerous subplots.
pos, type list of two entried
specify the subplot position of the ax object to plot in.
err_key, type str
specify error data to plot - valid key for one of the dictionaries: self.rel_mag_errors, self.rel_comp_errors, self.abs_mag_errors, self.abs_comp_errors, self.ratio_mag_errors, or self.ratio_comp_errors.
  • All keyword arguments are identical to the ones documented in the plot_line_data(), plot_line_errors(), plot_slice_data() and add_to_slice_plot() functions. Therefore, only new keyword arguments are listed below:
add_phase_bar(fig, pos=[0.9, 0.12, 0.03, 0.75], dummy=False, n_colors=3, fs=12, label='$\\phi$ (°)', p_lim=1.0, horizontal=False, where='left', diff=0.05, label_pos=[0.0, 1.02], delta=False, absdelta=False)[source]

Add colorbar to a 2D / 3D data plot at a custom position with custom style options.

add_to_line_plot(ax, pos, errors=False, mod=None, mod2=None, comp='x', log_scale=None, tcolor='#002C72', ap=False, key=None, key2=None, sf=False, sf2=False, grid=True, ri='real', EH='H', mesh=None, label=None, km=1000.0, llabel=None, fs=12, ylim=[0, 100.0], xlim=[-5.0, 5.0], err_type='rel', **kwargs)[source]

Add either line data or errors to a specific subplot.

  • All keyword arguments are identical to the ones documented in the previous methods.
add_to_slice_plot(ax, pos, comp='mag', ri='real', n_colors=101, mod=None, mesh=None, key=None, EH='E', label=None, fs=12, c_lim=None, sf=False, tcolor='#002C72', horz_only=False, cmap=None, equal_axis=True, quiver=True, title=None, save=True, s_name=None)[source]

Add a selected dataset, i.e., a specific component, real or imag part, to a subplot specified by a given figure axes object and position. In development (quiver option needs to get variable and no hard coded keyword arguments!)

ax, type matplotlib figure axes object
axes object of a matplotlib figure which might be separated into numerous subplots.
pos, type list of two entried
specify the subplot position of the ax object to plot in.
  • Most keyword arguments are identical to the ones documented in the plot_line_data(), plot_line_errors() and plot_slice_data() functions. Therefore, only new keyword arguments are listed below:
  • comp = ‘mag’, type str
    specify if either the ‘x’, ‘y’, ‘z’ component or the magnitude (‘mag’) should be visualized.
  • ri = ‘real’, type str
    plot either ‘real’ or ‘imag’ parts of the data.
  • quiver = True, type bool
    plot vector, this option is not optimized yet and work in progress.
amp_phase_comp(data, name=None, store=True, shift=0.0)[source]

Calculate component-wise amplitudes and phases.

amp_phase_mag(data, name=None, store=True)[source]

Calculate amplitude and phase of vector magnitudes.

import_line_data(linE, mod=None, mesh=None, approach=None, EH='EH', sf=None, path=None, key=None, stride=1, tx=None, freq=None)[source]

import line data from regular line (line-name must end with either “_x”, “_y” or “_z” for x-, y-, z-directed lines, respectively).

  • linE, type str
    name of the line-mesh on which the required data were interpolated
  • mod = None, type str
    specify if a different model than the overall defined self.mod (input when initiallizing Plot instance) should be imported
  • mesh = None, type str
    specify if a different mesh than the overall defined self.mesh (Plot instance) should be imported
  • approach = None, type str
    specify if a different approach than the overall defined self.approach (Plot instance) should be imported
  • EH=’EH’, type str
    Alternatively E or H, of solely electric or magentic fields should be imported
  • sf=False, type bool
    Set True, if secondary fields should be imported instead of total fields
  • path = None, type str
    if non-default interpolation directorys were chosen, specify the path in which the interpolation results are located
  • key = None, type str
    specify a key which can be used all over the Plot class functions to identify the imported data with this name; Otherwise, the name will generated by default (mod + ‘_E_t_on_’ + linE)
  • stride = 1, type int
    downsample observation points; return only every stride-th point
  • tx = None, type int
    if multiple Tx have been computed in the same model, specify which one to import
  • freq = None, type int
    if multiple frequencies have been computed in the same model, specify which one to import
import_point_data(points, mod=None, mesh=None, approach=None, EH='EH', sf=None, path=None, key=None, tx=None, freq=None)[source]

import line data from regular line (line-name must end with either “_x”, “_y” or “_z” for x-, y-, z-directed lines, respectively).

  • points, type str
    name of the path-mesh on which the required data were interpolated
  • mod = None, type str
    specify if a different model than the overall defined self.mod (input when initiallizing Plot instance) should be imported
  • mesh = None, type str
    specify if a different mesh than the overall defined self.mesh (Plot instance) should be imported
  • approach = None, type str
    specify if a different approach than the overall defined self.approach (Plot instance) should be imported
  • EH=’EH’, type str
    Alternatively E or H, of solely electric or magentic fields should be imported
  • sf=False, type bool
    Set True, if secondary fields should be imported instead of total fields
  • path = None, type str
    if non-default interpolation directorys were chosen, specify the path in which the interpolation results are located
  • key = None, type str
    specify a key which can be used all over the Plot class functions to identify the imported data with this name; Otherwise, the name will generated by default (mod + ‘_E_t_on_’ + linE)
  • tx = None, type int
    if multiple Tx have been computed in the same model, specify which one to import
  • freq = None, type int
    if multiple frequencies have been computed in the same model, specify which one to import
import_slice_data(slicE, mod=None, mesh=None, approach=None, EH='EH', sf=None, path=None, key=None, coord_key=None, stride=1, tx=None, freq=None)[source]

import slice data from regular slices (slice-name must end with either “_x”, “_y” or “_z” for x-, y-, z-directed slice-normals, respectively).

  • slicE, type str
    name of the slice-mesh on which required data were interpolated
  • mod = None, type str
    specify if a different model than the overall defined self.mod (input when initiallizing Plot instance) should be imported
  • mesh = None, type str
    specify if a different mesh than the overall defined self.mesh (Plot instance) should be imported
  • approach = None, type str
    specify if a different approach than the overall defined self.approach (Plot instance) should be imported
  • EH=’EH’, type str
    Alternatively E or H, of solely electric or magentic fields should be imported
  • sf=False, type bool
    Set True, if secondary fields should be imported instead of total fields
  • path = None, type str
    if non-default interpolation directorys were chosen, specify the path in which the interpolation results are located
  • key = None, type str
    specify a key which can be used all over the Plot class functions to identify the imported data with this name; Otherwise, the name will generated by default: (mod + ‘_E_t_on_’ + linE)
  • coord_key = None, type str
    specify a coord_key, if interpolated data are imported several times with a different stride, e.g. for ‘contour’ and ‘vector- arorow ‘(plt.contourf and plt.quiver) visualization at the same time. Later on, the underlying data coordinates can be referenced for plotting by these **coord_key**s
  • stride = 1, type int
    specify, if only every *stride*th (e.g., 10th) data point from a dense slice-interpolation mesh should be imported (stride equal in x- and y- direction). Too large 2D datasets make visualization VERY slow and even lead to crashes
  • tx = None, type int
    if multiple Tx have been computed in the same model, specify which one to import
  • freq = None, type int
    if multiple frequencies have been computed in the same model, specify which one to import
load_default_line_data(interp_meshes='small', **kwargs)[source]

laod all or specific line data from a default set of line-interpolation meshes.

  • interp_meshes = ‘small’, type str
    name of the default set of line-interpolation meshes
  • further keyword arguments listed in the import_line_data() docs
load_default_slice_data(interp_meshes='small', **kwargs)[source]

laod all or specific line data from a default set of slice-interpolation meshes.

  • interp_meshes = ‘small’, type str
    name of the default set of slice-interpolation meshes
  • further keyword arguments listed in the import_slice_data() docs
mean_errors(key, comp='mag', err_type='rel')[source]

Calculate Mean of abs(relative errors between two datasets).

median_errors(key, comp='mag', err_type='rel')[source]

Calculate Median of abs(relative errors between two datasets).

plot_line_data(mesh=None, EH='EH', mod=None, s_name=None, km=1000.0, ylim=None, xlim=[-5.0, 5.0], grid=True, sf=False, label=None, legend=True, title=None, sharey=False, ap=False, key=None, new=True, fs=12, save=True, **kwargs)[source]

Plot EM-data (if topo: projected) on 1D straight lines, separated by real and imaginary parts as well as the three vector components. The y-axis is always scaled logarithmically.

  • mesh = None, type str
    specify if data are not based on the same coordinates as the ones of the first dataset imported.
  • EH = ‘EH’, type str
    specify if either both (default) or only E or H fields should be plotted.
  • mod = None, type str
    model name to access data from another model that self.mod which was imported in the same Plot instance for comparison.
  • s_name = None, type str
    specify a custom name for saving plot(s) in self.s_dir. default is title + ‘_’ + mesh + ‘.pdf’
  • km = 1e3, type float
    Automatically convert coordinates from ‘m’ to km’, set to 1. if ‘m’ should be kept or something else.
  • ylim = None, type list with two arguments ‘y_min’ and ‘y_max’
    specify custom amplitude limits if required.
  • xlim = [-5., 5.], type list with two arguments ‘x_min’ and ‘x_max’
    specify custom coordinate limits if required.
  • grid = True, type bool
    switch on grid lines or not.
  • sf = False, type bool
    set True If secondary fields and no total fields of the given model should be visualized.
  • label = None, type str
    specify custom line label if required.
  • legend = True, type bool,
    switch on legend or not.
  • title = None, type str
    specify figure title if required. If s_name is None, title- and mesh-name will be used to autmatically generate a save-name.
  • key = None, type str
    access a certain model via the key if required. This overwrites the mod argument.
  • new = True, type bool
    set to False, if the current data should be added to the last line plot, hence, no new figure will be created.
  • fs = 12, type int
    font size for legend and ticklabels.
  • save = True, type bool
    flag which controls if the figure is saved.
  • **kwargs, type keyword arguments
    additional keyword arguments for plots, e.g., ‘lw’ or ‘color’.
plot_line_errors(mod=None, mod2=None, mesh=None, EH='EH', err_type='rel', key=None, key2=None, km=1000.0, ylim=[0.01, 100.0], new=True, sf=False, sf2=None, log_scale=True, pyhed_ref=False, magnitude=False, label=None, xlim=[-5.0, 5.0], legend=True, fs=12, title=None, save=True, s_name=None, **kwargs)[source]

Plot mismatch between two EM datasets, separated by real and imaginary parts as well as the three vector components.

  • Most keyword arguments are identical to the ones documented in the plot_line_data() function. Therefore, only differing arguments are listed here.
  • mod2 = None, type str
    specify the 2nd model for mismatch calculation.
  • key2 = None, type str
    access the second model via the key if required. This overwrites the mod2 argument.
  • err_type = ‘rel’, type str
    specify which type of errors between both datasets should be used: Either ‘rel’ or ‘abs’ or ‘ratio’.
  • log_scale = False, type bool
    set True for logarithmic error representation.
plot_magnitude_angle_misfits(mod=None, mod2=None, mesh=None, EH='EH', cmap_width=0.9, err_type='rel', key=None, key2=None, n_colors=101, e_lim=[0.1, 100.0], p_lim=10.0, sf=False, fs=12, a_lim=[1e-12, 1.0], label='err [%]', cmap=None, shift=0.0, equal_axis=True, xlim=None, ylim=None, title=None, save=True, s_name=None)[source]

Description!

plot_point_data(mesh=None, EH='EH', mod=None, s_name=None, ylim=None, grid=True, ap=False, sf=False, new=True, label=None, legend=True, title=None, sharey=False, key=None, stations=None, fs=12, save=True, **kwargs)[source]

work in priogress, see also plot_line_data docs

plot_point_errors(mod=None, mod2=None, mesh=None, EH='EH', err_type='rel', key=None, key2=None, ylim=[-100.0, 100.0], new=True, sf=False, sf2=False, log_scale=False, pyhed_ref=False, stations=None, label=None, xlim=[-5.0, 5.0], legend=True, fs=12, title=None, save=True, s_name=None, **kwargs)[source]

Plot mismatch between two EM datasets, separated by real and imaginary parts as well as the three vector components.

  • Most keyword arguments are identical to the ones documented in the plot_line_data() function. Therefore, only differing arguments are listed here.
  • mod2 = None, type str
    specify the 2nd model for mismatch calculation.
  • key2 = None, type str
    access the second model via the key if required. This overwrites the mod2 argument.
  • err_type = ‘rel’, type str
    specify which type of errors between both datasets should be used: Either ‘rel’ or ‘abs’ or ‘ratio’.
  • log_scale = False, type bool
    set True for logarithmic error representation.
plot_slice_data(mesh=None, mod=None, sf=False, km=1.0, ap=False, n_colors=21, EH='EH', label=None, fs=12, c_lim=None, cmap=None, equal_axis=True, xlim=None, ylim=None, key=None, title=None, save=True, s_name=None, shift=0.0, var=None, dummy=True, kk=0)[source]

Plot 2D EM-data (if topo: projected) on straight slices, separated by real and imaginary parts as well as the three vector components. The y-axis is always scaled logarithmically. Amplitudes are represented by the color map.

Most keyword arguments are identical to the ones documented in the plot_line_data() and plot_line_errors() functions. Therefore, only differing arguments are listed here.

  • n_colors = 101, type int

    number of different colors for the colormap

  • cmap = None, type str

    specify a custom matplotlib colormap via string-name. Currently supported: ‘magma’, ‘viridis’ and ‘RdBu_r’ by default: plt.cm.magma is used for E fields,

    plt.cm.virids is used for H fields, plt.cm.RdBu_r is used for error plots

  • c_lim = None, type list with two arguments ‘c_min’ and ‘c_max’

    specify custom amplitude limits if required

  • equal_axis = True, type bool

    set to False for non-equal x- and y-axis aspect ratio

plot_slice_errors(mod=None, mod2=None, mesh=None, EH='EH', err_type='rel', key=None, key2=None, ap=False, n_colors=101, c_lim=[0.1, 100.0], p_lim=1.0, sf=False, fs=12, pyhed_ref=False, mask=None, label='err [%]', cmap=None, equal_axis=True, xlim=None, ylim=None, magnitude=False, shift=0.0, title=None, save=True, s_name=None)[source]

Plot mismatches between two 2D EM-datasets, separated by real and imaginary parts as well as the three vector components. The y-axis is always scaled logarithmically. Amplitudes are represented by the color map.

  • All keyword arguments are identical to the ones documented in the plot_line_data(), plot_line_errors() and plot_slice_data() functions. It is referred to the latter.
ratio(data1, data2, name=None, store=True)[source]

Calculate ratio between two datasets, e.g., primary field magnitudes / secondary field magnitudes.

rel_errors(data1, data2, name=None, store=True)[source]

Calculate relative errors / mismatch between two datasets.

save_plot(EH, title, save, s_name, fs=10, mesh=None, png=False)[source]

custEM.post.plot_tools_td module

@author: Rochlitz.R

class custEM.post.plot_tools_td.PlotTD(mod, mesh, approach, **plot_kwargs)[source]

Bases: custEM.post.plot_utils.PlotBase

Plot class for visualization of custEM results.

!!! IN DEVELOPMENT !!!

import_line_data(linE, mod=None, mesh=None, approach=None, EH='EHdH', shut_off=True, shut_on=False, sf=None, path=None, key=None, stride=1, tx=None, times=None)[source]

custEM.post.plot_utils module

@author: Rochlitz.R

class custEM.post.plot_utils.PlotBase[source]

Bases: object

arrange_line_data(data, comp, step)[source]
calc_pyhed_reference(key, EH='E', line=None, mod=None, config_file=None, mesh=None)[source]

Deprecated! Might be edited for future purposes.

eval_properties(mod, key, label, EH, sf, mesh, line=True, points=False)[source]

Evalute names, labels, field qunatities etc. for all kinds of plots.

general_import(path, quantity, mesh, key, comp=None, stride=1, ckey=None)[source]

General import functions for interpolated results.

get_coords(name, for_pyhed=False)[source]

Initialize coordinates (km) for visualization, depending on the direction of the input line- or slice-mesh.

init_cmap(cmap=None, var='E')[source]

Initialize colormaps for 2D / 3D data visualization.

init_component_integers(string, line=True)[source]

Initializes integer mapping to handel x-, y-, and z-directed line and slice coordinates.

init_main_parameters(mod, mesh, approach, path)[source]

Initializes the most important class attributes.

load_model_parameters(mod=None, mesh=None, approach=None)[source]

Deprecated! Might be edited for future purposes.

print_import_error(field_type, name, path)[source]

Print an import error if a specified dataset for visulaization could not be found.

rearange_point_data(data)[source]
reduce_slice_data(data, comp1, comp2, step)[source]

Apply a stride for importing slice datasets to significantly reduce the amount of data to be plotted later on, if the interpolation mesh was set too dense.

custEM.post.plot_utils.adjust_axes(ax, equal_axis, x_lim=None, y_lim=None, size=3, width=2)[source]

Adjust axis properties (equal resolution for x- and y-coordinates).

custEM.post.plot_utils.adjust_log_ticks(ax, minlog, maxlog, symlog=False, additional=0)[source]

Improve style of ticks and labels of a logarithmic colorbar.

custEM.post.plot_utils.adjust_subfigure_box_axes(ax)[source]

As the title and the comment says…

custEM.post.plot_utils.adjust_ticks_and_labels(ax, remove_top_right=False)[source]
custEM.post.plot_utils.eval_colors(data=None, n_colors=101, c_lim=None, quant=99, symlog=False)[source]

Utility function for properly evaluating colorbar ranges using 99 % quantiles.

custEM.post.plot_utils.make_plain_subfigure_box(height=3, width=2, fs=12, log_scale=True, sharex=True, sharey=True, coord_axis=True)[source]

Create a plain subfigure box for custom illustrations, also used by the default plot functions.

custEM.post.plot_utils.make_subfigure_box(height=3, width=2, fs=12, var=['E', 'E', 'E'], sf=False, log_scale=True, cc='x', ylim=None, err_plot=None, sharex=True, sharey=False, xlim=None, grid=True, sliceplot=False, ap=False, add_km=True, clr=None)[source]

Initialize default fig/ax objects with six or eight subfigures for all kinds of line- and slice-data plots.

Module contents

post

Submodules:

  • interpolation_base for interpolation purposes
  • plot_tools_fd for visualization purposes of frequency-domain data
  • plot_tools_td for visualization purposes of time-domain data