barakuda_physics.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #
  2. # Laurent Brodeau
  3. #
  4. # November 2013
  5. import sys
  6. import numpy as nmp
  7. import math
  8. ########################
  9. # SIGMA DENSITY STUFFS #
  10. ########################
  11. rsigma_dense = 27.8
  12. zrau0 = 1000.
  13. rt0 = 273.16
  14. grav = 9.8 # gravity
  15. def sigma0(XT, XS):
  16. #--------------------------------------------------------------------
  17. # *** FUNCTION sigma0 ***
  18. #
  19. # ** Purpose : Compute the in situ density (ratio rho/rau0) and the
  20. # potential volumic mass (Kg/m3) from potential temperature
  21. # and salinity fields using an equation of state defined
  22. # through the namelist parameter neos.
  23. #
  24. # ** Method : Jackett and McDougall (1994) equation of state.
  25. # The in situ density is computed directly as a function of
  26. # potential temperature relative to the surface (the opa t
  27. # variable), salt and pressure (assuming no pressure variation
  28. # along geopotential surfaces, i.e. the pressure p in decibars
  29. # is approximated by the depth in meters.
  30. # prd(t,s,p) = ( rho(t,s,p) - rau0 ) / rau0
  31. # rhop(t,s) = rho(t,s,0)
  32. # with pressure p decibars
  33. # potential temperature t deg celsius
  34. # salinity s psu
  35. # reference volumic mass rau0 kg/m**3
  36. # in situ volumic mass rho kg/m**3
  37. # in situ density anomalie prd no units
  38. #
  39. #----------------------------------------------------------------------
  40. Vshape = nmp.shape(XT)
  41. nsize = nmp.size(XT) ; # number of elements in array
  42. nbdim = len(Vshape) ; # number of dimensions...
  43. if nmp.shape(XS) != Vshape:
  44. print 'ERROR in sigma0.lb_ocean_orca1: XT and XS dont have the same shape!'
  45. sys.exit(0)
  46. zr1 = nmp.zeros(nsize); zr1.shape = Vshape
  47. zr2 = nmp.zeros(nsize); zr2.shape = Vshape
  48. zr3 = nmp.zeros(nsize); zr3.shape = Vshape
  49. zr4 = nmp.zeros(nsize); zr4.shape = Vshape
  50. # compute volumic mass pure water at atm pressure
  51. zr1 = ( ( ( ( 6.536332e-9*XT -1.120083e-6 )*XT + 1.001685e-4)*XT - 9.095290e-3 )*XT + 6.793952e-2 )*XT + 999.842594
  52. # seawater volumic mass atm pressure
  53. zr2 = ( ( ( 5.3875e-9*XT-8.2467e-7 )*XT + 7.6438e-5 )*XT - 4.0899e-3 ) *XT + 0.824493
  54. zr3 = ( -1.6546e-6*XT+1.0227e-4 )*XT - 5.72466e-3
  55. zr4 = 4.8314e-4
  56. # potential volumic mass (reference to the surface)
  57. return ( zr4*XS + zr3*nmp.sqrt(nmp.abs(XS)) + zr2 ) *XS + zr1 - zrau0