0
# Core EOS-80 Functions
1
2
Fundamental equation of state calculations for seawater based on the UNESCO 1983 algorithms. These functions provide the essential relationships between salinity, temperature, pressure, and density that form the foundation of oceanographic calculations.
3
4
## Capabilities
5
6
### Density Calculations
7
8
Core density calculations using the EOS-80 equation of state.
9
10
```python { .api }
11
def dens(s, t, p):
12
"""
13
Density of seawater using the EOS-80 equation of state.
14
15
Parameters:
16
- s: array_like, salinity [psu (PSS-78)]
17
- t: array_like, temperature [°C (ITS-90)]
18
- p: array_like, pressure [db]
19
20
Returns:
21
- array_like: density [kg/m³]
22
"""
23
24
def dens0(s, t):
25
"""
26
Density of seawater at atmospheric pressure.
27
28
Parameters:
29
- s: array_like, salinity [psu (PSS-78)]
30
- t: array_like, temperature [°C (ITS-90)]
31
32
Returns:
33
- array_like: density at atmospheric pressure [kg/m³]
34
"""
35
36
def pden(s, t, p, pr=0):
37
"""
38
Potential density of seawater.
39
40
Parameters:
41
- s: array_like, salinity [psu (PSS-78)]
42
- t: array_like, temperature [°C (ITS-90)]
43
- p: array_like, pressure [db]
44
- pr: array_like, reference pressure [db], default 0
45
46
Returns:
47
- array_like: potential density [kg/m³]
48
"""
49
```
50
51
### Temperature Calculations
52
53
Temperature transformations and potential temperature calculations.
54
55
```python { .api }
56
def ptmp(s, t, p, pr=0):
57
"""
58
Potential temperature of seawater.
59
60
Parameters:
61
- s: array_like, salinity [psu (PSS-78)]
62
- t: array_like, in-situ temperature [°C (ITS-90)]
63
- p: array_like, pressure [db]
64
- pr: array_like, reference pressure [db], default 0
65
66
Returns:
67
- array_like: potential temperature [°C (ITS-90)]
68
"""
69
70
def temp(s, pt, p, pr=0):
71
"""
72
In-situ temperature from potential temperature.
73
74
Parameters:
75
- s: array_like, salinity [psu (PSS-78)]
76
- pt: array_like, potential temperature [°C (ITS-90)]
77
- p: array_like, pressure [db]
78
- pr: array_like, reference pressure [db], default 0
79
80
Returns:
81
- array_like: in-situ temperature [°C (ITS-90)]
82
"""
83
84
def adtg(s, t, p):
85
"""
86
Adiabatic temperature gradient.
87
88
Parameters:
89
- s: array_like, salinity [psu (PSS-78)]
90
- t: array_like, temperature [°C (ITS-90)]
91
- p: array_like, pressure [db]
92
93
Returns:
94
- array_like: adiabatic temperature gradient [°C/db]
95
"""
96
```
97
98
### Pressure and Depth
99
100
Conversions between pressure and depth.
101
102
```python { .api }
103
def pres(depth, lat):
104
"""
105
Pressure from depth using Fofonoff and Millard (1983).
106
107
Parameters:
108
- depth: array_like, depth [m]
109
- lat: array_like, latitude [decimal degrees]
110
111
Returns:
112
- array_like: pressure [db]
113
"""
114
115
def dpth(p, lat):
116
"""
117
Depth from pressure using Fofonoff and Millard (1983).
118
119
Parameters:
120
- p: array_like, pressure [db]
121
- lat: array_like, latitude [decimal degrees]
122
123
Returns:
124
- array_like: depth [m]
125
"""
126
```
127
128
### Salinity Calculations
129
130
Salinity calculations from conductivity measurements.
131
132
```python { .api }
133
def salt(r, t, p):
134
"""
135
Salinity from conductivity ratio using PSS-78.
136
137
Parameters:
138
- r: array_like, conductivity ratio (C/C[35,15,0])
139
- t: array_like, temperature [°C (ITS-90)]
140
- p: array_like, pressure [db]
141
142
Returns:
143
- array_like: salinity [psu (PSS-78)]
144
"""
145
```
146
147
### Sound Velocity
148
149
Sound velocity in seawater.
150
151
```python { .api }
152
def svel(s, t, p):
153
"""
154
Sound velocity in seawater using Chen and Millero (1977).
155
156
Parameters:
157
- s: array_like, salinity [psu (PSS-78)]
158
- t: array_like, temperature [°C (ITS-90)]
159
- p: array_like, pressure [db]
160
161
Returns:
162
- array_like: sound velocity [m/s]
163
"""
164
```
165
166
### Thermodynamic Properties
167
168
Thermodynamic properties of seawater.
169
170
```python { .api }
171
def cp(s, t, p):
172
"""
173
Heat capacity of seawater.
174
175
Parameters:
176
- s: array_like, salinity [psu (PSS-78)]
177
- t: array_like, temperature [°C (ITS-90)]
178
- p: array_like, pressure [db]
179
180
Returns:
181
- array_like: specific heat capacity [J/(kg·°C)]
182
"""
183
184
def alpha(s, t, p, *, pt=False):
185
"""
186
Thermal expansion coefficient of seawater.
187
188
Parameters:
189
- s: array_like, salinity [psu (PSS-78)]
190
- t: array_like, temperature [°C (ITS-90)]
191
- p: array_like, pressure [db]
192
- pt: bool, use potential temperature if True
193
194
Returns:
195
- array_like: thermal expansion coefficient [1/°C]
196
"""
197
198
def beta(s, t, p, *, pt=False):
199
"""
200
Saline contraction coefficient of seawater.
201
202
Parameters:
203
- s: array_like, salinity [psu (PSS-78)]
204
- t: array_like, temperature [°C (ITS-90)]
205
- p: array_like, pressure [db]
206
- pt: bool, use potential temperature if True
207
208
Returns:
209
- array_like: saline contraction coefficient [1/psu]
210
"""
211
212
def aonb(s, t, p, *, pt=False):
213
"""
214
Ratio of thermal expansion to saline contraction coefficients.
215
216
Parameters:
217
- s: array_like, salinity [psu (PSS-78)]
218
- t: array_like, temperature [°C (ITS-90)]
219
- p: array_like, pressure [db]
220
- pt: bool, use potential temperature if True
221
222
Returns:
223
- array_like: alpha/beta ratio [psu·°C⁻¹]
224
"""
225
```
226
227
### Gravity and Freezing Point
228
229
Gravity variations and freezing point calculations.
230
231
```python { .api }
232
def g(lat, z=0):
233
"""
234
Acceleration due to gravity as a function of latitude.
235
236
Parameters:
237
- lat: array_like, latitude [decimal degrees]
238
- z: array_like, height above sea level [m], default 0
239
240
Returns:
241
- array_like: acceleration due to gravity [m/s²]
242
"""
243
244
def fp(s, p):
245
"""
246
Freezing point of seawater.
247
248
Parameters:
249
- s: array_like, salinity [psu (PSS-78)]
250
- p: array_like, pressure [db]
251
252
Returns:
253
- array_like: freezing point temperature [°C (ITS-90)]
254
"""
255
```
256
257
## Usage Examples
258
259
### Basic Property Calculations
260
261
```python
262
import seawater as sw
263
import numpy as np
264
265
# Define typical oceanographic conditions
266
s = 35.0 # salinity in psu
267
t = 15.0 # temperature in °C
268
p = 100.0 # pressure in decibars
269
270
# Calculate fundamental properties
271
density = sw.dens(s, t, p)
272
potential_temp = sw.ptmp(s, t, p)
273
sound_vel = sw.svel(s, t, p)
274
275
print(f"Density: {density:.3f} kg/m³")
276
print(f"Potential temperature: {potential_temp:.3f} °C")
277
print(f"Sound velocity: {sound_vel:.2f} m/s")
278
```
279
280
### Profile Analysis
281
282
```python
283
import seawater as sw
284
import numpy as np
285
286
# Create a typical ocean profile
287
pressure = np.array([0, 50, 100, 200, 500, 1000]) # db
288
temperature = np.array([20, 18, 15, 10, 5, 3]) # °C
289
salinity = np.full_like(pressure, 35.0) # psu
290
291
# Calculate profile properties
292
density = sw.dens(salinity, temperature, pressure)
293
pot_temp = sw.ptmp(salinity, temperature, pressure)
294
pot_density = sw.pden(salinity, temperature, pressure)
295
296
# Display results
297
for i in range(len(pressure)):
298
print(f"P: {pressure[i]:4.0f} db, "
299
f"T: {temperature[i]:5.1f} °C, "
300
f"θ: {pot_temp[i]:5.2f} °C, "
301
f"ρ: {density[i]:7.3f} kg/m³")
302
```