[ncl-talk] Problem with gsn_csm_contour: smoothing + continental outline

Karin Meier-Fleischer meier-fleischer at dkrz.de
Mon Apr 25 06:01:13 MDT 2016


Hi Frank,

The overlayed grid is not smoothed. You can see the raster when zooming in.

For the second issue it was a little bit tricky to get the result you 
want. The fact that the geophysical outlines are not drawn is the result 
of setting cnres2 at cnFillDrawOrder = "PostDraw" which let us see nothing 
of the underlying map. If you want to see the map outlines on the 
overlayed plot2 without the grid lines as in your given PNG output plot, 
there is a way to attach a simple map with the outlines to the resulting 
map.

...

;-- create a simple map with geophysical outlines only
mpres at mpGridAndLimbOn           =  False
mpres at mpFillOn                  =  False
mpres at mpOutlineOn               =  True
map2 = gsn_csm_map(wks,mpres)

...

;-- overlay plot2 on map
overlay(map,plot2)

;-- attach map2 to map to draw the geophysical outlines ontop of the 
plot2, too.
anres =  True
anid  =  gsn_add_annotation(map,map2,anres)

;--draw the frame
draw(map)
frame(wks)
...

See attached script.

Bye,
Karin


Am 25.04.16 um 11:19 schrieb Kreienkamp Frank:
>
> Hello,
>
> i am using the attached ncl-script. Based on my data I get the 
> attached png-file. In principle it looks good. But there are minor 
> properties I would like to change:
>
> -The overlayed grid should not be smoothed, I would like to see a raster
>
> -Above the overlayed grid, I would like to see the continental outline
>
> What do I have to change / add to get the topics changed.
>
> Thanks in advance
>
> Frank
>
>
>
> _______________________________________________
> 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/20160425/9a8143d2/attachment-0001.html 
-------------- next part --------------
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin

f1 = addfile("/kp/kp05/fkreienk/data/CMIP5/MPI-ESM-LR/orog_fx_MPI-ESM-LR_rcp26_r0i0p0.nc","r") 
var1 = f1->orog(:,:) 

mask1 = addfile("/kp/kp05/fkreienk/data/CMIP5/MPI-ESM-LR/sftlf_fx_MPI-ESM-LR_rcp26_r0i0p0.nc","r") 
lsm1 = mask1->sftlf(:,:) 
lsm1 = where(lsm1.gt.0.5,-9999,lsm1) 
land_only1 = mask(var1,lsm1,-9999)  

lat = f1->lat 
lon = f1->lon 

land_only1!0   = "lat"
land_only1!1   = "lon"
land_only1&lat = lat
land_only1&lon = lon

f2          = addfile("/kp/kp02/CORDEX/Original/orog/orog_EUR-11_ECMWF-ERAINT_evaluation_r0i0p0_CLMcom-CCLM4-8-17_v1_fx.nc","r")
var2        = f2->orog(:,:)

mask2       = addfile("/kp/kp02/CORDEX/Original/orog/sftlf_EUR-11_ECMWF-ERAINT_evaluation_r0i0p0_CLMcom-CCLM4-8-17_v1_fx.nc","r")
lsm2        = mask2->sftlf(:,:)
lsm2        = where(lsm2.gt.0.5,-9999,lsm2)
land_only2  = var2
land_only2  = mask(var2,lsm2,-9999)

lat2d       = f2->lat
lon2d       = f2->lon

nlat        = dimsizes(lat2d(:,0))
nlon        = dimsizes(lon2d(0,:))

;--open workstation
wks_type                     = "png"
wks_type at wkBackgroundColor   = "grey1"
wks_type at wkForegroundColor   = "white"
wks_type at wkWidth    = 1500
wks_type at wkHeight   = 1500
wks  = gsn_open_wks(wks_type, "Globus_MPI+CCLM_Oro_Europe")

;--global resources 
res                             =  True
res at gsnDraw                     =  False
res at gsnFrame                    =  False

;--map resources   
mpres                           =  res
mpres at gsnMaximize               =  True
mpres at gsnBoxMargin              =  0.0
mpres at mpProjection              = "Orthographic"
mpres at mpLabelsOn                =  False
mpres at mpPerimOn                 =  True
mpres at mpGridLineColor           = "grey40"
mpres at mpGridAndLimbOn           =  True
mpres at mpFillOn                  =  True
mpres at mpFillDrawOrder           = "PreDraw"
mpres at mpOutlineOn               =  True
mpres at mpGeophysicalLineThicknessF  = 2.0
mpres at mpOceanFillColor          = (/ 0.824, 0.961, 1.0 /)
mpres at mpInlandWaterFillColor    = (/ 0.824, 0.961, 1.0 /)
mpres at mpLandFillColor           = (/ 0.7, 0.7, 0.7 /)
mpres at mpCenterLatF              =  50. 
mpres at mpCenterLonF              =  15.

map = gsn_csm_map(wks,mpres)

;-- create a simple map with geophysical outlines only
mpres at mpGridAndLimbOn           =  False
mpres at mpFillOn                  =  False
mpres at mpOutlineOn               =  True
map2 = gsn_csm_map(wks,mpres)

;-- contour resources
cnres = res
cnres at gsnMaximize               =  True
cnres at cnFillOn                  =  True
cnres at cnFillMode                = "RasterFill"       ; Raster Mode
cnres at cnMissingValFillColor     = "steelblue1" 
cnres at cnLinesOn                 =  False 
cnres at cnLineLabelsOn            =  False 
cnres at cnFillPalette             = "OceanLakeLandSnow" 
cnres at cnRasterSmoothingOn       =  False                  ;-- do not smooth contouring
cnres at cnLevelSelectionMode      = "ManualLevels"  
cnres at cnMinLevelValF            =  -100.0 
cnres at cnMaxLevelValF            =  3000.   
cnres at cnLevelSpacingF           =  50.  
cnres at gsnRightString            = "["+var1 at units+"]" 
cnres at gsnRightStringFontHeightF =  0.013 
cnres at gsnRightStringParallelPosF =  1.19 
cnres at gsnRightStringOrthogonalPosF =  -0.007
cnres at gsnLeftString             = "" 
cnres at tiXAxisString             = "" 
cnres at tiYAxisString             = ""     
cnres at lbOrientation             = "vertical" 
cnres at lbLabelFontHeightF        =  0.013 

;-- MPI-ESM 
cnres1 = cnres
cnres1 at gsnAddCyclic             =  True          ;-- KMF

plot1 = gsn_csm_contour(wks,land_only1,cnres1)   ;-- create global plot

;-- overlay plot1 on map
overlay(map,plot1)

;-- EUR-11
cnres2 = cnres
cnres2 at trYReverse               =  True
cnres2 at tfDoNDCOverlay           =  False         ; transform to standard lat/lon
cnres2 at sfXArray                 =  lon2d
cnres2 at sfYArray                 =  lat2d
cnres2 at lbLabelBarOn             =  False
cnres2 at cnFillDrawOrder          = "PostDraw"

plot2 = gsn_csm_contour(wks,land_only2,cnres2)   ;-- create Europe plot

;-- polyline resources
resl                            =  True
resl at gsLineThicknessF           =  8.0
resl at gsLineColor                = "black"

;-- define edges
lon_val_upper = lon2d(nlat-1,:)
lat_val_upper = lat2d(nlat-1,:)
lon_val_lower = lon2d(0,:)
lat_val_lower = lat2d(0,:)
lon_val_left  = lon2d(:,0)
lat_val_left  = lat2d(:,0)
lon_val_right = lon2d(:,nlon-1)
lat_val_right = lat2d(:,nlon-1)

;-- draw edges
upper = gsn_add_polyline(wks, plot2, lon_val_upper, lat_val_upper, resl)
lower = gsn_add_polyline(wks, plot2, lon_val_lower, lat_val_lower, resl)
left  = gsn_add_polyline(wks, plot2, lon_val_left,  lat_val_left,  resl)
right = gsn_add_polyline(wks, plot2, lon_val_right, lat_val_right, resl)

;-- overlay plot2 on map
overlay(map,plot2)

;-- attach map2 to map to draw the geophysical outlines ontop of the plot2, too.                                   
anres =  True
anid  =  gsn_add_annotation(map,map2,anres)
  
;--draw the frame
draw(map)
frame(wks)

end


-------------- next part --------------
A non-text attachment was scrubbed...
Name: Globus_MPI+CCLM_Oro_Europe.png
Type: image/png
Size: 880359 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160425/9a8143d2/attachment-0001.png 


More information about the ncl-talk mailing list