# How can I show the value of my variable at its deepest depth?

## Question:

I want to shade a variable (e.g. temp) at the deepest depth (highest k level) not including missing values.

## Explanation:

The @WEQ transformation lets us define a variable with the same shape as our original variable, weighted according to whether the value reaches a particular value. We will define a variable which is zero where the deepest depth exists, and use this to pick off the temperature values at that deepest depth for each (x,y) location.

## Solution:

Here is an example using the Levitus Climatology dataset:

yes? USE levitus_climatology

Define a variable containing the K index of all existing data (missing where TEMP is missing). Plot a slice of it at Y=10.

yes? LET kvals = k[G=temp] + 0*temp yes? SHADE/Y=10/TITLE="index of good data" kvals

Now define a variable which is always zero at the maximum existing depth. Plot a slice of it.

yes? LET kzero = kvals - kvals[K=1:`temp,RETURN=kend`@MAX] yes? SHADE/Y=10/TITLE="zero at max depth" kzero

The variable INTEGRAND has the value of TEMP, at the depth of deepest available data. Again, we will plot a slice of this at Y=10 and X=50E:150E.

yes? LET integrand = TEMP* kzero[K=@WEQ:0] yes? SHADE/TITLE="Temperature at depth of deepest data" integrand[Y=10,X=50E:150E]

Take the sum over depth. The integrand has just one value at each (X,Y) location, the temperature at the maximum depth. The sum removes the depth dependence, resulting in of TEMP at the deepest depth at each x,y location.

yes? let temp_bottom = integrand[k=1:`temp,return=kend`@sum] yes? shade/lev=v/title="Temperature at deepest depth" temp_bottom

Example contributed by Andrew Wittenberg, GFDL

Last modified: Dec 3 2004