This module provides tools to read, access, modify, and write settings for cape.pyus. It provides Options, which is based off of dict class, so options are stored in keys such as opts["InputInp"]. In addition, many convenience methods, such as opts.get_CFDSOLVER_ires(), are also provided.

See also:
class cape.pyus.options.Options(*args, **kw)

Bases: Options

Options interface for cape.pyfun

Call:
>>> opts = Options(fname=None, **kw)
Inputs:
fname: str

File to be read as a JSON file with comments

kw: dicts

Dictionary to be transformed into pyCart.options.Options

Versions:
  • 2014-07-28 @ddalle: v1.0

  • 2023-03-20 @ddalle: v2.0; use cape.optdict

apply_ArchiveTemplate()

Apply named template to set default files to delete/archive

Call:
>>> opts.apply_ArchiveTemplate()
Inputs:
opts: Options

Options interface

Versions:
  • 2016-02-29 @ddalle: v1.0

get_CFDSOLVER(j=None)

Return a "CFD_SOLVER" settings dict

Call:
>>> d = opts.get_CFDSOLVER(sec, j=None)
Inputs:
opts: :pyUS.options.Options`

Options interface

j: {None} | int

Phase number

Outputs:
d: cape.cfdx.options.odict

Settings for that section

Versions:
  • 2019-06-27 @ddalle: First version

get_CFDSOLVER_key(k, j=None)

Return a named parameter from the CFD_SOLVER section

Call:
>>> v = opts.get_CFDSOLVER_key(k, j=None)
Inputs:
opts: :pyUS.options.Options`

Options interface

k: str

Name of appropriate key from input.inp section

j: {None} | int

Phase number

Outputs:
v: int | float | list

Value for (numeric) parameter

Versions:
  • 2019-06-27 @ddalle: First version

get_ConfigInput(comp: str, **kw)

Return the input for a particular component

Call:
>>> inp = opts.get_ConfigInput(comp, **kw)
Inputs:
opts: cape.cfdx.options.Options

Options interface

comp: str

Name of component

Outputs:
inp: int | list[int]

List of BCs in this component

Versions:
  • 2015-10-20 @ddalle: v1.0

  • 2023-03-28 @ddalle: v2.0; use cape.optdict

get_InputInp(j=None, i=None, **kw)

Get name of input.inp template file

Call:
>>> InputInp = opts.get_InputInp(j=None, i=None, **kw)
Inputs:
opts: Options

options interface

j: {None} | int

Phase index; use None to just return v

i: {None} | int | np.ndarray

opts.x index(es) to use with @expr, @map, etc.

vdef: {None} | object

Manual default

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

ring: {opts._optring[key]} | True | False

Override option to loop through phase inputs

listdepth: {0} | int > 0

Depth of list to treat as a scalar

x: {None} | dict

Ref conditions to use with @expr, @map, etc.; often a run matrix; used in combination with i

sample: {True} | False

Apply j, i, and other settings recursively if output is a list or dict

Outputs:
InputInp: {None} | str

name of input.inp template file

get_InputInp_key(sec, key, j=None)

Select an input.inp setting from a specified section

Roughly, this returns opts[sec][key].

Call:
>>> val = opts.get_namelist_key(sec, key, j=None)
Inputs:
opts: pyUS.options.Options

Options interface

sec: str

Section name

key: str

Variable name

j: {None} | int

Phase number

Outputs:
val: JSON-type

Value from JSON options

Versions:
  • 2015-10-19 @ddalle: First version

  • 2019-06-27 @ddalle: From get_namelist_var()

get_PostScrFile(j=None, i=None, **kw)

Get name of post.scr file template

Call:
>>> PostScrFile = opts.get_PostScrFile(j=None, i=None, **kw)
Inputs:
opts: ConfigOpts

options interface

j: {None} | int

Phase index; use None to just return v

i: {None} | int | np.ndarray

opts.x index(es) to use with @expr, @map, etc.

vdef: {None} | object

Manual default

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

ring: {opts._optring[key]} | True | False

Override option to loop through phase inputs

listdepth: {0} | int > 0

Depth of list to treat as a scalar

x: {None} | dict

Ref conditions to use with @expr, @map, etc.; often a run matrix; used in combination with i

sample: {True} | False

Apply j, i, and other settings recursively if output is a list or dict

