Study file

Editor support

kipe schema prints the JSON schema of the study file. With it, an editor completes the keys, shows their documentation and marks invalid options while you type:

kipe schema > study.schema.json

and as the first line of the study file:

# yaml-language-server: $schema=study.schema.json

This works in editors that use the YAML language server, e.g., VS Code with Red Hat’s YAML extension, or Neovim and Helix with yaml-language-server. The path is relative to the study file. The schema belongs to the installed kipe version: generate it again after an update. The example study files have this line already, with the schema in examples/.

Overview

All keys of a study file: first as an overview, a commented study file, then section by section, each key with its type, its default (or whether it is required) and what it does. <name> stands for a name you choose, e.g., of a measurement. Anatomy of a study and Measurements explain how the keys work together.

This page is generated from the study file’s options (kipe.options), so it describes exactly what kipe accepts. Unknown keys are an error.

output:                                 # required
  path: <string>                        # required
  log_level: info                       # debug | info | warning | error

forward_solver:                         # required
  factory: <string>                     # required
  arguments: <mapping>                  # optional

parameters:
  reparameterization: <log | multiplicative | additive> # required
  priors:                               # required
    <name>:                             # a parameter of the solver
      mean: <number>                    # required
      relative_stddev: <number > 0>     # optional
      stddev: <number > 0>              # optional
      reparameterization: <log | multiplicative | additive> # optional

measurements:
  <name>:                               # a name you choose
    fields: <list of strings (at least 1)> # required
    data:                               # required
      type: numpy
      path: <string>                    # required
    noise:                              # required
      stddev: <number > 0 or list of number > 0 (at least 1)> # required
      seed: <integer ≥ 0>               # optional
    times: <list of numbers or {start, stop, step}> # optional
    spatial_sampling:                   # one of, by type
      type: array                       # the default
      # or:
      # type: fenicsx.mesh
      # mesh: <string>                  # required
      # mesh_name: mesh
      # element: P1                     # P1 | DG0
      # projection: <list of numbers (at least 1) or surface_normal> # optional
      # padding: 0.0
      # or:
      # type: fenicsx.points
      # points: <list of lists of numbers (at least 1)> # required
      # or:
      # type: fenicsx.displaced_vertices
      # tags: <list of integers (at least 1)> # required
      # combine: <union | intersection> # required
    model:                              # one of, by type
      type: difference                  # the default
      # or:
      # type: plane
      # normal_toward: <[number, number, number] (at least 3)> # optional

synthesis:
  truth:                                # one of, by type
    type: run                           # the default
    # or:
    # type: checkpoints
    # path: <string>                    # required
    # or:
    # type: data
    # path: <string>                    # required
  noise:
    <name>:                             # one of the measurements
      stddev: <number ≥ 0 or list of number ≥ 0 (at least 1)> # required
  realizations: 1

estimation:
  sigma_points: simplex                 # simplex | canonical | unique
  iterations: 1

sensitivity:
  step: 0.01

output

Output location and logging.

key

type

default

description

path

string

required

Directory for all results. Subcommands write into subdirectories.

log_level

debug | info | warning | error

info

Minimum level of the log messages kipe writes.

forward_solver

Construction of the forward solver.

key

type

default

description

factory

string

required

Import path of the factory, "module:name", e.g., "kipe.examples.fitzhugh_nagumo:Solver".

arguments

mapping

optional

Keyword arguments passed to the factory, as given (no path resolution).

parameters

Estimated parameters.

key

type

default

description

reparameterization

log | multiplicative | additive

required

How the estimated parameter \(\theta\) relates to the physical value \(\phi\), relative to the prior mean \(\phi_0\). Default for all parameters in priors, each can override it.

Available reparameterizations:

  • log: \(\phi = \phi_0 e^\theta\), starting at \(\theta = 0\), with a relative_stddev. Keeps the sign of \(\phi_0\); the prior mean may be positive or negative, but not zero.

  • multiplicative: \(\phi = \phi_0 \theta\), starting at \(\theta = 1\), with a relative_stddev. The prior mean must not be zero; \(\phi\) can change sign.

  • additive: \(\phi = \phi_0 + \theta\), starting at \(\theta = 0\), with an absolute stddev. \(\theta\) is the deviation from the prior mean, in the parameter’s physical unit. Accepts any prior mean, including zero.

priors

mapping: name → section, see below

required

Estimated parameters: parameter name -> prior (mean and standard deviation). All other parameters keep their nominal values.

parameters.priors

Estimated parameters: parameter name -> prior (mean and standard deviation). All other parameters keep their nominal values.

Each parameters.priors.<name>, where <name> is a parameter of the solver:

key

type

default

description

mean

number

required

Prior mean, as physical value: where the estimation starts.

relative_stddev

number > 0

optional

Standard deviation relative to the mean, e.g., 0.3 for 30%. For log and multiplicative.

The standard deviation of \(\theta\) is \(\sigma_\theta\) = relative_stddev, i.e., that of \(\ln \phi\) for log and that of \(\phi / \phi_0\) for multiplicative. To first order, both are the standard deviation of \(\phi\) relative to the mean, so both give about the same prior as long as relative_stddev is small. For large values they differ: log keeps the sign of the parameter, at the price of an asymmetric distribution. kipe list-parameters shows the resulting 1σ range.

stddev

number > 0

optional

Absolute standard deviation, in the parameter’s physical unit. For additive.

reparameterization

log | multiplicative | additive

optional

The distribution of this prior: Gaussian in \(\theta\), i.e., log-normal in the parameter for log, normal for multiplicative and additive. Overrides the section’s reparameterization for this parameter.

measurements

Measurements: name -> measurement. The names appear in logs, output and errors.

Each measurements.<name>, where <name> is a name you choose:

key

type

default

description

fields

list of strings (at least 1)

required

State fields the measurement observes.

data

section, see below

required

Where the measured data are: read by estimation, written by synthesis.

noise

section, see below

required

Measurement noise.

times

list of numbers or {start, stop, step}, see below

optional

Measurement times: a list or a range. Required by synthesis (the times to generate); for estimation a selection from the times in the data, all if not given.

spatial_sampling

one of, by type: array, fenicsx.mesh, fenicsx.points, fenicsx.displaced_vertices, see below

optional

How the observed fields are brought to the measurement locations; the kind is selected by type, array by default.

model

one of, by type: difference, plane, see below

optional

How predicted data are computed from the sampled fields and compared with the data.

measurements.<name>.data

Where the measured data are: read by estimation, written by synthesis.

key

type

default

description

type

numpy

required

Data format.

path

string

required

Path to the .npz file. With several noise realizations (synthesis.realizations), it contains the placeholder {realization}, e.g., "data/r{realization}/u.npz" or "data/u_{realization:02d}.npz": each realization has its own file. In quotes, since YAML reads braces in {type: ..., path: ...} as a mapping.

measurements.<name>.noise

Measurement noise.

key

type

default

description

stddev

number > 0 or list of number > 0 (at least 1)

required

Independent noise standard deviations: one scalar for all data entries, or a list with one positive value per entry, in the data’s global order and units.

seed

integer ≥ 0

optional

Seed of the noise added by synthesis (required there, unless it adds none, see synthesis.noise). The noise of the k-th time of the measurement is drawn from numpy.random.default_rng([seed, k]), so it does not depend on the other times. Measurements must have different seeds.

measurements.<name>.times

Measurement times: a list or a range. Required by synthesis (the times to generate); for estimation a selection from the times in the data, all if not given.

key

type

default

description

start

number

required

First time.

stop

number

required

Last time, included (up to round-off).

step

number > 0

required

Distance between successive times.

measurements.<name>.spatial_sampling

How the observed fields are brought to the measurement locations; the kind is selected by type, array by default.

type: array (the default)

Sample all entries of the observed fields, concatenated in the order of fields.

type: fenicsx.mesh

Interpolate the observed field onto a measurement mesh (FEniCSx backend).

The field must be a distributed field whose function space the forward solver provides (kipe.fenicsx.forward_solver.SupportsFunctionSpaces). The measurement mesh need not match the solver’s mesh. The data are in the order of the mesh file: by vertex for P1, by cell for DG0, independent of the number of ranks; for a vector field without projection, the components of each vertex or cell one after another.

key

type

default

description

mesh

string

required

Path to the measurement mesh, an XDMF file.

mesh_name

string

mesh

Name of the mesh in the XDMF file (its grid): mesh as dolfinx writes it; meshio writes Grid.

element

P1 | DG0

P1

Finite element on the measurement mesh: vertex values (P1) or cell values (DG0).

projection

list of numbers (at least 1) or surface_normal

optional

What is measured of a vector field; all components if not given. A direction, e.g., [0, 0, 1] for the z component (normalized by kipe), or surface_normal: the component along the cell normal of a surface mesh (needs element: DG0, one normal per cell). The normal’s orientation follows the order of each cell’s vertices in the mesh file, as ufl.CellNormal: the right-hand rule for triangles in 3D, the tangent rotated by +90° for lines in 2D; it is outward only if the mesh’s cells are oriented that way.

padding

number ≥ 0

0.0

Distance, in mesh units, by which a measurement point may lie outside the solver’s mesh, e.g., where a surface mesh cuts slightly across the solver’s boundary. Such a point takes the value of the field in the nearest cell, extrapolated; a point farther out is an error.

type: fenicsx.points

Evaluate the observed field at given points (FEniCSx backend).

The field must be a distributed field whose function space the forward solver provides (kipe.fenicsx.forward_solver.SupportsFunctionSpaces). The data are in the order of points; for a vector field, the components of each point one after another.

key

type

default

description

points

list of lists of numbers (at least 1)

required

Coordinates of the measurement points, one list per point, e.g., [[0.5, 0.5], [0.2, 0.8]] in 2D. Each point must lie in the solver’s mesh.

type: fenicsx.displaced_vertices

Return displaced vertices of tagged mesh facets (FEniCSx backend).

The observed field is a displacement vector with one component per spatial dimension. The mesh and facet tags are provided by the forward solver for the observed field. Vertices are ordered by their original geometry input indices.

