lenapy.lenapy_ocean

The lenapy_ocean module implements some useful TEOS10 gsw functions on oceanic dataset

lenapy.lenapy_ocean.proprietes(da, nom, label, unite)[source]
lenapy.lenapy_ocean.NoneType(var)[source]
class lenapy.lenapy_ocean.OceanSet(xarray_obj)[source]

Bases: object

This class extends any dataset to a xOcean object, that allows to access to any TEOS10 variable simply by calling the name of the variable through the xOcean interface. The initial dataset must contains the fields necessary to compute the output variable (ex : temperature and salinity to compute heat, heat to compute ohc,…)

Fields

Temperaturesone of the three types of temperature must be present in the original dataset to perform derived computation.
  • temp : in-situ temperature

  • PT : potential temperature

  • CT : conservative temperature

Salinitiesone of the three types of salinities must be present in the original dataset to perform derived computation.
  • psal : practical salinity

  • SR : relative salinity

  • SA : absolute salinity. If there is no location information (lat,lon), absolute salinity is returned equal to relative salinity

Physical properties :
  • P : pressure. If location information is present, pressure is adjusted with regard to latitude, otherwise latitude is equal to 0

  • Cp : heat capacity

  • rho : density

  • sigma0: potential density anomaly at 0 dbar

Heat content :
  • heat : specific heat content (J/m3)

  • ohc : local ocean heat content (J/m²), it is heat integrated over the whole ocean depth

  • gohc : global ocean heat content (J/m²), it is ohc averaged over latitude-longitude, excluding continents

  • gohc_TOA: idem gohc, including continents (where ohc=0)

  • ohc_above: idem ohc, where heat is integrated above a given depth

  • gohc_above: idem gohc, averaging ohc_above instead of ohc

Sea level :
  • slh : steric sea layer height anomaly (-), equal to (1. - rho/rhoref)

  • ssl : steric sea surface level anomaly (m), it is slh integrated over the whole ocean depth

  • ssl_above : idem ssl, where heat is integrated above a given depth

  • tssl : thermosteric sea surface level (m)

  • hssl : halosteric sea surface level (m)

  • ieeh : integrated expansion efficiency oh heat (m/(J/m²)), it is (tssl/ohc)

Layer depth :
  • ocean_depth : maximum depth with non Nan values for temperature

  • mld_theta0 : ocean mixed layer depth, defined by a temperature drop from 0.2°C wrt to -10m depth

  • mld_sigma0 : ocean mixed layer depth, defined by a potential density increase of 0.03kg/m3 wrt to -10m depth

  • mld_sigma0var: ocean mixed layer depth, defined by a potential density equal to the potential density at -10m depth with a temperature dropped by 0.2°C

Example

data=xr.open_dataset('/home/usr/lenapy/data/IAP',engine='lenapyOceanProduct',product='IAP')
print(data)
<xarray.Dataset>
Dimensions:    (latitude: 180, longitude: 360, time: 156, depth: 41)
Coordinates:
  * latitude   (latitude) float32 -89.5 -88.5 -87.5 -86.5 ... 87.5 88.5 89.5
  * longitude  (longitude) float32 1.0 2.0 3.0 4.0 ... 357.0 358.0 359.0 360.0
  * time       (time) datetime64[ns] 2005-01-15 2005-02-15 ... 2017-12-15
  * depth      (depth) float32 1.0 5.0 10.0 20.0 ... 1.7e+03 1.8e+03 2e+03
Data variables:
    temp       (time, latitude, longitude, depth) float32 dask.array<chunksize=(1, 180, 360, 10), meta=np.ndarray>
    SA         (time, latitude, longitude, depth) float32 dask.array<chunksize=(1, 180, 360, 10), meta=np.ndarray>
mld=data.lnocean.mld_sigma0
print(data.lnocean.ohc_above(mld))
<xarray.DataArray 'ohc_above' (time: 156, latitude: 180, longitude: 360)>
dask.array<where, shape=(156, 180, 360), dtype=float64, chunksize=(1, 180, 360), chunktype=numpy.ndarray>
Coordinates:
    depth      (time, latitude, longitude) float64 dask.array<chunksize=(1, 180, 360), meta=np.ndarray>
  * time       (time) datetime64[ns] 2005-01-15 2005-02-15 ... 2017-12-15
  * latitude   (latitude) float32 -89.5 -88.5 -87.5 -86.5 ... 87.5 88.5 89.5
  * longitude  (longitude) float32 1.0 2.0 3.0 4.0 ... 357.0 358.0 359.0 360.0
Attributes:
    long_name:  Ocean heat content
    units:      J/m^2
