[gradsusr] Feedback on Pole Lat/Lon Labelling Script.
Muhammad Yunus Ahmad Mazuki
ukm.yunus at gmail.com
Mon May 15 03:47:26 EDT 2017
Hi, initially I found a script by Colleen at
http://gradsusr.org/pipermail/gradsusr/2014-September/037452.html . After a
little tweaks I come out with two scripts below. So I would like to ask for
feedback on how to improve the scripts. Currently its two different scripts
for the two different pole projections. I'm planning to merge the two
script together later on.
I also would like to figure out how to change the original degree East to
degree East into degree East to degree West.
With regards to the Latitude labelling, I want to add a spacer/margin
between the plot and the label (like what I did to the Longitude Labelling
part), but this is quite hard. I could add some margin like 'draw string
'xpos+0.1' 'ypos-0.1' 'istart polelab, but this method is not dependant of
the plotting angles. I just would like to add spaces before the numbers but
GrADS don't register the spaces before that.
I have also not added the case where the plot is 0 to 360 degree East.
I would like to thank you in advance for any feedback.
* * * * * * * * * * * * * * * * * * * * * * * * * *
* Draws grid lines at specified intervals for South Pole Projection
* call is
* polargrid lonmin lonmax lonincr latmin latmax latincr
function polargrid(args)
* parse arguments
lonmin = subwrd(args,1)
lonmax = subwrd(args,2)
lonincr = subwrd(args,3)
latmin = subwrd(args,4)
latmax = subwrd(args,5)
latincr = subwrd(args,6)
'q gxinfo'
temp1 =sublin(result,6)
poleproj=subwrd(temp1,3)
*Determining how to label deg north or degree south.
if (poleproj<3|poleproj>4)
say 'This script is for plotting lat/lon label for pole projection only'
return
else
if (poleproj=4)
polelab='`3.`0S'
else
polelab='`3.`0N'
endif
endif
*
midlat = (latmax+latmin)/2
quarterlat = (latmax+midlat)/2
'q dims'
xline = sublin(result,2)
yline = sublin(result,3)
lonstart = subwrd(xline,6)
lonend = subwrd(xline,8)
*midlon = (lonstart+lonend)/2
midlon = (lonmax+lonmin)/2
*For drawing the LATITUDE lablelling
*Currently the labelling is perpendicular to the plot side.
*I think the ratio for the added margin needs to be based on the angle.
*The latitude labelling is quite hard to make it parallel to plot without
cutting into the longitude labelling.
*You can also use while (istart <=latmax-1) to skip the last latitude
labelling for reasons of its out of plotting area (especially if you use
panels) and/or it overlap with LONGITUDE labelling.
istart=latmin
angle=midlon-lonmax
while (istart <=latmax)
'q w2xy 'lonmax' ' istart
xpos=subwrd(result,3)
ypos=subwrd(result,6)
'set string 1 l 1 'angle
'set strsiz 0.12'
'draw string 'xpos' 'ypos' 'istart-istart-istart polelab
istart=istart+latincr
endwhile
*For drawing the LONGITUDE lablelling
*Can be improved to provide the East and West labelling.
istart=lonmin
angle=midlon-lonmin
while (istart <=lonmax)
'q w2xy 'istart' ' latmax+((latmax-latmin)*0.03)
xpos=subwrd(result,3)
ypos=subwrd(result,6)
'set strsiz 0.12'
'set string 1 bc 1 'angle
'draw string 'xpos' 'ypos' 'istart'`3.`0'
angle=angle-lonincr
istart=istart+lonincr
endwhile
return
* * * * * * * * * * * * * * * * * * * * * * * * * *
* Draws grid lines at specified intervals for North Pole Projection.
* call is
* polargrid lonmin lonmax lonincr latmin latmax latincr
function polargrid(args)
*{}//No effect, just to preserve highlighting under ATOM.
* parse arguments
lonmin = subwrd(args,1)
lonmax = subwrd(args,2)
lonincr = subwrd(args,3)
latmin = subwrd(args,4)
latmax = subwrd(args,5)
latincr = subwrd(args,6)
'q gxinfo'
temp1 =sublin(result,6)
poleproj=subwrd(temp1,3)
*Determining how to label deg north or degree south.
if (poleproj<3|poleproj>4)
say 'This script is for plotting lat/lon label for pole projection only'
return
else
if (poleproj=4)
polelab='`3.`0S'
else
polelab='`3.`0N'
endif
endif
*
midlat = (latmax+latmin)/2
quarterlat = (latmax+midlat)/2
'q dims'
xline = sublin(result,2)
yline = sublin(result,3)
lonstart = subwrd(xline,6)
lonend = subwrd(xline,8)
*midlon = (lonstart+lonend)/2
midlon = (lonmax+lonmin)/2
*For drawing the LATITUDE lablelling
*Currently the labelling is perpendicular to the plot side.
*I think the ratio for the added margin needs to be based on the angle.
*The latitude labelling is quite hard to make it parallel to plot without
cutting into the longitude labelling.
*You can also use while (istart <=latmax-1) to skip the last latitude
labelling for reasons of its out of plotting area (especially if you use
panels) and/or it overlap with LONGITUDE labelling.
istart=latmin
angle=midlon-lonmin
while (istart <=latmax)
'q w2xy 'lonmax' ' istart
xpos=subwrd(result,3)
ypos=subwrd(result,6)
'set string 1 l 1 'angle
'set strsiz 0.12'
'draw string 'xpos' 'ypos' 'istart polelab
istart=istart+latincr
endwhile
*For drawing the LONGITUDE lablelling
*Can be improved to provide the East and West labelling.
istart=lonmin
angle=midlon-lonmax
while (istart <=lonmax)
'q w2xy 'istart' ' latmin-((latmax-latmin)*0.03)
xpos=subwrd(result,3)
ypos=subwrd(result,6)
'set strsiz 0.12'
'set string 1 tc 1 'angle
'draw string 'xpos' 'ypos' 'istart'`3.`0'
angle=angle+lonincr
istart=istart+lonincr
endwhile
return
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20170515/0e909431/attachment.html
More information about the gradsusr
mailing list