# [idvusers] Ocean pressure => depth in IDV

```IDV users,

I just discovered that IDV cannot plot ocean profile data correctly
when the vertical coordinate is pressure.

Profiling instruments determine depth by measuring the hydrostatic
pressure, so pressure relative to the sea surface is commonly used as
the vertical coordinate for ocean profile data.    The units of ocean
pressure are nearly decibars, because they equate very nearly to
meters.    Here's an example table at 40 degrees north from "Data
Analysis Methods in Physical Oceanography" by Emery and Thomson:

Pressure     Depth   Difference
(dbar)         (m)            (%)
0                 0               0
100               99               1
1000             990               1
2000           1975            1.3
3000           2956            1.5
6000           5872            2.1

For the atmosphere, the IDV users guide says "the IDV displays
pressure surfaces by converting the pressure to a height in some
reference system. There are two reference systems that come standard
with the IDV - the U.S. Standard Atmosphere and a logarithmic
conversion (also used in Vis5D). The U.S. Standard Atmosphere only
computes conversions for pressures up to about 80 km. The logarithmic
coordinate system uses the following equations:
P = 1012.5 * e^( H / -7.2 )        (^ denotes exponentiation)
H = -7.2 * Ln( P / 1012.5 )        (Ln denotes natural log)
so can be used for heights above 80 km."

For the ocean, we either simply use decibars as depth, or as in the
atmophere, use a formula to convert pressure to depth.

I know of two standard  formulas (given here in Matlab syntax, but
hopefully understandable):

1. the official UNESCO formula to derive depth from pressure:
% Eqn 25, p26.  Unesco 1983.
%    Unesco 1983. Algorithms for computation of fundamental properties of
%    seawater, 1983. _Unesco Tech. Pap. in Mar. Sci._, No. 44, 53 pp.
%   coded in Matlab by Phil Morgan, CSIRO
%=========================================================================

function DEPTHM = sw_dpth(P,LAT)

% DEPTHM = depth in meters
% P = pressure in decibars
% LAT = latitude in decimal degrees north

c1 = +9.72659;
c2 = -2.2512E-5;
c3 = +2.279E-10;
c4 = -1.82E-15;
gam_dash = 2.184e-6;

LAT = abs(LAT);
X   = X.*X;
bot_line = 9.780318*(1.0+(5.2788E-3+2.36E-5*X).*X) + gam_dash*0.5*P;
top_line = (((c4*P+c3).*P+c2).*P+c1).*P;
DEPTHM   = top_line./bot_line;

2.  the simpler version from Saunders, which produces depths within
one meter of the more complex UNESCO formula:

%Saunders, 1981, "Practical conversion of pressure to depth"
% Journal of Physical Oceanography, April 1981, V11, p573-574.

function DEPTHM = sw_depth(P,LAT)
c1 = (5.92 + 5.25*X.*X)*1.e-3;
c2 = 2.21E-6;
DEPTHM = (1 - c1).*P - c2*P.*P;

If it were me, I'd use the latter.

Of course, how to determine whether we are in the ocean or not?

Perhaps in IDV we could just use the ocean formula when the units are
"decibars", "decibar", "dbar" or "dbars" until we have a CF convention
(or do we already have one) to determine if we are in the ocean or
not.

-Rich
--
Dr. Richard P. Signell (508) 457-2229
USGS, 384 Woods Hole Rd.
Woods Hole, MA 02543-1598

```