Outputs:
PostScrFile: {None} | str

name of post.scr file template

get_conn(j=None, i=None, **kw)

Get name of connectivity file made by us3d-prepar

Call:
>>> conn = opts.get_conn(j=None, i=None, **kw)
Inputs:
opts: US3DPreparOpts

options interface

j: {None} | int

Phase index; use None to just return v

i: {None} | int | np.ndarray

opts.x index(es) to use with @expr, @map, etc.

vdef: {None} | object

Manual default

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

ring: {opts._optring[key]} | True | False

Override option to loop through phase inputs

listdepth: {0} | int > 0

Depth of list to treat as a scalar

x: {None} | dict

Ref conditions to use with @expr, @map, etc.; often a run matrix; used in combination with i

sample: {True} | False

Apply j, i, and other settings recursively if output is a list or dict

Outputs:
conn: {'conn.h5'} | str

name of connectivity file made by us3d-prepar

get_gas(j=None, i=None, **kw)

Get name of gas model to use for US3D

Call:
>>> gas = opts.get_gas(j=None, i=None, **kw)
Inputs:
opts: US3DRunOpts

options interface

j: {None} | int

Phase index; use None to just return v

i: {None} | int | np.ndarray

opts.x index(es) to use with @expr, @map, etc.

vdef: {None} | object

Manual default

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

ring: {opts._optring[key]} | True | False

Override option to loop through phase inputs

listdepth: {0} | int > 0

Depth of list to treat as a scalar

x: {None} | dict

Ref conditions to use with @expr, @map, etc.; often a run matrix; used in combination with i

sample: {True} | False

Apply j, i, and other settings recursively if output is a list or dict

Outputs:
gas: {None} | str

name of gas model to use for US3D

get_grid(j=None, i=None, **kw)

Get name of US3D grid file

Call:
>>> grid = opts.get_grid(j=None, i=None, **kw)
Inputs:
opts: US3DRunOpts

options interface

j: {None} | int

Phase index; use None to just return v

i: {None} | int | np.ndarray

opts.x index(es) to use with @expr, @map, etc.

vdef: {None} | object

Manual default

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

ring: {opts._optring[key]} | True | False

Override option to loop through phase inputs

listdepth: {0} | int > 0

Depth of list to treat as a scalar

x: {None} | dict

Ref conditions to use with @expr, @map, etc.; often a run matrix; used in combination with i

sample: {True} | False

Apply j, i, and other settings recursively if output is a list or dict

Outputs:
grid: {'grid.h5'} | str

name of US3D grid file

get_input(j=None, i=None, **kw)

Get name of US3D input control file

Call:
>>> input = opts.get_input(j=None, i=None, **kw)
Inputs:
opts: US3DRunOpts

options interface

j: {None} | int

Phase index; use None to just return v

i: {None} | int | np.ndarray

opts.x index(es) to use with @expr, @map, etc.

vdef: {None} | object

Manual default

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

ring: {opts._optring[key]} | True | False

Override option to loop through phase inputs

listdepth: {0} | int > 0

Depth of list to treat as a scalar

x: {None} | dict

Ref conditions to use with @expr, @map, etc.; often a run matrix; used in combination with i

sample: {True} | False

Apply j, i, and other settings recursively if output is a list or dict

Outputs:
input: {'input.inp'} | str

name of US3D input control file

get_run(j=None, i=None, **kw)

Get whether to execute program

Call:
>>> run = opts.get_run(j=None, i=None, **kw)
Inputs:
opts: US3DRunOpts

options interface

j: {None} | int

Phase index; use None to just return v

i: {None} | int | np.ndarray

opts.x index(es) to use with @expr, @map, etc.

vdef: {None} | object

Manual default

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

ring: {opts._optring[key]} | True | False

Override option to loop through phase inputs

listdepth: {0} | int > 0

Depth of list to treat as a scalar

x: {None} | dict

Ref conditions to use with @expr, @map, etc.; often a run matrix; used in combination with i

sample: {True} | False

Apply j, i, and other settings recursively if output is a list or dict

Outputs:
run: {None} | True | False

whether to execute program

get_section(sec, j=None)

Return a settings dict for an input.inp section

