simetrix.Grid¶
- class simetrix.Grid¶
Bases:
GraphObjectRepresents a grid within a
Graph.Methods
plotData(ydata, xdata, ylabel, xlabel[, ...])Creates curve in the grid from the given X & Y data.
plotVector(vector[, ylabel, xlabel, yunit, ...])Creates curve in the grid from the given vector.
prop(propertyName)Returns the property with the name given.
Returns the set of properties for this object.
setPropertyValue(propertyName, propertyValue)Sets a property value for an object.
Attributes
Returns the ID of the object.
Returns the object type.
Returns True if the GraphObject is valid.
- property id: int¶
Returns the ID of the object. This can be used to pass to a native SIMetrix script function.
- plotData(ydata: ArrayLike, xdata: ArrayLike, ylabel: str, xlabel: str, yphystype: PhysicalType | str = PhysicalType.UNKNOWN, xphystype: PhysicalType | str = PhysicalType.UNKNOWN, yaxisoption: AxisOptions = AxisOptions.LINEAR, xaxisoption: AxisOptions = AxisOptions.LINEAR) PlotReturnData¶
Creates curve in the grid from the given X & Y data.
- Parameters:
ydata (float or complex array) – Y data providing the y-axis values. Data may be a numPy array or Python list of real or complex values. If complex data is provided, the magnitude of the data will be plotted on the graph, but the complex values will be retained within the curve’s data.
xdata (float array) – X data providing x-axis values. Data may be a numPy array or Python list of real values.
ylabel (str) – String defines the label used for the y-axis and the curve itself.
xlabel (str) – String defines the label used for the x-axis.
yunit (PhysicalType | str) – Defines the units used for the y-axis
xunit (PhysicalType | str) – Defines the units used for the x-axis
yoption (AxisOptions) – Defines linear or logarithmic y-axis
xoption (AxisOptions) – Defines linear or logarithmic x-axis
Examples
import simetrix as sx # Create a new empty Graph sheet newGraph = sx.newGraph("Demonstrate grid plotData") # Build complex data to plot ydata = [(-5.943112+0.0283819j),(-5.943057+0.0357305j),(-5.942968+0.0449816j),\ (-5.942828+0.0566276j),(-5.942606+0.0712882j),(-5.942255+0.0897432j),\ (-5.941697+0.1129733j),(-5.940814+0.1422115j),(-5.939415+0.179007j),\ (-5.937198+0.2253031j),(-5.933686+0.2835336j),(-5.928125+0.3567357j),\ (-5.919322+0.4486815j),(-5.905401+0.5640158j),(-5.883411+0.7083817j),\ (-5.848743+0.8884801j),(-5.794255+1.1119593j),(-5.709029+1.3869269j),\ (-5.576729+1.7207099j),(-5.373756+2.1172482j),(-5.067953+2.5722812j),\ (-4.619714+3.0656445j),(-3.988967+3.5514037j),(-3.152072+3.9504157j),\ (-2.128718+4.1556888j),(-1.006911+4.0621393j),(0.0584773+3.6182036j),\ (0.8907083+2.8707831j),(1.3640257+1.966516j),(1.4616953+1.0978072j),\ (1.2792536+0.4193534j)] freq = [10000,12589.254,15848.932,19952.623,\ 25118.864,31622.777,39810.717,50118.723,\ 63095.734,79432.823,100000,125892.54,\ 158489.32,199526.23,251188.64,316227.77,\ 398107.17,501187.23,630957.34,794328.23,\ 1000000,1258925.4,1584893.2,1995262.3,\ 2511886.4,3162277.7,3981071.7,5011872.3,\ 6309573.4,7943282.3,10000000] # Plot on log axis plotData = newGraph.grid.plotData(ydata, freq, \ "VOUT_AC", "Freq",\ sx.PhysicalType.VOLTS, sx.PhysicalType.HERTZ, \ sx.AxisOptions.LOGARITHMIC, sx.AxisOptions.LOGARITHMIC)
- plotVector(vector: GroupVector, ylabel: str = None, xlabel: str = None, yunit: str = None, xunit: str = None, yaxisoption: AxisOptions = AxisOptions.LINEAR, xaxisoption: AxisOptions = AxisOptions.LINEAR) PlotReturnData¶
Creates curve in the grid from the given vector.
- Parameters:
ylabel (str) – String defines the label used for the y-axis and the curve itself. If None or omitted, the vector name will be used.
xlabel (str) – String defines the label used for the x-axis. If None or omitted, the name of the vector’s x-data will be used.
yunit (str) – Defines the units used for the y-axis. If None or omitted, the units associated with the vector’s physical type will be used.
xunit (str) – Defines the units used for the x-axis. If None or omitted, the units associated with the physical type of the vector’s x-data will be used.
yoption (AxisOptions) – Defines linear or logarithmic y-axis
xoption (AxisOptions) – Defines linear or logarithmic x-axis
Examples
import simetrix as sx # Script assumes that a vector called VOUT exists in the current group # Create a new empty Graph sheet newGraph = sx.newGraph("Demonstrate plotVector") group = sx.currentGroup() if group.valid : plotData = newGraph.grid.plotVector(group.vectorOfName("VOUT"))
- prop(propertyName: str) GraphProperty¶
Returns the property with the name given. Can also use property().
Some properties have a symbolic value denoted by enclosing the value with ‘%’ characters. The property method will return the resolved value instead of the symbolic value if the name is prefixed with the ‘@’ character. For example:
print(curve.prop('@Label').Value)
The Label property usually has the value %DefaultLabel% which is what would be returned by the method if the ‘@’ character were omitted. The resolved value is the value of the DefaultLabel property.
- properties() list[GraphProperty]¶
Returns the set of properties for this object.
Example
Print the name and data type for all properties belonging to the current graph.
import simetrix as sx graph = sx.currentGraph() props= graph.properties() for p in props : print(p.name, p.type)
- setPropertyValue(propertyName: str, propertyValue: str | float)¶
Sets a property value for an object.
As explained in
GraphPropertyGraphProperty obejcts can have one of five data types. However, writeable properties can only be scalar string or scalar real valued. Hence this method can only accept real or string data for the property value.Example
import simetrix as sx # Get the current graph graph = sx.currentGraph() # Get the first curve available curve = graph.curves()[0] # Change the curve colour to green curve.setPropertyValue('RGBColour', 32768)
- property type: GraphObjectType¶
Returns the object type.
- property valid: bool¶
Returns True if the GraphObject is valid.
A GraphObject obtained from the GraphProperty of another GraphObject will not necessarily be valid. The following example obtains the MainCursor property of the current graph. This will be an invalid object if cursors are not enabled.
import simetrix as sx graph = sx.currentGraph() mainCursor = graph.prop('MainCursor') if mainCursor.value.valid : print("Cursors are enabled") else : print("Cursors are not enabled")