pycif.plugins.models.TM5 — API reference#

Configuration reference: TM5 plugin

pycif.plugins.models.TM5.compile.copytree(src, dst, symlinks=False, ignore=None)[source]#

Recursively copy src to dst, creating dst if it does not exist.

Behaves like shutil.copytree() but does not fail when dst already exists. File permissions are preserved.

Parameters:
  • src (str) – source directory path.

  • dst (str) – destination directory path (created if absent).

  • symlinks (bool) – if True, preserve symbolic links.

  • ignore – optional callable (as for shutil.copytree()) to filter files/directories.

pycif.plugins.models.TM5.compile.macros_to_file(macros, macros_file, macros_all)[source]#

PURPOSE Write a list of macros to a file.

IN/OUT macros = list of macros to write to file. Only unique entries

will be written fo file

macros_file = the file to write the macros to macros_all = each macro in macros should be present in this list

in order to prevent typos

KWARGS none

ASSUMPTIONS none

EXCEPTIONS When this function encounters a problem that it cannot solve, it will raise a RuntimeError. Pythons exeception handling will provide a traceback, including files, calls and line numbers.

PYTHON VERSION 3.7.6

VERSION CHANGE HISTORY 1.2 02-02-2021 by J.C.A. van Peet.

*) Updated PROG_NAME *) Used new PROG_NAME as local logger name.

1.1 26-01-2021 by J.C.A. van Peet.

Updated the local logger and ‘raise CifRuntimeError’ statement.

1.0 18-01-2021 by J.C.A. van Peet.

Original code.

pycif.plugins.models.TM5.compile.write_dims_grid(dims_grid_path, dx=6.0, dy=4.0, dz=1.0, nregions=1, len_region_name=10, regions=['glb600x400'], parents=['globe'], xcyc=1, touch_np=1, touch_sp=1, xbeg=-180, xend=180, ybeg=-90, yend=90, im=60, jm=45, maxref=10, xref=1, yref=1, zref=1, tref=1)[source]#

PURPOSE Write the Fortran source file dims_grid.F90

IN/OUT dims_grid_path = path to the location where to write dims_grid.F90. The

filename itself will be added automatically.

KWARGS dx = grid cell size in longitude dy = grid cell size in latitude dz = grid cell size in altitude, set to 1.0 nregions = 1 len_region_name = 10: the length of a string in the regions list regions = list with the name of the regions parents = list with the name of the parent regions

Global region 1 should have parent 0 (globe single cell); global surface region should have parent 1 (global region).

coordinates (in degrees) for each region: xcyc = 1 if the region has cyclic x-boundary conditions touch_np = 1 if region touches the north pole touch_sp = 1 if region touches the south pole xbeg = the westmost border of the region xend = the eastmost border of the region ybeg = the southmost border of the region yend = the northmost border of the region im = number of gridcells in longitude direction jm = number of gridcells in latitude direction

refinement factors for each region (<= maxref) tref may differ from xref/yref. In the current implementation it should be 1,2,4,6,… maxref = maximum refinement factor (can be arbitrary in principle) xref = yref = zref = tref =

ASSUMPTIONS none

EXCEPTIONS When this function encounters a problem that it cannot solve, it will raise a RuntimeError. Pythons exeception handling will provide a traceback, including files, calls and line numbers.

PYTHON VERSION 3.7.6

VERSION CHANGE HISTORY 1.2 02-02-2021 by J.C.A. van Peet.

*) Updated PROG_NAME *) Used new PROG_NAME as local logger name.

1.1 26-01-2021 by J.C.A. van Peet.

Updated the local logger.

1.0 18-01-2021 by J.C.A. van Peet.

Code to fill the list ‘lines’ copied from …TM5/base/py/TM5_Tools.py, class Build_Configure_Grid( object ), __init__(…), using “build_release = 1”.

pycif.plugins.models.TM5.compile.compile(self)[source]#

PURPOSE Compile the TM5 source tree into an executable

IN/OUT none

KWARGS none

ASSUMPTIONS none

EXCEPTIONS When this function encounters a problem that it cannot solve, it will raise a RuntimeError. Pythons exeception handling will provide a traceback, including files, calls and line numbers.

PYTHON VERSION 3.7.6

VERSION CHANGE HISTORY 2.4 19-04-2021 by J.C.A. van Peet.

After copying the model source from the TM5 source tree to the CIF source tree, I had to prepend self.direxec to a few variables.

2.3 02-02-2021 by J.C.A. van Peet.

*) Updated PROG_NAME *) Used new PROG_NAME as local logger name. *) Moved some compilation statements (see 18-01-2021) into

the “auto_recompile” if-statement.

*) Updated the subprocess commands so that the output is logged live. *) Updated comp_dir to self.workdir/model/src

2.2 26-01-2021 by J.C.A. van Peet.
*) Removed function logging.empty(…), you can now simply do

logger.info(“”) to print an empty line.

*) Initialised a local logger, so replaced all calls to logging with

calls to logger.

*) RuntimeErrors are now also logged in the logfile. *) Added universal_newlines=True to all subprocess.Popen calls. As a

result, you don’t have to do

logger.debug(”

“+””.join(stdout.decode(“ascii”)))
anymore, but you can just do

logger.debug(stdout)

2.1 19-01-2021 by J.C.A. van Peet.

Added custom function logging.empty(…) to write empty lines to logfile.

2.0 18-01-2021 by J.C.A. van Peet.

*) Added compilation of tm5. *) Renamed the tm5.exe to tm5.x *) Replaced print statements with logging statements.

1.0 03-11-2020 by J.C.A. van Peet.

Original code, based on an example by A. Berchet.

pycif.plugins.models.TM5.flushrun.flushrun(self, rundir, mode, transform_id, full_flush=True)[source]#

Cleaning the simulation directories to limit space usage

pycif.plugins.models.TM5.ini_mapper.ini_mapper(model, general_mapper={}, backup_comps={}, transforms_order=[], ref_transform='', **kwargs)[source]#

PURPOSE The ini_mapper function is mandatory to make a model work. It informs pycif about the inputs and outputs of the model. It should return a so-called “mapper”. A mapper is a dictionary with two keys:

*) inputs: all the inputs for the model (fluxes, meteo, chemical fields,

executables, parameter files, etc)

*) outputs: all the outputs; in our cases, concentrations (concs)

Both inputs and outputs keys are them selves dictionaries. Their format is:

*) (“type”, “parameter”): {information dictionary}

The pair (“type”, “parameter”) should cover all the necessary inputs and outputs. In the case when no “parameter” is relevant, and empty string can be specified.

The information dictionary can include the following information, depending on your model:

*) input_dates: all dates at which the model expects some inputs for the

given type/parameter; e.g., if TM5 needs 3-hourly meteo fields, input_dates will be the list of all dates in the simulation period with a frequency of 3H; it is recommended to initiate this variable in the function ini_periods, that initiates all date related variables for your model

*) domain: usually the same as the model domain *) force_dump: True if the given type/parameter should be dumped before

running the model executable

*) any other parameter that can be used in the native2inputs / outputs2native functions.

IN/OUT none

KWARGS none

ASSUMPTIONS none

EXCEPTIONS When this function encounters a problem that it cannot solve, it will raise a RuntimeError. Pythons exeception handling will provide a traceback, including files, calls and line numbers.

PYTHON VERSION 3.7.5

VERSION CHANGE HISTORY 1.0 18-09-2020 by J.C.A. van Peet.

Original code.

pycif.plugins.models.TM5.ini_periods.ini_periods(self, **kwargs)[source]#

Compute temporal discretisation for TM5.

TM5 runs as a single sub-simulation (no period chaining), so subsimu_dates contains only [datei, datef]. Time steps are hourly; flux inputs are at monthly resolution.

Sets on self:

  • subsimu_dates[datei, datef].

  • tstep_dates — 1-hourly time-step array for the full window.

  • tstep_all — same array (no chaining).

  • input_dates — monthly flux/meteo input dates.

Parameters:
  • self – TM5 model plugin instance with datei and datef set.

  • **kwargs – unused.

pycif.plugins.models.TM5.run.silent_remove(filename)[source]#

PURPOSE Delete a file without raising an exception if it doesn’t exist.

IN/OUT filename = string with the filename to remove.

VERSION CHANGE HISTORY 1.1 02-02-2021 by J.C.A. van Peet.

*) Added PROG_NAME *) Used new PROG_NAME as local logger name.

1.0 09-11-2020 by J.C.A. van Peet.

Copied from https://stackoverflow.com/a/10840586, changed function name from silentremove to silent_remove.

pycif.plugins.models.TM5.run.run(self, runsubdir, mode, workdir, ddi, do_simu=True, **kwargs)[source]#

PURPOSE Call this function to run the TM5 model. I’m not sure which module does call this function… The order appears to be to first call compile.py, then params.py and then the current function…

IN/OUT runsubdir = working directory for the current run (str) mode = forward or backward (str) workdir = pyCIF working directory (str)

KWARGS none

ASSUMPTIONS none

EXCEPTIONS When this function encounters a problem that it cannot solve, it will raise a RuntimeError. Pythons exeception handling will provide a traceback, including files, calls and line numbers.

PYTHON VERSION 3.7.6

VERSION CHANGE HISTORY 2.1 22-10-2021 by J.C.A. van Peet.

Writing point departure files has been moved by Antoine to the module

…/plugins/models/TM5/io/inputs/make_obs.py

which makes use of functions that have been moved from the current run.py module to

…/plugins/models/TM5/io/utils/point_data.py

2.0 23-07-2021 by J.C.A. van Peet.

*) Added calculation of point departure file.

1.2 02-02-2021 by J.C.A. van Peet.

*) Updated PROG_NAME *) Used new PROG_NAME as local logger name.

1.1 18-01-2021 by J.C.A. van Peet.

Renamed tm5.exe to tm5.x

1.0 09-11-2020 by J.C.A. van Peet.

Original code.

pycif.plugins.models.TM5.io.native2inputs.native2inputs(self, datastore, input_type, datei, datef, runsubdir, mode='fwd', onlyinit=False, do_simu=True, check_transforms=False, **kwargs)[source]#

Converts data at the model data resolution to model compatible input files. Input types should be consistent with the ones specified in the mapper. Calls sub-functions dealing with individual input types

The datastore provided to this function is a pyCIF Plugin, whose main interesting attribute is “datastore.datastore”. This attribute is a dictionary of which each key is a tuple (input_type, parameter). Associated values are the following:

  • spec: an xarray.Dataset including the corresponding input data

  • incr: same for increments

  • dirorig: directory where to find original files for that input

  • fileorig: file format for that input

Parameters:
  • self – the model Plugin

  • input_type (str) – one of ‘fluxes’

  • datastore (Plugin) – data to convert

  • datei – date interval of the sub-simulation

  • datef – date interval of the sub-simulation

  • mode (str) – running mode: one of ‘fwd’, ‘adj’ and ‘tl’

  • runsubdir (str) – sub-directory for the current simulation

  • workdir (str) – the directory of the whole pyCIF simulation

VERSION HISTORY 1.2 02-02-2021 by J.C.A. van Peet.

Updated the path to the TM5 executable.

1.1 18-01-2021 by J.C.A. van Peet.

Renamed tm5.exe to tm5.x

1.0 ??-??-???? by A. Berchet.

pycif.plugins.models.TM5.io.native2inputs_adj.native2inputs_adj_AB(self, datastore, input_type, datei, datef, runsubdir, mode='fwd', **kwargs)[source]#

Read sensitivity to input and converts them to pyCIF data

