Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Logarithmic Scale

by Anonymous Monk
on Jul 13, 2020 at 13:34 UTC ( #11119257=note: print w/replies, xml ) Need Help??


in reply to Re: Logarithmic Scale
in thread Logarithmic Scale

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.

Replies are listed 'Best First'.
Re^3: Logarithmic Scale
by kikuchiyo (Friar) on Jul 13, 2020 at 15:35 UTC

    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

        Ahh, now I understand the purpose of the distorted graph. Still, I think it's a distortion, because the real difference between 10 dB and -40 dB is five orders of magnitude - if you plot that on a polar chart with linear (undone logarithmic) scaling, you get a spike, not a slightly altered, "real-world" shape (and you can forget about everything under 0 dB, not -20).

        But I realize that for your application it is the kind of graph you and your users expect and understand. In that case it might be a good thing to provide an option to display either mode. To produce graphs that look like your PNG example (and like the examples I've found on the internet) you could use an exponential unscaling function with a very small exponent (something between 1.05 and 1.1 seemed to work for me).

        (By the way, one advantage of gnuplot is that it has an interactive mode, which helps to rapidly prototype the kind of chart you want, and find the right parameters, and then you can go and reuse the commands in a script that produces a publication-ready graph from the same data.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11119257]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2020-09-28 07:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (143 votes). Check out past polls.

    Notices?