print(data.lnocean.gohc)
<xarray.DataArray 'gohc' (time: 156)>
dask.array<truediv, shape=(156,), dtype=float64, chunksize=(1,), chunktype=numpy.ndarray>
Coordinates:
  * time     (time) datetime64[ns] 2005-01-15 2005-02-15 ... 2017-12-15
    depth    float32 1.0
Attributes:
    long_name:  Global ocean heat content wrt to ocean surface area
    units:      J/m^2
property temp
property PT
property CT
property psal
property SR
property SA
property P
property rho
property sigma0
property Cp
property heat
property slh
property ohc
property ssl
property tssl
property hssl
ssl_above(target)[source]
property eeh
property ieeh
property gohc
property msl
property tmsl
property hmsl
property gohc_TOA
ohc_above(target)[source]
gohc_above(target, na_eq_zero=False, mask=True)[source]
property ocean_depth
property mld_theta0
property mld_theta0minus_only
property mld_sigma0
property mld_sigma0var
class lenapy.lenapy_ocean.OceanArray(xarray_obj)[source]

Bases: object

This class extends any dataarray to a xOcean object, to perform specific operations on structured dataarray

add_value_surface(value=None)[source]

Add a surface layer with a specified value, or the previous upper value :param value: values to be added in the surface layer (depth=0). If None, the previous upper value is used to fill the new layer :type value: float or array-like, optional

Returns:

added – new dataarray with a extra layer at depth 0 filled with required values

Return type:

DataArray

Example

data=IAP('/home/usr/lenapy/data/IAP')
heat=data.lnocean.heat.lnocean.add_value_surface()
integ_depth()[source]

Returns the dataarray integrated over the whole depth. The surface value is supposed equal to the most shallow value. In order to deal with NaN values in deep water during integration,, all NaN are firt converted to 0, then in the output array NaN values are applied where initial surface values were NaN.

Example

data=IAP('/home/usr/lenapy/data/IAP')
data.lnocean.heat.lnocean.integ_depth()
<xarray.DataArray 'Heat' (time: 156, latitude: 180, longitude: 360)>
dask.array<where, shape=(156, 180, 360), dtype=float64, chunksize=(1, 180, 360), chunktype=numpy.ndarray>
Coordinates:
  * latitude   (latitude) float32 -89.5 -88.5 -87.5 -86.5 ... 87.5 88.5 89.5
  * longitude  (longitude) float32 1.0 2.0 3.0 4.0 ... 357.0 358.0 359.0 360.0
  * time       (time) datetime64[ns] 2005-01-15 2005-02-15 ... 2017-12-15
    depth      float32 1.0
cum_integ_depth()[source]

Returns a cumulative integrated dataarray integrated over the whole depth. The surface value is supposed equal to the most shallow value. A first integration layer by layer is performed, by multupliying the layer’s thickness by the mean value of upper and lower bound, then a cumulative sum is computed.

Example

data=IAP('/home/usr/lenapy/data/IAP')
data.lnocean.heat.lnocean.cum_integ_depth()
<xarray.DataArray (time: 156, latitude: 180, longitude: 360, depth: 41)>
dask.array<where, shape=(156, 180, 360, 41), dtype=float64, chunksize=(1, 180, 360, 10), chunktype=numpy.ndarray>
Coordinates:
  * latitude   (latitude) float32 -89.5 -88.5 -87.5 -86.5 ... 87.5 88.5 89.5
  * longitude  (longitude) float32 1.0 2.0 3.0 4.0 ... 357.0 358.0 359.0 360.0
  * time       (time) datetime64[ns] 2005-01-15 2005-02-15 ... 2017-12-15
  * depth      (depth) float64 1.0 5.0 10.0 20.0 ... 1.7e+03 1.8e+03 2e+03
above(depth, **kwargs)[source]

Returns the dataarray integrated above a given depth, by interpolating at this depth the cumulative integrale of the data array

Example

data=IAP('/home/usr/lenapy/data/IAP')
mld=data.lnocean.mld_sigma0
data.lnocean.heat.lnocean.above(mld)
<xarray.DataArray (time: 156, latitude: 180, longitude: 360)>
dask.array<where, shape=(156, 180, 360), dtype=float64, chunksize=(1, 180, 360), chunktype=numpy.ndarray>
Coordinates:
    depth      (time, latitude, longitude) float64 dask.array<chunksize=(1, 180, 360), meta=np.ndarray>
  * time       (time) datetime64[ns] 2005-01-15 2005-02-15 ... 2017-12-15
  * latitude   (latitude) float32 -89.5 -88.5 -87.5 -86.5 ... 87.5 88.5 89.5
  * longitude  (longitude) float32 1.0 2.0 3.0 4.0 ... 357.0 358.0 359.0 360.0