[pyngl-talk] Function similar to NCL's nggcog?
Mary Haley
haley at ucar.edu
Fri Oct 19 10:32:19 MDT 2018
Hi Alyssa,
Normally I would suggest googling something like "great circle numpy" and
you are likely to find a number of functions that calculate the same thing
as NCL's nggcog.
However, as an exercise, since I knew the nggcog Fortran routine was pretty
short, I decided to see what it took to convert it to python. This routine
calls an internal Fortran routine called ngritd, so I had to convert that
too.
I didn't try to do this the "pythonic" way, using array arithmetic instead
of looping, because doing a line-by-line conversion was simply faster.
See the attached nggcog.py which defines both nggcog and ngritd and has
some driver code that generates and plot a great circle. I attached the NCL
version for comparison. You should be able to run these as-is:
python nggcog.py
ncl nggcog.ncl
I'm in the process of learning how to create Python versions of NCL
scripts, so this was a good exercise. :-)
Note: the Python version of the nggcog routine is not tested, other than
this plotting program. You might want to look at the Fortran code yourself
to compare it with the Python code.
The Fortran routines can be found on github:
https://github.com/NCAR/ncl
and then navigate down to this path:
ncarg2d/src/libncarg/ngmisc
and the nggcog.f and ngridt.f Fortran code can be found on that page:
https://github.com/NCAR/ncl/tree/master/ncarg2d/src/libncarg/ngmisc
--Mary
On Wed, Oct 17, 2018 at 7:29 PM, Alyssa Stansfield via pyngl-talk <
pyngl-talk at ucar.edu> wrote:
> Hello,
>
> I am trying to plot a circle with a radius of 200 km around a certain
> latitude and longitude on a map. I know that NCL has the nggcog command,
> but does pyngl have anything similar? Or do you know of a workaround using
> pyngl commands?
>
> Thank you,
> Alyssa
>
> _______________________________________________
> pyngl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20181019/72380b16/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nggcog_python.000002.png
Type: image/png
Size: 95247 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20181019/72380b16/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nggcog_python.000001.png
Type: image/png
Size: 66572 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20181019/72380b16/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nggcog_ncl.000002.png
Type: image/png
Size: 93196 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20181019/72380b16/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nggcog_ncl.000001.png
Type: image/png
Size: 66977 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20181019/72380b16/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nggcog.ncl
Type: application/octet-stream
Size: 1015 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20181019/72380b16/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nggcog.py
Type: text/x-python-script
Size: 2784 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20181019/72380b16/attachment-0001.bin>
More information about the pyngl-talk
mailing list