gusto.diagnostics package

Submodules

gusto.diagnostics.compressible_euler_diagnostics module

Common diagnostic fields for the compressible Euler equations.

class gusto.diagnostics.compressible_euler_diagnostics.BruntVaisalaFrequencySquared(equations, space=None, method='interpolate')[source]

Bases: DiagnosticField

The diagnostic for the Brunt-Väisälä frequency.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'Brunt-Vaisala_squared'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.CompressibleKineticEnergy(space=None, method='interpolate')[source]

Bases: Energy

Diagnostic (dry) compressible kinetic energy density.

Parameters:
  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'CompressibleKineticEnergy'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field :param domain: the model’s domain object. :type domain: Domain :param state_fields: the model’s field container. :type state_fields: StateFields

class gusto.diagnostics.compressible_euler_diagnostics.DewpointTemperature(equations, space=None, method='interpolate', num_iterations=3, gamma=1.0)[source]

Bases: IterativeDiagnosticField

The dewpoint temperature diagnostic field. The temperature to which air must be cooled in order to become saturated.

Note: this will not give sensible answers in the absence of water vapour.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

  • num_iterations (integer, optional) – number of times to iteratively evaluate the expression. Defaults to 3.

  • gamma (float, optional) – weight given to previous guess, which is used to avoid numerical instabilities. Defaults to 1.0.

implicit_expr(domain, state_fields)[source]

The implicit UFL expression for the diagnostic, which should depend on self.field

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

name = 'Dewpoint'
set_first_guess(domain, state_fields)[source]

The first guess of the diagnostic, set to be the dry temperature.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.DynamicEntropy(equations, space=None, method='interpolate')[source]

Bases: Entropy

Dynamic entropy 0.5*ρ*θ^2 for Compressible Euler equations

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'DynamicEntropy'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.Entropy(equations, space=None, method='interpolate')[source]

Bases: DiagnosticField

Base diagnostic field for entropy diagnostic

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

class gusto.diagnostics.compressible_euler_diagnostics.Exner(parameters, reference=False, space=None, method='interpolate')[source]

Bases: DiagnosticField

The diagnostic Exner pressure field.

Parameters:
  • parameters (CompressibleParameters) – the configuration object containing the physical parameters for this equation.

  • reference (bool, optional) – whether to compute the reference Exner pressure field or not. Defaults to False.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.Exner_Vt(equations, space=None, method='interpolate')[source]

Bases: ThermodynamicDiagnostic

The Exner pressure field computed in the ‘theta’ space.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'Exner_Vt'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.HydrostaticImbalance(equations, space=None, method='interpolate')[source]

Bases: DiagnosticField

Hydrostatic imbalance diagnostic field.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

compute()[source]

Compute and return the diagnostic field from the current state.

name = 'HydrostaticImbalance'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.InternalEnergy(equations, space=None, method='interpolate')[source]

Bases: ThermodynamicDiagnostic

The moist compressible internal energy density.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'InternalEnergy'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.PhysicalEntropy(equations, space=None, method='interpolate')[source]

Bases: Entropy

Physical entropy ρ*ln(θ) for Compressible Euler equations

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'PhysicalEntropy'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.PotentialEnergy(equations, space=None, method='interpolate')[source]

Bases: ThermodynamicDiagnostic

The moist compressible potential energy density.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'PotentialEnergy'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.Precipitation[source]

Bases: DiagnosticField

The total precipitation falling through the domain’s bottom surface.

This is normalised by unit area, giving a result in kg / m^2.

Parameters:
  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

  • required_fields (tuple, optional) – tuple of names of the fields that are required for the computation of this diagnostic field. Defaults to ().

compute()[source]

Increment the precipitation diagnostic.

name = 'Precipitation'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.Pressure(equations, space=None, method='interpolate')[source]

Bases: ThermodynamicDiagnostic

The pressure field computed in the ‘theta’ space.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'Pressure_Vt'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.RelativeHumidity(equations, space=None, method='interpolate')[source]

Bases: ThermodynamicDiagnostic

The relative humidity diagnostic field.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'RelativeHumidity'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.RichardsonNumber(density_field, factor=1.0, space=None, method='interpolate')[source]

Bases: DiagnosticField

Dimensionless Richardson number diagnostic field.

Parameters:
  • density_field (str) – the name of the density field.

  • factor (float, optional) – a factor to multiply the Brunt-Väisälä frequency by. Defaults to 1.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'RichardsonNumber'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.Temperature(equations, space=None, method='interpolate')[source]

