Paths and variables in Yaml

Environment variables

When setting up pyCIF, please prefer absolute paths as much as possible. However, for conveniency, the YAML parser in pyCIF has been designed to understand environment variables, as well as the tilde expansion.

Below is a simple example of how it works:

myrefdir: ~/somedir/somesubdir

myrelativedirfromenvvariable: ${ENV_VARIABLE}/somesubdir

Please note that environment variables must be necessary between {}.

As a reminder, the following command should be used in bash to define an environment variable:

export ENV_VARIABLE="/some_path_to_whatever"

Anchors in Yaml

It is possible to define shortcuts to variables defined in your Yaml and use them elsewhere. However, concatenation does not work straight away in basic Yaml. A functionality was used in pyCIF following examples on StackOverflow.

The anchors are defined with the character &, and called with * and concatenation is allowed with the custom constructor !join:

ref_dir : &ref_dir /some/reference/dir/
secondary_dir : &second_dir /some/other/dir/
reference_ID: &ref_id some_ref

myrelativedir: !join [ *ref_dir, input/ ]
mycomplexname: !join [ *secondary_dir, *reference_ID, /complementary_name.txt ]

In the example, after initialization of the yaml, the configuration file is equivalent to:

myrelativedir: /some/reference/dir/input/
mycomplexname: /some/other/dir/some_ref/complementary_name.txt

File name formats and dates

Various types of files are necessary to run pyCIF. pyCIF accepts generic formats when file names are dependent on, e.g., the date of the simulation. In this case, the generic date-dependent file name should be given as a string compatible with the Python datetime function, strptime as detailed here.

For instance, if your meteo file names are function of the current date, the following syntax will be required in the Yaml file:

mymeteo: /mymeteo_folder/mymeteo_%Y%m%d_%H%M.nc

pyCIF will automatically recognize a date format as YYYYMMDD_HHMM, i.e. 20140327_1212 corresponds to March 27 th, 2014 at 12:12.