[ncl-talk] Trying to draw circles with different radius in Km around a station

Dennis Shea shea at ucar.edu
Thu Feb 8 20:53:46 MST 2018


NCL has had several requests for 'circle drawing' over a map'. Often, this
would be used in combination with 'gc_inout'.

         https://www.ncl.ucar.edu/Document/Functions/Built-in/gc_inout.shtml

Example:
         http://www.ncl.ucar.edu/Applications/unique.shtml
         See: Katrina_circle.ncl

---
Also, for tracking a moving storm: multiple times & center locations.
------------------------------------------------------------------------------------------------

Attached is a beta version of a function , tentatively named:
circle_around_geolocation

There is no documentation ... yet. However, the function has internal
documentation.

Hopefully, this will be distributed with 6.5 0

---------------------------------------------------------------------------------------------------


On Thu, Feb 8, 2018 at 1:55 PM, Alan Brammer <abrammer at albany.edu> wrote:

> Flip the lat and lon arguments in gsn_add_polyline function.   Almost all
> the gsn_add functions take longitude before latitude.
>
> gsn_add_polyline(wks, plot(ii),  Rlon(cc,:), Rlat(cc,:),  plres)
>
> On Thu, Feb 8, 2018 at 3:41 PM, Soumik Basu <sbasu at alaska.edu> wrote:
>
>> Hi,
>>
>> I got the first part working but the circles are not showing up in the
>> plot. I used "gsn_add_polyline" to draw the circle.
>>
>> Is it wrong to use gsn_add_polyline for drawing the circle?
>>
>> Here is the plotting part of the code.
>>
>> ; *********************************
>> ; Draw circle
>> ;**********************************
>>
>> ;---One station
>>
>>    slat     = 70.192               ; station lat
>>    slon     = -148.477             ; station lon
>>    srad_km  = (/ 50, 100, 150, 200, 250/)*1.0  ; station radii (km)
>>    km2deg   = 1/110.57             ; conversion factor: deg ==> km
>>                                    ; one degree is approximately 110.57
>> km.
>>    srad_dg  = srad_km*km2deg       ; km ==> deg; nggcog requires degrees
>>
>>    Nrad = dimsizes(srad_dg)        ; # of radii
>>    Npts = 360                      ; # of points at each radii (arbitrary)
>>
>>    Rlat = new((/Nrad, Npts/), "float")    ; lat at each radius
>>    Rlon = new((/Nrad, Npts/), "float")
>>
>>    do nr=0,Nrad-1
>>       print("nr="+nr+" srad_km="+srad_km(nr)+";   srad_dg="+srad_dg(nr))
>>       print("")
>>
>>       nggcog(slat, slon, srad_dg(nr), Rlat(nr,:), Rlon(nr,:))
>>
>>       print(Rlat(nr,:)+"   "+ Rlon(nr,:))
>>       print("========")
>>    end do
>>
>> ;*************************************************
>> ; Plot
>> ;*************************************************
>>   res                              = True
>>
>>   res at gsnSpreadColors              = True
>>   res at gsnDraw                      = False                          ;
>> don't draw
>>   res at gsnFrame                     = False
>> ;  res at gsnPolar                     = "NH"
>>
>>   res at cnFillOn                     = True
>>   res at cnLinesOn                    = False
>>   res at cnLevelSelectionMode         = "ManualLevels"
>>   res at cnMinLevelValF               = 0
>>   res at cnMaxLevelValF               = 30
>>   res at cnLevelSpacingF              = 0.25
>>   res at cnLineLabelsOn               = False
>>
>>   res at lbLabelStride                = 0.1
>>   res at lbOrientation                = "horizontal"       ;vertical label
>> bar
>>   res at lbLabelBarOn                 = False
>>
>>   res at tmLabelAutoStride            = True
>>   res at tmXTOn                       = False
>>   res at tmYROn                       = False
>>
>>   res at mpProjection                 = "CylindricalEquidistant" ; choose
>> map projection
>>   res at mpLimitMode                  = "LatLon"
>>   res at mpMinLatF                    = 60.
>>   res at mpMaxLatF                    = 80.
>>   res at mpMinLonF                    = 190.
>>   res at mpMaxLonF                    = 230.
>>   res at mpCenterLonF                 = 210
>>   res at mpGeophysicalLineThicknessF  = 1.5
>>
>>   colors  = (/"gray0","gray2","gray10","gray40","gray50"/)
>>
>> ;*****************************************************
>> ;               Plot
>> ;*****************************************************
>>
>>   wks = gsn_open_wks("x11","extreme_wind_days_spatial")
>>
>>   plot   = new(12,graphic)
>> ;  plot_c = new(12,graphic)
>>
>>   gsn_define_colormap(wks,"precip3_16lev")
>>
>>   do ii = 0,nmon-1
>>
>>   plot(ii)   = gsn_csm_contour_map(wks,wind_ext_count_1(ii,:,:),res)
>>
>>   do cc = 0,Nrad-1
>>
>>   plres = True
>>
>>   mks = unique_string("mks")
>>
>>   plres at gsLineColor = colors(cc)
>>
>>   plot@$mks$ = gsn_add_polyline(wks, plot(ii), Rlat(cc,:), Rlon(cc,:),
>> plres)
>>
>>   end do
>>
>>   end do
>>
>>   resPanel                          = True
>>   resPanel at gsnFrame         = False
>>   resPanel at gsnSpreadColors             = True
>>   resPanel at gsnPanelLabelBar         = True                       ; add
>> color bar
>>   resPanel at gsnMaximize                                      = True
>>
>>
>>   resPanel at gsnPanelFigureStrings     = (/"Jan","Feb","Mar","Apr","May
>> ","June","July","Aug","Sep","Oct","Nov","Dec"/)
>>   resPanel at gsnPanelFigureStringsFontHeightF     = 0.012
>>   resPanel at gsnPanelFigureStringsPerimOn     = True
>>   resPanel at gsnPanelFigureStringsBackgroundFillColor = -1
>>
>>   resPanel at amJust                             = "BottomRight"
>>
>>   resPanel at lbLabelBarOn                       = True
>>   resPanel at lbOrientation                      = "Vertical"
>>   resPanel at lbLabelAutoStride            = False
>>   resPanel at lbLabelStride             = 20
>>   resPanel at lbBoxLineThicknessF                = 0.1
>>   resPanel at lbLabelFontThicknessF              = 1.75
>>   resPanel at lbLabelFontHeightF                 = 0.015
>>   resPanel at lbBoxLinesOn                       = False
>>
>>   resPanel at gsnPanelMainString = "Test"
>>
>>   gsn_panel(wks,plot,(/4,3/),resPanel)
>>
>>   frame(wks)
>>
>>   end
>>
>> Thanks,
>> Soumik
>>
>> On Thu, Feb 8, 2018 at 5:45 AM, Dennis Shea <shea at ucar.edu> wrote:
>>
>>> An alternative:
>>>
>>> nggog can be used. Sample code segments follow. For small radii Npts=100
>>> is fine but for large radii and nice circles, Npts=360 might be better.
>>>
>>> ;===========================================================
>>> ==============
>>> ; On a sphere with radius 6371 km, one degree is approximately 110.57 km.
>>> ;---
>>> ; Of course, the earth is an oblate spheroid:
>>> ;      http://www.longitudestore.com/how-big-is-one-gps-degree.html
>>> ;===========================================================
>>> ==============
>>> ; https://www.ncl.ucar.edu/Document/Functions/Built-in/nggcog.shtml
>>> ;===========================================================
>>> ==============
>>>
>>> ;---One station
>>>
>>>    slat     = 0.0                  ; station lat
>>>    slon     = 0.0                  ;         lon
>>>    srad_km  = (/ 50, 100, 150, 5*110.57/)*1.0  ; station radii (km)
>>>    km2deg   = 1/110.57             ; conversion factor: deg ==> km
>>>                                    ; one degree is approximately 110.57
>>> km.
>>>    srad_dg  = srad_km*km2deg       ; km ==> deg; nggcog requires degrees
>>>
>>>    Nrad = dimsizes(srad_dg)        ; # of radii
>>>    Npts = 100                      ; # of points at each radii
>>> (arbitrary)
>>>
>>>    Rlat = new((/Nrad, Npts/), "float")    ; lat at each radius
>>>    Rlon = new((/Nrad, Npts/), "float")
>>>
>>>    do nr=0,Nrad-1
>>>       print("nr="+nr+" srad_km="+srad_km(nr)+";   srad_dg="+srad_dg(nr))
>>>       print("")
>>>
>>>       nggcog(slat, slon, srad_dg(nr), Rlat(nr,:), Rlon(nr,:))
>>>
>>>       print(Rlat(nr,:)+"   "+ Rlon(nr,:))
>>>       print("========")
>>>    end do
>>>
>>> +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>> ;---Multiple stations
>>>
>>>    slat     = (/ 0.0, 50.0     /)  ; station lat
>>>    slon     = (/ 0.0, 30.0     /)  ;         lon
>>>    srad_km  = (/ 50, 100, 150, 5*110.57/)*1.0  ; station radii (km)
>>>    km2deg   = 1/110.57                ; conversion factor: deg ==> km
>>>                                                     ; one degree is
>>> approximately 110.57 km.
>>>    srad_dg  = srad_km*km2deg   ; km ==> deg; nggcog requires degrees
>>>    Nrad     = dimsizes(srad_dg)    ; # of radii
>>>
>>>    Nsta     = dimsizes(slat)            ; # stations
>>>    Nrad     = dimsizes(srad)          ; # of radii
>>>    Npts     = 100                            ; # of points at each radii
>>> (arbitrary; eg 360)
>>>
>>>    Rlat = new((/Nsta, Nrad, Npts/), "float")    ; lat at each radius
>>>    Rlon = new((/Nsta, Nrad, Npts/), "float")
>>>
>>>    do ns=0,Nsta-1
>>>      do nr=0,Nrad-1
>>>         nggcog(slat(ns), slon(ns), srad(nr), Rlat(ns,nr,:),
>>> Rlon((ns,nr,:))
>>>      end do
>>>    end do
>>>
>>>
>>> On Thu, Feb 8, 2018 at 2:38 AM, Karin Meier-Fleischer <
>>> meier-fleischer at dkrz.de> wrote:
>>>
>>>> Hi Soumik,
>>>>
>>>> you can use polymarkers to plot the circles around lat/lon locations.
>>>> Have a look at example newcolor_4.ncl at http://ncl.ucar.edu/Applicatio
>>>> ns/Scripts/newcolor_4.ncl
>>>>
>>>> I've attached an example script using random data for marker size and
>>>> lat/lon locations overlayed on filled contour map.
>>>>
>>>> Hope this helps.
>>>>
>>>> -Karin
>>>>
>>>> Am 08.02.18 um 00:55 schrieb Soumik Basu:
>>>>
>>>> Hello NCL-users,
>>>>
>>>> I am trying to draw circles around a station with different radius. For
>>>> example 50 Km, 100 Km, 150 Km etc.
>>>>
>>>> So, I am wondering if there is any way to do it in NCL.
>>>>
>>>> I looked at the "nggcog" function but from the description what I
>>>> understand is that it can draw circles along a great circle only not
>>>> according to a given distance.
>>>>
>>>> Thank you for any help.
>>>>
>>>> Thanks,
>>>> Soumik
>>>>
>>>> --
>>>> --
>>>> “We’ve all got both light and dark inside us. What matters is the part
>>>> we choose to act on. That’s who we really are.” – J.K. Rowling
>>>>
>>>> ************************************************************
>>>> **************************************
>>>> Dr. Soumik Basu
>>>> Post Doctoral Research Faculty
>>>> International Arctic Research Center, UAF, Fairbanks, AK, USA
>>>> PhD in Atmospheric Sciences
>>>> M.Sc. in Atmospheric Sciences
>>>> Email: suvro05 at gmail.com
>>>> website: http://soumikbasu.weebly.com/
>>>>
>>>> ************************************************************
>>>> ***************************************
>>>>
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing listncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> ncl-talk mailing list
>>>> ncl-talk at ucar.edu
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>>
>> --
>> --
>> “We’ve all got both light and dark inside us. What matters is the part we
>> choose to act on. That’s who we really are.” – J.K. Rowling
>>
>> ************************************************************
>> **************************************
>> Dr. Soumik Basu
>> Post Doctoral Research Faculty
>> International Arctic Research Center, UAF, Fairbanks, AK, USA
>> PhD in Atmospheric Sciences
>> M.Sc. in Atmospheric Sciences
>> Email: suvro05 at gmail.com
>> website: http://soumikbasu.weebly.com/
>>
>> ************************************************************
>> ***************************************
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180208/41aa666d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: circle_around_geolocation.ncl
Type: application/octet-stream
Size: 3620 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180208/41aa666d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tst_circle.ncl
Type: application/octet-stream
Size: 3450 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180208/41aa666d/attachment-0001.obj>


More information about the ncl-talk mailing list