Waveform class and generic sweeped data

15 views
Skip to first unread message

Brecht

unread,
Jan 22, 2010, 9:51:03 AM1/22/10
to pycircuit
Hello,

I'm trying to load simulation data into a Waveform object. For sweeped
AC analysis data, this is no problem, as the frequency samples are
equal for each sweep. The time samples in sweeped transient analysis
data may be different however (sweeping a capacitor value, for
example). I suspect the Waveform class supports this kind of sweep,
named "Initiating N-dimensional data where the inner dimension has
variable length" in the Waveform docstring. I have created the example
Waveform object from the docstring. I don't understand how to
interpret this data, however. astable() unfortunately doesn't work on
this type of Waveform.

Suppose I want to represent the following:
R1 (Ohm) time (s) vout (V)
50 1 10
50 3 20
70 1 40
70 2 50
70 3 60

How would I put that into a Waveform object?

Kind regards,
Brecht Machiels

Henrik Johansson

unread,
Jan 25, 2010, 3:34:51 AM1/25/10
to pyci...@googlegroups.com, Brecht

Hi Brecht,

You are right, the docstring is not very clear.

The idea is that you give the x and y arrays as "ragged" numpy arrays which are

entered as arrays of arrays where all arrays are of type "object. Very awkward to type.

Your example goes like this:

>>> x1=array([array([50,50]),array([70,70,70])],dtype=object)

>>> x2=array([array([1,3]),array([1,2,3])],dtype=object)

>>> y=array([array([10,20]),array([40,50,60])],dtype=object)

>>> w=Waveform([x1,x2], y, xlabels=('R1', time'), xunits=('Ohm','s'), ylabel='vout', yunit='V')

>>> print w.astable

===== ====== ======

R1 time vout

Ohm s V

===== ====== ======

50 1 10

50 3 20

70 1 40

70 2 50

70 3 60

===== ====== ======

The support for irregular grid waveforms like this is not very developed at the moment and I have just added support for this in the "astable" function.

So you need the latest git version to run the example.

I'm thinking about other ways to enter waveforms like this like just entering flat waveforms for x and y values (Example. Waveform([[50,50,70,70,70], [1,3,1,2,3]], [10,20,40,50,60]).

The downside is that it would hide the structure of the sweep and interpolations would be much more difficult.

Best regards,

Henrik

Brecht

unread,
Jan 26, 2010, 8:03:06 AM1/26/10
to pycircuit

On Jan 25, 9:34 am, Henrik Johansson <hen...@johome.net> wrote:
> The support for irregular grid waveforms like this is not very developed at the moment and I have just added support for this in the "astable" function.
> So you need the latest git version to run the example.

Thanks! I've now managed to transform my data in the required format.

> I'm thinking about other ways to enter waveforms like this like just entering flat waveforms for x and y values (Example. Waveform([[50,50,70,70,70], [1,3,1,2,3]], [10,20,40,50,60]).
> The downside is that it would hide the structure of the sweep and interpolations would be much more difficult.

It seems a bit of a waste of memory to store the value of R1 for each
sample. I am afraid that for large datasets, this will needlessly make
the waveform object twice the size of the actual information stored
inside.

Wouldn't it be possible to store sweep variables such as R1 only once?
A Waveform would then be a collection of x-y datasets, each associated
with a number of values for the sweep parameters. I'm not sure how
that would affect interpolations though.

Kind regards,
Brecht

Reply all
Reply to author
Forward
0 new messages