Source code for pycif.plugins.modes.co2mvs.utils.forward

from .....utils import path
from .....utils.yml import ordered_dump
from logging import info
import subprocess


[docs] def run_forward(self, ): workdir = self.workdir controlvect = self.controlvect platform = self.platform # Create the batch directory ref_fwd_dir = f"{workdir}/sub_runs/ref_forward" path.init_dir(ref_fwd_dir) # Dump the reference control vector to the directory controlvect.dump( f"{ref_fwd_dir}/controlvect.pickle", to_netcdf=controlvect.save_out_netcdf, dir_netcdf=f"{ref_fwd_dir}/controlvect/") # Updating configuration dictionary yml_dict = \ self.from_yaml( self.reference_instances["reference_setup"].def_file) yml_dict["workdir"] = ref_fwd_dir yml_dict["mode"] = { **yml_dict["mode"], **{"plugin": { "name": "forward", "version": "std" } } } # Dumps new yml file yml_file = f"{ref_fwd_dir}/config_ref_fwd.yml" with open(yml_file, "w") as outfile: ordered_dump(outfile, yml_dict) # Running the forward info("Running the reference trajectory as a sub-process") process = subprocess.Popen( f"{platform.python} -m pycif {yml_file}".split(), cwd=ref_fwd_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) stdout, stderr = process.communicate()