Demo 2: Obtain Graph Measurements

Download demo 2 Python script

Download demo 2 SIMetrix Schematic

Download demo 2 SIMPLIS Schematic

In this example a schematic which plots a graph with measurements, is run. On completion, the Python script extracts the measurements from the graph then displays them. To run the example download the above files. Then open one of the schematics and run the Python script. The first schematic is for SIMetrix while the second uses the SIMPLIS simulator.

In the previous example the script opened the schematic file automatically. Here we present an alternative which is to get a schematic that is already open using the currentSchematic() function.

So the opening lines get the schematic then run the simulation:

# Get current schematic
schem = sx.currentSchematic()

# Run simulation
sim = schem.run()

The schematic plots a graph which we now obtain using the currentGraph() function:

# get graph
graph = sx.currentGraph()

Now we get the curves associated with the graph which is a list of GraphObject objects. GraphObjects have a range of properties which can be read to find out information about the object.

# get curves
curves = graph.curves

In our example there is only one curve but the following code allows for there being any number of curves. Each one is examined in turn to find its measurements.

# for each curve obtain the measurement objects
print("\nMeasurements")
for curve in curves() :

    # measurement_objects is the list of measurement objects for curve
    measurement_objects = curve.prop("MeasurementIds").objects

    # Iterate through each measurement
    for v in measurement_objects  :

        # Print curve name followed by measurement label then measurement value
        print(curve.prop("Name").string, v.prop("Label").string, "=", v.prop("RawValues").strings[0])

In the above the “MeasurementIds” property is obtained from each curve. This property actually provides another list of GraphObject objects which is assigned to the measurement_objects variable. Next the measurement_objects variable is iterated to obtain each measurement. Finally, the information is printed out. First the name of the curve followed by the measurement label, then finally the measurement’s value. The “RawValues” property is an array of strings which in this case is of length one. But in a multi-step simulation this would have one element for each step.