Call:
>>> d = opts.get_section(sec, j=None)
Inputs:
opts: :pyUS.options.Options`

Options interface

sec: str

Name of appropriate input.inp section

j: {None} | int

Phase number

Outputs:
d: cape.cfdx.options.odict

Settings for that section

Versions:
  • 2019-06-27 @ddalle: First version

init_post()

Initialization hook for Options

Call:
>>> opts.init_post()
Inputs:
opts: Options

Options interface

Versions:
  • 2022-10-23 @ddalle: Version 1.0

select_InputInp(j=0)

Reduce input.inp options to options for a single phase

Call:
>>> d = opts.select_InputInp(j=0)
Inputs:
opts: pyUS.options.Options

Options interface

j: {0} | int

Phase number

Outputs:
d: cape.cfdx.options.odict

Project settings for phase j

Versions:
  • 2019-06-27 @ddalle: First version

set_InputInp(v, j=None, mode=None)

Get name of input.inp template file

Call:
>>> opts.set_InputInp(InputInp, j=None, i=None, **kw)
Inputs:
opts: Options

options interface

InputInp: {None} | str

name of input.inp template file

j: {None} | int

Phase index; use None to just return v

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

listdepth: {0} | int > 0

Depth of list to treat as a scalar

set_InputInp_key(sec, key, val, j=None)

Set a namelist key for a specified phase or phases

Roughly, this sets opts["US3D"][sec][key] or opts["US3D"][sec][key][i] equal to val

Call:
>>> opts.set_InputInp_key(sec, key, val, j=None)
Inputs:
opts: pyUS.options.Options

Options interface

sec: str

Section name

key: str

Variable name

val: JSON-type

Value for JSON options

j: {None} | int

Phase number

Versions:
  • 2017-04-05 @ddalle: First version

  • 2019-06-27 @ddalle: From set_namelist_var()

set_PostScrFile(v, j=None, mode=None)

Get name of post.scr file template

Call:
>>> opts.set_PostScrFile(PostScrFile, j=None, i=None, **kw)
Inputs:
opts: ConfigOpts

options interface

PostScrFile: {None} | str

name of post.scr file template

j: {None} | int

Phase index; use None to just return v

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

listdepth: {0} | int > 0

Depth of list to treat as a scalar

set_conn(v, j=None, mode=None)

Get name of connectivity file made by us3d-prepar

Call:
>>> opts.set_conn(conn, j=None, i=None, **kw)
Inputs:
opts: US3DPreparOpts

options interface

conn: {'conn.h5'} | str

name of connectivity file made by us3d-prepar

j: {None} | int

Phase index; use None to just return v

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

listdepth: {0} | int > 0

Depth of list to treat as a scalar

set_gas(v, j=None, mode=None)

Get name of gas model to use for US3D

Call:
>>> opts.set_gas(gas, j=None, i=None, **kw)
Inputs:
opts: US3DRunOpts

options interface

gas: {None} | str

name of gas model to use for US3D

j: {None} | int

Phase index; use None to just return v

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

listdepth: {0} | int > 0

Depth of list to treat as a scalar

set_grid(v, j=None, mode=None)

Get name of US3D grid file

Call:
>>> opts.set_grid(grid, j=None, i=None, **kw)
Inputs:
opts: US3DRunOpts

options interface

grid: {'grid.h5'} | str

name of US3D grid file

j: {None} | int

Phase index; use None to just return v

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

listdepth: {0} | int > 0

Depth of list to treat as a scalar

set_input(v, j=None, mode=None)

Get name of US3D input control file

Call:
>>> opts.set_input(input, j=None, i=None, **kw)
Inputs:
opts: US3DRunOpts

options interface

input: {'input.inp'} | str

name of US3D input control file

j: {None} | int

Phase index; use None to just return v

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

listdepth: {0} | int > 0

Depth of list to treat as a scalar

set_run(v, j=None, mode=None)

Get whether to execute program

Call:
>>> opts.set_run(run, j=None, i=None, **kw)
Inputs:
opts: US3DRunOpts

options interface

run: {None} | True | False

whether to execute program

j: {None} | int

Phase index; use None to just return v

mode: {None} | 0 | 1 | 2 | 3

Warning mode code

0:

no checks

1:

validate silently

2:

validate and show warnings

3:

raise an exception if invalid

listdepth: {0} | int > 0

Depth of list to treat as a scalar