Parsers and variables

The XML configuration file is evaluated by two parsers. In a first step a text parser is applied. In the second step mathematical expressions are resolved to a number. Variables (see section variables) can be referenced via their name directly for the expression parser or in the form {name} for the text parser.

Mathematical expression parser

In all input fields that accept numbers (int, uint, double, angle, time) numerical expressions are also allowed. Declared variables can be accessed via their name. The following operations and functions are defined:

Text parser

Before the mathematical expression parser evaluates the expression, a simple text parser is applied. The text parser is used for all input fields (also file names). It scans the text for terms like {variable} and replaces it by the text content of the variable. A literal '{' character must be escaped with '#{'.

The text parser allows regex replacements in the form {text/regex/replace}. All matches of regex in the text are replaced by replace. Possible {variables} in the three parts are evaluated beforehand. Capturing groups () can be accessed by $1, $2, … in the replacement ($0 is the complete match). Additional escape sequences are:

Examples:

The text parser also evaluates terms in the form {expression:format} and replaces it by a formatted output. In order not to get confused with the regex replacements, the '/' character must be escaped with '#/' in the expression. The format contains the text to be written as output. It can contain embedded format specifiers that are replaced by the value of the expression and formatted as requested (also multiple times). In the following, the resulting formatted output is given in the brackets for an expression with the example value of 57493.8:

The following specifiers interpret the value of the expression as MJD (modified Julian date): The format can be specified further with %[width][.precision]specifier, where [width] is the minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded with blank spaces (or zeros if [width] starts with a zero). The [.precision] defines the number of digits after the period (for %g the number of significant digits instead).

Example: Two variables time=57493+19/24+12/1440 and satellite=swarm are set in the global section. The inputfile=data/{time:%y}/{satellite}_{time:%D}.dat is expanded to "data/2016/swarm_2016-04-15.dat".

Example: The variable x=3+5 is set in the global section. The expression number=2*x is evaluated by the expression parser to =16. In contrast if we use brackets like in number=2*{x} the expression is first evaluated by the text parser to "2*3+5" and the expression parser now gives the result =11.

Variables for data

Some programs (e.g. FunctionsCalculate, InstrumentArcCalculate, GriddedDataCalculate, or the plot programs) read data (matrix) or gridded data and evaluate input/output expressions for each data row. For these kind of expressions additional variables are automatically defined for each data column (X stands for the data column number: $0\ldots n$):

For gridded data input the following variables are additionally defined for each data point: