cf.load_stash2standard_name

cf.load_stash2standard_name(table=None, delimiter='!', merge=True, reset=False)[source]

Load a STASH to standard name conversion table from a file.

This used when reading PP and UM fields files.

Each mapping is defined by a separate line in a text file. Each line contains nine !-delimited entries:

  1. ID: UM sub model identifier (1 = atmosphere, 2 = ocean, etc.)

  2. STASH: STASH code (e.g. 3236)

  3. STASHmaster description:STASH name as given in the STASHmaster files

  4. Units: Units of this STASH code (e.g. ‘kg m-2’)

  5. Valid from: This STASH valid from this UM version (e.g. 405)

  6. Valid to: This STASH valid to this UM version (e.g. 501)

  7. CF standard name: The CF standard name

  8. CF info: Anything useful (such as standard name modifiers)

  9. PP conditions: PP conditions which need to be satisfied for this translation

Only entries “ID”, “STASH”, and “CF standard name” are mandatory, all other entries may be left blank. For example, 1!999!!!!!ultraviolet_index!! is a valid mapping from atmosphere STASH code 999 to the standard name ultraviolet_index.

If the “Valid from” and “Valid to” entries are omitted then the stash mapping is assumed to apply to all UM versions.

Parameters:
table: str or None, optional

Use the conversion table at this file location. By default the default table of the umfive library will be loaded.

delimiter: str, optional

The delimiter of the table columns. By default, ! is taken as the delimiter.

merge: bool, optional

If False then the table is updated to only contain the mappings defined by the table parameter. By default the mappings defined by the table parameter are incorporated into the existing table, overwriting any entries which already exist.

reset: bool, optional

If True then clear all entries and re-load the default table.

Returns:
dict

The new STASH to standard name conversion table.

Examples

>>> cf.load_stash2standard_name()
>>> cf.load_stash2standard_name('my_table.txt')
>>> cf.load_stash2standard_name('my_table2.txt', ',')
>>> cf.load_stash2standard_name('my_table3.txt', merge=True)
>>> cf.load_stash2standard_name('my_table4.txt', merge=False)