cape.pylch.varsfile
: Interface for Loci/CHEM .vars
files¶
This module provides the class VarsFile
that reads, modifies,
and writes instances of the Loci/CHEM primary input file with the
extension .vars
.
- class cape.pylch.varsfile.VFileFunction(a, name: str)¶
Section for reading “functions” marked by regular parentheses
- class cape.pylch.varsfile.VFileList(a=None)¶
Section for reading subsections marked by angle-brackets
- class cape.pylch.varsfile.VFileSubsec(a: str | dict | None = None)¶
Section for reading subsections marked by angle-brackets
- Call:
>>> sec = VFileSubsec(a=None) >>> sec = VFileSubsec(fp)
- Inputs:
- Outputs:
- sec:
VFileSubsec
Vars file subsection instance
- sec:
- class cape.pylch.varsfile.VarsFile(*args, **kw)¶
-
- find_function(name: str, nmax: int | None = None) dict ¶
Find function(s) by name within
.vars
file- Call:
>>> funcs = opts.find_function(name, nmax=None)
- Inputs:
- Outputs:
- funcs:
dict
Each instance of name function found; key of each item says where the function was located w/i data
- funcs:
- Versions:
2024-02-24
@ddalle
: v1.0
- get_alpha(name: str = 'farfield', comp: str | None = None) float | None ¶
Get current angle of attack for one BC, in degrees
- get_beta(name: str = 'farfield', comp: str | None = None) float | None ¶
Get current angle of attack for one BC, in degrees
- get_mach(name: str = 'farfield', comp: str | None = None) float | None ¶
Get current Mach number, usually from “farifled” BC
- Call:
>>> m = opts.get_mach(name="farfield", comp=None)
- Inputs:
- Outputs:
- m:
float
|None
Mach number from first farfield() function, if any
- m:
- Versions:
2024-02-26
@ddalle
: v1.02024-10-21
@ddalle
: v2.0
- get_rho(name: str = 'farfield', comp: str | None = None) float | None ¶
Get current density, usually from “farifled” BC
- Call:
>>> rho = opts.get_rho(name="farfield", comp=None)
- Inputs:
- Outputs:
- rho:
float
|None
Density from first name function, if any [kg/m^3]
- rho:
- Versions:
2024-10-21
@ddalle
: v1.0
- get_temperature(name: str = 'farfield', comp: str | None = None) float | None ¶
Get current density, usually from “farifled” BC
- Call:
>>> t = opts.get_temperature(name="farfield", comp=None)
- Inputs:
- Outputs:
- t:
float
|None
Temperature from first name function, if any [K]
- t:
- Versions:
2024-10-21
@ddalle
: v1.0
- read_varsfile(fname: str)¶
Read a Chem
.vars
file- Call:
>>> opts.read_varsfile(fname)
- Inputs:
- fname:
str
Name of file to read
- fname:
- Versiosn:
2024-03-12
@ddalle
: v1.0
- set_alpha(a: float, name: str = 'farfield', comp: str | None = None)¶
Set the angle of attack for one or more farfield condition
- Call:
>>> opts.set_alpha(a, name="farfield")
- Inputs:
- Versions:
2024-02-26
@ddalle
: v1.02024-10-21
@ddalle
: v2.0
- set_beta(b: float, name: str = 'farfield', comp: str | None = None)¶
Set the sideslip angle for one or more farfield condition
- set_mach(m: float, name: str = 'farfield', comp: str | None = None)¶
Set the Mach number for one or more farfield condition
- Call:
>>> opts.set_mach(m, name="farfield")
- Inputs:
- Versions:
2024-02-26
@ddalle
: v1.02024-10-21
@ddalle
: v2.0
- set_rho(rho: float, name: str = 'farfield', comp: str | None = None)¶
Set the Mach number for one or more farfield condition
- cape.pylch.varsfile.assert_nextstr(c: str, target: str, desc=None)¶
Check if a string matches a specified target
- Call:
>>> assert_nextstr(c, target, desc=None)
- Inputs:
- Raises:
ValueError
if c does not match target
- Versions:
2024-02-23
@ddalle
: v1.0
- cape.pylch.varsfile.assert_regex(c: str, regex, desc=None)¶
Check if a string matches a compiled regular expression
- Call:
>>> assert_regex(c, regex, desc=None)
- Inputs:
- Raises:
ValueError
if c does not match regex
- Versions:
2024-02-23
@ddalle
: v1.0
- cape.pylch.varsfile.set_func_arg(func: dict | None, funcname: str, j: int, v: Any, args: list | None = None) dict ¶
Set an argument value by position
- Call:
>>> newfunc = set_func_arg(func, funcname, j, v, args=None)
- Inputs:
- Outputs:
- newfunc:
dict
Modified func, in-place unless func is
None
- newfunc:
- cape.pylch.varsfile.set_polar_arg(func: dict | None, j: int, v: Any, args: list | None = None) dict ¶
Set an argument value by position
- Call:
>>> newfunc = set_polar_arg(func, j, v, args=None)
- Inputs:
- Outputs:
- newfunc:
dict
Modified func, in-place unless func is
None
- newfunc:
- cape.pylch.varsfile.to_text(val: object) str ¶
Convert appropriate Python value to
.vars
file text- Call:
>>> txt = to_text(val)
- Inputs:
- val:
object
One of several appropriate values for
.vars
files
- val:
- Outputs:
- txt:
str
Converted text
- txt:
- Versions:
2024-02-24
@ddalle
: v1.0