Parameters:
  • self – the model Plugin

  • input_type (str) – one of ‘fluxes’

  • datastore – data to convert if input_type == ‘fluxes’,

  • datei – date interval of the sub-simulation

  • datef – date interval of the sub-simulation

  • mode (str) – running mode: one of ‘fwd’, ‘adj’ and ‘tl’

  • runsubdir (str) – sub-directory for the current simulation

  • workdir (str) – the directory of the whole pyCIF simulation

Notes

  • CHIMERE expects hourly inputs;

pycif.plugins.models.TM5.io.native2inputs_adj.native2inputs_adj(self, datastore, input_type, datei, datef, runsubdir, check_transforms=False, mode='fwd', **kwargs)[source]#

PURPOSE Read sensitivity to input and converts them to pyCIF data.

ARGS self = the model Plugin datastore = data to convert if input_type == ‘fluxes’ input_type = (str) one of ‘fluxes’ datei = initial date of the sub-simulation interval datef = final date of the sub-simulation interval runsubdir = (str) sub-directory for the current simulation

KWARGS mode = (str) running mode, one of ‘fwd’, ‘adj’ and ‘tl’ workdir = (str) the directory of the whole pyCIF simulation

NOTE None

VERSION HISTORY 2.1 DD-MM-YYYY by J.C.A. van Peet

Continued development

2.0 02-08-2021 by J.C.A. van Peet

Adapted for TM5.

1.0 ??-??-???? by A. Berchet

See original code above.

pycif.plugins.models.TM5.io.outputs2native.outputs2native(self, data2dump, input_type, di, df, runsubdir, mode='fwd', dump=True, onlyinit=False, check_transforms=False, **kwargs)[source]#

Read concentrations as simulated by TM5 at observation points

pycif.plugins.models.TM5.io.outputs2native_adj.outputs2native_adj_AB(self, data2dump, input_type, di, df, runsubdir, mode='fwd', dump=True, onlyinit=False, do_simu=True, **kwargs)[source]#

Produce the point_observation file prior to the simulation

pycif.plugins.models.TM5.io.outputs2native_adj.outputs2native_adj(self, data2dump, input_type, di, df, runsubdir, mode='fwd', dump=True, onlyinit=False, do_simu=True, check_transforms=False, **kwargs)[source]#

PURPOSE Produce the point_observation file prior to the simulation

ARGS No idea…

KWARGS No idea…

NOTE This function calls the function self.make_obs, which is defined in pycif/plugins/models/TM5/io/inputs/make_obs.py.

VERSION HISTORY 2.1 22-10-2021 by J.C.A. van Peet

Updated by A. Berchet.

2.0 17-06-2021 by J.C.A. van Peet

Adapted for TM5.

1.0 ??-??-???? by A. Berchet

See original code above.

pycif.plugins.models.TM5.io.inputs.make_auxiliary.make_auxiliary(self, ddi, runsubdir, onlyinit=False, do_simu=True, mode='fwd', **kwargs)[source]#

Set up the TM5 executable and configuration file for one sub-simulation period.

Symlinks the TM5 binary (tm5.x) into runsubdir and calls make_config() to write the TM5 configuration file (rc).

Returns immediately when do_simu=False or onlyinit=True.

Parameters:
  • self – TM5 model plugin instance with workdir set.

  • ddi (datetime) – sub-simulation period start.

  • runsubdir (str) – path to the period run directory.

  • onlyinit (bool) – skip if True (adjoint initialisation pass).

  • do_simu (bool) – skip if False.

  • mode (str) – 'fwd', 'tl', or 'adj'.

  • **kwargs – unused.

pycif.plugins.models.TM5.io.inputs.make_chemistry.make_chemistry(self, data, runsubdir, mode, datei, datef)[source]#

Initialize chemitry files properly here

pycif.plugins.models.TM5.io.inputs.make_fluxes.make_fluxes_AB(self, data, runsubdir, datei, mode)[source]#

Make emission file for TM5

Parameters:
  • self (pycif.utils.classes.fluxes.Flux) – Flux plugin with all attributes

  • data (Plugin) – information on flux species

  • runsubdir (str) – directory to the current run

  • nho (int) – number of hours in the run

  • mode (str) – running mode: ‘fwd’, ‘tl’ or ‘adj’

pycif.plugins.models.TM5.io.inputs.make_fluxes.make_fluxes(self, datastore, runsubdir, datei, mode)[source]#

PURPOSE Make emission file for TM5

ARGS self (pycif.utils.classes.fluxes.Flux) = Flux plugin with all attributes datastore (dict) = information on flux species runsubdir (str) = directory to the current run nho (int) = number of hours in the run mode (str) = running mode: ‘fwd’, ‘tl’ or ‘adj’

NOTE This function calls the function self.flux.write, which is defined in pycif/plugins/fluxes/tm5/write.py

VERSION HISTORY 2.2 21-10-2021 by J.C.A. van Peet

Updated writing of fluxes.

2.1 20-07-2021 by J.C.A. van Peet

*) Added the “adj” mode to cases when to write emissions.

2.0 21-05-2021 by J.C.A. van Peet

Adapted for TM5.

1.0 20-05-2021 by A. Berchet

See original code above.

pycif.plugins.models.TM5.io.inputs.make_inicond.make_inicond(self, datastore, runsubdir, mode, datei, datef)[source]#

Write or symlink the TM5 initial-condition restart file.

For the first sub-simulation period only. Filters datastore to 'inicond' entries, then for each active species either symlinks the original restart file or copies and overwrites the species variable.

Parameters:
  • self – TM5 model plugin instance.

  • datastore (dict) – tracer-ID-keyed CIF data-store entries.

  • runsubdir (str) – path to the period run directory.

  • mode (str) – 'fwd', 'tl', or 'adj'.

  • datei (datetime) – period start date.

  • datef (datetime) – period end date.

pycif.plugins.models.TM5.io.inputs.make_meteo.make_meteo_AB(self, datastore, runsubdir, mode, ddi, ddf)[source]#

Link TM5 meteorological input files from the original source directory.

Reads the original meteo file directory (dirorig) from datastore and creates symlinks inside runsubdir pointing at the meteo files expected by TM5 for the period [ddi, ddf].

Parameters:
  • self – TM5 model plugin instance.

  • datastore – meteo data-store containing the dirorig path.

  • runsubdir (str) – path to the period run directory.

  • mode (str) – 'fwd', 'tl', or 'adj'.

  • ddi (datetime) – period start date.

  • ddf (datetime) – period end date.

pycif.plugins.models.TM5.io.inputs.make_meteo.make_meteo(self, datastore, runsubdir, mode, ddi, ddf)[source]#

PURPOSE Link to datavect/meteo from obsoperator/fwd_0000/2018-01-01_00-00/meteo.

VERSION HISTORY 2.0 17-05-2021 by J.C.A. van Peet

Link to datavect/meteo from obsoperator/fwd_0000/2018-01-01_00-00/meteo.

1.0 28-04-2021 by A. Berchet

Original code (see above)

pycif.plugins.models.TM5.io.inputs.make_obs.make_obs_AB(self, datastore, runsubdir, mode, tracer, do_simu=True)[source]#

Write the TM5 observation file for one sub-period and one tracer.

Formats observation metadata (station ID, level, coordinates, parameter, time step) and writes to the TM5 point-data observation file under runsubdir. For adjoint mode, also writes the departure vector.

Parameters:
  • self – TM5 model plugin instance.

  • datastore – CIF data-store for the observation tracer.

  • runsubdir (str) – path to the period run directory.

  • mode (str) – 'fwd', 'tl', or 'adj'.

  • tracer (str) – tracer / species name.

  • do_simu (bool) – if False, skip writing and only update bookkeeping.

pycif.plugins.models.TM5.io.inputs.make_obs.make_obs(self, datastore, runsubdir, mode, tracer, ddi, do_simu=True)[source]#

PURPOSE Write point observations to file readable by TM5

ARGS No idea…

KWARGS No idea…

NOTE This function is called from the function outputs2native_adj, which is defined in pycif/plugins/models/TM5/io/outputs2native_adj.py

VERSION HISTORY 2.3 28-10-2021 by J.C.A. van Peet

*) Updated determination of iter_nr. *) When mode=adj, the CIF observation increments (‘adj_out’) are now

written to the point departure file instead of the TM5 forcings (which are retained for comparison purposes).

2.2 22-10-2021 by J.C.A. van Peet

Antoine Berchet added ddi to the function header. No idea what it does though…

2.1 20-07-2021 by J.C.A. van Peet

*) Updated the way time is selected from the data2write variable *) Added on-the-fly generation of stationlist_CH4.dat, which is

then used in params.py for the variable station.list.file.

2.0 05-07-2021 by J.C.A. van Peet

Adapted for TM5.

1.0 ??-??-???? by A. Berchet

See original code above.

pycif.plugins.models.TM5.io.inputs.params.pp_list(some_list, indent=0, items_per_line=8)[source]#

PURPOSE Pretty Print a list with names (i.e. strings) such as returned by the dir function.

RETURNS A string with the list items concatenated and inserted newlines.

ARGS some_list = the list to print

KWARGS indent = additional indent so that the list items line up nicely if

they are printed on multiple lines.

items_per_line = number of list items to print on a single line

ASSUMPTIONS none

EXCEPTIONS When this function encounters a problem that it cannot solve, it will raise a RuntimeError. Pythons exeception handling will provide a traceback, including files, calls and line numbers.

PYTHON VERSION 3.8.6

VERSION CHANGE HISTORY 1.0 15-04-2021 by J.C.A. van Peet.

Original code.

pycif.plugins.models.TM5.io.inputs.params.write_tm5_rc(self, config_file, runsubdir, mode, **kwargs)[source]#

PURPOSE There are two types of rc files for running TM5: ‘tm5.rc’ and ‘tmvar-precon-run.rc’. The first is used in the jobs ‘fwd’, ‘apos’ and ‘grd’, the second in the jobs ‘g2gc’ and ‘xc2x’. Some parameters in the ‘tm5.rc’ file vary from iteration to iteration, but most are constant. These few parameters are changed using the keyword arguments to this function. The same is true for the ‘tmvar-precon-run.rc’ files, but the set of parameters is very different than that for the ‘tm5.rc’ files, so they are written in their own function.

IN/OUT self = TM5 model plugin, containing all TM5 settings. config_file = filename to write the config settings to mode = String with the mode of the TM5 run. Can be either ‘fwd’

for a forward run or ‘adj’ for an adjoint run.

KWARGS A lot, probably. To keep the function header clean, they are set in the function body using kwargs.pop(…).

ASSUMPTIONS none

EXCEPTIONS When this function encounters a problem that it cannot solve, it will raise a RuntimeError. Pythons exeception handling will provide a traceback, including files, calls and line numbers.

PYTHON VERSION 3.8.6

VERSION CHANGE HISTORY 2.2 28-10-2021 by J.C.A. van Peet.

Updated determination of iter_nr.

2.1 22-10-2021 by J.C.A. van Peet.

Updated path to point departures file following changes by Antoine.

2.0 20-07-2021 by J.C.A. van Peet.
*) Added the mode argument to indicate forward (fwd) or adjoint (adj)

runs.

*) Added extraction of the iteration number from config_file. *) Updated the setting of station.list.file *) Updated write statements to include adj variables when they are

different than the fwd variables.

1.1 22-02-2021 by J.C.A. van Peet.

Added runsubdir as a parameter to this function. See the function make_config below for more information.

1.0 03-02-2021 by J.C.A. van Peet.

Original code.

pycif.plugins.models.TM5.io.inputs.params.make_config(self, runsubdir, sdc, mode)[source]#

PURPOSE Write a configuration file for running TM5. This file will have the name ‘tm5.rc’ and is therefore also called an rc-file. This function is imported/called in native2inputs.py.

