Source code for salishsea_tools.psu_tools

# Copyright 2016 The Salish Sea NEMO Project and
# The University of British Columbia

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#    http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Functions for converting temperature and salinity(psu) to density
"""


[docs]def calculate_density(t, s): """Calculates the density given temperature in deg C (t) and salinity in psu (s). The reference for this calculation is: Pond and Pickard, (1983). Introductory Dynamical Oceanography :arg t: temperature array in deg C :type t: numpy array :arg s: salinity array in psu :type s: numpy array :returns: the density as an array (rho) in kg/m^3 """ rho = ( 999.842594 + 6.793952e-2 * t - 9.095290e-3 * t*t + 1.001685e-4 * t*t*t - 1.120083e-6 * t*t*t*t + 6.536332e-9 * t*t*t*t*t + 8.24493e-1 * s - 4.0899e-3 * t*s + 7.6438e-5 * t*t*s - 8.2467e-7 * t*t*t*s + 5.3875e-9 * t*t*t*t*s - 5.72466e-3 * s**1.5 + 1.0227e-4 * t*s**1.5 - 1.6546e-6 * t*t*s**1.5 + 4.8314e-4 * s*s ) return rho