Bases: ThermodynamicDiagnostic

The absolute temperature diagnostic field.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'Temperature'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.ThermodynamicKineticEnergy(equations, space=None, method='interpolate')[source]

Bases: ThermodynamicDiagnostic

The moist compressible kinetic energy density.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'ThermodynamicKineticEnergy'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.Theta_d(equations, space=None, method='interpolate')[source]

Bases: ThermodynamicDiagnostic

The dry potential temperature diagnostic field.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'Theta_d'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.Theta_e(equations, space=None, method='interpolate')[source]

Bases: ThermodynamicDiagnostic

The moist equivalent potential temperature diagnostic field.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'Theta_e'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.compressible_euler_diagnostics.WetBulbTemperature(equations, space=None, method='interpolate', num_iterations=3, gamma=0.5)[source]

Bases: IterativeDiagnosticField

The wet-bulb temperature diagnostic field. The temperature of air cooled to saturation by the evaporation of water.

Parameters:
  • equations (PrognosticEquationSet) – the equation set being solved by the model.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

  • num_iterations (integer, optional) – number of times to iteratively evaluate the expression. Defaults to 3.

  • gamma (float, optional) – weight given to previous guess, which is used to avoid numerical instabilities. Defaults to 0.8.

implicit_expr(domain, state_fields)[source]

The implicit UFL expression for the diagnostic, which should depend on self.field

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

name = 'WetBulb'
set_first_guess(domain, state_fields)[source]

The first guess of the diagnostic, set to be the dry temperature.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

gusto.diagnostics.diagnostics module

Common diagnostic fields.

class gusto.diagnostics.diagnostics.CourantNumber(velocity='u', component='whole', name=None, to_dump=True, space=None, method='interpolate', required_fields=())[source]

Bases: DiagnosticField

Dimensionless Courant number diagnostic field.

Parameters:
  • velocity (str or ufl.Expr, optional) – the velocity field to take the Courant number of. Can be a string referring to an existing field, or an expression. If it is an expression, the name argument is required. Defaults to ‘u’.

  • component (str, optional) – the component of the velocity to use for calculating the Courant number. Valid values are “whole”, “horizontal” or “vertical”. Defaults to “whole”.

  • name (str, optional) – the name to append to “CourantNumber” to form the name of this diagnostic. This argument must be provided if the velocity is an expression (rather than a string). Defaults to None.

  • to_dump (bool, optional) – whether this diagnostic should be dumped. Defaults to True.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

  • required_fields (tuple, optional) – tuple of names of the fields that are required for the computation of this diagnostic field. Defaults to ().

compute()[source]

Compute the diagnostic field from the current state.

name = 'CourantNumber'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.DiagnosticField(space=None, method='interpolate', required_fields=())[source]

Bases: object

Base object to represent diagnostic fields for outputting.

Parameters:
  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

  • required_fields (tuple, optional) – tuple of names of the fields that are required for the computation of this diagnostic field. Defaults to ().

compute()[source]

Compute the diagnostic field from the current state.

abstract property name

The name of this diagnostic field

abstract setup(domain, state_fields, space=None)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

  • space (FunctionSpace, optional) – the function space for the diagnostic field to be computed in. Defaults to None, in which case the space will be DG0.

class gusto.diagnostics.diagnostics.Diagnostics(*fields)[source]

Bases: object

Stores all diagnostic fields, and controls global diagnostics computation.

This object stores the diagnostic fields to be output, and the computation of global values from them (such as global maxima or norms).

Parameters:

*fields – list of Function objects of fields to be output.

available_diagnostics = ['min', 'max', 'rms', 'l2', 'total']
static l2(f)[source]

Calculates the L2 norm of a field.

Parameters:

f (Function) – field to compute diagnostic for.

static max(f)[source]

Finds the global maximum DoF value of a field.

Parameters:

f (Function) – field to compute diagnostic for.

static min(f)[source]

Finds the global minimum DoF value of a field.

Parameters:

f (Function) – field to compute diagnostic for.

register(*fields)[source]

Registers diagnostic fields for outputting.

Parameters:

*fields – list of Function objects of fields to be output.

static rms(f)[source]

Calculates the root-mean-square of a field.

Parameters:

f (Function) – field to compute diagnostic for.

static total(f)[source]

Calculates the total of a field. Only applicable for fields with scalar-values.

