pycif.plugins.models.template — API reference#
Configuration reference: template plugin
- pycif.plugins.models.template.compile.compile(self)[source]#
The
compilefunction initializes all model information and executables prior to any run. Files must be copied in$workdir/model.This includes:
copying executable if exist
Warning
It is recommended to copy executable files to make sure than later simulations in the present pyCIF computation use the same executable. Indeed, it can happen that one runs very long inversions in the background and carries on developments, forgetting about the background inversions, thus potentially breaking the background inversions, or worse, changing the result without error…
copy sources and compile if no executable is around, or if explicitly required to re-compile.
Note
As much as possible, the model should be compiled within pyCIF to guarantee a traceability of the options used for compiling and also dealing with
platformspecificities through theplatformPlugin (see details here)copy extra configuration files, e.g., templates for namelists, etc.
- pycif.plugins.models.template.ini_mapper.ini_mapper(model, general_mapper={}, backup_comps={}, transforms_order=[], ref_transform='', transform_name='', all_transforms=None, **kwargs)[source]#
- pycif.plugins.models.template.ini_periods.ini_periods(self, **kwargs)[source]#
The function
ini_periodsis optional but very recommended. It is used to define the temporal variablessubsimu_dates,input_dates,tstep_datesandtstep_all. The function is automatically called at the initialization of themodelclass if available. If not available, the temporal variables should be defined manually in theini_datafunction (not recommended).ini_periodsis a class method that applies to themodelplugin itself. Therefore, the only expected argument isself.def ini_periods(self, **kwargs): self.subsimu_dates = XXXX self.tstep_dates = XXXXX self.input_dates = XXXXX self.tstep_all = XXXXX
- pycif.plugins.models.template.run.run(self, runsubdir, mode, workdir, ddi, nbproc=1, do_simu=True, approx_transf=False, ref_fwd_dir='', overlap=False, **kwargs)[source]#
Run the model in forward, tangent-linear or adjoint mode. This includes:
executing the model external executable
updating
adj_refdirmoving files needed for chained simulations to “{}/../”.format(runsubdir)
Note
For model for which the adjoint is not coded, make sure to return a clear error if the
runfunction is called inadjmode and withdo_simu = True- Parameters:
self – the model Plugin
runsubdir (str) – working directory for the current run
mode (str) – forward or backward
workdir (str) – pyCIF working directory
do_simu (bool) – re-run or not existing simulation