esys.downunder Package¶
Data inversion module built on escript
Classes¶
-
class
esys.downunder.AbstractMinimizer(J=None, m_tol=0.0001, J_tol=None, imax=300)¶ Base class for function minimization methods.
-
__init__(J=None, m_tol=0.0001, J_tol=None, imax=300)¶ Initializes a new minimizer for a given cost function.
- Parameters
J (
CostFunction) – the cost function to be minimizedm_tol (float) – terminate interations when relative change of the level set function is less than or equal m_tol
-
getCostFunction()¶ return the cost function to be minimized
- Return type
-
getOptions()¶ Returns a dictionary of minimizer-specific options.
-
getResult()¶ Returns the result of the minimization.
-
logSummary()¶ Outputs a summary of the completed minimization process to the logger.
-
run(x0)¶ Executes the minimization algorithm for f starting with the initial guess
x0.- Returns
the result of the minimization
-
setCallback(callback)¶ Sets a callback function to be called after every iteration. It is up to the specific implementation what arguments are passed to the callback. Subclasses should at least pass the current iteration number k, the current estimate x, and possibly f(x), grad f(x), and the current error.
-
setCostFunction(J)¶ set the cost function to be minimized
- Parameters
J (
CostFunction) – the cost function to be minimized
-
setMaxIterations(imax)¶ Sets the maximum number of iterations before the minimizer terminates.
-
setOptions(**opts)¶ Sets minimizer-specific options. For a list of possible options see
getOptions().
-
setTolerance(m_tol=0.0001, J_tol=None)¶ Sets the tolerance for the stopping criterion. The minimizer stops when an appropriate norm is less than
m_tol.
-
-
class
esys.downunder.AcousticVelocityMapping(V_prior, Q_prior)¶ Maps a p-velocity and Q-index to slowness square sigma=(V*(1-i*1/(2*Q))^{-2} in the form sigma=e^{Mr+m[0])}*( cos(Mi+m[1])) + i * sin(Mi+m[1])
-
__init__(V_prior, Q_prior)¶ initializes the mapping
- Parameters
V_prior – a-priori p-wave velocity
Q_prior – a-priori Q-index (must be positive)
-
getDerivative(m)¶ returns the value for the derivative of the mapping for m
-
getInverse(s)¶ returns the value of the inverse of the mapping for s
-
getValue(m)¶ returns the value of the mapping for m
-
-
class
esys.downunder.AcousticWaveForm(domain, omega, w, data, F, coordinates=None, fixAtBottom=False, tol=1e-10, saveMemory=True, scaleF=True)¶ Forward Model for acoustic waveform inversion in the frequency domain. It defines a cost function:
- Math
defect = 1/2 integrate( ( w * ( a * u - data ) ) ** 2 )
where w are weighting factors, data are the measured data (as a 2-comp vector of real and imaginary part) for real frequency omega, and u is the corresponding result produced by the forward model. u (as a 2-comp vector) is the solution of the complex Helmholtz equation for frequency omega, source F and complex, inverse, squared p-velocity sigma:
- Math
-u_{ii} - omega**2 * sigma * u = F
It is assumed that the exact scale of source F is unknown and the scaling factor a of F is calculated by minimizing the defect.
-
__init__(domain, omega, w, data, F, coordinates=None, fixAtBottom=False, tol=1e-10, saveMemory=True, scaleF=True)¶ initializes a new forward model with acoustic wave form inversion.
- Parameters
domain (
Domain) – domain of the modelw (
Scalar) – weighting factorsdata (
escript.Dataof shape (2,)) – real and imaginary part of dataF (
escript.Dataof shape (2,)) – real and imaginary part of source given at Dirac points, on surface or at volume.coordinates (
ReferenceSystemorSpatialCoordinateTransformation) – defines coordinate system to be used (not supported yet)tol (positive
float) – tolerance of underlying PDEsaveMemory (
bool) – if true stiffness matrix is deleted after solution of PDE to minimize memory requests. This will require more compute time as the matrix needs to be reallocated.scaleF (
bool) – if true source F is scaled to minimize defect.fixAtBottom (
bool) – if true pressure is fixed to zero at the bottom of the domain
-
getArguments(sigma)¶ Returns precomputed values shared by
getDefect()andgetGradient().- Parameters
sigma (
escript.Dataof shape (2,)) – a suggestion for complex 1/V**2- Returns
solution, uTar, uTai, uTu
- Return type
escript.Dataof shape (2,), 3 xfloat
-
getCoordinateTransformation()¶ returns the coordinate transformation being used
- Return type
CoordinateTransformation
-
getDefect(sigma, u, uTar, uTai, uTu)¶ Returns the defect value.
- Parameters
sigma (
escript.Dataof shape (2,)) – a suggestion for complex 1/V**2u (
escript.Dataof shape (2,)) – a u vectoruTar (
float) – equalsintegrate( w * (data[0]*u[0]+data[1]*u[1]))uTai – equals
integrate( w * (data[1]*u[0]-data[0]*u[1]))uTu (
float) – equalsintegrate( w * (u,u))
- Return type
float
-
getDomain()¶ Returns the domain of the forward model.
- Return type
Domain
-
getGradient(sigma, u, uTar, uTai, uTu)¶ Returns the gradient of the defect with respect to density.
- Parameters
sigma (
escript.Dataof shape (2,)) – a suggestion for complex 1/V**2u (
escript.Dataof shape (2,)) – a u vectoruTar (
float) – equalsintegrate( w * (data[0]*u[0]+data[1]*u[1]))uTai – equals
integrate( w * (data[1]*u[0]-data[0]*u[1]))uTu (
float) – equalsintegrate( w * (u,u))
-
getSourceScaling(u)¶ returns the scaling factor s required to rescale source F to minimize defect
|s * u- data|^2- Parameters
u (
escript.Dataof shape (2,)) – value of pressure solution (real and imaginary part)- Return type
complex
-
getSurvey(index=None)¶ Returns the pair (data, weight)
If argument index is ignored.
-
rescaleWeights(scale=1.0, sigma_scale=1.0)¶ rescales the weights such that
- Math
integrate( ( w omega**2 * sigma_scale * data * ((1/L_j)**2)**-1) +1 )/(data*omega**2 * ((1/L_j)**2)**-1) * sigma_scale )=scale
- Parameters
scale (positive
float) – scale of data weighting factorssigma_scale (
Scalar) – scale of 1/vp**2 velocity.
-
setUpPDE()¶ Creates and returns the underlying PDE.
- Return type
lpde.LinearPDE
-
class
esys.downunder.ArithmeticTuple(*args)¶ Tuple supporting inplace update x+=y and scaling x=a*y where
x,yis an ArithmeticTuple andais a float.Example of usage:
from esys.escript import Data from numpy import array a=eData(...) b=array([1.,4.]) x=ArithmeticTuple(a,b) y=5.*x
-
__init__(*args)¶ Initializes object with elements
args.- Parameters
args – tuple of objects that support inplace add (x+=y) and scaling (x=a*y)
-
-
class
esys.downunder.BoundedRangeMapping(s_min=0, s_max=1)¶ Maps an unbounded parameter to a bounded range. The mapping is smooth and continuous.
-
__init__(s_min=0, s_max=1)¶ Initialize self. See help(type(self)) for accurate signature.
-
getDerivative(m)¶ returns the value for the derivative of the mapping for m
-
getInverse(s)¶ returns the value of the inverse of the mapping for s
-
getValue(m)¶ returns the value of the mapping for m
-
-
class
esys.downunder.CartesianReferenceSystem(name='CARTESIAN')¶ Identifies the Cartesian coordinate system
-
__init__(name='CARTESIAN')¶ set up Cartesian coordinate system
-
createTransformation(domain)¶ creates an appropriate coordinate transformation on a given domain
- Parameters
domain (
esys.escript.AbstractDomain) – domain of transformation- Return type
-
isCartesian()¶ returns if the reference system is Cartesian
- Return type
bool
-
isTheSame(other)¶ test if argument
otherdefines the same reference system- Parameters
other (
ReferenceSystem) – a second reference system- Returns
Trueifotheris aCartesianReferenceSysteminstance.- Return type
bool- Note
every two
CartesianReferenceSysteminstances are considered as being the same.
-
-
class
esys.downunder.CostFunction¶ A function f(x) that can be minimized (base class).
Example of usage:
cf=DerivedCostFunction() # ... calculate x ... args=cf.getArguments(x) # this could be potentially expensive! f=cf.getValue(x, *args) # ... it could be required to update x without using the gradient... # ... but then ... gf=cf.getGradient(x, *args)
The class distinguishes between the representation of the solution x (x-type) and the gradients (r-type).
- Note
The provides_inverse_Hessian_approximation class member should be set to
Truein subclasses that provide a valid implementation ofgetInverseHessianApproximation()
-
__init__()¶ Constructor. Initializes logger.
-
getArguments(x)¶ returns precalculated values that are shared in the calculation of f(x) and grad f(x) and the Hessian operator. The default implementation returns an empty tuple.
Note
The tuple returned by this call will be passed back to this
CostFunctionin other calls(eg:getGradient). Its contents are not specified at this level because no code, other than theCostFunctionwhich created it, will be interacting with it. That is, the implementor can put whatever information they find useful in it.- Parameters
x (x-type) – location of derivative
- Return type
tuple
-
getDualProduct(x, r)¶ returns the dual product of
xandr- Return type
float
-
getGradient(x, *args)¶ returns the gradient of f at x using the precalculated values for x.
- Parameters
x (x-type) – location of derivative
args – pre-calculated values for
xfromgetArguments()
- Return type
r-type
-
getInverseHessianApproximation(x, r, *args)¶ returns an approximative evaluation p of the inverse of the Hessian operator of the cost function for a given gradient r at a given location x: H(x) p = r
- Parameters
x (x-type) – location of Hessian operator to be evaluated
r (r-type) – a given gradient
args – pre-calculated values for
xfromgetArguments()
- Return type
x-type
- Note
In general it is assumed that the Hessian H(x) needs to be calculated in each call for a new location x. However, the solver may suggest that this is not required, typically when the iteration is close to completeness.
- Note
Subclasses that implement this method should set the class variable
provides_inverse_Hessian_approximationtoTrueto enable the solver to call this method.
-
getNorm(x)¶ returns the norm of
x- Return type
float
-
getValue(x, *args)¶ returns the value f(x) using the precalculated values for x.
- Parameters
x (x-type) – a solution approximation
- Return type
float
-
provides_inverse_Hessian_approximation= False¶
-
updateHessian()¶ notifies the class that the Hessian operator needs to be updated. This method is called by the solver class.
-
class
esys.downunder.DataSource(reference_system=None, tags=[])¶ A class that provides survey data for the inversion process. This is an abstract base class that implements common functionality. Methods to be overwritten by subclasses are marked as such. This class assumes 2D data which is mapped to a slice of a 3D domain. For other setups override the methods as required.
-
__init__(reference_system=None, tags=[])¶ Constructor. Sets some defaults and initializes logger.
- Parameters
tags (
listof almost any type (typicallystr)) – a list of tags associated with the data set.reference_system (
NoneorReferenceSystem) – the reference coordinate system
-
ACOUSTIC= 2¶
-
GRAVITY= 0¶
-
MAGNETIC= 1¶
-
MT= 3¶
-
getDataExtents()¶ returns a tuple of tuples
( (x0, y0), (nx, ny), (dx, dy) ), wherex0,y0= coordinates of data originnx,ny= number of data points in x and ydx,dy= spacing of data points in x and y
This method must be implemented in subclasses.
-
getDataType()¶ Returns the type of survey data managed by this source. Subclasses must return
GRAVITYorMAGNETICorACOUSTICas appropriate.
-
getHeightScale()¶ returns the height scale factor to convert from meters to the appropriate units of the reference system used.
- Return type
float
-
getReferenceSystem()¶ returns the reference coordinate system
- Return type
-
getSubsamplingFactor()¶ Returns the subsampling factor that was set via
setSubsamplingFactor(see there).
-
getSurveyData(domain, origin, NE, spacing)¶ This method is called by the
DomainBuilderto retrieve the survey data asDataobjects on the given domain.Subclasses should return one or more
Dataobjects with survey data interpolated on the givenescriptdomain. The exact return type depends on the type of data.- Parameters
domain (
esys.escript.Domain) – the escript domain to useorigin (
tupleorlist) – the origin coordinates of the domainNE (
tupleorlist) – the number of domain elements in each dimensionspacing (
tupleorlist) – the cell sizes (node spacing) in the domain
-
getTags()¶ returns the list of tags
- Return type
list
-
getUtmZone()¶ All data source coordinates are converted to UTM (Universal Transverse Mercator) in order to have useful domain extents. Subclasses should implement this method and return the UTM zone number of the projected coordinates.
-
hasTag(tag)¶ returns true if the data set has tag
tag- Return type
bool
-
setSubsamplingFactor(f)¶ Sets the data subsampling factor (default=1).
The factor is applied in all dimensions. For example a 2D dataset with 300 x 150 data points will be reduced to 150 x 75 when a subsampling factor of 2 is used. This becomes important when adding data of varying resolution to a
DomainBuilder.
-
-
class
esys.downunder.DcRes(domain, locator, delphiIn, sampleTags, phiPrimary, sigmaPrimary, w=1.0, coordinates=None, tol=1e-08, saveMemory=True, b=None)¶ Forward Model for DC resistivity, with a given source pair. The cost function is defined as:
- Math
defect = 1/2 (sum_s sum_pq w_pqs * ((phi_sp-phi_sq)-v_pqs)**2
-
__init__(domain, locator, delphiIn, sampleTags, phiPrimary, sigmaPrimary, w=1.0, coordinates=None, tol=1e-08, saveMemory=True, b=None)¶ setup new forward model
- Parameters
domain – the domain of the model
locator – contains locator to the measurement pairs
sampleTags (list of tuples) – tags of measurement points from which potential differences will be calculated.
phiPrimary (
Scalar) – primary potential.
- Type
escript domain
- Type
listofLocator- Param
delphiIn: this is v_pq, the potential difference for the current source and a set of measurement pairs. A list of measured potential differences is expected. Note this should be the secondary potential only.
-
getArguments(sigma)¶ Returns precomputed values shared by
getDefect()andgetGradient().- Parameters
sigma (
Dataof shape (1,)) – conductivity- Returns
phi
- Return type
Dataof shape (1,)
-
getCoordinateTransformation()¶ returns the coordinate transformation being used
- Return type
CoordinateTransformation
-
getDefect(sigma, phi, loc_phi)¶ Returns the defect value.
- Parameters
sigma (
Dataof shape (1,)) – a suggestion for conductivityphi (
Dataof shape (1,)) – potential field
- Return type
float
-
getDomain()¶ Returns the domain of the forward model.
- Return type
Domain
-
getGradient(sigma, phi, loc_phi)¶ Returns the gradient of the defect with respect to density.
- Parameters
sigma (
Dataof shape (1,)) – a suggestison for conductivityphi (
Dataof shape (1,)) – potential field
-
getPrimaryPotential()¶ returns the primary potential :rtype:
Data
-
class
esys.downunder.DcResistivityForward¶ This class allows for the solution of dc resistivity forward problems via the calculation of a primary and secondary potential. Conductivity values are to be provided for the primary problem which is a homogeneous half space of a chosen conductivity and for the secondary problem which typically varies it conductivity spatially across the domain. The primary potential acts as a reference point typically based of some know reference conductivity however any value will suffice. The primary potential is implemented to avoid the use of dirac delta functions.
-
__init__()¶ This is a skeleton class for all the other forward modeling classes.
-
checkBounds()¶
-
getApparentResistivity()¶
-
getElectrodes()¶ retuns the list of electrodes with locations
-
getPotential()¶
-
-
class
esys.downunder.DensityMapping(domain, z0=None, rho0=None, drho=None, beta=None)¶ Density mapping with depth weighting
rho = rho0 + drho * ( (x_2 - z0)/l_z)^(beta/2) ) * m
-
__init__(domain, z0=None, rho0=None, drho=None, beta=None)¶ initializes the mapping
- Parameters
domain (
Domain) – domain of the mappingz0 (scalar) – depth weighting offset. If not present no depth scaling is applied.
rho0 (scalar) – reference density, defaults to 0
drho (scalar) – density scale. By default density of granite = 2750kg/m**3 is used.
beta (
float) – depth weighting exponent, defaults to 2
-
-
class
esys.downunder.DipoleDipoleSurvey(domain, primaryConductivity, secondaryConductivity, current, a, n, midPoint, directionVector, numElectrodes)¶ DipoleDipoleSurvey forward modeling
-
__init__(domain, primaryConductivity, secondaryConductivity, current, a, n, midPoint, directionVector, numElectrodes)¶ This is a skeleton class for all the other forward modeling classes.
-
getApparentResistivityPrimary()¶
-
getApparentResistivitySecondary()¶
-
getApparentResistivityTotal()¶
-
getPotential()¶ Returns 3 list each made up of a number of list containing primary, secondary and total potentials diferences. Each of the lists contain a list for each value of n.
-
-
class
esys.downunder.DomainBuilder(dim=3, reference_system=None)¶ This class is responsible for constructing an escript Domain object with suitable extents and resolution for survey data (
DataSourceobjects) that are added to it.The domain covers a region above and below the Earth surface. The East-West direction is used as the x- or longitudinal or x[0] direction, the North-South direction is used as the y- or latitudinal or x[1] direction, the vertical direction is denoted by z or radial or x[2] direction. The corresponding terms are used synonymously.
-
__init__(dim=3, reference_system=None)¶ Constructor.
- Parameters
dim (
int) – Dimensionality (2 or 3) of the target domain. This has implications for the survey data than can be added. By default a 3D domain is created.reference_system (
ReferenceSystem) – reference coordinate system. By default the Cartesian coordinate system is used.
-
addSource(source)¶ Adds a survey data provider to the domain builder. An exception is raised if the domain has already been built. An exception is also reported if the reference system used is cartesian and the UTM zone of
sourcedoes not match the UTM zone of sources already added to the domain builder (see Inversion Cookbook for more information). The dimensionality of the data source must be compatible with this domain builder. That is, the dimensionality of the data must be one less than the dimensionality of the domain (specified in the constructor).- Parameters
source (
DataSource) – The data source to be added. Its reference system needs to match the reference system of the DomainBuilder.
-
fixDensityBelow(depth=None)¶ Defines the depth below which the density anomaly is set to a given value. If no value is given zero is assumed.
- Parameters
depth (
float) – depth below which the density is fixed. If not set, no constraint at depth is applied.
-
fixSusceptibilityBelow(depth=None)¶ Defines the depth below which the susceptibility anomaly is set to a given value. If no value is given zero is assumed.
- Parameters
depth (
float) – depth below which the susceptibility is fixed. If not set, no constraint at depth is applied.
-
fixVelocityBelow(depth=None)¶ Defines the depth below which the velocity and Q index is set to a given value. If no value is given zero is assumed.
- Parameters
depth (
float) – depth below which the velocity is fixed. If not set, no constraint at depth is applied.
-
getBackgroundMagneticFluxDensity()¶ Returns the background magnetic flux density.
-
getDomain()¶ Returns a domain that spans the data area plus padding.
The domain is created the first time this method is called, subsequent calls return the same domain so anything that affects the domain (such as padding) needs to be set beforehand.
- Returns
The escript domain for this data source
- Return type
-
getGravitySurveys()¶ Returns a list of gravity surveys, see
getSurveysfor details.
-
getMagneticSurveys()¶ Returns a list of magnetic surveys, see
getSurveysfor details.
-
getReferenceSystem()¶ returns the reference coordinate system
- Return type
-
getSetDensityMask()¶ Returns the density mask data object which is non-zero for cells whose density value is fixed, zero otherwise.
-
getSetSusceptibilityMask()¶ Returns the susceptibility mask data object which is non-zero for cells whose susceptibility value is fixed, zero otherwise.
-
getSurveys(datatype, tags=None)¶ Returns a list of
Dataobjects for all surveys of typedatatypeavailable to this domain builder. If a list oftagsis given only data sources whose tag matches the tag list are returned.- Returns
List of surveys which are tuples (anomaly,error).
- Return type
list
-
getTags()¶ returns a list of all tags in use by the attached data sources. The list may be empty.
-
setBackgroundMagneticFluxDensity(B)¶ Sets the background magnetic flux density B=(B_East, B_North, B_Vertical)
-
setElementPadding(pad_x=None, pad_y=None, pad_lat=None, pad_lon=None)¶ Sets the amount of padding around the dataset in number of elements (cells).
When the domain is constructed
pad_x(pad_y) elements are added on each side of the x- (y-) dimension. The arguments must be non-negative.- Parameters
pad_x (
int) – Padding per side in x direction (default: no padding)pad_y (
int) – Padding per side in y direction (default: no padding)
- Note
pad_yis ignored for 2-dimensional datasets.
-
setFractionalPadding(pad_x=None, pad_y=None, pad_lat=None, pad_lon=None)¶ Sets the amount of padding around the dataset as a fraction of the dataset side lengths.
For example, calling
setFractionalPadding(0.2, 0.1)with a data source of size 10x20 will result in the padded data set size 14x24 (10*(1+2*0.2), 20*(1+2*0.1))- Parameters
pad_x (
float) – Padding per side in x direction (default: no padding)pad_y (
float) – Padding per side in y direction (default: no padding)pad_lat (
float) – Padding per side in latitudinal direction (default: no padding)pad_lon (
float) – Padding per side in longitudinal direction (default: no padding)
- Note
pad_yis ignored for 2-dimensional domains.
-
setGeoPadding(pad_lat=None, pad_lon=None)¶ Sets the amount of padding around the dataset in longitude and latitude.
The final domain size will be the extent in the latitudinal (in longitudinal) direction of the dataset plus twice the value of
pad_lat(pad_lon). The arguments must be non-negative.- Parameters
pad_lat (
floatin units of degree) – Padding per side in latitudinal direction (default: 0)pad_lon (
floatin units of degree) – Padding per side in longitudinal direction (default: 0)
- Note
pad_lonis ignored for 2-dimensional domains.- Note
this function can only be used if the reference system is not Cartesian
-
setPadding(pad_x=None, pad_y=None, pad_lat=None, pad_lon=None)¶ Sets the amount of padding around the dataset in absolute length units.
The final domain size will be the length in x (in y) of the dataset plus twice the value of
pad_x(pad_y). The arguments must be non-negative.- Parameters
pad_x (
floatin units of length (meter)) – Padding per side in x direction (default: no padding)pad_y (
floatin units of length (meter)) – Padding per side in y direction (default: no padding)
- Note
pad_yis ignored for 2-dimensional domains.- Note
this function can only be used if the reference system is Cartesian
-
setVerticalExtents(depth=40000.0, air_layer=10000.0, num_cells=25)¶ This method sets the target domain parameters for the vertical dimension.
- Parameters
depth (
float) – Depth of the domain (in meters)air_layer (
float) – Depth of the layer above sea level (in meters)num_cells (
int) – Number of domain elements for the entire vertical dimension
-
-
class
esys.downunder.ErMapperData(data_type, headerfile, datafile=None, altitude=0.0, error=None, scale_factor=None, null_value=None, reference_system=None)¶ Data Source for ER Mapper raster data. Note that this class only accepts a very specific type of ER Mapper data input and will raise an exception if other data is found.
-
__init__(data_type, headerfile, datafile=None, altitude=0.0, error=None, scale_factor=None, null_value=None, reference_system=None)¶ - Parameters
data_type (
int) – type of data, must beGRAVITYorMAGNETICheaderfile (
str) – ER Mapper header file (usually ends in .ers)datafile (
str) – ER Mapper binary data file name. If not supplied the name of the header file without ‘.ers’ is assumedaltitude (
float) – altitude of measurements above ground in meterserror (
float) – constant value to use for the data uncertainties. If a value is supplied, it is scaled by the same factor as the measurements. If not provided the error is assumed to be 2 units for all measurements (i.e. 0.2 mGal and 2 nT for gravity and magnetic, respectively)scale_factor (
float) – the measurements and error values are scaled by this factor. By default, gravity data is assumed to be given in 1e-6 m/s^2 (0.1 mGal), while magnetic data is assumed to be in 1e-9 T (1 nT).null_value (
float) – value that is used in the file to mark undefined areas. This information is usually included in the file.reference_system (
ReferenceSystem) – reference coordinate system to be used. For a Cartesian reference (default) the appropriate UTM transformation is applied.
- Note
consistence in the reference coordinate system and the reference coordinate system used in the data source is not checked.
-
getDataExtents()¶ returns ( (x0, y0), (nx, ny), (dx, dy) )
-
getDataType()¶ Returns the type of survey data managed by this source. Subclasses must return
GRAVITYorMAGNETICorACOUSTICas appropriate.
-
getSurveyData(domain, origin, NE, spacing)¶ This method is called by the
DomainBuilderto retrieve the survey data asDataobjects on the given domain.Subclasses should return one or more
Dataobjects with survey data interpolated on the givenescriptdomain. The exact return type depends on the type of data.- Parameters
domain (
esys.escript.Domain) – the escript domain to useorigin (
tupleorlist) – the origin coordinates of the domainNE (
tupleorlist) – the number of domain elements in each dimensionspacing (
tupleorlist) – the cell sizes (node spacing) in the domain
-
getUtmZone()¶ All data source coordinates are converted to UTM (Universal Transverse Mercator) in order to have useful domain extents. Subclasses should implement this method and return the UTM zone number of the projected coordinates.
-
-
class
esys.downunder.ForwardModel¶ An abstract forward model that can be plugged into a cost function. Subclasses need to implement
getDefect(),getGradient(), and possiblygetArguments()and ‘getCoordinateTransformation’.-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
-
getArguments(x)¶
-
getCoordinateTransformation()¶
-
getDefect(x, *args)¶
-
getGradient(x, *args)¶
-
-
class
esys.downunder.ForwardModelWithPotential(domain, w, data, coordinates=None, fixPotentialAtBottom=False, tol=1e-08)¶ Base class for a forward model using a potential such as magnetic or gravity. It defines a cost function:
defect = 1/2 sum_s integrate( ( weight_i[s] * ( r_i - data_i[s] ) )**2 )
where s runs over the survey, weight_i are weighting factors, data_i are the data, and r_i are the results produced by the forward model. It is assumed that the forward model is produced through postprocessing of the solution of a potential PDE.
-
__init__(domain, w, data, coordinates=None, fixPotentialAtBottom=False, tol=1e-08)¶ initializes a new forward model with potential.
- Parameters
domain (
Domain) – domain of the modelw (
Vectoror list ofVector) – data weighting factorsdata (
Vectoror list ofVector) – datacoordinates (
ReferenceSystemorSpatialCoordinateTransformation) – defines coordinate system to be usedfixPotentialAtBottom (
bool) – if true potential is fixed to zero at the bottom of the domain in addition to the top.tol (positive
float) – tolerance of underlying PDE
-
getCoordinateTransformation()¶ returns the coordinate transformation being used
- Return type
CoordinateTransformation
-
getData()¶ Returns the data
- Return type
listofData
-
getDataFunctionSpace()¶ Returns the
FunctionSpaceof the data- Return type
FunctionSpace
-
getDefectGradient(result)¶
-
getDomain()¶ Returns the domain of the forward model.
- Return type
Domain
-
getMisfitWeights()¶ Returns the weights of the misfit function
- Return type
listofData
-
getSurvey(index=None)¶ Returns the pair (data_index, weight_index), where data_i is the data of survey i, weight_i is the weighting factor for survey i. If index is None, all surveys will be returned in a pair of lists.
-
-
class
esys.downunder.FunctionJob(fn, *args, **kwargs)¶ Takes a python function (with only self and keyword params) to be called as the work method
-
__init__(fn, *args, **kwargs)¶ It ignores all of its parameters, except that, it requires the following as keyword arguments
- Variables
domain – Domain to be used as the basis for all
Dataand PDEs in this Job.jobid – sequence number of this job. The first job has id=1
-
work()¶ Need to be overloaded for the job to actually do anthing. A return value of True indicates this job thinks it is done. A return value of False indicates work still to be done
-
-
class
esys.downunder.GeodeticCoordinateTransformation(domain, reference=<esys.downunder.coordinates.GeodeticReferenceSystem object>)¶ A geodetic coordinate transformation
-
__init__(domain, reference=<esys.downunder.coordinates.GeodeticReferenceSystem object>)¶ set up the orthogonal coordinate transformation.
- Parameters
domain (
esys.escript.AbstractDomain) – domain in the domain of the coordinate transformationreference (
ReferenceSystem) – the reference system
-
-
class
esys.downunder.GeodeticReferenceSystem(a=6378137.0, f=0.0033528106647474805, angular_unit=0.017453292519943295, height_unit=1000.0, name='WGS84')¶ Identifies a Geodetic coordinate system
-
__init__(a=6378137.0, f=0.0033528106647474805, angular_unit=0.017453292519943295, height_unit=1000.0, name='WGS84')¶ initializes a geodetic reference system
- Parameters
a (positive
double) – semi-major axis in meterf (non-negative
double, less than one) – flatteningname (
str) – name of the reference systemangular_unit (positive
double) – factor to scale the unit of latitude and longitude to radians.height_unit (positive
double) – factor to scale the unit of latitude and longitude to radians.
-
createTransformation(domain)¶ creates an appropriate coordinate transformation on a given domain
- Parameters
domain (
esys.escript.AbstractDomain) – domain of transformation- Return type
-
getAngularUnit()¶ returns the angular unit
-
getFlattening()¶ returns the flattening
-
getHeightUnit()¶ returns the height unit
-
getSemiMajorAxis()¶ returns the length of semi major axis
-
getSemiMinorAxis()¶ returns the length of semi minor axis
-
isCartesian()¶ returns if the reference system is Cartesian
- Return type
bool
-
isTheSame(other)¶ test if
otherdefines the same reference system- Parameters
other (
ReferenceSystem) – a second reference system- Returns
Trueif other defines then same reference system- Return type
bool
Note
two
GeodeticReferenceSystemare considered to be the same if the use the same semi major axis, the same flattening and the same angular unit.
-
-
class
esys.downunder.GravityInversion(solverclass=None, debug=False, self_demagnetization=False, magnetic_intensity_data=False)¶ Driver class to perform an inversion of Gravity (Bouguer) anomaly data. The class uses the standard
Regularizationclass for a single level set function,DensityMappingmapping, and the gravity forward modelGravityModel.-
__init__(solverclass=None, debug=False, self_demagnetization=False, magnetic_intensity_data=False)¶ creates an instance of an inversion driver.
- Parameters
solverclass ('AbstractMinimizer'.) – class of the solver to be used.
self_demagnetization – if True self-demagnitization is applied.
magnetic_intensity_data – if True magnetic intensity is used in the cost function.
-
setInitialGuess(rho=None)¶ set the initial guess rho for density the inversion iteration. If no rho present then an appropriate initial guess is chosen.
- Parameters
rho (
Scalar) – initial value for the density anomaly.
-
setup(domainbuilder, rho0=None, drho=None, z0=None, beta=None, w0=None, w1=None, rho_at_depth=None)¶ Sets up the inversion parameters from a
DomainBuilder.- Parameters
domainbuilder (
DomainBuilder) – Domain builder object with gravity source(s)rho0 (
floatorScalar) – reference density, seeDensityMapping. If not specified, zero is used.drho (
floatorScalar) – density scale, seeDensityMapping. If not specified, 2750kg/m^3 is used.z0 (
floatorScalar) – reference depth for depth weighting, seeDensityMapping. If not specified, zero is used.beta (
floatorScalar) – exponent for depth weighting, seeDensityMapping. If not specified, zero is used.w0 (
Scalarorfloat) – weighting factor for level set term regularization. If not set zero is assumed.w1 (
Vectoror list offloat) – weighting factor for the gradient term in the regularization. If not set zero is assumedrho_at_depth (
floatorNone) – value for density at depth, seeDomainBuilder.
-
siloWriterCallback(k, x, Jx, g_Jx, norm_dJ=None, norm_dx=None)¶ callback function that can be used to track the solution
- Parameters
k – iteration count
x – current approximation
Jx – value of cost function
g_Jx – gradient of f at x
-
-
class
esys.downunder.GravityModel(domain, w, g, gravity_constant=6.6742e-11, coordinates=None, fixPotentialAtBottom=False, tol=1e-08)¶ Forward Model for gravity inversion as described in the inversion cookbook.
-
__init__(domain, w, g, gravity_constant=6.6742e-11, coordinates=None, fixPotentialAtBottom=False, tol=1e-08)¶ Creates a new gravity model on the given domain with one or more surveys (w, g).
- Parameters
domain (
Domain) – domain of the modelw (
Vectoror list ofVector) – data weighting factorsg (
Vectoror list ofVector) – gravity anomaly datacoordinates (ReferenceSystem` or
SpatialCoordinateTransformation) – defines coordinate system to be usedtol (positive
float) – tolerance of underlying PDEfixPotentialAtBottom (
bool) – if true potential is fixed to zero at the base of the domain in addition to the top
- Note
It is advisable to call rescaleWeights() to rescale weights before starting the inversion.
-
getArguments(rho)¶ Returns precomputed values shared by
getDefect()andgetGradient().- Parameters
rho (
Scalar) – a suggestion for the density distribution- Returns
gravity potential and corresponding gravity field.
- Return type
Scalar,Vector
-
getDefect(rho, phi, gravity_force)¶ Returns the value of the defect
- Parameters
rho (
Scalar) – density distributionphi (
Scalar) – corresponding potentialgravity_force (
Vector) – gravity force
- Return type
float
-
getGradient(rho, phi, gravity_force)¶ Returns the gradient of the defect with respect to density.
- Parameters
rho (
Scalar) – density distributionphi (
Scalar) – corresponding potentialgravity_force (
Vector) – gravity force
- Return type
Scalar
-
getPotential(rho)¶ Calculates the gravity potential for a given density distribution.
- Parameters
rho (
Scalar) – a suggestion for the density distribution- Returns
gravity potential
- Return type
Scalar
-
rescaleWeights(scale=1.0, rho_scale=1.0)¶ rescales the weights such that
sum_s integrate( ( w_i[s] *g_i[s]) (w_j[s]*1/L_j) * L**2 * 4*pi*G*rho_scale )=scale
- Parameters
scale (positive
float) – scale of data weighting factorsrho_scale (
Scalar) – scale of density.
-
-
class
esys.downunder.HTIWave(domain, v_p, v_s, wavelet, source_tag, source_vector=[1.0, 0.0, 0.0], eps=0.0, gamma=0.0, delta=0.0, rho=1.0, dt=None, u0=None, v0=None, absorption_zone=None, absorption_cut=0.01, lumping=True, disable_fast_assemblers=False)¶ Solving the HTI wave equation (along the x_0 axis)
- Note
In case of a two dimensional domain a horizontal domain is considered, i.e. the depth component is dropped.
-
__init__(domain, v_p, v_s, wavelet, source_tag, source_vector=[1.0, 0.0, 0.0], eps=0.0, gamma=0.0, delta=0.0, rho=1.0, dt=None, u0=None, v0=None, absorption_zone=None, absorption_cut=0.01, lumping=True, disable_fast_assemblers=False)¶ initialize the VTI wave solver
- Parameters
domain (
Domain) – domain of the problemv_p (
escript.Scalar) – vertical p-velocity fieldv_s (
escript.Scalar) – vertical s-velocity fieldwavelet (
Wavelet) – wavelet to describe the time evolution of source termsource_tag ('str' or 'int') – tag of the source location
source_vector – source orientation vector
eps – first Thompsen parameter
delta – second Thompsen parameter
gamma – third Thompsen parameter
rho – density
dt – time step size. If not present a suitable time step size is calculated.
u0 – initial solution. If not present zero is used.
v0 – initial solution change rate. If not present zero is used.
absorption_zone – thickness of absorption zone
absorption_cut – boundary value of absorption decay factor
lumping – if True mass matrix lumping is being used. This is accelerates the computing but introduces some diffusion.
disable_fast_assemblers – if True, forces use of slower and more general PDE assemblers
-
setQ(q)¶ sets the PDE q value
- Parameters
q – the value to set
-
class
esys.downunder.InversionCostFunction(regularization, mappings, forward_models)¶ Class to define cost function J(m) for inversion with one or more forward models based on a multi-valued level set function m:
J(m) = J_reg(m) + sum_f mu_f * J_f(p)
where J_reg(m) is the regularization and cross gradient component of the cost function applied to a level set function m, J_f(p) are the data defect cost functions involving a physical forward model using the physical parameter(s) p and mu_f is the trade-off factor for model f.
A forward model depends on a set of physical parameters p which are constructed from components of the level set function m via mappings.
- Example 1 (single forward model):
m=Mapping() f=ForwardModel() J=InversionCostFunction(Regularization(), m, f)
- Example 2 (two forward models on a single valued level set)
m0=Mapping() m1=Mapping() f0=ForwardModel() f1=ForwardModel()
J=InversionCostFunction(Regularization(), mappings=[m0, m1], forward_models=[(f0, 0), (f1,1)])
- Example 3 (two forward models on 2-valued level set)
m0=Mapping() m1=Mapping() f0=ForwardModel() f1=ForwardModel()
J=InversionCostFunction(Regularization(self.numLevelSets=2), mappings=[(m0,0), (m1,0)], forward_models=[(f0, 0), (f1,1)])
- Note
If provides_inverse_Hessian_approximation is true, then the class provides an approximative inverse of the Hessian operator.
-
__init__(regularization, mappings, forward_models)¶ constructor for the cost function. Stores the supplied object references and sets default weights.
- Parameters
regularization (
Regularization) – the regularization part of the cost functionmappings (
Mappingorlist) – the mappings to calculate physical parameters from the regularization. This is a list of 2-tuples (map, i) where the first component map defines aMappingand the second component i defines the index of the component of level set function to be used to calculate the mapping. Items in the list may also be justMappingobjects in which case the entire level set function is fed into theMapping(typically used for a single-component level set function.forward_models – the forward models involved in the calculation of the cost function. This is a list of 2-tuples (f, ii) where the first component f defines a
ForwardModeland the second component ii a list of indexes referring to the physical parameters in themappingslist. The 2-tuple can be replaced by aForwardModelif themappingslist has a single entry.forward_models –
ForwardModelorlist
-
createLevelSetFunction(*props)¶ returns an instance of an object used to represent a level set function initialized with zeros. Components can be overwritten by physical properties
props. If present entries must correspond to themappingsarguments in the constructor. UseNonefor properties for which no value is given.
-
getComponentValues(m, *args)¶
-
getDomain()¶ returns the domain of the cost function
- Return type
Domain
-
getForwardModel(idx=None)¶ returns the idx-th forward model.
- Parameters
idx (
int) – model index. If cost function contains one model onlyidxcan be omitted.
-
getNumTradeOffFactors()¶ returns the number of trade-off factors being used including the trade-off factors used in the regularization component.
- Return type
int
-
getProperties(m, return_list=False)¶ returns a list of the physical properties from a given level set function m using the mappings of the cost function.
- Parameters
m (
Data) – level set functionreturn_list (
bool) – ifTruea list is returned.
- Return type
listofData
-
getRegularization()¶ returns the regularization
- Return type
-
getTradeOffFactors(mu=None)¶ returns a list of the trade-off factors.
- Return type
listoffloat
-
getTradeOffFactorsModels()¶ returns the trade-off factors for the forward models
- Return type
floatorlistoffloat
-
provides_inverse_Hessian_approximation= True¶
-
setTradeOffFactors(mu=None)¶ sets the trade-off factors for the forward model and regularization terms.
- Parameters
mu (
listoffloat) – list of trade-off factors.
-
setTradeOffFactorsModels(mu=None)¶ sets the trade-off factors for the forward model components.
- Parameters
mu (
floatin case of a single model or alistoffloatwith the length of the number of models.) – list of the trade-off factors. If not present ones are used.
-
setTradeOffFactorsRegularization(mu=None, mu_c=None)¶ sets the trade-off factors for the regularization component of the cost function, see
Regularizationfor details.- Parameters
mu – trade-off factors for the level-set variation part
mu_c – trade-off factors for the cross gradient variation part
-
updateHessian()¶ notifies the class that the Hessian operator needs to be updated.
-
class
esys.downunder.InversionDriver(solverclass=None, debug=False, self_demagnetization=False, magnetic_intensity_data=False)¶ Base class for running an inversion
-
__init__(solverclass=None, debug=False, self_demagnetization=False, magnetic_intensity_data=False)¶ creates an instance of an inversion driver.
- Parameters
solverclass ('AbstractMinimizer'.) – class of the solver to be used.
self_demagnetization – if True self-demagnitization is applied.
magnetic_intensity_data – if True magnetic intensity is used in the cost function.
-
fixGravityPotentialAtBottom(status=False)¶ indicates to fix the gravity potential at the bottom to zero (in addition to the top)
- Parameters
status (
bool) – if True gravity potential at the bottom is set to zero
-
fixMagneticPotentialAtBottom(status=True)¶ indicates to fix the magnetic potential at the bottom to zero (in addition to the top)
- Parameters
status (
bool) – if True magnetic potential at the bottom is set to zero
-
getCostFunction()¶ returns the cost function of the inversion.
- Return type
‘InversionCostFunction’
-
getDomain()¶ returns the domain of the inversion
- Return type
Domain
-
getLevelSetFunction()¶ returns the level set function as solution of the optimization problem
- Return type
Data
-
getSolver()¶ The solver to be used in the inversion process. See the minimizers module for available solvers. By default, the L-BFGS minimizer is used.
- Return type
‘AbstractMinimizer’.
-
isSetUp()¶ returns True if the inversion is set up and is ready to run.
- Return type
bool
-
run()¶ Executes the inversion.
- Returns
physical parameters as result of the inversion
- Return type
listof physical parameters or a physical parameter
-
setCostFunction(costfunction)¶ sets the cost function of the inversion. This function needs to be called before the inversion iteration can be started.
- Parameters
costfunction ('InversionCostFunction') – domain of the inversion
-
setInitialGuess(*props)¶ Sets the initial guess for the inversion iteration. By default zero is used.
-
setSolverCallback(callback=None)¶ Sets the callback function which is called after every solver iteration.
-
setSolverMaxIterations(maxiter=None)¶ Sets the maximum number of solver iterations to run. If
maxiteris reached the iteration is terminated andMinimizerMaxIterReachedis thrown.- Parameters
maxiter (positive
int) – maximum number of iteration steps.
-
setSolverTolerance(m_tol=None, J_tol=None)¶ Sets the error tolerance for the solver. An acceptable solution is considered to be found once the tolerance is reached.
- Parameters
m_tol (
floatorNone) – tolerance for changes to level set function. IfNonechanges to the level set function are not checked for convergence during iteration.J_tol (
floatorNone) – tolerance for changes to cost function. IfNonechanges to the cost function are not checked for convergence during iteration.
- Note
if both arguments are
Nonethe default setting m_tol=1e-4, J_tol=None is used.
-
-
class
esys.downunder.IsostaticPressure(domain, p0=0.0, level0=0, gravity0=- 9.81, background_density=2670.0, gravity_constant=6.6742e-11, coordinates=None, tol=1e-08)¶ class to calculate isostatic pressure field correction due to gravity forces
-
__init__(domain, p0=0.0, level0=0, gravity0=- 9.81, background_density=2670.0, gravity_constant=6.6742e-11, coordinates=None, tol=1e-08)¶ - Parameters
domain (
Domain) – domain of the modelp0 (scalar
Dataorfloat) – pressure at level0background_density (
float) – defines background_density in kg/m^3coordinates (ReferenceSystem` or
SpatialCoordinateTransformation) – defines coordinate system to be usedtol (positive
float) – tolerance of underlying PDElevel0 (
float) – pressure for z>=`level0` is set to zero.gravity0 (
float) – vertical background gravity atlevel0
-
getPressure(g=None, rho=None)¶ return the pressure for gravity force anomaly
gand density anomalyrho- Parameters
g (
Vector) – gravity anomaly datarho (
Scalar) – gravity anomaly data
- Returns
pressure distribution
- Return type
Scalar
-
-
class
esys.downunder.Job(*args, **kwargs)¶ Describes a sequence of work to be carried out in a subworld. The instances of this class used in the subworlds will be constructed by the system. To do specific work, this class should be subclassed and the work() (and possibly __init__ methods overloaded). The majority of the work done by the job will be in the overloaded work() method. The work() method should retrieve values from the outside using importValue() and pass values to the rest of the system using exportValue(). The rest of the methods should be considered off limits.
-
__init__(*args, **kwargs)¶ It ignores all of its parameters, except that, it requires the following as keyword arguments
- Variables
domain – Domain to be used as the basis for all
Dataand PDEs in this Job.jobid – sequence number of this job. The first job has id=1
-
clearExports()¶ Remove exported values from the map
-
clearImports()¶ Remove imported values from their map
-
declareImport(name)¶ Adds name to the list of imports
-
exportValue(name, v)¶ Make value v available to other Jobs under the label name. name must have already been registered with the SplitWorld instance. For use inside the work() method.
- Variables
name – registered label for exported value
v – value to be imported
-
importValue(name)¶ For use inside the work() method.
- Variables
name – label for imported value.
-
setImportValue(name, v)¶ Use to make a value available to the job (ie called from outside the job)
- Variables
name – label used to identify this import
v – value to be imported
-
work()¶ Need to be overloaded for the job to actually do anthing. A return value of True indicates this job thinks it is done. A return value of False indicates work still to be done
-
-
class
esys.downunder.JointGravityMagneticInversion(solverclass=None, debug=False, self_demagnetization=False, magnetic_intensity_data=False)¶ Driver class to perform a joint inversion of Gravity (Bouguer) and magnetic anomaly data. The class uses the standard
Regularizationclass for two level set functions with cross-gradient correlation,DensityMappingandSusceptibilityMappingmappings, the gravity forward modelGravityModeland the linear magnetic forward modelMagneticModel.-
__init__(solverclass=None, debug=False, self_demagnetization=False, magnetic_intensity_data=False)¶ creates an instance of an inversion driver.
- Parameters
solverclass ('AbstractMinimizer'.) – class of the solver to be used.
self_demagnetization – if True self-demagnitization is applied.
magnetic_intensity_data – if True magnetic intensity is used in the cost function.
-
DENSITY= 0¶
-
SUSCEPTIBILITY= 1¶
-
setInitialGuess(rho=None, k=None)¶ set the initial guess rho for density and k for susceptibility for the inversion iteration.
- Parameters
rho (
Scalar) – initial value for the density anomaly.k (
Scalar) – initial value for the susceptibility anomaly.
-
setup(domainbuilder, rho0=None, drho=None, rho_z0=None, rho_beta=None, k0=None, dk=None, k_z0=None, k_beta=None, w0=None, w1=None, w_gc=None, rho_at_depth=None, k_at_depth=None)¶ Sets up the inversion from an instance
domainbuilderof aDomainBuilder. Gravity and magnetic data attached to thedomainbuilderare considered in the inversion. If magnetic data are given as scalar it is assumed that values are collected in direction of the background magnetic field.- Parameters
domainbuilder (
DomainBuilder) – Domain builder object with gravity source(s)rho0 (
floatorScalar) – reference density, seeDensityMapping. If not specified, zero is used.drho (
floatorScalar) – density scale, seeDensityMapping. If not specified, 2750kg/m^3 is used.rho_z0 (
floatorScalar) – reference depth for depth weighting for density, seeDensityMapping. If not specified, zero is used.rho_beta (
floatorScalar) – exponent for depth weighting for density, seeDensityMapping. If not specified, zero is used.k0 (
floatorScalar) – reference susceptibility, seeSusceptibilityMapping. If not specified, zero is used.dk (
floatorScalar) – susceptibility scale, seeSusceptibilityMapping. If not specified, 2750kg/m^3 is used.k_z0 (
floatorScalar) – reference depth for depth weighting for susceptibility, seeSusceptibilityMapping. If not specified, zero is used.k_beta (
floatorScalar) – exponent for depth weighting for susceptibility, seeSusceptibilityMapping. If not specified, zero is used.w0 (
es.Dataorndarrayof shape (2,)) – weighting factors for level set term regularization, seeRegularization. If not set zero is assumed.w1 (
es.Dataorndarrayof shape (2,DIM)) – weighting factor for the gradient term in the regularization seeRegularization. If not set zero is assumedw_gc (
Scalarorfloat) – weighting factor for the cross gradient term in the regularization, seeRegularization. If not set one is assumedk_at_depth (
floatorNone) – value for susceptibility at depth, seeDomainBuilder.rho_at_depth (
floatorNone) – value for density at depth, seeDomainBuilder.
-
siloWriterCallback(k, x, Jx, g_Jx, norm_dJ=None, norm_dx=None)¶ callback function that can be used to track the solution
- Parameters
k – iteration count
x – current approximation
Jx – value of cost function
g_Jx – gradient of f at x
-
-
class
esys.downunder.LinearMapping(a=1.0, p0=0.0)¶ Maps a parameter by a linear transformation p = a * m + p0
-
__init__(a=1.0, p0=0.0)¶ Initialize self. See help(type(self)) for accurate signature.
-
getDerivative(m)¶ returns the value for the derivative of the mapping for m
-
getInverse(p)¶ returns the value of the inverse of the mapping for s
-
getTypicalDerivative()¶ returns a typical value for the derivative
-
getValue(m)¶ returns the value of the mapping for m
-
-
class
esys.downunder.LinearPDE(domain, numEquations=None, numSolutions=None, isComplex=False, debug=False)¶ This class is used to define a general linear, steady, second order PDE for an unknown function u on a given domain defined through a
Domainobject.For a single PDE having a solution with a single component the linear PDE is defined in the following form:
-(grad(A[j,l]+A_reduced[j,l])*grad(u)[l]+(B[j]+B_reduced[j])u)[j]+(C[l]+C_reduced[l])*grad(u)[l]+(D+D_reduced)=-grad(X+X_reduced)[j,j]+(Y+Y_reduced)
where grad(F) denotes the spatial derivative of F. Einstein’s summation convention, ie. summation over indexes appearing twice in a term of a sum performed, is used. The coefficients A, B, C, D, X and Y have to be specified through
Dataobjects inFunctionand the coefficients A_reduced, B_reduced, C_reduced, D_reduced, X_reduced and Y_reduced have to be specified throughDataobjects inReducedFunction. It is also allowed to use objects that can be converted into suchDataobjects. A and A_reduced are rank two, B, C, X, B_reduced, C_reduced and X_reduced are rank one and D, D_reduced, Y and Y_reduced are scalar.The following natural boundary conditions are considered:
n[j]*((A[i,j]+A_reduced[i,j])*grad(u)[l]+(B+B_reduced)[j]*u)+(d+d_reduced)*u=n[j]*(X[j]+X_reduced[j])+y
where n is the outer normal field. Notice that the coefficients A, A_reduced, B, B_reduced, X and X_reduced are defined in the PDE. The coefficients d and y are each a scalar in
FunctionOnBoundaryand the coefficients d_reduced and y_reduced are each a scalar inReducedFunctionOnBoundary.Constraints for the solution prescribe the value of the solution at certain locations in the domain. They have the form
u=r where q>0
r and q are each scalar where q is the characteristic function defining where the constraint is applied. The constraints override any other condition set by the PDE or the boundary condition.
The PDE is symmetrical if
A[i,j]=A[j,i] and B[j]=C[j] and A_reduced[i,j]=A_reduced[j,i] and B_reduced[j]=C_reduced[j]
For a system of PDEs and a solution with several components the PDE has the form
-grad((A[i,j,k,l]+A_reduced[i,j,k,l])*grad(u[k])[l]+(B[i,j,k]+B_reduced[i,j,k])*u[k])[j]+(C[i,k,l]+C_reduced[i,k,l])*grad(u[k])[l]+(D[i,k]+D_reduced[i,k]*u[k] =-grad(X[i,j]+X_reduced[i,j])[j]+Y[i]+Y_reduced[i]
A and A_reduced are of rank four, B, B_reduced, C and C_reduced are each of rank three, D, D_reduced, X_reduced and X are each of rank two and Y and Y_reduced are of rank one. The natural boundary conditions take the form:
n[j]*((A[i,j,k,l]+A_reduced[i,j,k,l])*grad(u[k])[l]+(B[i,j,k]+B_reduced[i,j,k])*u[k])+(d[i,k]+d_reduced[i,k])*u[k]=n[j]*(X[i,j]+X_reduced[i,j])+y[i]+y_reduced[i]
The coefficient d is of rank two and y is of rank one both in
FunctionOnBoundary. The coefficients d_reduced is of rank two and y_reduced is of rank one both inReducedFunctionOnBoundary.Constraints take the form
u[i]=r[i] where q[i]>0
r and q are each rank one. Notice that at some locations not necessarily all components must have a constraint.
The system of PDEs is symmetrical if
A[i,j,k,l]=A[k,l,i,j]
A_reduced[i,j,k,l]=A_reduced[k,l,i,j]
B[i,j,k]=C[k,i,j]
B_reduced[i,j,k]=C_reduced[k,i,j]
D[i,k]=D[i,k]
D_reduced[i,k]=D_reduced[i,k]
d[i,k]=d[k,i]
d_reduced[i,k]=d_reduced[k,i]
LinearPDEalso supports solution discontinuities over a contact region in the domain. To specify the conditions across the discontinuity we are using the generalised flux J which, in the case of a system of PDEs and several components of the solution, is defined asJ[i,j]=(A[i,j,k,l]+A_reduced[[i,j,k,l])*grad(u[k])[l]+(B[i,j,k]+B_reduced[i,j,k])*u[k]-X[i,j]-X_reduced[i,j]
For the case of single solution component and single PDE J is defined as
J[j]=(A[i,j]+A_reduced[i,j])*grad(u)[j]+(B[i]+B_reduced[i])*u-X[i]-X_reduced[i]
In the context of discontinuities n denotes the normal on the discontinuity pointing from side 0 towards side 1 calculated from
FunctionSpace.getNormalofFunctionOnContactZero. For a system of PDEs the contact condition takes the formn[j]*J0[i,j]=n[j]*J1[i,j]=(y_contact[i]+y_contact_reduced[i])- (d_contact[i,k]+d_contact_reduced[i,k])*jump(u)[k]
where J0 and J1 are the fluxes on side 0 and side 1 of the discontinuity, respectively. jump(u), which is the difference of the solution at side 1 and at side 0, denotes the jump of u across discontinuity along the normal calculated by
jump. The coefficient d_contact is of rank two and y_contact is of rank one both inFunctionOnContactZeroorFunctionOnContactOne. The coefficient d_contact_reduced is of rank two and y_contact_reduced is of rank one both inReducedFunctionOnContactZeroorReducedFunctionOnContactOne. In case of a single PDE and a single component solution the contact condition takes the formn[j]*J0_{j}=n[j]*J1_{j}=(y_contact+y_contact_reduced)-(d_contact+y_contact_reduced)*jump(u)
In this case the coefficient d_contact and y_contact are each scalar both in
FunctionOnContactZeroorFunctionOnContactOneand the coefficient d_contact_reduced and y_contact_reduced are each scalar both inReducedFunctionOnContactZeroorReducedFunctionOnContactOne.Typical usage:
p = LinearPDE(dom) p.setValue(A=kronecker(dom), D=1, Y=0.5) u = p.getSolution()
-
__init__(domain, numEquations=None, numSolutions=None, isComplex=False, debug=False)¶ Initializes a new linear PDE.
- Parameters
domain (
Domain) – domain of the PDEnumEquations – number of equations. If
Nonethe number of equations is extracted from the PDE coefficients.numSolutions – number of solution components. If
Nonethe number of solution components is extracted from the PDE coefficients.debug – if True debug information is printed
-
checkSymmetry(verbose=True)¶ Tests the PDE for symmetry.
- Parameters
verbose (
bool) – if set to True or not present a report on coefficients which break the symmetry is printed.- Returns
True if the PDE is symmetric
- Return type
bool- Note
This is a very expensive operation. It should be used for degugging only! The symmetry flag is not altered.
-
createOperator()¶ Returns an instance of a new operator.
-
getFlux(u=None)¶ Returns the flux J for a given u.
J[i,j]=(A[i,j,k,l]+A_reduced[A[i,j,k,l]]*grad(u[k])[l]+(B[i,j,k]+B_reduced[i,j,k])u[k]-X[i,j]-X_reduced[i,j]
or
J[j]=(A[i,j]+A_reduced[i,j])*grad(u)[l]+(B[j]+B_reduced[j])u-X[j]-X_reduced[j]
- Parameters
u (
Dataor None) – argument in the flux. If u is not present or equalsNonethe current solution is used.- Returns
flux
- Return type
Data
-
getRequiredOperatorType()¶ Returns the system type which needs to be used by the current set up.
-
getResidual(u=None)¶ Returns the residual of u or the current solution if u is not present.
- Parameters
u (
Dataor None) – argument in the residual calculation. It must be representable inself.getFunctionSpaceForSolution(). If u is not present or equalsNonethe current solution is used.- Returns
residual of u
- Return type
Data
-
getSolution()¶ Returns the solution of the PDE.
- Returns
the solution
- Return type
Data
-
getSystem()¶ Returns the operator and right hand side of the PDE.
- Returns
the discrete version of the PDE
- Return type
tupleofOperatorandData
-
insertConstraint(rhs_only=False)¶ Applies the constraints defined by q and r to the PDE.
- Parameters
rhs_only (
bool) – if True only the right hand side is altered by the constraint
-
setValue(**coefficients)¶ Sets new values to coefficients.
- Parameters
coefficients – new values assigned to coefficients
A (any type that can be cast to a
Dataobject onFunction) – value for coefficientAA_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientA_reducedB (any type that can be cast to a
Dataobject onFunction) – value for coefficientBB_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientB_reducedC (any type that can be cast to a
Dataobject onFunction) – value for coefficientCC_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientC_reducedD (any type that can be cast to a
Dataobject onFunction) – value for coefficientDD_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientD_reducedX (any type that can be cast to a
Dataobject onFunction) – value for coefficientXX_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientX_reducedY (any type that can be cast to a
Dataobject onFunction) – value for coefficientYY_reduced (any type that can be cast to a
Dataobject onReducedFunction) – value for coefficientY_reducedd (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficientdd_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnBoundary) – value for coefficientd_reducedy (any type that can be cast to a
Dataobject onFunctionOnBoundary) – value for coefficientyd_contact (any type that can be cast to a
Dataobject onFunctionOnContactOneorFunctionOnContactZero) – value for coefficientd_contactd_contact_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnContactOneorReducedFunctionOnContactZero) – value for coefficientd_contact_reducedy_contact (any type that can be cast to a
Dataobject onFunctionOnContactOneorFunctionOnContactZero) – value for coefficienty_contacty_contact_reduced (any type that can be cast to a
Dataobject onReducedFunctionOnContactOneorReducedFunctionOnContactZero) – value for coefficienty_contact_reducedd_dirac (any type that can be cast to a
Dataobject onDiracDeltaFunctions) – value for coefficientd_diracy_dirac (any type that can be cast to a
Dataobject onDiracDeltaFunctions) – value for coefficienty_diracr (any type that can be cast to a
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the solution) – values prescribed to the solution at the locations of constraintsq (any type that can be cast to a
Dataobject onSolutionorReducedSolutiondepending on whether reduced order is used for the representation of the equation) – mask for location of constraints
- Raises
IllegalCoefficient – if an unknown coefficient keyword is used
-
class
esys.downunder.Locator(where, x=array([0., 0., 0.]))¶ Locator provides access to the values of data objects at a given spatial coordinate x.
In fact, a Locator object finds the sample in the set of samples of a given function space or domain which is closest to the given point x.
-
__init__(where, x=array([0., 0., 0.]))¶ Initializes a Locator to access values in Data objects on the Doamin or FunctionSpace for the sample point which is closest to the given point x.
- Parameters
where (
escript.FunctionSpace) – function spacex (
numpy.ndarrayorlistofnumpy.ndarray) – location(s) of the Locator
-
getFunctionSpace()¶ Returns the function space of the Locator.
-
getId(item=None)¶ Returns the identifier of the location.
-
getValue(data)¶ Returns the value of
dataat the Locator ifdatais aDataobject otherwise the object is returned.
-
getX()¶ Returns the exact coordinates of the Locator.
-
setValue(data, v)¶ Sets the value of the
dataat the Locator.
-
-
class
esys.downunder.MT2DModelTEMode(domain, omega, x, Z_XY, eta=None, w0=1.0, mu=1.2566370614359173e-06, sigma0=0.01, airLayerLevel=None, coordinates=None, Ex_top=1, fixAtTop=False, tol=1e-08, saveMemory=False, directSolver=True)¶ Forward Model for two dimensional MT model in the TE mode for a given frequency omega. It defines a cost function:
defect = 1/2 integrate( sum_s w^s * ( E_x/H_y - Z_XY^s ) ) ** 2 *
where E_x is the horizontal electric field perpendicular to the YZ-domain, horizontal magnetic field H_y=1/(i*omega*mu) * E_{x,z} with complex unit i and permeability mu. The weighting factor w^s is set to
w^s(X) = w_0^s *
if length(X-X^s) <= eta and zero otherwise. X^s is the location of impedance measurement Z_XY^s, w_0^s is the level of confidence (eg. 1/measurement error) and eta is level of spatial confidence.
E_x is given as solution of the PDE
-E_{x,ii} - i omega * mu * sigma * E_x = 0
where E_x at top and bottom is set to solution for background field. Homogeneous Neuman conditions are assumed elsewhere.
-
__init__(domain, omega, x, Z_XY, eta=None, w0=1.0, mu=1.2566370614359173e-06, sigma0=0.01, airLayerLevel=None, coordinates=None, Ex_top=1, fixAtTop=False, tol=1e-08, saveMemory=False, directSolver=True)¶ initializes a new forward model. See base class for a description of the arguments.
-
getArguments(sigma)¶ Returns precomputed values shared by
getDefect()andgetGradient().- Parameters
sigma (
Dataof shape (2,)) – conductivity- Returns
E_x, E_z
- Return type
Dataof shape (2,)
-
getDefect(sigma, Ex, dExdz)¶ Returns the defect value.
- Parameters
sigma (
Dataof shape ()) – a suggestion for conductivityEx (
Dataof shape (2,)) – electric fielddExdz (
Dataof shape (2,)) – vertical derivative of electric field
- Return type
float
-
getGradient(sigma, Ex, dExdz)¶ Returns the gradient of the defect with respect to density.
- Parameters
sigma (
Dataof shape ()) – a suggestion for conductivityEx (
Dataof shape (2,)) – electric fielddExdz (
Dataof shape (2,)) – vertical derivative of electric field
-
class
esys.downunder.MT2DModelTMMode(domain, omega, x, Z_YX, eta=None, w0=1.0, mu=1.2566370614359173e-06, sigma0=0.01, airLayerLevel=None, coordinates=None, tol=1e-08, saveMemory=False, directSolver=True)¶ Forward Model for two-dimensional MT model in the TM mode for a given frequency omega. It defines a cost function:
defect = 1/2 integrate( sum_s w^s * ( rho*H_x/Hy - Z_YX^s ) ) ** 2 *
where H_x is the horizontal magnetic field perpendicular to the YZ-domain, horizontal magnetic field H_y=1/(i*omega*mu) * E_{x,z} with complex unit i and permeability mu. The weighting factor w^s is set to
w^s(X) = w_0^s *
if length(X-X^s) <= eta and zero otherwise. X^s is the location of impedance measurement Z_XY^s, w_0^s is the level of confidence (eg. 1/measurement error) and eta is level of spatial confidence.
H_x is given as solution of the PDE
-(rho*H_{x,i})_{,i} + i omega * mu * H_x = 0
where H_x at top and bottom is set to solution for background field. Homogeneous Neuman conditions are assumed elsewhere.
-
__init__(domain, omega, x, Z_YX, eta=None, w0=1.0, mu=1.2566370614359173e-06, sigma0=0.01, airLayerLevel=None, coordinates=None, tol=1e-08, saveMemory=False, directSolver=True)¶ initializes a new forward model. See base class for a description of the arguments.
-
getArguments(rho)¶ Returns precomputed values shared by
getDefect()andgetGradient().- Parameters
rho (
Dataof shape (2,)) – resistivity- Returns
Hx, grad(Hx)
- Return type
tupleofData
-
getDefect(rho, Hx, g_Hx)¶ Returns the defect value.
- Parameters
rho (
Dataof shape ()) – a suggestion for resistivityHx (
Dataof shape (2,)) – magnetic fieldg_Hx (
Dataof shape (2,2)) – gradient of magnetic field
- Return type
float
-
getGradient(rho, Hx, g_Hx)¶ Returns the gradient of the defect with respect to resistivity.
- Parameters
rho (
Dataof shape ()) – a suggestion for resistivityHx (
Dataof shape (2,)) – magnetic fieldg_Hx (
Dataof shape (2,2)) – gradient of magnetic field
-
class
esys.downunder.MTMapping(sigma_prior, a=1.0)¶ mt mapping
sigma=sigma0*exp(a*m)
-
__init__(sigma_prior, a=1.0)¶ initializes the mapping
- Parameters
sigma_prior – a a-priori conductivity
-
getDerivative(m)¶ returns the derivative of the mapping for m
-
getInverse(s)¶ returns the value of the inverse of the mapping for s
-
getValue(m)¶ returns the value of the mapping for m
-
-
class
esys.downunder.MagneticIntensityModel(domain, w, b, background_magnetic_flux_density, coordinates=None, fixPotentialAtBottom=False, tol=1e-08)¶ Forward Model for magnetic intensity inversion as described in the inversion cookbook.
-
__init__(domain, w, b, background_magnetic_flux_density, coordinates=None, fixPotentialAtBottom=False, tol=1e-08)¶ Creates a new magnetic intensity model on the given domain with one or more surveys (w, b).
- Parameters
domain (
Domain) – domain of the modelw (
Scalaror list ofScalar) – data weighting factorsb (
Scalaror list ofScalar) – magnetic intensity field datatol (positive
float) – tolerance of underlying PDEbackground_magnetic_flux_density (
Vectoror list offloat) – background magnetic flux density (in Tesla) with components (B_east, B_north, B_vertical)coordinates (None) – defines coordinate system to be used
fixPotentialAtBottom (
bool) – if true potential is fixed to zero at the bottom of the domain in addition to the top
-
getArguments(k)¶ Returns precomputed values shared by
getDefect()andgetGradient().- Parameters
k (
Scalar) – susceptibility- Returns
scalar magnetic potential and corresponding magnetic field
- Return type
Scalar,Vector
-
getDefect(k, phi, magnetic_flux_density)¶ Returns the value of the defect.
- Parameters
k (
Scalar) – susceptibilityphi (
Scalar) – corresponding potentialmagnetic_flux_density (
Vector) – magnetic field
- Return type
float
-
getGradient(k, phi, magnetic_flux_density)¶ Returns the gradient of the defect with respect to susceptibility.
- Parameters
k (
Scalar) – susceptibilityphi (
Scalar) – corresponding potentialmagnetic_flux_density (
Vector) – magnetic field
- Return type
Scalar
-
getPotential(k)¶ Calculates the magnetic potential for a given susceptibility.
- Parameters
k (
Scalar) – susceptibility- Returns
magnetic potential
- Return type
Scalar
-
rescaleWeights(scale=1.0, k_scale=1.0)¶ rescales the weights such that
sum_s integrate( ( w_i[s] *B_i[s]) (w_j[s]*1/L_j) * L**2 * (background_magnetic_flux_density_j[s]*1/L_j) * k_scale )=scale
- Parameters
scale (positive
float) – scale of data weighting factorsk_scale (
Scalar) – scale of susceptibility.
-
-
class
esys.downunder.MagneticInversion(solverclass=None, debug=False, self_demagnetization=False, magnetic_intensity_data=False)¶ Driver class to perform an inversion of magnetic anomaly data. The class uses the standard
Regularizationclass for a single level set function,SusceptibilityMappingmapping and the linear magnetic forward modelMagneticModel.-
__init__(solverclass=None, debug=False, self_demagnetization=False, magnetic_intensity_data=False)¶ creates an instance of an inversion driver.
- Parameters
solverclass ('AbstractMinimizer'.) – class of the solver to be used.
self_demagnetization – if True self-demagnitization is applied.
magnetic_intensity_data – if True magnetic intensity is used in the cost function.
-
setInitialGuess(k=None)¶ set the initial guess k for susceptibility for the inversion iteration. If no k present then an appropriate initial guess is chosen.
- Parameters
k (
Scalar) – initial value for the susceptibility anomaly.
-
setup(domainbuilder, k0=None, dk=None, z0=None, beta=None, w0=None, w1=None, k_at_depth=None)¶ Sets up the inversion from a
DomainBuilder. If magnetic data are given as scalar it is assumed that values are collected in direction of the background magnetic field.- Parameters
domainbuilder (
DomainBuilder) – Domain builder object with gravity source(s)k0 (
floatorScalar) – reference susceptibility, seeSusceptibilityMapping. If not specified, zero is used.dk (
floatorScalar) – susceptibility scale, seeSusceptibilityMapping. If not specified, 1. is used.z0 (
floatorScalar) – reference depth for depth weighting, seeSusceptibilityMapping. If not specified, zero is used.beta (
floatorScalar) – exponent for depth weighting, seeSusceptibilityMapping. If not specified, zero is used.w0 (
Scalarorfloat) – weighting factor for level set term regularization. If not set zero is assumed.w1 (
Vectoror list offloat) – weighting factor for the gradient term in the regularization. If not set zero is assumedk_at_depth (
floatorNone) – value for susceptibility at depth, seeDomainBuilder.
-
siloWriterCallback(k, x, Jx, g_Jx, norm_dJ=None, norm_dx=None)¶ callback function that can be used to track the solution
- Parameters
k – iteration count
x – current approximation
Jx – value of cost function
g_Jx – gradient of f at x
-
-
class
esys.downunder.MagneticModel(domain, w, B, background_magnetic_flux_density, coordinates=None, fixPotentialAtBottom=False, tol=1e-08)¶ Forward Model for magnetic inversion as described in the inversion cookbook.
-
__init__(domain, w, B, background_magnetic_flux_density, coordinates=None, fixPotentialAtBottom=False, tol=1e-08)¶ Creates a new magnetic model on the given domain with one or more surveys (w, B).
- Parameters
domain (
Domain) – domain of the modelw (
Vectoror list ofVector) – data weighting factorsB (
Vectoror list ofVector) – magnetic field datatol (positive
float) – tolerance of underlying PDEbackground_magnetic_flux_density (
Vectoror list offloat) – background magnetic flux density (in Tesla) with components (B_east, B_north, B_vertical)coordinates (
ReferenceSystemorSpatialCoordinateTransformation) – defines coordinate system to be usedfixPotentialAtBottom (
bool) – if true potential is fixed to zero at the bottom of the domain in addition to the top
-
getArguments(k)¶ Returns precomputed values shared by
getDefect()andgetGradient().- Parameters
k (
Scalar) – susceptibility- Returns
scalar magnetic potential and corresponding magnetic field
- Return type
Scalar,Vector
-
getDefect(k, phi, magnetic_flux_density)¶ Returns the value of the defect.
- Parameters
k (
Scalar) – susceptibilityphi (
Scalar) – corresponding potentialmagnetic_flux_density (
Vector) – magnetic field
- Return type
float
-
getGradient(k, phi, magnetic_flux_density)¶ Returns the gradient of the defect with respect to susceptibility.
- Parameters
k (
Scalar) – susceptibilityphi (
Scalar) – corresponding potentialmagnetic_flux_density (
Vector) – magnetic field
- Return type
Scalar
-
getPotential(k)¶ Calculates the magnetic potential for a given susceptibility.
- Parameters
k (
Scalar) – susceptibility- Returns
magnetic potential
- Return type
Scalar
-
rescaleWeights(scale=1.0, k_scale=1.0)¶ rescales the weights such that
sum_s integrate( ( w_i[s] *B_i[s]) (w_j[s]*1/L_j) * L**2 * (background_magnetic_flux_density_j[s]*1/L_j) * k_scale )=scale
- Parameters
scale (positive
float) – scale of data weighting factorsk_scale (
Scalar) – scale of susceptibility.
-
-
class
esys.downunder.Mapping(*args)¶ An abstract mapping class to map level set functions m to physical parameters p.
-
__init__(*args)¶ Initialize self. See help(type(self)) for accurate signature.
-
getDerivative(m)¶ returns the value for the derivative of the mapping for m
-
getInverse(s)¶ returns the value of the inverse of the mapping for physical parameter p
-
getTypicalDerivative()¶ returns a typical value for the derivative
-
getValue(m)¶ returns the value of the mapping for m
-
-
class
esys.downunder.MeteredCostFunction¶ This an intrumented version of the
CostFunctionclass. The function calls update statistical information. The actual work is done by the methods with corresponding name and a leading underscore. These functions need to be overwritten for a particular cost function implementation.-
__init__()¶ the base constructor initializes the counters so subclasses should ensure the super class constructor is called.
-
getArguments(x)¶ returns precalculated values that are shared in the calculation of f(x) and grad f(x) and the Hessian operator
Note
The tuple returned by this call will be passed back to this
CostFunctionin other calls(eg:getGradient). Its contents are not specified at this level because no code, other than theCostFunctionwhich created it, will be interacting with it. That is, the implementor can put whatever information they find useful in it.- Parameters
x (x-type) – location of derivative
- Return type
tuple
-
getDualProduct(x, r)¶ returns the dual product of
xandr- Return type
float
-
getGradient(x, *args)¶ returns the gradient of f at x using the precalculated values for x.
- Parameters
x (x-type) – location of derivative
args – pre-calculated values for
xfromgetArguments()
- Return type
r-type
-
getInverseHessianApproximation(x, r, *args)¶ returns an approximative evaluation p of the inverse of the Hessian operator of the cost function for a given gradient r at a given location x: H(x) p = r
Note
In general it is assumed that the Hessian H(x) needs to be calculate in each call for a new location x. However, the solver may suggest that this is not required, typically when the iteration is close to completeness.
- Parameters
x (x-type) – location of Hessian operator to be evaluated.
r (r-type) – a given gradient
args – pre-calculated values for
xfromgetArguments()
- Return type
x-type
-
getNorm(x)¶ returns the norm of
x- Return type
float
-
getValue(x, *args)¶ returns the value f(x) using the precalculated values for x.
- Parameters
x (x-type) – a solution approximation
- Return type
float
-
resetCounters()¶ resets all statistical counters
-
-
class
esys.downunder.MinimizerException¶ This is a generic exception thrown by a minimizer.
-
__init__(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
esys.downunder.MinimizerIterationIncurableBreakDown¶ Exception thrown if the iteration scheme encountered an incurable breakdown.
-
__init__(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
esys.downunder.MinimizerLBFGS(J=None, m_tol=0.0001, J_tol=None, imax=300)¶ Minimizer that uses the limited-memory Broyden-Fletcher-Goldfarb-Shanno method. See Chapter 6 of ‘Numerical Optimization’ by J. Nocedal for an explanation.
-
__init__(J=None, m_tol=0.0001, J_tol=None, imax=300)¶ Initializes a new minimizer for a given cost function.
- Parameters
J (
CostFunction) – the cost function to be minimizedm_tol (float) – terminate interations when relative change of the level set function is less than or equal m_tol
-
getOptions()¶ returns a dictionary of LBFGS options rtype: dictionary with keys ‘truncation’, ‘initialHessian’, ‘restart’, ‘max_linesearch_steps’, ‘max_zoom_steps’ ‘interpolationOrder’, ‘tol_df’, ‘tol_sm’
-
run(x)¶ - The callback function is called with the following arguments:
k - iteration number x - current estimate Jx - value of cost function at x g_Jx - gradient of cost function at x norm_dJ - ||Jx_k - Jx_{k-1}|| (only if J_tol is set) norm_dx - ||x_k - x_{k-1}|| (only if m_tol is set)
- Parameters
x (
Data) – Level set function representing our initial guess- Returns
Level set function representing the solution
- Return type
Data
-
setOptions(**opts)¶ setOptions for LBFGS. use solver.setOptions( key = value) :key truncation: sets the number of previous LBFGS iterations to keep :type truncation : int :default truncation: 30 :key initialHessian: 1 if initial Hessian is given :type initialHessian: 1 or 0 :default initialHessian: 1 :key restart: restart after this many iteration steps :type restart: int :default restart: 60 :key max_linesearch_steps: maximum number of line search iterations :type max_linesearch_steps: int :default max_linesearch_steps: 25 :key max_zoom_steps: maximum number of zoom iterations :type max_zoom_steps: int :default max_zoom_steps: 60 :key interpolationOrder: order of the interpolation used for line search :type interpolationOrder: 1,2,3 or 4 :default interpolationOrder: 1 :key tol_df: interpolated value of alpha, alpha_i, must differ
: from the previous value by at least this much : abs(alpha_i-alpha_{i-1}) < tol_df (line search)
- Default tol_df
1e-6
- Key tol_sm
interpolated value of alpha must not be less than tol_sm : abs(alpha_i) < tol_sm*abs(alpha_{i-1})
- Default tol_sm
1e-5
- Example of usage::
cf=DerivedCostFunction() solver=MinimizerLBFGS(J=cf, m_tol = 1e-5, J_tol = 1e-5, imax=300) solver.setOptions(truncation=20, tol_df =1e-7) solver.run(initial_m) result=solver.getResult()
-
-
class
esys.downunder.MinimizerMaxIterReached¶ Exception thrown if the maximum number of iteration steps is reached.
-
__init__(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
-
class
esys.downunder.MinimizerNLCG(J=None, m_tol=0.0001, J_tol=None, imax=300)¶ Minimizer that uses the nonlinear conjugate gradient method (Fletcher-Reeves variant).
-
__init__(J=None, m_tol=0.0001, J_tol=None, imax=300)¶ Initializes a new minimizer for a given cost function.
- Parameters
J (
CostFunction) – the cost function to be minimizedm_tol (float) – terminate interations when relative change of the level set function is less than or equal m_tol
-
run(x)¶ - The callback function is called with the following arguments:
k - iteration number x - current estimate Jx - value of cost function at x g_Jx - gradient of cost function at x gnorm - norm of g_Jx (stopping criterion)
-
-
class
esys.downunder.NetCdfData(data_type, filename, altitude=0.0, data_variable=None, error=None, scale_factor=None, null_value=None, reference_system=None)¶ Data Source for gridded netCDF data that use CF/COARDS conventions.
-
__init__(data_type, filename, altitude=0.0, data_variable=None, error=None, scale_factor=None, null_value=None, reference_system=None)¶ - Parameters
filename (
str) – file name for survey data in netCDF formatdata_type (
int) – type of data, must beGRAVITYorMAGNETICaltitude (
float) – altitude of measurements in metersdata_variable (
str) – name of the netCDF variable that holds the data. If not provided an attempt is made to determine the variable and an exception thrown on failure.error (
strorfloat) – either the name of the netCDF variable that holds the uncertainties of the measurements or a constant value to use for the uncertainties. If a constant value is supplied, it is scaled by the same factor as the measurements. If not provided the error is assumed to be 2 units for all measurements (i.e. 0.2 mGal and 2 nT for gravity and magnetic, respectively)scale_factor (
float) – the measurements and error values are scaled by this factor. By default, gravity data is assumed to be given in 1e-6 m/s^2 (0.1 mGal), while magnetic data is assumed to be in 1e-9 T (1 nT).null_value (
float) – value that is used in the file to mark undefined areas. This information is usually included in the file.reference_system (
ReferenceSystem) – reference coordinate system to be used. For a Cartesian reference (default) the appropriate UTM transformation is applied.
- Note
it is the responsibility of the caller to ensure all data sources and the domain builder use the same reference system.
-
getDataExtents()¶ returns ( (x0, y0), (nx, ny), (dx, dy) )
-
getDataType()¶ Returns the type of survey data managed by this source. Subclasses must return
GRAVITYorMAGNETICorACOUSTICas appropriate.
-
getScaleFactor()¶ returns the data scale factor for adjusting measurement to SI
-
getSurveyData(domain, origin, NE, spacing)¶ This method is called by the
DomainBuilderto retrieve the survey data asDataobjects on the given domain.Subclasses should return one or more
Dataobjects with survey data interpolated on the givenescriptdomain. The exact return type depends on the type of data.- Parameters
domain (
esys.escript.Domain) – the escript domain to useorigin (
tupleorlist) – the origin coordinates of the domainNE (
tupleorlist) – the number of domain elements in each dimensionspacing (
tupleorlist) – the cell sizes (node spacing) in the domain
-
getUtmZone()¶ All data source coordinates are converted to UTM (Universal Transverse Mercator) in order to have useful domain extents. Subclasses should implement this method and return the UTM zone number of the projected coordinates.
-
-
class
esys.downunder.NumpyData(data_type, data, error=1.0, length=1000.0, null_value=- 1.0, tags=[], origin=None)¶ -
__init__(data_type, data, error=1.0, length=1000.0, null_value=- 1.0, tags=[], origin=None)¶ A data source that uses survey data from a
numpyobject or list instead of a file. The dimensionality is inferred from the shape ofdata(1- and 2-dimensional data is supported). The data origin is assumed to be at the coordinate origin.- Parameters
data_type (
DataSource.GRAVITY,DataSource.MAGNETIC) – data type indicatordata (
numpy.arrayorlist) – the survey data array. Note that for a cartesian coordinate system the shape of the data is considered to be (nz,ny,nx).error (
floatorlistorndarray) – constant value to use for the data uncertainties or a numpy object with uncertainties for every data point.length (
floatorlistorndarray) – side length(s) of the data slice/volume. This can be a scalar to indicate constant length in all dimensions or an array/list of values in each coordinate dimension.null_value (
float) – value that is used in the undefined regions of the survey data object.tags (
listof almost any type (typicallystr)) – a list of tags associated with the data set.origin (
listoffloat) – offset of origin of offset
-
getDataExtents()¶ returns a tuple of tuples
( (x0, y0), (nx, ny), (dx, dy) ), wherex0,y0= coordinates of data originnx,ny= number of data points in x and ydx,dy= spacing of data points in x and y
This method must be implemented in subclasses.
-
getDataType()¶ Returns the type of survey data managed by this source. Subclasses must return
GRAVITYorMAGNETICorACOUSTICas appropriate.
-
getSurveyData(domain, origin, NE, spacing)¶ This method is called by the
DomainBuilderto retrieve the survey data asDataobjects on the given domain.Subclasses should return one or more
Dataobjects with survey data interpolated on the givenescriptdomain. The exact return type depends on the type of data.- Parameters
domain (
esys.escript.Domain) – the escript domain to useorigin (
tupleorlist) – the origin coordinates of the domainNE (
tupleorlist) – the number of domain elements in each dimensionspacing (
tupleorlist) – the cell sizes (node spacing) in the domain
-
getUtmZone()¶ returns a dummy UTM zone since this class does not use real coordinate values.
-
-
class
esys.downunder.PoleDipoleSurvey(domain, primaryConductivity, secondaryConductivity, current, a, n, midPoint, directionVector, numElectrodes)¶ Forward model class for a poledipole setup
-
__init__(domain, primaryConductivity, secondaryConductivity, current, a, n, midPoint, directionVector, numElectrodes)¶ - Parameters
domain (
Domain) – domain of the modelprimaryConductivity (data) – preset primary conductivity data object
secondaryConductivity (data) – preset secondary conductivity data object
current (float or int) – amount of current to be injected at the current electrode
a (list) – the spacing between current and potential electrodes
n (float or int) – multiple of spacing between electrodes. typicaly interger
midPoint – midPoint of the survey, as a list containing x,y coords
directionVector – two element list specifying the direction the survey should extend from the midpoint
numElectrodes (int) – the number of electrodes to be used in the survey must be a multiple of 2 for polepole survey:
-
getApparentResistivityPrimary()¶
-
getApparentResistivitySecondary()¶
-
getApparentResistivityTotal()¶
-
getPotential()¶ Returns 3 list each made up of a number of list containing primary, secondary and total potentials diferences. Each of the lists contain a list for each value of n.
-
-
class
esys.downunder.PolePoleSurvey(domain, primaryConductivity, secondaryConductivity, current, a, midPoint, directionVector, numElectrodes)¶ Forward model class for a polepole setup
-
__init__(domain, primaryConductivity, secondaryConductivity, current, a, midPoint, directionVector, numElectrodes)¶ - Parameters
domain (
Domain) – domain of the modelprimaryConductivity (data) – preset primary conductivity data object
secondaryConductivity (data) – preset secondary conductivity data object
current (float or int) – amount of current to be injected at the current electrode
a (list) – the spacing between current and potential electrodes
midPoint – midPoint of the survey, as a list containing x,y coords
directionVector – two element list specifying the direction the survey should extend from the midpoint
numElectrodes (int) – the number of electrodes to be used in the survey must be a multiple of 2 for polepole survey:
-
getApparentResistivityPrimary()¶
-
getApparentResistivitySecondary()¶
-
getApparentResistivityTotal()¶
-
getPotential()¶ returns a list containing 3 lists one for each the primary, secondary and total potential.
-
-
class
esys.downunder.ReferenceSystem(name='none')¶ Generic identifier for coordinate systems.
-
__init__(name='none')¶ initialization of reference system
- Parameters
name (
str) – name of the reference system
-
createTransformation(domain)¶ creates an appropriate coordinate transformation on a given domain
Note
needs to be overwritten by a particular reference system
- Parameters
domain (
esys.escript.AbstractDomain) – domain of transformation- Return type
-
getName()¶ returns the name of the reference system
-
isCartesian()¶ returns if the reference system is Cartesian
Note
needs to be overwritten by a particular reference system
- Return type
bool
-
isTheSame(other)¶ test if argument
otherdefines the same reference system- Parameters
other (
ReferenceSystem) – a second reference system- Returns
Trueif other defines the same reference system- Return type
bool
Note
needs to be overwritten by a particular reference system
-
-
class
esys.downunder.Regularization(domain, numLevelSets=1, w0=None, w1=None, wc=None, location_of_set_m=<esys.escriptcore.escriptcpp.Data object>, useDiagonalHessianApproximation=False, tol=1e-08, coordinates=None, scale=None, scale_c=None)¶ The regularization term for the level set function
mwithin the cost function J for an inversion:J(m)=1/2 * sum_k integrate( mu[k] * ( w0[k] * m_k**2 * w1[k,i] * m_{k,i}**2) + sum_l<k mu_c[l,k] wc[l,k] * | curl(m_k) x curl(m_l) |^2
where w0[k], w1[k,i] and wc[k,l] are non-negative weighting factors and mu[k] and mu_c[l,k] are trade-off factors which may be altered during the inversion. The weighting factors are normalized such that their integrals over the domain are constant:
integrate(w0[k] + inner(w1[k,:],1/L[:]**2))=scale[k] volume(domain)* integrate(wc[l,k]*1/L**4)=scale_c[k] volume(domain) *
-
__init__(domain, numLevelSets=1, w0=None, w1=None, wc=None, location_of_set_m=<esys.escriptcore.escriptcpp.Data object>, useDiagonalHessianApproximation=False, tol=1e-08, coordinates=None, scale=None, scale_c=None)¶ initialization.
- Parameters
domain (
Domain) – domainnumLevelSets (
int) – number of level setsw0 (
ScalarifnumLevelSets== 1 orDataobject of shape (numLevelSets,) ifnumLevelSets> 1) – weighting factor for the m**2 term. If not set zero is assumed.w1 (
VectorifnumLevelSets== 1 orDataobject of shape (numLevelSets, DIM) ifnumLevelSets> 1) – weighting factor for the grad(m_i) terms. If not set zero is assumedwc (
Dataobject of shape (numLevelSets,numLevelSets)) – weighting factor for the cross gradient terms. If not set zero is assumed. Used for the case ifnumLevelSets> 1 only. Only valueswc[l,k]in the lower triangle (l<k) are used.location_of_set_m (
ScalarifnumLevelSets== 1 orDataobject of shape (numLevelSets,) ifnumLevelSets> 1) – marks location of zero values of the level set functionmby a positive entry.useDiagonalHessianApproximation (
bool) – if True cross gradient terms between level set components are ignored when calculating approximations of the inverse of the Hessian Operator. This can speed-up the calculation of the inverse but may lead to an increase of the number of iteration steps in the inversion.tol (positive
float) – tolerance when solving the PDE for the inverse of the Hessian Operatorcoordinates (ReferenceSystem` or
SpatialCoordinateTransformation) – defines coordinate system to be usedscale (
ScalarifnumLevelSets== 1 orDataobject of shape (numLevelSets,) ifnumLevelSets> 1) – weighting factor for level set function variation terms. If not set one is used.scale_c (
Dataobject of shape (numLevelSets,``numLevelSets``)) – scale for the cross gradient terms. If not set one is assumed. Used for the case ifnumLevelSets> 1 only. Only valuesscale_c[l,k]in the lower triangle (l<k) are used.
-
getArguments(m)¶
-
getCoordinateTransformation()¶ returns the coordinate transformation being used
- Return type
CoordinateTransformation
-
getDomain()¶ returns the domain of the regularization term
- Return type
Domain
-
getDualProduct(m, r)¶ returns the dual product of a gradient represented by X=r[1] and Y=r[0] with a level set function m:
Y_i*m_i + X_ij*m_{i,j}
- Return type
float
-
getGradient(m, grad_m)¶ returns the gradient of the cost function J with respect to m.
- Note
This implementation returns Y_k=dPsi/dm_k and X_kj=dPsi/dm_kj
-
getInverseHessianApproximation(m, r, grad_m, solve=True)¶
-
getNorm(m)¶ returns the norm of
m.- Parameters
m (
Data) – level set function- Return type
float
-
getNumLevelSets()¶ returns the number of level set functions
- Return type
int
-
getNumTradeOffFactors()¶ returns the number of trade-off factors being used.
- Return type
int
-
getPDE()¶ returns the linear PDE to be solved for the Hessian Operator inverse
- Return type
-
getValue(m, grad_m)¶ returns the value of the cost function J with respect to m. This equation is specified in the inversion cookbook.
- Return type
float
-
setTradeOffFactors(mu=None)¶ sets the trade-off factors for the level-set variation and the cross-gradient.
- Parameters
mu (
listoffloator`numpy.array`) – new values for the trade-off factors where values mu[:numLevelSets] are the trade-off factors for the level-set variation and the remaining values for the cross-gradient part with mu_c[l,k]=mu[numLevelSets+l+((k-1)*k)/2] (l<k). If no values for mu are given ones are used. Values must be positive.
-
setTradeOffFactorsForCrossGradient(mu_c=None)¶ sets the trade-off factors for the cross-gradient terms.
- Parameters
mu_c (
float,listoffloatornumpy.array) – new values for the trade-off factors for the cross-gradient terms. Values must be positive. If no value is given ones are used. Only value mu_c[l,k] for l<k are used.
-
setTradeOffFactorsForVariation(mu=None)¶ sets the trade-off factors for the level-set variation part.
- Parameters
mu (
float,listoffloator`numpy.array`) – new values for the trade-off factors. Values must be positive.
-
updateHessian()¶ notifies the class to recalculate the Hessian operator.
-
-
class
esys.downunder.Ricker(f_dom=40, t_dom=None)¶ The Ricker Wavelet w=f(t)
-
__init__(f_dom=40, t_dom=None)¶ Sets up a Ricker wavelet wih dominant frequence
f_domand center at timet_dom. Ift_domis not given an estimate for suitablet_domis calculated so f(0)~0.- Note
maximum frequence is about 2 x the dominant frequence.
-
getAcceleration(t)¶ get the acceleration f’’(t) at time
t
-
getCenter()¶ Return value of wavelet center
-
getTimeScale()¶ Returns the time scale which is the inverse of the largest frequence with a significant spectral component.
-
getValue(t)¶ get value of wavelet at time
t
-
getVelocity(t)¶ get the velocity f’(t) at time
t
-
-
class
esys.downunder.SchlumbergerSurvey(domain, primaryConductivity, secondaryConductivity, current, a, n, midPoint, directionVector, numElectrodes)¶ Schlumberger survey forward calculation
-
__init__(domain, primaryConductivity, secondaryConductivity, current, a, n, midPoint, directionVector, numElectrodes)¶ This is a skeleton class for all the other forward modeling classes.
-
getApparentResistivity(delPhiList)¶
-
getElectrodeDict()¶ retuns the electrode dictionary
-
getPotentialAnalytic()¶ Returns 3 list each made up of a number of list containing primary, secondary and total potentials diferences. Each of the lists contain a list for each value of n.
-
getPotentialNumeric()¶ Returns 3 list each made up of a number of list containing primary, secondary and total potentials diferences. Each of the lists contain a list for each value of n.
-
getSourcesSamples()¶ return a list of tuples of sample locations followed by a list of tuples of source locations.
-
-
class
esys.downunder.SeismicSource(x, y=0.0, omega=0.0, elevation=0.0, power=None, orientation=None)¶ describes a seimic source by location (x,y), frequency omega, power (if known) and orientation (if known). this class is used to tag seismic data sources.
-
__init__(x, y=0.0, omega=0.0, elevation=0.0, power=None, orientation=None)¶ initiale the source
- Parameters
x (
float) – lateral x locationy (
float) – lateral y locationomega (
float) – frequency of sourceelevation – elevation of source above reference level
power (
complexorNone) – power of source at frequenceorientation (vector of appropriate length or
None) – oriententation of source in 3D or 2D (or None)
-
getElevation()¶ return elevation of source :rtype:
float
-
getFrequency()¶ return frequency of source :rtype:
float
-
getLocation()¶ return location of source :rtype:
tupleoffloat
-
getOrientation()¶ return power of source orientation at frequency :rtype: vector type object or
None
-
getPower()¶ return power of source at frequency :rtype:
complexorNone
-
-
class
esys.downunder.SelfDemagnetizationModel(domain, w, B, background_magnetic_flux_density, coordinates=None, fixPotentialAtBottom=False, tol=1e-08)¶ Forward Model for magnetic inversion with self-demagnetization as described in the inversion cookbook.
-
__init__(domain, w, B, background_magnetic_flux_density, coordinates=None, fixPotentialAtBottom=False, tol=1e-08)¶ Creates a new magnetic model on the given domain with one or more surveys (w, B).
- Parameters
domain (
Domain) – domain of the modelw (
Vectoror list ofVector) – data weighting factorsB (
Vectoror list ofVector) – magnetic field databackground_magnetic_flux_density (
Vectoror list offloat) – background magnetic flux density (in Tesla) with components (B_east, B_north, B_vertical)coordinates (
ReferenceSystemorSpatialCoordinateTransformation) – defines coordinate system to be usedfixPotentialAtBottom (
bool) – if true potential is fixed to zero at the bottom of the domain in addition to the toptol (positive
float) – tolerance of underlying PDE
-
getArguments(k)¶ Returns precomputed values shared by
getDefect()andgetGradient().- Parameters
k (
Scalar) – susceptibility- Returns
scalar magnetic potential and corresponding magnetic field
- Return type
Scalar,Vector
-
getDefect(k, phi, grad_phi, magnetic_flux_density)¶ Returns the value of the defect.
- Parameters
k (
Scalar) – susceptibilityphi (
Scalar) – corresponding potentialmagnetic_flux_density (
Vector) – magnetic field
- Return type
float
-
getGradient(k, phi, grad_phi, magnetic_flux_density)¶ Returns the gradient of the defect with respect to susceptibility.
- Parameters
k (
Scalar) – susceptibilityphi (
Scalar) – corresponding potentialmagnetic_flux_density (
Vector) – magnetic field
- Return type
Scalar
-
getPotential(k)¶ Calculates the magnetic potential for a given susceptibility.
- Parameters
k (
Scalar) – susceptibility- Returns
magnetic potential
- Return type
Scalar
-
rescaleWeights(scale=1.0, k_scale=1.0)¶ rescales the weights such that
sum_s integrate( ( w_i[s] *B_i[s]) (w_j[s]*1/L_j) * L**2 * (background_magnetic_flux_density_j[s]*1/L_j) * k_scale )=scale
- Parameters
scale (positive
float) – scale of data weighting factorsk_scale (
Scalar) – scale of susceptibility.
-
-
class
esys.downunder.SimpleSEGYWriter(receiver_group=None, source=0.0, sampling_interval=0.004, text='some seimic data')¶ A simple writer for 2D and 3D seismic lines, in particular for synthetic data
Typical usage:
from esys.escript import unitsSI as U sw=SimpleSEGYWriter([0.,100*U.m,200*U,m,300.], source=200*U.m, sampling_interval=4*U.msec) while n < 10: sw.addRecord([i*2., i*0.67, i**2, -i*7]) sw.write('example.segy')
- Note
the writer uses
obspy
-
__init__(receiver_group=None, source=0.0, sampling_interval=0.004, text='some seimic data')¶ initalize writer
- Parameters
receiver_group – list of receiver coordinates (in meters). For the 2D case a list of floats is given, for the 3D case a list of coordinate tuples are given
source – coordinates of the source (in meters). For the 2D case a single floats is given, for the 3D case a coordinate tuples
sampling_interval – sample rate in seconds
text – a text for the header file (e.g a description)
-
COORDINATE_SCALE= 1000.0¶
-
addRecord(record)¶ Adds a record to the traces. A time difference of sample_interval between two records is assumed. The record mast be a list of as many values as given receivers or a float if a single receiver is used.
- Parameters
record – list of tracks to be added to the record.
-
getSamplingInterval()¶ returns the sampling interval in seconds.
-
obspy_available()¶ for checking if the obspy module is available
-
write(filename)¶ writes to segy file
- Parameters
filename – file name
- Note
the function uses the
obspymodule.
-
class
esys.downunder.SmoothAnomaly(lx, ly, lz, x, y, depth, v_inner=None, v_outer=None)¶ A source feature in the form of a blob (roughly gaussian).
-
__init__(lx, ly, lz, x, y, depth, v_inner=None, v_outer=None)¶ Intializes the smooth anomaly data.
- Parameters
lx – size of blob in x-dimension
ly – size of blob in y-dimension
lz – size of blob in z-dimension
x – location of blob in x-dimension
y – location of blob in y-dimension
depth – depth of blob
v_inner – value in the centre of the blob
v_outer – value in the periphery of the blob
-
getMask(x)¶ Returns the mask of the area of interest for this feature. That is, mask is non-zero where the value returned by
getValue()should be applied, zero elsewhere.
-
getValue(x)¶ Returns the value for the area covered by mask. It can be constant or a
Dataobject with spatial dependency.
-
-
class
esys.downunder.SonicHTIWave(domain, v_p, wavelet, source_tag, source_vector=[1.0, 0.0], eps=0.0, delta=0.0, azimuth=0.0, dt=None, p0=None, v0=None, absorption_zone=300.0, absorption_cut=0.01, lumping=True)¶ Solving the HTI wave equation (along the x_0 axis) with azimuth (rotation around verticle axis) under the assumption of zero shear wave velocities The unknowns are the transversal (along x_0) and vertial stress (Q, P)
- Note
In case of a two dimensional domain the second spatial dimenion is depth.
-
__init__(domain, v_p, wavelet, source_tag, source_vector=[1.0, 0.0], eps=0.0, delta=0.0, azimuth=0.0, dt=None, p0=None, v0=None, absorption_zone=300.0, absorption_cut=0.01, lumping=True)¶ initialize the HTI wave solver
- Parameters
domain (
Doamin) – domain of the problemv_p (
escript.Scalar) – vertical p-velocity fieldv_s (
escript.Scalar) – vertical s-velocity fieldwavelet (
Wavelet) – wavelet to describe the time evolution of source termsource_tag ('str' or 'int') – tag of the source location
source_vector – source orientation vector
eps – first Thompsen parameter
azimuth – azimuth (rotation around verticle axis)
gamma – third Thompsen parameter
rho – density
dt – time step size. If not present a suitable time step size is calculated.
p0 – initial solution (Q(t=0), P(t=0)). If not present zero is used.
v0 – initial solution change rate. If not present zero is used.
absorption_zone – thickness of absorption zone
absorption_cut – boundary value of absorption decay factor
lumping – if True mass matrix lumping is being used. This is accelerates the computing but introduces some diffusion.
-
class
esys.downunder.SonicWave(domain, v_p, wavelet, source_tag, dt=None, p0=None, p0_t=None, absorption_zone=300.0, absorption_cut=0.01, lumping=True)¶ Solving the sonic wave equation
p_tt = (v_p**2 * p_i)_i + f(t) * delta_swhere (p-) velocity v_p.f(t) is wavelet acting at a point source term at positon s
-
__init__(domain, v_p, wavelet, source_tag, dt=None, p0=None, p0_t=None, absorption_zone=300.0, absorption_cut=0.01, lumping=True)¶ initialize the sonic wave solver
- Parameters
domain (
Domain) – domain of the problemv_p (
escript.Scalar) – p-velocity fieldwavelet (
Wavelet) – wavelet to describe the time evolution of source termsource_tag ('str' or 'int') – tag of the source location
dt – time step size. If not present a suitable time step size is calculated.
p0 – initial solution. If not present zero is used.
p0_t – initial solution change rate. If not present zero is used.
absorption_zone – thickness of absorption zone
absorption_cut – boundary value of absorption decay factor
lumping – if True mass matrix lumping is being used. This is accelerates the computing but introduces some diffusion.
-
-
class
esys.downunder.SpatialCoordinateTransformation(domain, reference=<esys.downunder.coordinates.CartesianReferenceSystem object>)¶ Defines an orthogonal coordinate transformation from a domain into the Cartesian domain using a coordinate transformation.
The default implementation is the identity transformation (i.e. no changes are applied to the domain). Overwrite the appropriate methods to define other coordinate systems.
-
__init__(domain, reference=<esys.downunder.coordinates.CartesianReferenceSystem object>)¶ set up the orthogonal coordinate transformation.
- Parameters
domain (
esys.escript.AbstractDomain) – domain in the domain of the coordinate transformationreference (
ReferenceSystem) – the reference system
-
getDomain()¶ returns the domain of the coordinate transformation.
- Return type
esys.escript.AbstractDomain
-
getGradient(u)¶ returns the gradient of a scalar function in direction of the coordinate axis.
- Return type
-
getReferenceSystem()¶ returns the reference system used to to define the coordinate transformation
- Return type
-
getScalingFactors()¶ returns the scaling factors
- Return type
-
getVolumeFactor()¶ returns the volume factor for the coordinate transformation
- Return type
-
isCartesian()¶ returns
Trueif the scaling factors (and the volume factor) are equal to 1- Return type
bool
-
isTheSame(other)¶ test if argument
otherdefines the same coordinate transformation- Parameters
other (
SpatialCoordinateTransformation) – a second coordinate transformation- Returns
Trueif other defines then same coordinate transformation- Return type
bool
-
-
class
esys.downunder.SplitInversionCostFunction(numLevelSets=None, numModels=None, numMappings=None, splitworld=None, worldsinit_fn=None)¶ Class to define cost function J(m) for inversion with one or more forward models based on a multi-valued level set function m:
J(m) = J_reg(m) + sum_f mu_f * J_f(p)
where J_reg(m) is the regularization and cross gradient component of the cost function applied to a level set function m, J_f(p) are the data defect cost functions involving a physical forward model using the physical parameter(s) p and mu_f is the trade-off factor for model f.
A forward model depends on a set of physical parameters p which are constructed from components of the level set function m via mappings.
- Example 1 (single forward model):
m=Mapping() f=ForwardModel() J=InversionCostFunction(Regularization(), m, f)
- Example 2 (two forward models on a single valued level set)
m0=Mapping() m1=Mapping() f0=ForwardModel() f1=ForwardModel()
J=InversionCostFunction(Regularization(), mappings=[m0, m1], forward_models=[(f0, 0), (f1,1)])
- Example 3 (two forward models on 2-valued level set)
m0=Mapping() m1=Mapping() f0=ForwardModel() f1=ForwardModel()
J=InversionCostFunction(Regularization(self.numLevelSets=2), mappings=[(m0,0), (m1,0)], forward_models=[(f0, 0), (f1,1)])
- Note
If provides_inverse_Hessian_approximation is true, then the class provides an approximative inverse of the Hessian operator.
-
__init__(numLevelSets=None, numModels=None, numMappings=None, splitworld=None, worldsinit_fn=None)¶ fill this in.
-
calculateGradient(vnames1, vnames2)¶ The gradient operation produces two components (designated (Y^,X) in the non-split version). vnames1 gives the variable name(s) where the first component should be stored. vnames2 gives the variable name(s) where the second component should be stored.
-
static
calculatePropertiesHelper(self, m, mappings)¶ returns a list of the physical properties from a given level set function m using the mappings of the cost function.
- Parameters
m (
Data) – level set function- Return type
listofData
-
calculateValue(vname)¶
-
createLevelSetFunction(*props)¶ returns an instance of an object used to represent a level set function initialized with zeros. Components can be overwritten by physical properties
props. If present entries must correspond to themappingsarguments in the constructor. UseNonefor properties for which no value is given.
-
static
createLevelSetFunctionHelper(self, regularization, mappings, *props)¶ Returns an object (init-ed) with 0s. Components can be overwritten by physical properties
props. If present entries must correspond to themappingsarguments in the constructor. UseNonefor properties for which no value is given.
-
static
formatMappings(mappings, numLevelSets)¶
-
static
formatModels(forward_models, numMappings)¶
-
getComponentValues(m, *args)¶
-
getDomain()¶ returns the domain of the cost function
- Return type
Domain
-
getForwardModel(idx=None)¶ returns the idx-th forward model.
- Parameters
idx (
int) – model index. If cost function contains one model onlyidxcan be omitted.
-
static
getModelArgs(self, fwdmodels)¶ Attempts to import the arguments for forward models, if they are not available, Computes and exports them
-
getNumTradeOffFactors()¶ returns the number of trade-off factors being used including the trade-off factors used in the regularization component.
- Return type
int
-
getProperties(m, return_list=False)¶ returns a list of the physical properties from a given level set function m using the mappings of the cost function.
- Parameters
m (
Data) – level set functionreturn_list (
bool) – ifTruea list is returned.
- Return type
listofData
-
getRegularization()¶ returns the regularization
- Return type
-
getTradeOffFactors(mu=None)¶ returns a list of the trade-off factors.
- Return type
listoffloat
-
getTradeOffFactorsModels()¶ returns the trade-off factors for the forward models
- Return type
floatorlistoffloat
-
provides_inverse_Hessian_approximation= True¶
-
setPoint()¶
-
setTradeOffFactors(mu=None)¶ sets the trade-off factors for the forward model and regularization terms.
- Parameters
mu (
listoffloat) – list of trade-off factors.
-
setTradeOffFactorsModels(mu=None)¶ sets the trade-off factors for the forward model components.
- Parameters
mu (
floatin case of a single model or alistoffloatwith the length of the number of models.) – list of the trade-off factors. If not present ones are used.
-
setTradeOffFactorsRegularization(mu=None, mu_c=None)¶ sets the trade-off factors for the regularization component of the cost function, see
Regularizationfor details.- Parameters
mu – trade-off factors for the level-set variation part
mu_c – trade-off factors for the cross gradient variation part
-
static
subworld_setMu_model(self, **args)¶
-
updateHessian()¶ notifies the class that the Hessian operator needs to be updated.
-
static
update_point_helper(self, newpoint)¶ Call within a subworld to set ‘current_point’ to newpoint and update all the cached args info
-
class
esys.downunder.SplitMinimizerLBFGS(J=None, m_tol=0.0001, J_tol=None, imax=300)¶ Minimizer that uses the limited-memory Broyden-Fletcher-Goldfarb-Shanno method.
version modified to fit with split world.
-
__init__(J=None, m_tol=0.0001, J_tol=None, imax=300)¶ Initializes a new minimizer for a given cost function.
- Parameters
J (
CostFunction) – the cost function to be minimizedm_tol (float) – terminate interations when relative change of the level set function is less than or equal m_tol
-
getOptions()¶ Returns a dictionary of minimizer-specific options.
-
static
move_point_from_base(self, **kwargs)¶
-
run()¶ This version relies on the costfunction already having an initial guess loaded. It also does not return the result, meaning a job needs to be submitted to get the result out.
-
setOptions(**opts)¶ Sets minimizer-specific options. For a list of possible options see
getOptions().
-
-
class
esys.downunder.SplitRegularization(domain, numLevelSets=1, w0=None, w1=None, wc=None, location_of_set_m=<esys.escriptcore.escriptcpp.Data object>, useDiagonalHessianApproximation=False, tol=1e-08, coordinates=None, scale=None, scale_c=None)¶ The regularization term for the level set function
mwithin the cost function J for an inversion:J(m)=1/2 * sum_k integrate( mu[k] * ( w0[k] * m_k**2 * w1[k,i] * m_{k,i}**2) + sum_l<k mu_c[l,k] wc[l,k] * | curl(m_k) x curl(m_l) |^2
where w0[k], w1[k,i] and wc[k,l] are non-negative weighting factors and mu[k] and mu_c[l,k] are trade-off factors which may be altered during the inversion. The weighting factors are normalized such that their integrals over the domain are constant:
integrate(w0[k] + inner(w1[k,:],1/L[:]**2))=scale[k] volume(domain)* integrate(wc[l,k]*1/L**4)=scale_c[k] volume(domain) *
-
__init__(domain, numLevelSets=1, w0=None, w1=None, wc=None, location_of_set_m=<esys.escriptcore.escriptcpp.Data object>, useDiagonalHessianApproximation=False, tol=1e-08, coordinates=None, scale=None, scale_c=None)¶ initialization.
- Parameters
domain (
Domain) – domainnumLevelSets (
int) – number of level setsw0 (
ScalarifnumLevelSets== 1 orDataobject of shape (numLevelSets,) ifnumLevelSets> 1) – weighting factor for the m**2 term. If not set zero is assumed.w1 (
VectorifnumLevelSets== 1 orDataobject of shape (numLevelSets, DIM) ifnumLevelSets> 1) – weighting factor for the grad(m_i) terms. If not set zero is assumedwc (
Dataobject of shape (numLevelSets,numLevelSets)) – weighting factor for the cross gradient terms. If not set zero is assumed. Used for the case ifnumLevelSets> 1 only. Only valueswc[l,k]in the lower triangle (l<k) are used.location_of_set_m (
ScalarifnumLevelSets== 1 orDataobject of shape (numLevelSets,) ifnumLevelSets> 1) – marks location of zero values of the level set functionmby a positive entry.useDiagonalHessianApproximation (
bool) – if True cross gradient terms between level set components are ignored when calculating approximations of the inverse of the Hessian Operator. This can speed-up the calculation of the inverse but may lead to an increase of the number of iteration steps in the inversion.tol (positive
float) – tolerance when solving the PDE for the inverse of the Hessian Operatorcoordinates (ReferenceSystem` or
SpatialCoordinateTransformation) – defines coordinate system to be usedscale (
ScalarifnumLevelSets== 1 orDataobject of shape (numLevelSets,) ifnumLevelSets> 1) – weighting factor for level set function variation terms. If not set one is used.scale_c (
Dataobject of shape (numLevelSets,``numLevelSets``)) – scale for the cross gradient terms. If not set one is assumed. Used for the case ifnumLevelSets> 1 only. Only valuesscale_c[l,k]in the lower triangle (l<k) are used.
-
getArguments(m)¶
-
getCoordinateTransformation()¶ returns the coordinate transformation being used
- Return type
CoordinateTransformation
-
getDomain()¶ returns the domain of the regularization term
- Return type
Domain
-
getDualProduct(m, r)¶ returns the dual product of a gradient represented by X=r[1] and Y=r[0] with a level set function m:
Y_i*m_i + X_ij*m_{i,j}
- Return type
float
-
getGradient()¶ returns the gradient of f at x using the precalculated values for x.
- Parameters
x (x-type) – location of derivative
args – pre-calculated values for
xfromgetArguments()
- Return type
r-type
-
getGradientAtPoint()¶ returns the gradient of the cost function J with respect to m.
- Note
This implementation returns Y_k=dPsi/dm_k and X_kj=dPsi/dm_kj
-
getInverseHessianApproximationAtPoint(r, solve=True)¶
-
getNorm(m)¶ returns the norm of
m.- Parameters
m (
Data) – level set function- Return type
float
-
getNumLevelSets()¶ returns the number of level set functions
- Return type
int
-
getNumTradeOffFactors()¶ returns the number of trade-off factors being used.
- Return type
int
-
getPDE()¶ returns the linear PDE to be solved for the Hessian Operator inverse
- Return type
linearPDEs.LinearPDE
-
getValue(m, grad_m)¶ returns the value of the cost function J with respect to m. This equation is specified in the inversion cookbook.
- Return type
float
-
getValueAtPoint()¶ returns the value of the cost function J with respect to m. This equation is specified in the inversion cookbook.
- Return type
float
-
setPoint(m)¶ sets the point which this function will work with
- Parameters
m (
Data) – level set function
-
setTradeOffFactors(mu=None)¶ sets the trade-off factors for the level-set variation and the cross-gradient.
- Parameters
mu (
listoffloator`numpy.array`) – new values for the trade-off factors where values mu[:numLevelSets] are the trade-off factors for the level-set variation and the remaining values for the cross-gradient part with mu_c[l,k]=mu[numLevelSets+l+((k-1)*k)/2] (l<k). If no values for mu are given ones are used. Values must be positive.
-
setTradeOffFactorsForCrossGradient(mu_c=None)¶ sets the trade-off factors for the cross-gradient terms.
- Parameters
mu_c (
float,listoffloatornumpy.array) – new values for the trade-off factors for the cross-gradient terms. Values must be positive. If no value is given ones are used. Only value mu_c[l,k] for l<k are used.
-
setTradeOffFactorsForVariation(mu=None)¶ sets the trade-off factors for the level-set variation part.
- Parameters
mu (
float,listoffloator`numpy.array`) – new values for the trade-off factors. Values must be positive.
-
updateHessian()¶ notifies the class to recalculate the Hessian operator.
-
-
class
esys.downunder.StrongJointGravityMagneticInversion(solverclass=None, debug=False, self_demagnetization=False, magnetic_intensity_data=False)¶ Driver class to perform a joint inversion of Gravity (Bouguer) and magnetic anomaly data with the assumption that there is a functional relationship between density and susceptibility.
The class uses the standard
Regularizationclass for a single level set function,DensityMappingandSusceptibilityMappingmappings, the gravity forward modelGravityModeland the linear magnetic forward modelMagneticModel.-
__init__(solverclass=None, debug=False, self_demagnetization=False, magnetic_intensity_data=False)¶ creates an instance of an inversion driver.
- Parameters
solverclass ('AbstractMinimizer'.) – class of the solver to be used.
self_demagnetization – if True self-demagnitization is applied.
magnetic_intensity_data – if True magnetic intensity is used in the cost function.
-
DENSITY= 0¶
-
SUSCEPTIBILITY= 1¶
-
setInitialGuess(rho=None, k=None)¶ set the initial guess rho for density and k for susceptibility for the inversion iteration.
- Parameters
rho (
Scalar) – initial value for the density anomaly.k (
Scalar) – initial value for the susceptibility anomaly.
-
setup(domainbuilder, rho0=None, drho=None, rho_z0=None, rho_beta=None, k0=None, dk=None, k_z0=None, k_beta=None, w0=None, w1=None, w_gc=None, rho_at_depth=None, k_at_depth=None)¶ Sets up the inversion from an instance
domainbuilderof aDomainBuilder. Gravity and magnetic data attached to thedomainbuilderare considered in the inversion. If magnetic data are given as scalar it is assumed that values are collected in direction of the background magnetic field.- Parameters
domainbuilder (
DomainBuilder) – Domain builder object with gravity source(s)rho0 (
floatorScalar) – reference density, seeDensityMapping. If not specified, zero is used.drho (
floatorScalar) – density scale, seeDensityMapping. If not specified, 2750 kg/m^3 is used.rho_z0 (
floatorScalar) – reference depth for depth weighting for density, seeDensityMapping. If not specified, zero is used.rho_beta (
floatorScalar) – exponent for density depth weighting, seeDensityMapping. If not specified, zero is used.k0 (
floatorScalar) – reference susceptibility, seeSusceptibilityMapping. If not specified, zero is used.dk (
floatorScalar) – susceptibility scale, seeSusceptibilityMapping. If not specified, 1. is used.k_z0 (
floatorScalar) – reference depth for susceptibility depth weighting, seeSusceptibilityMapping. If not specified, zero is used.k_beta (
floatorScalar) – exponent for susceptibility depth weighting, seeSusceptibilityMapping. If not specified, zero is used.w0 (
Scalarorfloat) – weighting factor for level set term in the regularization. If not set zero is assumed.w1 (
es.Dataorndarrayof shape (DIM,)) – weighting factor for the gradient term in the regularization seeRegularization. If not set zero is assumed.w_gc (
Scalarorfloat) – weighting factor for the cross gradient term in the regularization, seeRegularization. If not set one is assumed.k_at_depth (
floatorNone) – value for susceptibility at depth, seeDomainBuilder.rho_at_depth (
floatorNone) – value for density at depth, seeDomainBuilder.
-
siloWriterCallback(k, x, Jx, g_Jx, norm_dJ=None, norm_dx=None)¶ callback function that can be used to track the solution
- Parameters
k – iteration count
x – current m approximation
Jx – value of cost function
g_Jx – gradient of f at x
-
-
class
esys.downunder.Subsidence(domain, w, d, lam, mu, coordinates=None, tol=1e-08)¶ Forward Model for subsidence inversion minimizing integrate( (inner(w,u)-d)**2) where u is the surface displacement due to a pressure change P
-
__init__(domain, w, d, lam, mu, coordinates=None, tol=1e-08)¶ Creates a new subsidence on the given domain
- Parameters
domain (
Domain) – domain of the modelw (
VectorwithFunctionOnBoundary) – data weighting factors and directiond (
ScalarwithFunctionOnBoundary) – displacement measured at surfacelam (
ScalarwithFunction) – 1st Lame coefficientlam – 2st Lame coefficient/Shear modulus
coordinates (
ReferenceSystemorSpatialCoordinateTransformation) – defines coordinate system to be used (not supported yet))tol (positive
float) – tolerance of underlying PDE
-
getArguments(P)¶ Returns precomputed values shared by
getDefect()andgetGradient().- Parameters
P (
Scalar) – pressure- Returns
displacement u
- Return type
Vector
-
getDefect(P, u)¶ Returns the value of the defect.
- Parameters
P (
Scalar) – pressureu (
Vector) – corresponding displacement
- Return type
float
-
getGradient(P, u)¶ Returns the gradient of the defect with respect to susceptibility.
- Parameters
P (
Scalar) – pressureu (
Vector) – corresponding displacement
- Return type
Scalar
-
rescaleWeights(scale=1.0, P_scale=1.0)¶ rescales the weights
- Parameters
scale (positive
float) – scale of data weighting factorsP_scale (
Scalar) – scale of pressure increment
-
-
class
esys.downunder.SusceptibilityMapping(domain, z0=None, k0=None, dk=None, beta=None)¶ Susceptibility mapping with depth weighting
k = k0 + dk * ( (x_2 - z0)/l_z)^(beta/2) ) * m
-
__init__(domain, z0=None, k0=None, dk=None, beta=None)¶ set up mapping
- Parameters
domain (
Domain) – domain of the mappingz0 (scalar) – depth weighting offset. If not present no depth scaling is applied.
k0 (scalar) – reference density, defaults to 0
dk (scalar) – susceptibility scale, defaults to 1
beta (
float) – depth weighting exponent, defaults to 2
-
-
class
esys.downunder.SyntheticData(data_type, n_length=1, n_depth=1, depth_offset=0.0, depth=None, amplitude=None, DIM=2, number_of_elements=10, length=1000.0, B_b=None, data_offset=0, full_knowledge=False, s=0.0)¶ Defines synthetic gravity/magnetic data based on harmonic property anomaly
rho = amplitude * sin(n_depth * pi /depth * (z+depth_offset)) * sin(n_length * pi /length * (x - shift) )
for all x and z<=0. For z>0 rho = 0.
-
__init__(data_type, n_length=1, n_depth=1, depth_offset=0.0, depth=None, amplitude=None, DIM=2, number_of_elements=10, length=1000.0, B_b=None, data_offset=0, full_knowledge=False, s=0.0)¶ - Parameters
data_type (
DataSource.GRAVITY,DataSource.MAGNETIC) – data type indicatorn_length (
int) – number of oscillations in the anomaly data within the observation regionn_depth (
int) – number of oscillations in the anomaly data below surfacedepth_offset (
float) – vertical offset of the datadepth (
float) – vertical extent in the anomaly data. If not present the depth of the domain is used.amplitude – data amplitude. Default value is 200 U.kg/U.m**3 for gravity and 0.1 for magnetic data.
DIM (
int(2 or 3)) – spatial dimensionalitynumber_of_elements (
int) – lateral number of elements in the region where data are collectedlength (
float) – lateral extent of the region where data are collectedB_b (
listofScalar) – background magnetic flux density [B_r, B_latiude, B_longitude]. Only used for magnetic data.data_offset (
float) – offset of the data collection region from the surfacefull_knowledge (
Bool) – ifTruedata are collected from the entire subsurface region. This is mainly for testing.
-
getReferenceProperty(domain=None)¶ Returns the reference
Dataobject that was used to generate the gravity/susceptibility anomaly data.
-
-
class
esys.downunder.SyntheticDataBase(data_type, DIM=2, number_of_elements=10, length=1000.0, B_b=None, data_offset=0, full_knowledge=False)¶ Base class to define reference data based on a given property distribution (density or susceptibility). Data are collected from a square region of vertical extent
lengthon a grid withnumber_of_elementscells in each direction.The synthetic data are constructed by solving the appropriate forward problem. Data can be sampled with an offset from the surface at z=0 or using the entire subsurface region.
-
__init__(data_type, DIM=2, number_of_elements=10, length=1000.0, B_b=None, data_offset=0, full_knowledge=False)¶ - Parameters
data_type (
DataSource.GRAVITY,DataSource.MAGNETIC) – data type indicatorDIM (
int(2 or 3)) – number of spatial dimensionsnumber_of_elements (
int) – lateral number of elements in the region where data are collectedlength (
float) – lateral extent of the region where data are collectedB_b (
listofScalar) – background magnetic flux density [B_r, B_latiude, B_longitude]. Only used for magnetic data.data_offset (
float) – offset of the data collection region from the surfacefull_knowledge (
Bool) – ifTruedata are collected from the entire subsurface region. This is mainly for testing.
-
getDataExtents()¶ returns the lateral data extend of the data set
-
getDataType()¶ returns the data type
-
getReferenceProperty(domain=None)¶ Returns the reference
Dataobject that was used to generate the gravity/susceptibility anomaly data.- Returns
the density or susceptibility anomaly used to create the survey data
- Note
it can be assumed that in the first call the
domainargument is present so the actual anomaly data can be created. In subsequent calls this may not be true.- Note
method needs to be overwritten
-
getSurveyData(domain, origin, number_of_elements, spacing)¶ returns the survey data placed on a given domain.
- Parameters
domain (
Domain) – domain on which the data are to be placedorigin (
listoffloat) – origin of the domainnumber_of_elements (
listofint) – number of elements (or cells) in each spatial direction used to span the domainspacing (
listoffloat) – cell size in each spatial direction
- Returns
observed gravity field or magnetic flux density for each cell in the domain and for each cell an indicator 1/0 if the data are valid or not.
- Return type
pair of
Scalar
-
getUtmZone()¶ returns a dummy UTM zone since this class does not use real coordinate values.
-
-
class
esys.downunder.SyntheticFeatureData(data_type, features, DIM=2, number_of_elements=10, length=1000.0, B_b=None, data_offset=0, full_knowledge=False)¶ Uses a list of
SourceFeatureobjects to define synthetic anomaly data.-
__init__(data_type, features, DIM=2, number_of_elements=10, length=1000.0, B_b=None, data_offset=0, full_knowledge=False)¶ - Parameters
data_type (
DataSource.GRAVITY,DataSource.MAGNETIC) – data type indicatorfeatures (
listofSourceFeature) – list of features. It is recommended that the features are located entirely below the surface.DIM (
int(2 or 3)) – spatial dimensionalitynumber_of_elements (
int) – lateral number of elements in the region where data are collectedlength (
float) – lateral extent of the region where data are collectedB_b (
listofScalar) – background magnetic flux density [B_r, B_latiude, B_longitude]. Only used for magnetic data.data_offset (
float) – offset of the data collection region from the surfacefull_knowledge (
Bool) – ifTruedata are collected from the entire subsurface region. This is mainly for testing.
-
getReferenceProperty(domain=None)¶ Returns the reference
Dataobject that was used to generate the gravity/susceptibility anomaly data.
-
-
class
esys.downunder.TTIWave(domain, v_p, v_s, wavelet, source_tag, source_vector=[0.0, 1.0], eps=0.0, delta=0.0, theta=0.0, rho=1.0, dt=None, u0=None, v0=None, absorption_zone=300.0, absorption_cut=0.01, lumping=True)¶ Solving the 2D TTI wave equation with
sigma_xx= c11*e_xx + c13*e_zz + c15*e_xzsigma_zz= c13*e_xx + c33*e_zz + c35*e_xzsigma_xz= c15*e_xx + c35*e_zz + c55*e_xzthe coefficients
c11,c13, etc are calculated from the tompsen parameterseps,deltaand the tilttheta- Note
currently only the 2D case is supported.
-
__init__(domain, v_p, v_s, wavelet, source_tag, source_vector=[0.0, 1.0], eps=0.0, delta=0.0, theta=0.0, rho=1.0, dt=None, u0=None, v0=None, absorption_zone=300.0, absorption_cut=0.01, lumping=True)¶ initialize the TTI wave solver
- Parameters
domain (
Domain) – domain of the problemv_p (
escript.Scalar) – vertical p-velocity fieldv_s (
escript.Scalar) – vertical s-velocity fieldwavelet (
Wavelet) – wavelet to describe the time evolution of source termsource_tag ('str' or 'int') – tag of the source location
source_vector – source orientation vector
eps – first Thompsen parameter
delta – second Thompsen parameter
theta – tilting (in Rad)
rho – density
dt – time step size. If not present a suitable time step size is calculated.
u0 – initial solution. If not present zero is used.
v0 – initial solution change rate. If not present zero is used.
absorption_zone – thickness of absorption zone
absorption_cut – boundary value of absorption decay factor
lumping – if True mass matrix lumping is being used. This is accelerates the computing but introduces some diffusion.
-
class
esys.downunder.VTIWave(domain, v_p, v_s, wavelet, source_tag, source_vector=[0.0, 0.0, 1.0], eps=0.0, gamma=0.0, delta=0.0, rho=1.0, dt=None, u0=None, v0=None, absorption_zone=None, absorption_cut=0.01, lumping=True, disable_fast_assemblers=False)¶ Solving the VTI wave equation
- Note
In case of a two dimensional domain the second spatial dimenion is depth.
-
__init__(domain, v_p, v_s, wavelet, source_tag, source_vector=[0.0, 0.0, 1.0], eps=0.0, gamma=0.0, delta=0.0, rho=1.0, dt=None, u0=None, v0=None, absorption_zone=None, absorption_cut=0.01, lumping=True, disable_fast_assemblers=False)¶ initialize the VTI wave solver
- Parameters
domain (
Domain) – domain of the problemv_p (
escript.Scalar) – vertical p-velocity fieldv_s (
escript.Scalar) – vertical s-velocity fieldwavelet (
Wavelet) – wavelet to describe the time evolution of source termsource_tag ('str' or 'int') – tag of the source location
source_vector – source orientation vector
eps – first Thompsen parameter
delta – second Thompsen parameter
gamma – third Thompsen parameter
rho – density
dt – time step size. If not present a suitable time step size is calculated.
u0 – initial solution. If not present zero is used.
v0 – initial solution change rate. If not present zero is used.
absorption_zone – thickness of absorption zone
absorption_cut – boundary value of absorption decay factor
lumping – if True mass matrix lumping is being used. This is accelerates the computing but introduces some diffusion.
disable_fast_assemblers (
boolean) – if True, forces use of slower and more general PDE assemblers
-
setQ(q)¶ sets the PDE q value
- Parameters
q – the value to set
-
class
esys.downunder.WaveBase(dt, u0, v0, t0=0.0)¶ Base for wave propagation using the Verlet scheme.
u_tt = A(t,u), u(t=t0)=u0, u_t(t=t0)=v0with a given acceleration force as function of time.
a_n=A(t_{n-1}) v_n=v_{n-1} + dt * a_n u_n=u_{n-1} + dt * v_n
-
__init__(dt, u0, v0, t0=0.0)¶ set up the wave base
- Parameters
dt – time step size (need to be sufficiently small)
u0 – initial value
v0 – initial velocity
t0 – initial time
-
getTimeStepSize()¶
-
update(t)¶ returns the solution for the next time marker t which needs to greater than the time marker from the previous call.
-
-
class
esys.downunder.WennerSurvey(domain, primaryConductivity, secondaryConductivity, current, a, midPoint, directionVector, numElectrodes)¶ WennerSurvey forward calculation
-
__init__(domain, primaryConductivity, secondaryConductivity, current, a, midPoint, directionVector, numElectrodes)¶ - Parameters
domain (
Domain) – domain of the modelprimaryConductivity (
data) – preset primary conductivity data objectsecondaryConductivity (
data) – preset secondary conductivity data objectcurrent (
floatorint) – amount of current to be injected at the current electrodea (
list) – the spacing between current and potential electrodesmidPoint – midPoint of the survey, as a list containing x,y coords
directionVector – two element list specifying the direction the survey should extend from the midpoint
numElectrodes (
int) – the number of electrodes to be used in the survey must be a multiple of 2 for polepole survey
-
getApparentResistivityPrimary()¶
-
getApparentResistivitySecondary()¶
-
getApparentResistivityTotal()¶
-
getPotential()¶ returns a list containing 3 lists one for each the primary, secondary and total potential.
-
-
esys.downunder.xrange¶ alias of
range
Functions¶
-
esys.downunder.CartesianCoordinateTransformation(domain, reference=<esys.downunder.coordinates.CartesianReferenceSystem object>)¶
-
esys.downunder.GRS80ReferenceSystem()¶ returns the
GeodeticReferenceSystemfor the GRS80 Ellipsoid eg. used by Geocentric Datum of Australia GDA94
-
esys.downunder.SphericalReferenceSystem(R=6378137.0)¶ returns the
GeodeticReferenceSystemof a sphere :param R: sphere radius :type R: positivedouble
-
esys.downunder.WGS84ReferenceSystem()¶ returns the
GeodeticReferenceSystemfor the WGS84 Ellipsoid
-
esys.downunder.createAbsorptionLayerFunction(x, absorption_zone=300.0, absorption_cut=0.01, top_absorption=False)¶ Creates a distribution which is one in the interior of the domain of
xand is falling down to the value ‘absorption_cut’ over a margin of thickness ‘absorption_zone’ toward each boundary except the top of the domain.- Parameters
x (
escript.Data) – location of points in the domainabsorption_zone – thickness of the absorption zone
absorption_cut – value of decay function on domain boundary
- Returns
function on ‘x’ which is one in the iterior and decays to almost zero over a margin toward the boundary.
-
esys.downunder.makeTransformation(domain, coordinates=None)¶ returns a
SpatialCoordinateTransformationfor the given domain- Parameters
domain (
esys.escript.AbstractDomain) – domain in the domain of the coordinate transformationcoordinates (
ReferenceSystemorSpatialCoordinateTransformation) – the reference system or spatial coordinate system.
- Returns
the spatial coordinate system for the given domain of the specified reference system
coordinates. Ifcoordinatesis already spatial coordinate system based on the riven domaincoordinatesis returned. Otherwise an appropriate spatial coordinate system is created.- Return type
-
esys.downunder.saveSilo(filename, domain=None, write_meshdata=False, time=0.0, cycle=0, **data)¶ Writes
Dataobjects and their mesh to a file using the SILO file format.Example:
temp=Scalar(..) v=Vector(..) saveSilo("solution.silo", temperature=temp, velocity=v)
tempandvare written to “solution.silo” wheretempis named “temperature” andvis named “velocity”.- Parameters
filename (
str) – name of the output file (‘.silo’ is added if required)domain (
escript.Domain) – domain of theDataobjects. If not specified, the domain of the givenDataobjects is used.write_meshdata (
bool) – whether to save mesh-related data such as element identifiers, ownership etc. This is mainly useful for debugging.time (
float) – the timestamp to save within the filecycle (
int) – the cycle (or timestep) of the data<name> – writes the assigned value to the Silo file using <name> as identifier
- Note
All data objects have to be defined on the same domain but they may be defined on separate
FunctionSpaces.
Others¶
pi