Parameters:

f (Function) – field to compute diagnostic for.

class gusto.diagnostics.diagnostics.Difference(field_name1, field_name2)[source]

Bases: DiagnosticField

Base diagnostic for calculating the difference between two fields.

Parameters:
  • field_name1 (str) – the name of the field to be subtracted from.

  • field_name2 (str) – the name of the field to be subtracted.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.Divergence(name='u', space=None, method='interpolate')[source]

Bases: DiagnosticField

Diagnostic for computing the divergence of vector-valued fields.

Parameters:
  • name (str, optional) – name of the field to compute the gradient of. Defaults to ‘u’, in which case this takes the divergence of the wind field.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case the default space is the domain’s DG space.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.Energy(space=None, method='interpolate', required_fields=())[source]

Bases: DiagnosticField

Base diagnostic field for computing energy density fields.

Parameters:
  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

  • required_fields (tuple, optional) – tuple of names of the fields that are required for the computation of this diagnostic field. Defaults to ().

kinetic(u, factor=None)[source]

Computes a kinetic energy term.

Parameters:
  • u (ufl.Expr) – the velocity variable.

  • factor (ufl.Expr, optional) – factor to multiply the term by (e.g. a density variable). Defaults to None.

Returns:

the kinetic energy term

Return type:

ufl.Expr

class gusto.diagnostics.diagnostics.Gradient(name, space=None, method='solve')[source]

Bases: DiagnosticField

Diagnostic for computing the gradient of fields.

Parameters:
  • name (str) – name of the field to compute the gradient of.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘solve’.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.IterativeDiagnosticField(space=None, method='interpolate', required_fields=(), num_iterations=3, gamma=0.8)[source]

Bases: DiagnosticField

Iterative evaluation of a diagnostic expression for diagnostics with no explicit definition but an implicit definition. This uses a form of damped Picard iteration.

Parameters:
  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

  • required_fields (tuple, optional) – tuple of names of the fields that are required for the computation of this diagnostic field. Defaults to ().

  • num_iterations (integer, optional) – number of times to iteratively evaluate the expression. Defaults to 3.

  • gamma (float, optional) – weight given to previous guess, which is used to avoid numerical instabilities.

compute()[source]

Compute the diagnostic field from the current state.

abstract property implicit_expr

The implicit UFL expression for the diagnostic, which should depend on self.field

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

abstract property set_first_guess

The first guess of the diagnostic

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

setup(domain, state_fields, space=None)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

  • space (FunctionSpace, optional) – the function space for the diagnostic field to be computed in. Defaults to None, in which case the space will be DG0.

class gusto.diagnostics.diagnostics.KineticEnergy(space=None, method='interpolate')[source]

Bases: Energy

Diagnostic kinetic energy density.

Parameters:
  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'KineticEnergy'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.MeridionalComponent(name, rotated_pole=None, space=None, method='interpolate')[source]

Bases: SphericalComponent

The meridional component of a vector-valued field.

Parameters:
  • name (str) – name of the field to compute the component of.

  • rotated_pole (tuple of floats, optional) – a tuple of floats (lon, lat) of the new pole, in the original coordinate system. The longitude and latitude must be expressed in radians. Defaults to None, corresponding to a pole of (0, pi/2).

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case the default space is the domain’s DG space.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.Perturbation(name)[source]

Bases: Difference

Base diagnostic for computing perturbations from a reference profile.

Parameters:

name (str) – name of the field to take the perturbation of.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.RadialComponent(name, rotated_pole=None, space=None, method='interpolate')[source]

Bases: SphericalComponent

The radial component of a vector-valued field.

Parameters:
  • name (str) – name of the field to compute the component of.

  • rotated_pole (tuple of floats, optional) – a tuple of floats (lon, lat) of the new pole, in the original coordinate system. The longitude and latitude must be expressed in radians. Defaults to None, corresponding to a pole of (0, pi/2).

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case the default space is the domain’s DG space.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.SteadyStateError(name)[source]

Bases: Difference

Base diagnostic for computing the steady-state error in a field.

Parameters:

name (str) – name of the field to take the steady-state error of.

compute()[source]

Compute the diagnostic field from the current state.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.Sum(field_name1, field_name2)[source]

Bases: DiagnosticField

Base diagnostic for computing the sum of two fields.

Parameters:
  • field_name1 (str) – the name of one field to be added.

  • field_name2 (str) – the name of the other field to be added.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.TracerDensity(mixing_ratio_name, density_name, space=None, method='interpolate')[source]