IN/OUT self = TM5 model plugin, containing all TM5 settings. runsubdir = The directory in which TM5 is run. Probably depends on iteration

number and date.

sdc = No idea. Is set in native2inputs as

ddi = min(datei, datef) sdc = ddi.strftime(“%Y%m%d%H”)

so it is probably the formatted start date of the current iteration.

mode = in native2inputs this is described as

“running mode: one of ‘fwd’, ‘adj’ and ‘tl’”. I’m not sure what ‘tl’ stands for.

KWARGS none

ASSUMPTIONS none

EXCEPTIONS When this function encounters a problem that it cannot solve, it will raise a RuntimeError. Pythons exeception handling will provide a traceback, including files, calls and line numbers.

PYTHON VERSION 3.8.6

VERSION CHANGE HISTORY 2.0 20-07-2021 by J.C.A. van Peet.

Added selection of fwd and adj mode, and writing of corresponding rc-files.

1.2 22-02-2021 by J.C.A. van Peet.

As Antoine pointed out, the initial condition file defined in the yaml file (datavect.components.inicond.[dir|file]) is linked as ini.nc in runsubdir (see make_inicond.py). So to access that file from TM5, you only have to set runsubdir/ini.nc in the rc-file. But runsubdir is not part of the TM5 object (‘self’) but passed as a parameter to the current function. So you have to pass it explicitly to the function write_tm5_rc, to be able to write it to rc file.

1.1 02-02-2021 by J.C.A. van Peet.

*) Added MODULE_NAME *) Added import of the logging module *) Updated PROG_NAME *) Used new PROG_NAME as local logger name. *) Moved writing of rc-file to separate function.

1.0 09-11-2020 by J.C.A. van Peet.

Original code.

pycif.plugins.models.TM5.io.utils.point_data.read_point_output(filename)[source]#

PURPOSE Read a TM5 point_output.nc4 file.

IN/OUT filename = string with the filename to read.

VERSION CHANGE HISTORY 1.0 23-07-2021 by J.C.A. van Peet.

Original code

pycif.plugins.models.TM5.io.utils.point_data.read_point_input(filename, sample_id)[source]#

PURPOSE Read a TM5 point_input.nc4 file.

IN/OUT filename = string with the filename to read. sample_id = numpy array with the observations ids from a point_output

file pointing to the stations in the point_input file.

VERSION CHANGE HISTORY 1.0 23-07-2021 by J.C.A. van Peet.

Original code

pycif.plugins.models.TM5.io.utils.point_data.calc_and_write_point_dep(pod, apod, apid, filename, adj_out=None)[source]#

PURPOSE Calculate the point departure data and write it to file. In TM5, this is calculated in the “dep” job by TMVar.py, which calls Observations_JRC.PointObs_JRC.applyPointObs(…) as:

point.applyPointObs( trackfile=trackfile, trackfile_apri=trackfile_apri,

mismatchfile=departurefile, Params=None, montecarlo=False )

where: trackfile = some/path/to/point_output.nc4 (written by TM5) trackile_apri = some/path/to/point_output.nc4 from the apri run (i.e. iter 1) departurefile = some/path/to/point_departures.nc4 (which is read by the

adjoint run of TM5, and which is set in params.py when the config file is written).

IN/OUT pod = Point Output Data, the dict produced by read_point_output() above apod = A-priori Point Output Data, the dict produced by read_point_output() above apid = A-priori Point Input Data, the dict produced by read_point_input() above filename = Name of file to write

KWARGS adj_out = Forcings calculated by CIF as “R^(-1) x (H(xb) - y)”. If present,

replace forcings as TM5 would have calculated them with these values.

VERSION CHANGE HISTORY 2.0 28-10-2021 by J.C.A. van Peet.

Added the adj_out keyword, which is written to file as ‘forcing’ while the original TM5 focings are retained in the ‘forcing_TM5’ variable for comparison purposes.

1.0 23-07-2021 by J.C.A. van Peet.

Original code, based on Observations_JRC.PointObs_JRC.applyPointObs(…)