POSTPROCESS¶
An optional verbatim section that post processes the c[X]
variables after running the PREDICTIONS section. This section can be used to alter the final c[X]
variables, or possibly remove some data, e.g. negative concentrations.
A kind of flexible post generation filter implemented in Python, similar in functionality to PREPROCESS.
The POSTPROCESS is available in the following scripts:-
i.e. any script that generates a population data set from a model.
Example POSTPROCESS section¶
Some simple examples of using a POSTPROCESS section. Use the ‘return’ syntax to remove observation rows with negative concentrations:-
POSTPROCESS: |
if c[CONC] < 0.0 and c[TYPE] == 'obs':
return
Setting negative concentrations to zero for observation rows:-
POSTPROCESS: |
if c[CONC] < 0.0 and c[TYPE] == 'obs':
c[CONC] = 0.0
Enforcing a below quantification limit for observation rows:-
POSTPROCESS: |
bql_limit = 5.0
if c[CONC] < bql_limit and c[TYPE] == 'obs':
c[CONC] = bql_limit
Creating some derived data for observation rows:-
POSTPROCESS: |
if c[CONC] > 100 and c[TYPE] == 'obs':
c[HIGH_CONC_FLAG] = 1.0
else:
c[HIGH_CONC_FLAG] = 0.0
Like the PREPROCESS section each row of the data is processed separately, but otherwise any valid Python function can be used to create new c[X]
data or remove rows using the “return” syntax.
Rules for POSTPROCESS section¶
Like all verbatim sections the POSTPROCESS section of the config file accepts free form pseudo Python code, but there are some rules regarding which variables are allowed in a POSTPROCESS section as follows:-
- Only
c[X]
variables and local Python variables are allowed c[X]
on the right hand side and withinif
statements must be previously defined on the left hand side or in the data filec[X]
declared on the left hand side must not already exist in the data file- return must always be null
So you can not use m[X]
, f[X]
, r[X]
, d[X]
etc variables in this section.
Like all verbatim sections it is possible to introduce syntax errors by writing malformed Python. This will hopefully be picked up when PoPy attempts to compile or run the POSTPROCESS function as a temporary .py file.