key

type

default

description

tags

list of integers (at least 1)

required

Tag IDs of the mesh facets whose vertices are selected. Cell tags are not supported.

combine

union | intersection

required

union: select vertices of facets with any listed tag; intersection: select vertices shared by the facet sets of all listed tags. Must be specified explicitly.

measurements.<name>.model

How predicted data are computed from the sampled fields and compared with the data.

type: difference (the default)

Measured data are the sampled fields; innovation = measured - predicted.

type: plane (the default)

Fit z = a*x + b*y + c to sampled 3D vertices by orthogonal least squares.

The sampler must return flattened vertex coordinates, with x, y and z together for each vertex. Predicted and measured data are the three coefficients, ordered [a, b, c]. The innovation is measured minus predicted coefficients.

key

type

default

description

normal_toward

[number, number, number] (at least 3)

optional

Optional reference point toward which the first fitted normal is oriented.

Coordinates use the mesh’s coordinate system and units. The point must lie off the first plane. Later normals align with the first normal, whether or not a point was provided. This affects the exposed normal, not the predicted [a, b, c].

synthesis

Generation of synthetic measurement data.

key

type

default

description

truth

one of, by type: run, checkpoints, data, see below

optional

Source of the true state the data are generated from: a run of the forward solver, its checkpoints, or given data. From a run or checkpoints, synthesis also writes the noise-free data, to <output.path>/synthesis/noise_free/<measurement>.npz.

noise

mapping: name → section, see below

optional

Noise synthesis adds to the data of the listed measurements (measurement name -> noise), instead of their noise.stddev, which estimation assumes: for noise-free data (stddev: 0) or studies with misspecified noise. Measurements not listed get their noise.stddev.

realizations

integer > 0

1

Number of noise realizations, e.g., for the statistics of the estimates over the noise. Synthesis computes the true state once and writes the data of realizations \(r = 0, \dots, n - 1\), each to the data.path of the measurements with {realization} replaced by \(r\); kipe estimation --realization r estimates from one of them. Realization 0 has the noise of a study without realizations.

synthesis.truth

Source of the true state the data are generated from: a run of the forward solver, its checkpoints, or given data. From a run or checkpoints, synthesis also writes the noise-free data, to <output.path>/synthesis/noise_free/<measurement>.npz.

type: run (the default)

Generate the data by running the forward solver with its nominal parameters.

type: checkpoints

Generate the data from the checkpoints of an earlier run of the forward solver.

The solver reads the true states at the measurement times from the checkpoints at path; it needs kipe.forward_solver.SupportsCheckpoints. The run may differ from the model of the forward_solver section (e.g., in its time step or parameters), as long as the solver can read its checkpoints into the model’s state.

key

type

default

description

path

string

required

Location of the checkpoints, as the solver understands it (e.g., the output directory of the run).

type: data

Generate the data from given true data, read from files, with noise added.

E.g., the noise-free data of an earlier synthesis (in <output.path>/synthesis/ noise_free/), for other noise levels, seeds or realizations without running the solver again; or measured data, to test the estimation with more noise. A measurement’s times select from the file’s times; without times, all of them are used. The forward solver is built, for the layout of the measurements, but not run.

key

type

default

description

path

string

required

Path to the true data of each measurement, an .npz file in the format of the data files, with the placeholder {measurement} for the measurement’s name, e.g., "results/synthesis/noise_free/{measurement}.npz". In quotes, since YAML reads braces as a mapping. Without the placeholder, all measurements read the same file, so a study with several measurements needs it.

synthesis.noise

Noise synthesis adds to the data of the listed measurements (measurement name -> noise), instead of their noise.stddev, which estimation assumes: for noise-free data (stddev: 0) or studies with misspecified noise. Measurements not listed get their noise.stddev.

Each synthesis.noise.<name>, where <name> is one of the measurements:

key

type

default

description

stddev

number ≥ 0 or list of number ≥ 0 (at least 1)

required

Added independent noise: a scalar or one value per data entry; 0 means noise-free.

estimation

Parameter estimation.

key

type

default

description

sigma_points

simplex | canonical | unique

simplex

Sigma-point stencil, the pattern along which the estimates are perturbed. Each sigma point costs one forward run per measurement time:

  • simplex: \(p + 1\) sigma points, the cheapest.

  • canonical: \(2p\) sigma points, \(\pm\) along each parameter.

  • unique: one sigma point at the estimate, no spread: no correction. A sanity check of the whole pipeline (with the true parameters, the innovations are pure noise).

iterations

integer ≥ 1

1

Number of passes over the measurements. Each pass after the first starts from the previous estimate, with the prior’s uncertainty: relative to that estimate for log, the same physical spread for multiplicative and additive.

sensitivity

Sensitivity analysis with the Fisher information (kipe sensitivity).

key

type

default

description

step

number > 0

0.01

Step of the finite differences: for log parameters, the relative change of each, e.g., 0.01 for 1 %; for multiplicative parameters, a change by that fraction of their prior mean; for additive parameters, a fraction of their prior stddev, which gives the step its unit.