First inversion with CHIMERE#

Here we run an inversion with CHIMERE, starting from a YAML designed for a forward simulation. Only the changes and additions relative to the forward YAML are described here.

Warning

It is strongly recommended to run a forward simulation and perform thorough checks on it before running an inversion.

Prepare the executable#

If you are not using automatic compilation by the CIF, compile the tangent-linear and/or adjoint code (depending on the inversion type) with:

./compile_chimere -m L
./compile_chimere -m A

See here for more details.

⟹ check that you obtain executables in sub-directories src_tl and src_ad named respectively tlchimere.e (about 2.7M in size) and achimere.e (about 2.9M in size).

Section for pyCIF parameters#

Specify a WORKDIR for the inversion with sufficient disk space. Most inversions require multiple iterations and therefore need more space than the equivalent forward simulation.

Mode (mode)#

Here, an inversion is the chosen mode for running the model. See mode for the available inversion types. In the example below, a variational inversion is used:

mode:
  plugin:
    name: 4dvar
    version: std
    type: mode
  save_out_netcdf: True

The optional argument saves results in NetCDF files, which are larger but easier to read and post-process than the default pickle files. To save time and disk space, consider running the inversion first without this option and then, once it has converged, re-running with the option as explained here.

Unchanged paragraphs#

The observation operator (obsoperator) and control vector (controlvect) are unchanged for this first inversion. The model, obsvect, platform, domain, and chemistry sections are identical to those in the forward simulation.

Nevertheless, certain options are particularly useful for inversions even if they were not needed in the forward simulation:

  • for obsoperator:

    • autorestart: useful because an inversion typically takes longer than a forward simulation

    • autoflush: useful because iterations accumulate more disk usage than a single forward run

  • for model:

    • autoflush / force_clean_run: removes large files generated by the adjoint

    • useRAMonly: very useful for the adjoint (irrelevant for the forward) if enough RAM is available

  • for obsvect:

    • dir_obsvect: to use the monitor.nc output from the forward simulation, or a filtered version of it (e.g. with invalid data removed)

Data vector (datavect)#

Components which are not inverted#

The observation component and the CHIMERE input components that are not being inverted are unchanged from the forward simulation.

Components to be inverted#

For each component to be inverted, the parameters must be specified and at least the horizontal control resolution must be defined. Any component that does not comply will not be inverted.

For example, to invert S1 emissions, from the forward yaml:

datavect:
  plugin:
    name: standard
    version: std
  components:
    meteo:
      dir: directory_containing_METEO.YYYYMMDDHH.*.nc_files
      file: METEO.%Y%m%d%H.X.nc
      plugin:
        name: CHIMERE
        version: std
        type: meteo
      file_freq: XH
    flux:
      dir: directory_containing_AEMISSIONS.YYYYMMDDHH.*.nc_files
      file: AEMISSIONS.%Y%m%d%H.X.nc
      plugin:
        name: CHIMERE
        version: AEMISSIONS
        type: flux
      file_freq: XH

specify at least:

datavect:
  plugin:
    name: standard
    version: std
  components:
    meteo:
      dir: directory_containing_METEO.YYYYMMDDHH.*.nc_files
      file: METEO.%Y%m%d%H.X.nc
      plugin:
        name: CHIMERE
        version: std
        type: meteo
      file_freq: XH
    flux:
      dir: directory_containing_AEMISSIONS.YYYYMMDDHH.*.nc_files
      file: AEMISSIONS.%Y%m%d%H.X.nc
      plugin:
        name: CHIMERE
        version: AEMISSIONS
        type: flux
      file_freq: XH
      parameters:
        S1:
          dir: directory_containing_AEMISSIONS.YYYYMMDDHH.*.nc_files
          file: AEMISSIONS.%Y%m%d%H.X.nc
          plugin:
            name: CHIMERE
            version: AEMISSIONS
            type: flux
          hresol: hpixels
          err: 0.1

S1 emissions will be inverted at pixel resolution, with variances set to 10% of the prior flux value per pixel and no spatial or temporal correlations.

Many options are available for controlling the resolution (horizontal, vertical, temporal), the error correlations (in space and time), and the error specification. See the control vector arguments in the data vector documentation for full descriptions and examples.

Run the simulation#

Warning

Before running the inversion, test the adjoint (and, if relevant, the tangent-linear) using the configuration chosen for the inversion.

Once the adjoint test passes, launch the inversion with:

python -m pycif path/to/your_inversion_config.yml

For the toy Gaussian model, complete ready-to-run YAML files are available in Examples for dummy (see entries prefixed with config_inversion_). The first inversion with the toy Gaussian model tutorial points directly to the recommended starting YAML.

Check and post-process the results#

Examples of codes for post-processing the results of an inversion are provided in various projects such as VERIFY.