Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to retrieve .measure results #346

Open
infinitymdm opened this issue Jun 19, 2023 · 1 comment
Open

How to retrieve .measure results #346

infinitymdm opened this issue Jun 19, 2023 · 1 comment

Comments

@infinitymdm
Copy link

infinitymdm commented Jun 19, 2023

The main problem I'm having is that I just don't know where to find the results of .measure calls after running a simulation using PySpice. I get pretty plots that show I'm reaching what should be my measurement triggers, but I don't know where to find the data captured by the .measure call.

Environment (OS, Python version, PySpice version, simulator)

  • OS: Ubuntu 22.04
  • Python: 3.10.6
  • Pyspice: git master with a few tiny tweaks (see note below)
  • ngspice version 36

Note: I am using a slightly tweaked version of Pyspice. However, my changes are very small and shouldn't affect the ability to get results from .measure calls. You can compare differences here: https://github.com/PySpice-org/PySpice/compare/master...infinitymdm:PySpice:master?expand=1

Expected Behaviour

Results from simulator.measure() will be returned from the measure() call, or be accessible via __getitem__() in the Waveform object after running the appropriate simulation (e.g. for .meas tran my_var_name [...], results should be accessible via analysis['my_var_name']).

Actual Behaviour

I can't find the results from .measure() calls anywhere. It's possible I'm just misunderstanding how this is meant to be used, but I also can't seem to find much documentation on this feature. Poring through the source code seems to indicate to me that simulator.analyses should have an object containing the .measure results, but I can't seem to find anything there either.

Steps to reproduce the behaviour

Run make after setting up CharLib at commit f4bd88d8. See characterizer/char_comb.py for relevant code for setting up and running the spice simulation.

@infinitymdm
Copy link
Author

I've spent some time digging into this today. It seems to me that the Analysis class should have a member dedicated to storing results of .meas lines in spice simulations. But since the ngspice FFI doesn't seem to surface .meas results except through ngspice_Command run calls, the measurement results simply get dropped. Since the API doesn't surface them, the object doesn't make space to store them, and I as a user don't have access to the parameters I expect in my simulation.

One solution I can think of (at least when using the ngspice-shared backend, and not running ngspice in the background) is to parse the measurements out of the results returned by NgShared.exec_command('run'). This isn't a pretty solution, but it should work for me for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant