cape.pycart.options.util: Utilities for pyCart Options Module

This module provides tools to read, access, modify, and write settings for cape.pycart. It is based off of the cape.cfdx.options.util module and provides a special class cape.cfdx.options.odict that is subclassed from the Python built-in dict. Behavior, such as opts['InputCntl'] or opts.get('InputCntl') are also present. In addition, many convenience methods, such as opts.set_it_fc(n), which sets the number of flowCart iterations, are provided.

In addition, this module controls default values of each pyCart parameter in a two-step process. The precedence used to determine what the value of a given parameter should be is below.

  1. Values directly specified in the input file, pyCart.json

  2. Values specified in the default control file, $PYCART/settings/pyCart.default.json

  3. Hard-coded defaults from this module

See Also:
cape.pycart.options.util.getCart3DTemplate(fname)

Get full path to template with file name fname

Call:
>>> fabs = getPyCartTemplate(fname)
Inputs:
fname: str

Name of file, such as input.cntl

Outputs:
fabs: str

Full path to the file, $PYCART/templates/cart3d/$fname

Versions:
  • 2015-10-26 @ddalle: Version 1.0

  • 2021-03-01 @ddalle: Version 2.0; see get_template()

cape.pycart.options.util.get_pycart_defaults()

Read pyCart.default.json default settings file

Call:
>>> defs = get_pycart_defaults()
Outputs:
defs: dict

Dictionary of settings read from JSON file

Versions:
  • 2014-06-03 @ddalle: Version 1.0

  • 2014-07-28 @ddalle: Version 1.1; options module

  • 2021-03-01 @ddalle: Version 1.2
    • local JSON file

    • setuptools compatible

    • was getPyCartDefaults()

cape.pycart.options.util.get_template(fname)

Get the absolute path to a template file by name

Call:
>>> fabs = get_template(fname)
Inputs:
fname: str

Name of file, such as input.cntl

Outputs:
fabs: str

Full path to file

Versions:
  • 2015-10-26 @ddalle: Version 1.0; getTemplateFolder()

  • 2021-03-01 @ddalle: Version 2.0
    • Moved to cape/pycart/ folder

    • Compatible with setuptools

cape.pycart.options.util.rc0(p)

Get setting from cape.pycart.options.rc, but ensure a scalar

Call:
>>> v = rc0(s)
Inputs:
s: str

Name of parameter to extract

Outputs:
v: any

Either rc[s] or rc[s][0], whichever is appropriate

Versions:
  • 2014-08-01 @ddalle: Version 1.0