Internal functions - presented here for their doc

init_period

This function should not be called directly ; it is presented here mainly for documenting the syntax of the strings describing a period of time

climaf.period.init_period(dates)[source]

Init a CliMAF ‘period’ object

Parameters:dates (str) – must match YYYY[MM[DD[HH[MM]]]][(-|_)YYYY[MM[DD[HH[MM]]]]] , or be ‘fx’ for fixed fields
Returns:the corresponding CliMAF ‘period’ object

When using only YYYY, can omit some Ys (for zeros). Cannot handle year 0000

Examples :

  • a one-year long period : ‘1980’, or ‘1980-1980’
  • a decade : ‘1980-1989’
  • first millenium : 1-1000 # Must have leading zeroes if you want to quote a month
  • first century : 1-100
  • one month : ‘198005’
  • two months : ‘198003-198004’
  • one day : ‘17890714’
  • the same single day, in a more complicated way : ‘17890714-17890714’

CliMAF internally handles date-time values with a 1 minute accurracy; it can provide date information to external scripts in two forms; see keywords ‘period’ and ‘period_iso’ in cscript()

selectFiles

This function should not be called directly ; it is presented here mainly for documenting the list of organizations it can handle for function dataloc

climaf.dataloc.selectFiles(return_wildcards=None, **kwargs)[source]

Returns the shortest list of (local or remote) files which include the data for the list of (facet,value) pairs provided

Method :

  • use datalocations indexed by dataloc() to identify data organization and data store urls for these (facet,value) pairs
  • check that data organization is as known one, i.e. is one of ‘generic’, CMIP5_DRS’ or ‘EM’
  • derive relevant filenames search function such as as : py:func:~climaf.dataloc.selectCmip5DrsFiles from data organization scheme
  • pass urls and relevant facet values to this filenames search function

selectGenericFiles

This function should not be called directly ; it is presented here mainly for documenting the syntax of argument url of function dataloc when organization is set to generic

climaf.dataloc.selectGenericFiles(urls, return_wildcards=None, sort_periods_on=None, **kwargs)[source]

Allow to describe a generic file organization : the list of files returned by this function is composed of files which :

  • match the patterns in url once these patterns are instantiated by the values in kwargs, and
  • contain the variable provided in kwargs
  • match the period` provided in kwargs

In the pattern strings, no keyword is mandatory. However, for remote files, filename pattern must include ${varname}, which is instanciated by variable name or filenameVar (given via calias()); this is for the sake of efficiency (please complain if inadequate)

Example :

>>> selectGenericFiles(project='my_projet',model='my_model', simulation='lastexp', variable='tas', period='1980', urls=['~/DATA/${project}/${model}/*${variable}*YYYY*.nc)']
/home/stephane/DATA/my_project/my_model/somefilewith_tas_Y1980.nc

In the pattern strings, the keywords that can be used in addition to the argument names (e.g. ${model}) are:

  • ${variable} : use it if the files are split by variable and filenames do include the variable name, as this speed up the search
  • ${PERIOD} or YYYY, YYYYMM, YYYYMMDD, YYYYMMDDHH, , YYYYMMDDMM : use it for indicating the start date of the period covered by each file, if this is applicable in the file naming; If not using ${PERIOD}, use YYYYxx a second time for end date, if applicable (otherwise the assumption is that the whole year -resp. month or day- is included in the file
  • wildcards ‘?’ and ‘*’ for matching respectively one and any number of characters

Table Of Contents

Previous topic

Utility functions and variables

Next topic

Functions returning ClimAF objects

This Page