Bases: DiagnosticField

Diagnostic for computing the density of a tracer. This is computed as the product of a mixing ratio and dry density

Parameters:
  • mixing_ratio_name (str) – the name of the tracer mixing ratio variable

  • density_name (str) – the name of the tracer density variable

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a new space will be constructed for this diagnostic. This space will have enough a high enough degree to accurately compute the product of the mixing ratio and density.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’ and ‘assign’. Defaults to ‘interpolate’.

property name

Gives the name of this diagnostic field. This records the mixing ratio and density names, in case multiple tracer densities are used.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.XComponent(name, space=None, method='interpolate')[source]

Bases: VectorComponent

The geocentric Cartesian x-component of a vector-valued field.

Parameters:
  • name (str) – name of the field to compute the component of.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case the default space is the domain’s DG space.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.YComponent(name, space=None, method='interpolate')[source]

Bases: VectorComponent

The geocentric Cartesian y-component of a vector-valued field.

Parameters:
  • name (str) – name of the field to compute the component of.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case the default space is the domain’s DG space.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.ZComponent(name, space=None, method='interpolate')[source]

Bases: VectorComponent

The geocentric Cartesian z-component of a vector-valued field.

Parameters:
  • name (str) – name of the field to compute the component of.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case the default space is the domain’s DG space.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.diagnostics.ZonalComponent(name, rotated_pole=None, space=None, method='interpolate')[source]

Bases: SphericalComponent

The zonal component of a vector-valued field.

Parameters:
  • name (str) – name of the field to compute the component of.

  • rotated_pole (tuple of floats, optional) – a tuple of floats (lon, lat) of the new pole, in the original coordinate system. The longitude and latitude must be expressed in radians. Defaults to None, corresponding to a pole of (0, pi/2).

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case the default space is the domain’s DG space.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

gusto.diagnostics.shallow_water_diagnostics module

Common diagnostic fields for the Shallow Water equations.

class gusto.diagnostics.shallow_water_diagnostics.AbsoluteVorticity(space=None, method='solve')[source]

Bases: Vorticity

Diagnostic field for absolute vorticity, ζ=∇×(u+f)

Parameters:
  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘solve’.

name = 'AbsoluteVorticity'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.shallow_water_diagnostics.PotentialVorticity(space=None, method='solve')[source]

Bases: Vorticity

Diagnostic field for shallow-water potential vorticity, q=(∇×(u+f))/D

Parameters:
  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘solve’.

name = 'PotentialVorticity'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.shallow_water_diagnostics.RelativeVorticity(space=None, method='solve')[source]

Bases: Vorticity

Diagnostic field for relative vorticity, ζ=∇×u

Parameters:
  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘solve’.

name = 'RelativeVorticity'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.shallow_water_diagnostics.ShallowWaterKineticEnergy(space=None, method='interpolate')[source]

Bases: Energy

Diagnostic shallow-water kinetic energy density.

Parameters:
  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'ShallowWaterKineticEnergy'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.shallow_water_diagnostics.ShallowWaterPotentialEnergy(parameters, space=None, method='interpolate')[source]

Bases: Energy

Diagnostic shallow-water potential energy density.

Parameters:
  • parameters (ShallowWaterParameters) – the configuration object containing the physical parameters for this equation.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

name = 'ShallowWaterPotentialEnergy'
setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

class gusto.diagnostics.shallow_water_diagnostics.ShallowWaterPotentialEnstrophy(base_field_name='PotentialVorticity', space=None, method='interpolate')[source]

Bases: DiagnosticField

Diagnostic (dry) compressible kinetic energy density.

Parameters:
  • base_field_name (str, optional) – the base potential vorticity field to compute the enstrophy from. Defaults to “PotentialVorticity”.

  • space (FunctionSpace, optional) – the function space to evaluate the diagnostic field in. Defaults to None, in which case a default space will be chosen for this diagnostic.

  • method (str, optional) – a string specifying the method of evaluation for this diagnostic. Valid options are ‘interpolate’, ‘project’, ‘assign’ and ‘solve’. Defaults to ‘interpolate’.

property name

Gives the name of this diagnostic field.

setup(domain, state_fields)[source]

Sets up the Function for the diagnostic field.

Parameters:
  • domain (Domain) – the model’s domain object.

  • state_fields (StateFields) – the model’s field container.

Module contents