pyCAPS
pyCAPS: A Python Extension Module for CAPS
|
Defines a CAPS problem object. More...
Public Member Functions | |
def | __init__ (self, libDir=None, raiseException=True) |
Initialize the problem. More... | |
def | loadCAPS (self, capsFile, projectName=None, verbosity=None) |
Loads a *.csm, *.caps, or *.egads file into the problem. More... | |
def | setVerbosity (self, verbosityLevel) |
Set the verbosity level of the CAPS output. More... | |
def | saveCAPS (self, filename="saveCAPS.caps") |
Save a CAPS problem. More... | |
def | closeCAPS (self) |
Close a CAPS problem. More... | |
def | dirtyAnalysis (self) |
Report what analyses loaded into the problem are dirty. More... | |
def | loadAIM (self, kwargs) |
Load an AIM (Analysis Interface Module) into the problem. More... | |
def | createDataTransfer (self, kwargs) |
Alteranative to createDataBound. More... | |
def | createDataBound (self, kwargs) |
Create a CAPS data bound/transfer into the problem. More... | |
def | createValue (self, name, data, units=None, limits=None, fixedLength=True, fixedShape=True) |
Create a CAPS value object. More... | |
def | autoLinkValue (self, value=None) |
Create a link between a created CAPS value parameter and analyis inputs of all loaded AIMs, automatically. More... | |
def | addAttribute (self, name, data) |
Add an attribute (that is meta-data) to the problem object. More... | |
def | getAttribute (self, name) |
Get an attribute (that is meta-data) that exists on the problem object. More... | |
def | createTree (self, filename="myProblem", kwargs) |
Create a HTML dendrogram/tree of the current state of the problem. More... | |
Public Attributes | |
status | |
Current CAPS status code. | |
raiseException | |
Raise an exception after a CAPS error is found (default - True). More... | |
geometry | |
Geometry object loaded into the problem. More... | |
aimGlobalCount | |
Number of AIMs loaded into the problem. More... | |
analysisDir | |
Current analysis directory which was used to load the latest AIM. More... | |
capsIntent | |
Default intent used to load the AIM if capsIntent is not provided. More... | |
analysis | |
Dictionary of analysis objects loaded into the problem. More... | |
dataBound | |
Dictionary of data transfer/bound objects loaded into the problem. More... | |
value | |
Dictionary of value objects loaded into the problem. More... | |
Defines a CAPS problem object.
A capsProblem is the top-level object for a single mission/problem. It maintains a single set of interrelated geometric models (see pyCAPS._capsGeometry), analyses to be executed (see pyCAPS._capsAnalysis), connectivity and data (see pyCAPS._capsBound) associated with the run(s), which can be both multi-fidelity and multi-disciplinary.
def __init__ | ( | self, | |
libDir = None , |
|||
raiseException = True |
|||
) |
Initialize the problem.
See problem.py for a representative use case.
libDir | Deprecated option, no longer required. |
raiseException | Raise an exception after a CAPS error is encountered (default - True). See raiseException . |
def addAttribute | ( | self, | |
name, | |||
data | |||
) |
Add an attribute (that is meta-data) to the problem object.
See example problem7.py for a representative use case.
name | Name used to define the attribute. |
data | Data value(s) for the attribute. Note that type casting in done automatically based on the determined type of the Python object. |
def autoLinkValue | ( | self, | |
value = None |
|||
) |
Create a link between a created CAPS value parameter and analyis inputs of all loaded AIMs, automatically.
Valid CAPS value, parameter objects must be created with createValue(). Note, only links to ANALYSISIN inputs are currently made at this time. See value6.py for a representative use case.
value | Value to use when creating the link (default - None). A combination (i.e. a single or list) of value dictionary entries and/or value object instances (returned from a call to createValue()) can be used. If no value is provided, all entries in the value dictionary (value) will be used. |
def closeCAPS | ( | self | ) |
Close a CAPS problem.
See problem1.py for a representative use case.
def createDataBound | ( | self, | |
kwargs | |||
) |
Create a CAPS data bound/transfer into the problem.
**kwargs | See below. |
Valid keywords:
capsBound | Name of capsBound to use for the data bound. |
variableName | Single or list of variables names to add. |
aimSrc | Single or list of AIM names that will be the data sources for the bound. |
aimDest | Single or list of AIM names that will be the data destinations during the transfer. |
transferMethod | Single or list of transfer methods to use during the transfer. |
initValueDest | Single or list of initial values for the destication data. |
def createDataTransfer | ( | self, | |
kwargs | |||
) |
Alteranative to createDataBound.
Enforces that at least 2 AIMs must be already loaded into the problem. See createDataBound for details.
def createTree | ( | self, | |
filename = "myProblem" , |
|||
kwargs | |||
) |
Create a HTML dendrogram/tree of the current state of the problem.
See example problem6.py for a representative use case. The HTML file relies on the open-source JavaScript library, D3, to visualize the data. This library is freely available from https://d3js.org/ and is dynamically loaded within the HTML file. If running on a machine without internet access a (miniaturized) copy of the library may be written to a file alongside the generated HTML file by setting the internetAccess keyword to False. If set to True, internet access will be necessary to view the tree.
filename | Filename to use when saving the tree (default - "myProblem"). Note an ".html" is automatically appended to the name (same with ".json" if embedJSON = False). |
**kwargs | See below. |
Valid keywords:
embedJSON | Embed the JSON tree data in the HTML file itself (default - True). If set to False a seperate file is generated for the JSON tree data. |
internetAccess | Is internet access available (default - True)? If set to True internet access will be necessary to view the tree. |
analysisGeom | Show the geometry for each analysis entity (default - False). |
internalGeomAttr | Show the internal attributes (denoted by starting with an underscore, for example "_AttrName") that exist on the geometry (default - False). |
reverseMap | Reverse the geometry attribute map (default - False). |
def createValue | ( | self, | |
name, | |||
data, | |||
units = None , |
|||
limits = None , |
|||
fixedLength = True , |
|||
fixedShape = True |
|||
) |
Create a CAPS value object.
Only a value of subtype in PARAMETER is currently supported. See value.py for a representative use case. Value objects are stored the value dictionary.
name | Name used to define the value. This will be used as the keyword entry in the value dictionary. |
data | Data value(s) for the variable. Note that type casting in done automatically based on the determined type of the Python object. Be careful with the Integers and Floats/Reals, for example 10 would be type casted as an Integer, while 10.0 would be a float - this small discrepancy may lead to type errors when linking values to analysis inputs. |
units | Units associated with the value (default - None). |
limits | Valid/acceptable range for the value (default - None). |
fixedLength | Should the length of the value object be fixed (default - True)? For example if the object is initialized with a value of [1, 2] it can not be changed to [1, 2, 3]. |
fixedShape | Should the shape of the value object be fixed (default - True)? For example if the object is initialized with a value of 1 it can not be changed to [1, 2] or [[1, 2, 3], [4, 5, 6]] can not be changed to [[1, 2], [4, 5]]. |
def dirtyAnalysis | ( | self | ) |
Report what analyses loaded into the problem are dirty.
def getAttribute | ( | self, | |
name | |||
) |
Get an attribute (that is meta-data) that exists on the problem object.
See example problem7.py for a representative use case.
name | Name of attribute to retrieve. |
def loadAIM | ( | self, | |
kwargs | |||
) |
Load an AIM (Analysis Interface Module) into the problem.
See examples problem3.py and problem4.py for typical representative use cases.
**kwargs | See below. |
Valid keywords:
aim | Name of the requested AIM. |
altName | Alternative name to use when referencing AIM inside the problem (dictionary key in analysis). The name of the AIM, aim, will be used if no $altName is provided (see remarks). |
analysisDir | Directory for AIM analysis. If none is provided the directory of the last loaded AIM will be used; if no AIMs have been load the current working directory is used. CAPS requires that an unique directory be specified for each instance of AIM. |
capsIntent | Analysis intention in which to invoke the AIM. |
parents | Single or list of parent AIM names to initilize the AIM with. |
copyAIM | Name of AIM to copy. Creates the new AIM instance by duplicating an existing AIM. Analysis directory ($analysisDir) and $altName should be provided and different from the AIM being copied. See example analysis2.py for a representative use case. |
copyParents | When copying an AIM, should the same parents also be used (default - True). |
def loadCAPS | ( | self, | |
capsFile, | |||
projectName = None , |
|||
verbosity = None |
|||
) |
Loads a *.csm, *.caps, or *.egads file into the problem.
See problem1.py, problem2.py, and problem8.py for example use cases.
capsFile | CAPS file to load. Options: *.csm, *.caps, or *.egads. If the filename has a *.caps extension the pyCAPS analysis, bound, and value objects will be re-populated (see remarks). |
projectName | CAPS project name. projectName=capsFile if not provided. |
verbosity | Level of output verbosity. See setVerbosity . |
def saveCAPS | ( | self, | |
filename = "saveCAPS.caps" |
|||
) |
Save a CAPS problem.
See problem8.py for example use case.
filename | File name to use when saving CAPS problem. |
def setVerbosity | ( | self, | |
verbosityLevel | |||
) |
Set the verbosity level of the CAPS output.
See problem5.py for a representative use case.
verbosityLevel | Level of output verbosity. Options: 0 (or "minimal"), 1 (or "standard") [default], and 2 (or "debug"). |
aimGlobalCount |
Number of AIMs loaded into the problem.
analysis |
Dictionary of analysis objects loaded into the problem.
Set via loadAIM.
analysisDir |
Current analysis directory which was used to load the latest AIM.
capsIntent |
Default intent used to load the AIM if capsIntent is not provided.
dataBound |
Dictionary of data transfer/bound objects loaded into the problem.
Set via createDataBound or createDataTransfer.
geometry |
Geometry object loaded into the problem.
Set via loadCAPS.
raiseException |
Raise an exception after a CAPS error is found (default - True).
Disabling (i.e. setting to False) may have unexpected consequences; in general the value should be set to True.
value |
Dictionary of value objects loaded into the problem.
Set via createValue.