Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Postprocessing and plot from OpenModelica Compiler CLI in OMEdit

Postprocessing and plot from OpenModelica Compiler CLI in OMEdit

I would like to create a way to make the Discrete Fourier Transform (DFT) of selected simulated signals, and then plot them to see the harmonic spectrum.
This is would be very useful in electric circuits and system analysis, but useful also for vibration analysis in mechanical systems.

This DFT is immediately available in Dymola, and called FFT (as common although partially wrong).
In OMEdit I thought to deal with the issue creating a script.

I have several hurdles to overcome.
One is to plot an array against another instead of time. This can be solved, I think, using the code suggested in permalink #2475 from this forum.

Another issue is to find a way to create a new plot in OMEdit from CLI.
Obviously I launch OMEdit with the command line option  "--OMCLogger=true", so I'm able to read a mat file, and read names and values of stored variables.

But it seems that I cannot use plot() and plotParametric() command from there. Is it true?

if I could execute a plotParametric() in OMEdit from CLI, and I overcome some additional hurdles, I could create a mos script to perform DFT that I could share with anyone interested.

Thanks




Re: Postprocessing and plot from OpenModelica Compiler CLI in OMEdit

OMEdit handles the simulation and result file a bit differently. If you want to use plot API you should use it like this,

Code:

plot(x, fileName="model_res.mat")

Note that it will launch OMPlot and will show the plot there instead of integrated OMEdit plotting.

Adeel.

Re: Postprocessing and plot from OpenModelica Compiler CLI in OMEdit

I think that there are several things here:
1. OpenModelica should support DFT via an API so you can plot these kind of things as many people are asking for it.
2. OMEdit should support some sort of scripting for ploting so you can plot using OMC API.

I think we should open 2 Trac tickets about this. ceraolo, can you do that?

Re: Postprocessing and plot from OpenModelica Compiler CLI in OMEdit

adrpo wrote:

2. OMEdit should support some sort of scripting for ploting so you can plot using OMC API.

We can do this the same way we do for OMNotebook. Set plot to silent via `setPlotSlilent(true)`, plot API then output data, read the output and plot inside OMEdit.
The problem is i need some parsing on OMCLogger to know what command user has sent.

Re: Postprocessing and plot from OpenModelica Compiler CLI in OMEdit

Thank you,
this suggestion makes me a big step forward.
Even though, as adrpo mentions it would be even better to have the opportunity to make plots displayed directly within OMEdit.

Re: Postprocessing and plot from OpenModelica Compiler CLI in OMEdit

Replying to adrpo.

1. OpenModelica should support DFT via an API so you can plot these kind of things as many people are asking for it.

Good knowing this!

2. OMEdit should support some sort of scripting for ploting so you can plot using OMC API.

You mean that adeas' suggestion is imperfect because allows plotting only outside OMEdit?
Yes, plotting in a OMEdit window from script commands would be nice for all kinds of post-processing. One example is DFT; but also in case DFT is implemented via API, other useful postprocessing stuff could be usefully done.

I think we should open 2 Trac tickets about this. ceraolo, can you do that?

Yes I can do, and I will probably today in the evening.

I intend the second one as something that asks for a way to make, using CLI commands or scripts,  plots to be shown in the Plotting perspective of OMEdit.
In fact adeas has shown a way to see plots, but in a separate window.
Am I correctly interpreting the meaning of your 2nd suggestion?


Re: Postprocessing and plot from OpenModelica Compiler CLI in OMEdit

Starting from r25689 it is now possible to call plot and see the plots inside OMEdit.

Adeel.

There are 0 guests and 0 other users also viewing this topic
You are here: