Hi Mary,
I am apologize for my previous message, because when I take on count the suggestions of Jamie and your one, every think are working perfectly on a map using ncl command "gsn_csm_map_ce".
After, I try the same thing with "gsn_csm_contour_map", to add box on topography but the box disappears on my map.
There is something to modify?
Here the script I am using.
;*****************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;*****************************************************
begin
f1 = addfile("xtopo.nc","r")
fsd0=f1->HT
fsd = fsd0(0, :, :)
lat = fsd&lat
lon = fsd&lon
nlat = dimsizes(lat)
nlon = dimsizes(lon)
;print(nlon)
;**************************************
; Create plot
;***************************************
wks = gsn_open_wks("ps", "topo_box")
gsn_define_colormap (wks,"gsltod") ; choose colormap
setvalues wks
"wkColorMap" : "gsltod"
"wkForegroundColor" : (/0.,0.,0./)
"wkBackgroundColor" : (/1.,1.,1./)
end setvalues
res = True ; plot mods desired
res_at_cnFillOn = True ; turn on color
res_at_cnLinesOn = False ; no contour lines
res_at_gsnSpreadColors = True ; use full color map
res_at_cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
res_at_cnMinLevelValF = 200 ; set min contour level
res_at_cnMaxLevelValF = 4000 ; set max contour level
res_at_cnLevelSpacingF = 200 ; contour spacing
res_at_mpPerimOn = True
res_at_mpFillOn = False ; turn off map fill
;res_at_mpOutlineBoundarySets = "GeophysicalAndUSStates"
res_at_mpOutlineBoundarySets = "National" ; turn on country boundaries
res_at_mpGeophysicalLineColor = "Black" ; color of cont. outlines
res_at_mpGeophysicalLineThicknessF = 2 ; thickness of outlines
; res_at_gsLineDashPattern = 1
res_at_gsnSpreadColors = True ; use full color map
res_at_gsnSpreadColorEnd = -3 ; don't use added gray
res_at_lbOrientation ="vertical" ; vertical label bar
res_at_mpDataBaseVersion = "Ncarg4_1" ; use finer database
res_at_pmTickMarkDisplayMode = "Always" ; turn on tickmarks
res_at_gsnAddCyclic = False ; regional data, don't add pt
res_at_mpProjection = "mercator" ; projection
res_at_mpLimitMode = "Corners" ; method to zoom
res_at_mpLeftCornerLatF = min(lat)
res_at_mpLeftCornerLonF = min(lon)
res_at_mpRightCornerLatF = max(lat)
res_at_mpRightCornerLonF = max(lon)
res_at_tfDoNDCOverlay = True ; do not transform data
; res_at_cnLineLabelsOn = True
res_at_cnLineLabelBackgroundColor = "white" ; white bckgrnd around label
res_at_cnLineLabelDensityF = 1.0
res_at_cnLevelSpacingF = 400
res_at_cnFillOn = True
res_at_cnLinesOn = False
res_at_cnLineLabelsOn = False
res_at_gsnSpreadColors = True
res_at_mpGridAndLimbOn = False ; lat/lon lines on
res_at_mpGridSpacingF = 0.5 ; lat/lon lines every 10 deg
res_at_mpGridLineDashPattern = 2.5 ; lat/lon lines as dashed
;res_at_pmTickMarkDisplayMode = "Always" ; turn on tickmark
res_at_tiMainString = " "
plot = gsn_csm_contour_map(wks, fsd, res) ; create plot
; add boxes for regional averages
; add the box
;************************************************
resb = True ; polyline mods desired
resb_at_gsLineColor = "black" ; color of lines
resb_at_gsLineThicknessF = 2.5 ; thickness of lines
rega=new(4,graphic) ; new graphic variable -- one for each line in rectangle
ilat = (/12., 5., 5., 12., 12./) ;define lat points for each line
ilon = (/10., 10., 15., 15., 10./) ; define lon points for each line
;draw each line on plot
do i = 0,3
rega(i)=gsn_add_polyline(wks,plot,ilon(i:i+1), ilat(i:i+1),resb) ;draw line from start point to end point
end do
;;;;;;;;;;;;;;;;;;
end
God day
Mary Haley <haley_at_ucar.edu> a écrit :
Hi Louis,
The method that Jamie showed you is correct. When you use
gsn_add_polyline, it actually attaches the lines to your plot, so in
order for the boxes to show up, you need to draw the plot:
begin
...
res = True ; mods desdired
res_at_gsnDraw = False ; Turn off draw of plot
; until we add boxes.
res_at_mpOceanFillColor = 5 ; array index in color map
res_at_mpLandFillColor = 164 ; for land, ocean, and inland h20
res_at_mpInlandWaterFillColor = 54
plot = gsn_csm_map_ce(wks,res) ; draw global map
draw(plot)
frame(wks)
end
Also, you need to make sure that the "xptsa" points are the longitude
values, and the "yptsa" are the latitude values.
If you are doing all of this and still having a problem, then feel
free to email me your code and I'll take a look.
--Mary
On Thu, 13 Dec 2007, louis Vonder wrote:
> Thanks,
> Despite the suggestion of James I am not able to add boxes on map.
>
> Thank yoou for your time
>
> Jamie Scott a écrit : Add this after your call to gsn_csm_map_ce:
>
> ; add boxes for regional averages
> ; add the box
> ;************************************************
> resb = True ; polyline mods desired
> resb_at_gsLineColor = "black" ; color of lines
> resb_at_gsLineThicknessF = 2.5 ; thickness of lines
>
>
>
> rega=new(4,graphic) ; new graphic variable -- one for each line in rectangle
>
>
> yptsa = (/25., -25., -25., 25.,25./) ;define lat points for each line
> xptsa = (/310., 310., 360., 360.,310./) ; define lon points for each line
>
>
> ;draw each line on plot
> do i = 0,3
> rega(i)=gsn_add_polyline(wks,plot,xptsa(i:i+1),yptsa(i:i+1),resb) ;draw line from start point to end point
>
> end do
> ;;;;;;;;;;;;;;;;;;
>
>
>
> Jamie Scott
> NOAA/ESRL/PSD
> james.d.scott_at_noaa.gov
>
>
> On Dec 12, 2007, at 9:31 AM, ncl-talk-request_at_ucar.edu wrote:
>
> Dear NCL users,
>
>
> I am trying to add rectagle on a map.
>
>
> There is way to modify the following NCL example to perform it?
>
>
> To add for exemple a rectangle bounded by coordinates
>
>
> (-50°, 0°) Longitude and (-25°, 25°) latitude.
>
>
>
>
> ;================================================;
> ; maponly_3.ncl
> ;================================================;
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> ; ================================================;
> begin
>
>
> wks = gsn_open_wks("ps","maponly") ; open a ps file
> gsn_define_colormap(wks,"wh-bl-gr-ye-re") ; choose a colormap
>
>
> res = True ; mods desdired
> res_at_mpOceanFillColor = 5 ; array index in color map
> res_at_mpLandFillColor = 164 ; for land, ocean, and inland h20
> res_at_mpInlandWaterFillColor = 54
>
>
> plot = gsn_csm_map_ce(wks,res) ; draw global map
>
>
> end
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> ---------------------------------
> Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
---------------------------------
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Dec 14 2007 - 00:49:11 MST
This archive was generated by hypermail 2.2.0 : Mon Dec 17 2007 - 08:25:02 MST