http://qs321.pair.com?node_id=11119252


in reply to Logarithmic Scale

You could do it with gnuplot: it can do polar plots with logarithmic axes, or even axes with arbitrary scaling functions in newer versions. You'd also have complete control over the presentation (line widths, colors etc.) and the output format.

That said, I can't make sense of your data file: what data is in the columns, and where are the angles? Also, I can't download your perl script, it shows a server error instead.

Replies are listed 'Best First'.
Re^2: Logarithmic Scale
by Anonymous Monk on Jul 13, 2020 at 13:34 UTC

    Thank you, I had considered gnuplot, but was sort of wanting to do it myself. I'd like something self-contained that I can call directly from LabVIEW. I'll burn an *.exe via pp once it's all tidy. The LabVIEW, along with any Perl will be distributed for free, source code and all, just as always I do.

    As for the *.n2p file, the first line is header. After then, because it's for an antenna modeled in "Free Space" (versus over ground), the tally of rows is 722. Those comprise two sets of 361. Each set of 361 represents a closed circle. The top closed circle is Azimuth, the lower one Elevation. Thus two cross-sections of the antenna's radiation lobe. And with each row of each set representing 1 degree of the circle, either azimuth or elevation. That for the two sets of rows.

    My Perl code, as presently constituted, deals only with the leftmost column, and just its first 361 rows.

    Describing all:

    Column 0 on left is net gain versus an isotropic radiator, comprising the sum of the other two columns.
    Column 1 in the middle is gain in the vertical plane (low because this is a horizontal antenna).
    Column 2 on the right is gain in the horizontal gain.

    Thus, data for two plots of antenna directionality at one given frequency. Not really high gain, because this is a very, very broadband antenna: a log-periodic sawtooth array.

    That *.n2p file, therefor, is the source data for both azimuthal plots: my SVG, and Net2Go's own screenshot. Only have the azimuthal working, so far. Have paused in hopes of properly spacing the concentric rings by some factor closer to logarithmic than linear.

      Thanks, that makes the layout of the data clear.

      Now that I've thought about it, I've never seen a polar plot distorted in a way you describe. The polar axis is in decibels, so it already uses logarithmic scale - by "making the outer donuts larger", as you say, you actually want to undo the logarithmic scaling, at least partially. In any case, I see this as a cosmetic alteration that may be harmful, because it changes the shape of the curve you want to show, without good reason.

      With that in mind, here is a gnuplot script that produces a graph close to what you want:

      set polar set rr [-40:10] set rtics 10 unset border unset xtics unset ytics set grid lt 1 lc rgb "blue" f(x) = (x+50)**2 g(x) = sqrt(x)-50 set nonlinear r via f(r) inverse g(r) plot '/tmp/foo.n2p' u ($0>0&&$0<=361 ? $0*pi/180. : 1/0):1 w l lw 2 n +otit

      The scaling function (that determines the spacing of the grid circles) is a square function (f(x) in the script) as opposed to exponential. You could use this function in your script if you prefer to stay with your pure perl solution.

        Thank you! Very helpful. Since you mentioned, I did an image search in Bing for "antenna polar plot" and find a mix of grid circles, some evenly spaced to maintain the dBi scaling, others undoing it to reveal the real-world lobe profile.

        And in the case of the Nec2Go program's default, it was showing real-world … which I was trying to emulate.

        So now I'm thinking I should make it an option to scale the grid either way. Which means I'm half done, versus wrong. I still want the other, as it is more intuitive to look at when wanting to overlay the outline onto a great circle map for positioning. Being able to clearly read the values below -20 dBi is of very small interest, yes?

        Respectfully,
        Gan, KY8D

Re^2: Logarithmic Scale
by aplonis (Pilgrim) on Jul 13, 2020 at 13:54 UTC

    Humble apology for the *.pl causing a server error. I have changed the suffix from *.pl to *.txt, so now the server won't try to run it instead.

Re^2: Logarithmic Scale
by perlfan (Vicar) on Jul 14, 2020 at 00:46 UTC
    I have no business getting in the middle of this discussion (thank you), but PDL might provide some useful visualization options, including an interface to gnuplot, PDL::Graphics::Gnuplot.
      A specific PDL thing that might save some lines of code would be to use PDL::Transform, possibly t_lookup.