pygcam.gcam

Functions for running the GCAM model. Provides the functionality of the gcam sub-command.

API

pygcam.gcam.getGcamVersion(exeDir, preferPath=False)

Try to get GCAM version by running gcam with –version flag, but if that fails, try to extract it from the path.

pygcam.gcam.runGCAM(scenario, workspace=None, refWorkspace=None, scenariosDir=None, groupDir='', configFile=None, forceCreate=False, noRun=False, noWrapper=False)
Parameters:
  • scenario – (str) the scenario to run
  • workspace – (str) path to the workspace to run in, or None, in which case the model is run in {GCAM.SandboxDir}/{scenario} if scenario is given otherwise, the default scenario in the configuration.xml in the GCAM.RefWorkspace is run.
  • refWorkspace – (str) a workspace to copy files from to create the sandbox, if the workspace is not given, or doesn’t exist.
  • scenariosDir – (str) the directory in which the config.xml file for the given scenario is found. Defaults to GCAM.ScenariosDir, if given, or “.”
  • groupDir – (str) the name of the scenario group if group sub-directories are to be used when computing the location of the scenario’s config.xml.
  • configFile – (str) if scenario is not given, the name of a configuration file to run. If scenario is given, this parameter is ignored.
  • forceCreate – (bool) if True, recreate the sandbox even if it already exists.
  • noRun – (bool) if True, don’t run the model, just create the sandbox and display the command that would be executed.
  • noWrapper – (bool) if True, don’t run GCAM inside a “wrapper” that reads output and kills the model run as soon as an error is detected.
Returns:

none

Raises:

ProgramExecutionError – if GCAM exits with non-zero status

pygcam.gcam.setJavaPath(exeDir)

Update the PATH to be able to find the Java dlls. Modeled on run-gcam.bat in the GCAM distribution.