# The Base Operator Module (Prior, Identity Operator) Documentation¶

## The eoldas_Operator Module¶

class eoldaslib.eoldas_Operator.Operator(options, general, parameter=None, datatype={'y': 'y', 'x': 'x'}, state={'y': None, 'x': None}, sd={'y': None, 'x': None}, names={'y': None, 'x': None}, control={'y': None, 'x': None}, location={'y': None, 'x': None}, name=None, env=None, logger=None, logdir=None, logfile=None, datadir=None, doY=None)

A generic class for the EOLDAS operator

Methods

H(x)

The default operator: an identity operator

This should return self.linear.H with dimensions the same as y if there is a y state. Otherwise, it is assumed of size x.

H_prime(x)

The default differential operator

dH(x)/dx

Here, we return a full matrix but that is not always needed as it can be large for large problems

It may be called by J_prime_prime if there is no better way to calculate J_prime_prime

If you want to circumvent

H_prime_prime(x)

Not yet implemented

d^2H(x)/dxi dxj

J()

The operator contribution to the cost function:

J = 0.5 (y - H(x))^T (C_y^-1 + C_H(x)^-1) (y - H(x))

This is a single value, J

JJ(x)

A call to self.J that also loads x

Required by self.J_prime_approx_3()

J_prime()

The operator contribution to the cost function:

J’ = dJ/dx = (y - H(x))^T (C_y^-1) H’(x)

This should be of dimensions n_

J_prime_approx_1()

A discrete approximation to J_prime

The method assumes that J_prime is independent for each sample in the last column of the state vector.

This will be appropriate e.g. for observation operators where the derivative of one observation does does not depend on any other samples. This means that we can take finite difference steps only over this last dimension and not over all samples.

J_prime_approx_3 J_prime_approx_2 (not yet implemented)
J_prime_approx_3()

A discrete approximation to J_prime

This method is the ‘backup’ and default approximation method for J_prime as it treats all samples independently and so has to go ober x.size finite steps for J.

Generally, J_prime_approx_2 or J_prime_approx_1 will be significantly faster than this, but there may be occasions when this method is appropriate.

The method makes use of and requires DerApproximator so will only work if this python library is available.

It might be adviseable at some point to write a backup method in case that is not installed, but thats not a very good use of time really ...

J_prime_prime()

The operator contribution to the cost function:

J’’ = d^2J/(dx_idx_j)

Here, this is simply Cy^-1

NB: if you inherit this class you must

define a new J_prime_prime if you want to calculate uncertainties

or sel J_prime_prime to return J_prime_prime_approx

J_prime_prime_approx()

The operator contribution to the cost function:

J’’ = d^2J/(dx_idx_j)

numerically.

This is costly and you can normally find a better way to do it.

cost()

If the Operator is a super operator it may contain other operators in self.operators in which case, cost() returns J and J_prime for all sub operators

If not, then just calculate the cost in this operator. Note that in the case of a super operator, we do not count self cost.

fwdError()
Calculate the fwd modelling uncertainty for all operators

This assumes that self.Ihessian has been calculated

For each operator then, op.fwdUncert = H_prime.T self.Ihessian H_prime

getxy(diag=False)
hessian()

If the Operator is a super operator it may contain other operators in self.operators in which case, cost() returns J_prime_prime summed for all sub operators

If not, then just calculate the J_prime_prime in this operator. Note that in the case of a super operator, we do not count self cost.

invtrans(x, lim=[])

Apply the inverse transform to the state vector if it is defined

Utility to load the state vector required here (self.input_x) from fullx

memory()
plot(noy=False, ploterr=False)

Form a plot of the x & y state

A method that gets accessed after data are loaded. You should think of this as a hook so that you don’t have to write a whole new __init__ method.

In this default method, we use it to declare that the operator is linear (self.isLinear = True) and also to set up H_prime for an identity operator.

A method that gets accessed before data are loaded. You should think of this as a hook so that you don’t have to write a whole new __init__ method.

Utility to return a full state vector representation from one that may be only partial

If sum is True, then if multiple items appear per location they are summed. That is a bit fiddly, but is needed e.g. for loading derivative data.

If sum is False, then only the first instance we come across is loaded.

If M is True, then we are unloading a matrix which will normally be the hessian

write(filename, dataset, fmt='pickle')

A write method for outputting state variables

e.g. self.write(‘xxx.dat’,’x’,fmt=’PARAMETERS’)

Will also do basic plotting of state and observations if possible.

eoldaslib.eoldas_Operator.demonstration(plot=False)
eoldaslib.eoldas_Operator.tester(plot=True)

Derivative test for individual J_primes