Field

class emg3d.fields.Field[source]

Bases: numpy.ndarray

Create a Field instance with x-, y-, and z-views of the field.

A Field is an ndarray with additional views of the x-, y-, and z-directed fields as attributes, stored as fx, fy, and fz. The default array contains the whole field, which can be the electric field, the source field, or the residual field, in a 1D array. A Field instance has additionally the property ensure_pec which, if called, ensures Perfect Electric Conductor (PEC) boundary condition. It also has the two attributes amp and pha for the amplitude and phase, as common in frequency-domain CSEM.

A Field can be initiated in three ways:

  1. Field(grid, dtype=np.complex128): Calling it with a emg3d.meshes.TensorMesh instance returns a Field instance of correct dimensions initiated with zeroes of data type dtype.
  2. Field(grid, field): Calling it with a emg3d.meshes.TensorMesh instance and an ndarray returns a Field instance of the provided ndarray, of same data type.
  3. Field(fx, fy, fz): Calling it with three ndarray’s which represent the field in x-, y-, and z-direction returns a Field instance with these views, of same data type.

Sort-order is ‘F’.

Parameters:
fx_or_grid : emg3d.meshes.TensorMesh or ndarray

Either a TensorMesh instance or an ndarray of shape grid.nEx or grid.vnEx. See explanations above. Only mandatory parameter; if the only one provided, it will initiate a zero-field of dtype.

fy_or_field : Field or ndarray, optional

Either a Field instance or an ndarray of shape grid.nEy or grid.vnEy. See explanations above.

fz : ndarray, optional

An ndarray of shape grid.nEz or grid.vnEz. See explanations above.

dtype : dtype, optional

Only used if fy_or_field=None and fz=None; the initiated zero-field for the provided TensorMesh has data type dtype. Default: complex.

freq : float, optional

Source frequency (Hz), used to compute the Laplace parameter s. Either positive or negative:

  • freq > 0: Frequency domain, hence \(s = -\mathrm{i}\omega = -2\mathrm{i}\pi f\) (complex);
  • freq < 0: Laplace domain, hence \(s = f\) (real).

Just added as info if provided.

Attributes Summary

ensure_pec Set Perfect Electric Conductor (PEC) boundary condition.
field Entire field, 1D [fx, fy, fz].
freq Return frequency.
fx View of the x-directed field in the x-direction (nCx, nNy, nNz).
fy View of the field in the y-direction (nNx, nCy, nNz).
fz View of the field in the z-direction (nNx, nNy, nCz).
is_electric Returns True if Field is electric, False if it is magnetic.
smu0 Return s*mu_0; mu_0 = Magn.
sval Return s; s=iw in frequency domain; s=freq in Laplace domain.

Methods Summary

amp() Amplitude of the electromagnetic field.
copy() Return a copy of the Field.
from_dict(inp) Convert dictionary into Field instance.
pha([deg, unwrap, lag]) Phase of the electromagnetic field.
to_dict([copy]) Store the necessary information of the Field in a dict.

Attributes Documentation

ensure_pec

Set Perfect Electric Conductor (PEC) boundary condition.

field

Entire field, 1D [fx, fy, fz].

freq

Return frequency.

fx

View of the x-directed field in the x-direction (nCx, nNy, nNz).

fy

View of the field in the y-direction (nNx, nCy, nNz).

fz

View of the field in the z-direction (nNx, nNy, nCz).

is_electric

Returns True if Field is electric, False if it is magnetic.

smu0

Return s*mu_0; mu_0 = Magn. permeability of free space [H/m].

sval

Return s; s=iw in frequency domain; s=freq in Laplace domain.

Methods Documentation

amp()[source]

Amplitude of the electromagnetic field.

copy()[source]

Return a copy of the Field.

classmethod from_dict(inp)[source]

Convert dictionary into Field instance.

Parameters:
inp : dict

Dictionary as obtained from Field.to_dict(). The dictionary needs the keys field, freq, vnEx, vnEy, and vnEz.

Returns:
obj : Field instance
pha(deg=False, unwrap=True, lag=True)[source]

Phase of the electromagnetic field.

Parameters:
deg : bool

If True the returned phase is in degrees, else in radians. Default is False (radians).

unwrap : bool

If True the returned phase is unwrapped. Default is True (unwrapped).

lag : bool

If True the returned phase is lag, else lead defined. Default is True (lag defined).

to_dict(copy=False)[source]

Store the necessary information of the Field in a dict.