lenapy.readers.ocean

Load temperature and salinity data from ocean products

lenapy.readers.ocean.filtered_list(files, year, ymin, ymax, pattern)[source]

Returns a filtered list of files fitting year range and pattern

Parameters:
  • files (Array of strings) – Array with filenames to be filtered

  • year (function) – Function to be applied on each filename, returning the data year

  • ymin (integer) – Lowest bound of the time range

  • ymax (integer) – Highest bound of the time range

  • pattern (string) – Pattern that must fit the filenames

Returns:

filtered – Extract of th input array fitting year and pattern conditions

Return type:

Array

Example

def year(f):
return f.split('_')[1]
fics=filtre_liste(glob(os.path.join(rep,'**','*.nc')),year,2005,2006,'ARGO')
class lenapy.readers.ocean.lenapyOceanProducts[source]

Bases: BackendEntrypoint

Open netcdf ocean product

This module allows to load temperature and salinity data from different products and format the data with unified definition for variables and coordinates, compatible with the use of lenapy_ocean :

  • standardized coordinates names : latitude, longitude, depth, time

  • standardized variables names : temp or PT or CT for temperature, psal, SA, SR for salinity

When loading a product, all the files present in the product directory are parsed. To gain computing time, a first filter on the years to load can be applied, as well as a text filter. A second date filter can be apply afterwards with the .sel(time=slice(‘begin_date’,’end_date’) method. All keyword arguments associated with xr.open_dataset can be passed. Dask is implicitely used when using these interface methods.

It is imperative to chunk the dataset along time dimension (chunks=dict(depth=10)), and recommanded to chunk the dataset along depth dimension (chunks=dict(depth=10))

Parameters:
  • directory (string) – path of the product’s directory

  • product (string) – identifier of the product to be opened. Can be one of : “ISAS”,”NCEI”,”SIO”,”IPRC”,”ISHII”,”IAP”,”EN4”,”JAMSTEC”,”ECCO”,”NOC_OI”,”SODA”

  • corr (string, optional) – additional parameter for EN4 prodcut ensemble. Can be one of: ‘g10’,’l09’,’c13’,’c14’

  • ymin (int, optional) – lowest bound of the time intervalle to be loaded (year)

  • ymax (int, optional) – highest bound of the time intervalle to be loaded (year)

  • filter (string, optionnal) – string pattern to filter datafiles names

  • chunks (dict, optionnal) – dictionnary {dim:chunks}

  • open_dataset_kwargs (dict, optional) – The keyword arguments form of open_mfdataset

Returns:

product – New dataset containing temperature and salinity data from the product

Return type:

Dataset

Examples

data=xr.open_dataset('/home/usr/lenapy/data/ISAS20', engine='lenapyOceanProducts', product='ISAS', ymin=2005, ymax=2007, filter='ARGO', chunks={'time':1,'depth':10})
open_dataset(directory, product=None, corr=None, ymin=0, ymax=9999, filter='', drop_variables=None, open_dataset_kwargs={})[source]

Backend open_dataset method used by Xarray in open_dataset().