KJ7LNW / xnec2c

Xnec2c is a high-performance multi-threaded electromagnetic simulation package to model antenna near- and far-field radiation patterns for Linux and UNIX operating systems.
https://www.xnec2c.org/
GNU General Public License v3.0
78 stars 17 forks source link

Have all input values into a unique datafile #5

Closed scaramacai closed 2 years ago

scaramacai commented 2 years ago

When saving any of VSWR, Zreal, Zimag etc, also the other input values are saved in the order: Frequency[MHz] Real{Zin}[Ohm] Imag{Zin}[Ohm] Mag{Zin}[Ohm] Phase{Zin}[deg.] VSWR Mag{S11}[dB] Z0 is also saved.

scaramacai commented 2 years ago

One can use "plot using 1:n ...", where 1 means the first column (Frequency) and n is any of Real(Zin), Imag(Zin) and so on.

KJ7LNW commented 2 years ago

Thanks for the pull request. It has highlighted some other issues in the code that need to be fixed as well. Here are the things that I would like to address if possible:

Are you interested in working on any of these additional items?

KJ7LNW commented 2 years ago

I've staged these changes:

These are outstanding:

KJ7LNW commented 2 years ago

It might be nice to include a gnuplot template with the xnec2c package so the graphs look beautiful and users can use the .gplot template to load their exported data if they wish; xnec2c could even launch the gnuplot window using that template.

Would you like to contribute a beautified gnuplot template that takes your `plot "file.gplot" using 1:2, ..." that does the following?

scaramacai commented 2 years ago

I know some tricks to do cartesian plots with gnuplot. You can, for example, have each quantity plotted in a different window in an almost automatic way, by using the recursive capabilities of gnuplot. Another possibility could be to plot together R(Zin) and Imag(Zin), Mag(Zin) and Arg(Zin) and maybe VSWR and |S11|. I'll try to provide you with some templates. Some time ago I implemented launching a gnuplot session from gtk. I should have still the code. I'll look for. With respect this pull request I experimented also another format, made by a simple heading line, without comments, and where all columns are separated by tabs. This work for me with gnuplot 5.2, but have no idea if there could be issues with older versions. The advantage would be that the file can be read as a CSV file by ParaView (I'm using version 5.7). Note that using commas to separate fields can be do also for gnuplot, but you must explicitly declare the separator. As for ParaView, I managed to export the 3D radiation patter in vtk format. I will open another issue for that. As for your request to work on 2D polar plot, may be I can help. I have limited time but I'll try to do my best.

KJ7LNW commented 2 years ago

Tab separated might work for gnuplot. Also there is a "set delimiter" command for gnuplot.

ewheelerinc commented 2 years ago

@scaramacai:

I just refactored the measurements code so plots can be generalized. This will facilitate both gnuplot output and s1p/s2p output in the future as well.

Using the measurements code is pretty easy, especially if you are just dumping all measurements to a file. See how optimize.c generates the CSV. You should be able to generate a .gnuplot easily using this example:

https://github.com/KJ7LNW/xnec2c/blob/master/src/optimize.c#L61

I'm not sure if you will need it, but see meas_format() if you need specific measurement values.

-Eric

KJ7LNW commented 2 years ago

GnuPlot columns from this PR were added in v4.4.7, so closing the PR.