Skip to content

Resolve "Export Generic ResultTree Item"

Lucas POLO-LOPEZ requested to merge 35-export-generic-resulttree-item into develop

Closes #35 (closed)

Since the goal is to have a method as generic as possible, it will be better to return a CST result object as output parameter. From this object, the user will be able to retrieve the X and Y data, in either complex and or real part form, without the method having to do any assumption on the format and type of the data.

getResultTreeItem(self, resultTreeItem: str, format: str = "complex", runID: int = 0) -> tuple[np.ndarray, np.ndarray, str, str]

Input parameters

resultTreeItem

String containing the path of the result tree item to be retrieved.

format

Indicates how the Y data of the result must be returned. Possible options are:

  • real
  • imaginary
  • complex
  • magnitude
  • phase

runID

INteger indicaring the runID for which the contents of the result tree item must be retrieved. A value of 0 indicates the current run.

Output parameters

xData

X data of the result tree item.

yData

Y data of the result tree item, in the format indicated by the format input parameter.

xUnit

Units of the xData vector.

yUnit

Units of the yData vector.

Flow

  1. Retrieve the list of runIDs for which this result tree item presents valid values.
    • If an error occurs (typically, the result tree item does not exist), raise an exception.
  2. Check if the required runID is present in the former list.
    • If not, raise an exception.
  3. Retrieve the value of the result tree item for the required runID.
  4. Extract the X and Y data from the retrieved value, and return it using the adequate format.

Issues with 0D results

The approach described above will only work for 1D results. The main issue is related to step 5 of the flow. When working with 1Dresults we use the GetArray() method of the CST COM interface to extract the data from the result object. Nevertheless, for 0Dresults it is necessary to use the GetData() method. This method requires an input parameter of type double that will be used as output parameter, similarly to what has been done for retrieving the parameter values in !26 (merged). Nevertheless, I have tried to follow a similar approach to implement the retrieval of 0D results and I have not been able to make it work.

I have tried to explicitly declare the type of the parameters as:

valueRe = VARIANT(pythoncom.VT_ARRAY|pythoncom.VT_R8,[42.5])

Nevertheless, I am getting an error after calling GetData() which states that "The type does not match".

For the moment, I am leaving the implementation of the getTreeResult method as it is, allowing only the retrieval of 1D results. I am explaining this in the documentation and, eventually, I will create a new issue to add the possibility of retrieving 0D results.

Edited by Lucas POLO-LOPEZ

Merge request reports

Loading