gruvoc.surfconfig
: Surface name, ID, and property management¶
This module provides an interface to surface grid configuration control. Perhaps the primary goal is simply to associate a name with each ID number in a surface grid.
- class cape.gruvoc.surfconfig.JSONOpts(*args, **kw)¶
- class cape.gruvoc.surfconfig.SurfConfig(fname: str | None = None, **kw)¶
Surface properties and configurations
- Call:
>>> cfg = SurfConfig(fname=None, **kw)
- Outputs:
- cfg:
SurfConfig
Surface configuration
- cfg:
- Attributes:
- add_face(comp: str, comp_id: int)¶
Add a new face with specified ID number
- Call:
>>> cfg.add_face(comp, comp_id)
- Inputs:
- cfg:
SurfConfig
Surface configuration
- comp:
str
Name of component (face/family)
- comp_id:
int
ID number for comp
- cfg:
- add_parent(parent: str, child: str)¶
Add a parent-child relationship for two named components
- Call:
>>> cfg.add_parent(parent, child)
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- parent:
str
Name of parent component
- child:
str
Name of child component
- cfg:
- Attributes:
parents
: parent added tocfg.parents[child]
- apply_comp_dict(configdict: dict)¶
Renumber components to match dict and remove unused comps
- Call:
>>> cfg.apply_comp_dict(configdict)
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- configdict:
dict
[int
] Dictionary of components to keep and their final IDs
- cfg:
- assert_comp(comp: str)¶
Test of comp is in the configuration
- Call:
>>> cfg.assert_comp(comp)
- Inputs:
- cfg:
SurfConfig
Surface configuration
- comp:
str
Name of component (face/family)
- cfg:
- Raises:
GruvocValueError
if comp is not present
- clear_parent_comp_ids()¶
Remove CompID setting from any comp that is a parent
This means that only the base-level components are numbered.
- Call:
>>> cfg.clear_parent_comp_ids()
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- cfg:
- get_comp_ids(comp: str) list ¶
Get list of component IDs within a component, expanding tree
- Call:
>>> comp_ids = cfg.get_comp_ids(comp)
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- comp:
str
Name of component
- cfg:
- Outputs:
- get_complist() list ¶
Get full list components from tree and props
- Call:
>>> complist = cfg.get_complist()
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- cfg:
- Outputs:
- get_name(surf_id: int) str ¶
Find face name from a single component ID
- Call:
>>> face = cfg.get_name(surf_id)
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- surf_id:
int
Surface index
- cfg:
- get_prop(comp: str, opt: str) Any ¶
Get any property for one component, including from parents
- Call:
>>> val = cfg.get_prop(comp, opt)
- Inputs:
- cfg:
SurfConfig
Surface configuration
- comp:
str
Name of component (face/family)
- opt:
str
Name of poperty to set
- cfg:
- Outputs:
- val:
object
Value to set for that property
- val:
- get_prop_comp(comp: str, opt: str) Any ¶
Get any property for one component, no recursion
- Call:
>>> val = cfg.get_prop(comp, opt)
- Inputs:
- cfg:
SurfConfig
Surface configuration
- comp:
str
Name of component (face/family)
- opt:
str
Name of poperty to set
- cfg:
- Outputs:
- val:
object
Value to set for that property
- val:
- read_json(fname: str)¶
Read surface configuration from JSON file
- Call:
>>> cfg.read_json(fname)
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- fname:
str
Name of file to read
- cfg:
- read_mapbc(fname_or_fp: IOBase | str)¶
Read a MapBC text file
- Call:
>>> cfg.read_mapbc(fname) >>> cfg.read_mapbc(fp)
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- fname:
str
Name of file to read
- fp:
IOBase
File handle to read from
- cfg:
- remove_comp(comp: str)¶
Remove a component from configuration, including tree
- Call:
>>> cfg.remove_comp(comp)
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- comp:
str
Name of component to remove
- cfg:
- Attributes:
- renumber_comps()¶
Renumber used components 1, 2, …
- Call:
>>> cfg.renumber_comps()
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- cfg:
- restrict_comp_ids(comp_ids: list | ndarray)¶
Restrict configuration to comps with specified IDs
- Call:
>>> cfg.restrict_comp_ids(comp_ids)
- Inputs:
- cfg:
SurfConfig
Surface component configuration instance
- comp_ids:
list
[int
] List/array of CompIDs to keep
- cfg: