# Re: [ferret_users] calculate the density with Pressure

```Hi Jim, Dawn -

```
No, I don't think Jim is correct. If a reference pressure is used, then you must use potential temperature theta instead of temperature. It does not make sense to calculate density at 0 pressure but with temperature at depth (where the pressure affects the temperature). Instead, bring the water parcel adiabatically to the surface by finding theta, then use your reference pressure:
```
```
let theta=theta_fo(salt,temp,z[gz=temp],0) ! potential temperature theta
```let sigma_theta=rho_un(salt,theta,0)-1000

```
See the documentation for the THETA_FO function. For sigma-2, use 2000 instead of zero in the above.
```
```
But I think Dawn is asking something different. Instead of z, she wants to use pressure. Frankly, I don't know the answer to her question ("the results are obviously wrong" doesn't give me much of a clue). However, I think she is on the right track, because I believe the 3rd argument to THETA_FO really should be pressure, not depth (the documentation is unclear on this point). I suggest looking at the reference given under the THETA_FO function (Bryden 1973). Then tell us so the documentation can be fixed if necessary.
```
Billy K

On Jan 22, 2007, at 9:59 AM, James Orr wrote:

```
```Dawn,

```
Your pressure in the 3rd argument of the rho_un function should be the reference pressure:
```
0 for sigma_0
2000 for sigma_2

Cheers,

Jim

On Mon, 22 Jan 2007, ferret ocean wrote:

```
```Dear ferreters,

```
I want to calculate the density with pressure instead of depth (more accuate way), but when I get the pressure with the following scipt to convert the depth to pressure,
```
let x0 = sin(y[g=v]*3.1415926/180);
let c1 = 5.92E-3 + x0*x0 * 5.25E-3;
```
let pres = ((1-c1)-(((1-c1)*(1-c1))-(8.84E-6 * z[g=v]))^0.5) / 4.42E-6;
```
then let rho=rho_un(salt,temp,pres)-1000;

But the results are obviously wrong. Do you have any suggestions?

Dawn
```
```
```
```

```