[ncl-talk] problem with gsn_csm_contour in drawing a globe

Karin Meier-Fleischer meier-fleischer at dkrz.de
Fri Apr 22 04:57:12 MDT 2016


Hi Frank,

your latitude and longitude arrays are 1D so you don't need the sfXArray 
and sfYArray resource settings. For land_only1 you have to define the 
named dimensions lat and lon and create the coordinate variables.

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

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

See the attached script with minor changes.

the plot seems to be familiar. ;)
Karin

Am 22.04.16 um 11:49 schrieb Kreienkamp Frank:
>
> Hello Guido,
>
> Thanks for your suggestions.
>
> unfortunately gsnAddCyclic  = False not helps. The them goes for 
>   gsnAddCyclic  = True. In this configuration I get a warning:
>
> /warning:ScalarFieldSetValues: coordinate array sfXArray requires 193 
> elements: defaulting/
>
> The second problem was solved after I included gsnMaximixe + 
> gsnBoxMargin in the first plot.
>
> Frank
>
> *Von:*ncl-talk-bounces at ucar.edu [mailto:ncl-talk-bounces at ucar.edu] *Im 
> Auftrag von *Guido Cioni
> *Gesendet:* Freitag, 22. April 2016 11:29
> *An:* Kreienkamp Frank
> *Cc:* ncl-talk at ucar.edu
> *Betreff:* Re: [ncl-talk] problem with gsn_csm_contour in drawing a globe
>
> Hey Frank,
>
> I’m pretty sure (but not completely) that the first problem will be 
> solved by setting gsnAddCyclic = False. For the second one it seems 
> that you are correctly setting the gsnMaximize resource to True, so I 
> don’t know what you could do… Can’t you just cut the resulting png 
> file? It seems that changing the paper orientation wouldn't affect the 
> plot since it is squared, but you can try to play around with the 
> resources related to the Maximize option (maybe setting /gsnBoxMargin/ 
> <https://www.ncl.ucar.edu/Document/Graphics/Resources/gsn.shtml#gsnBoxMargin> to 
> 0.0?); see hereinafter.
>
> *gsnMaximize***
>
> If set to True, then any plot drawn by a gsn 
> <https://www.ncl.ucar.edu/Document/Graphics/Interfaces/> function will 
> be maximized in the workstation on which it is being drawn. For an X11 
> window or an NCGM file, this means the plot will be expanded to fill 
> the biggest possible space within a square, with a small margin around 
> all edges. You can get rid of this margin by setting /gsnBoxMargin/ 
> <https://www.ncl.ucar.edu/Document/Graphics/Resources/gsn.shtml#gsnBoxMargin> to 
> 0.0. The aspect ratio will be preserved. For a PostScript or PDF file, 
> the plot will be expanded to fill the biggest possible space on an 8 
> 1/2" x 11" sheet of paper.
>
> For a PS or PDF file, you can change the default paper size, margins, 
> or orientation with the resources/gsnPaperOrientation/ 
> <https://www.ncl.ucar.edu/Document/Graphics/Resources/gsn.shtml#gsnPaperOrientation>, 
> /gsnPaperMargin/ 
> <https://www.ncl.ucar.edu/Document/Graphics/Resources/gsn.shtml#gsnPaperMargin>, 
> /gsnPaperWidth/ 
> <https://www.ncl.ucar.edu/Document/Graphics/Resources/gsn.shtml#gsnPaperWidth>, 
> and /gsnPaperHeight 
> <https://www.ncl.ucar.edu/Document/Graphics/Resources/gsn.shtml#gsnPaperHeight>/
>
> Guido Cioni
>
> http://guidocioni.altervista.org
>
>     On 22 Apr 2016, at 11:19, Kreienkamp Frank
>     <Frank.Kreienkamp at dwd.de <mailto:Frank.Kreienkamp at dwd.de>> wrote:
>
>     Hello,
>
>     i am trying to draw a globe with a GCM orography. I nearly get
>     what I want. Unfortunately I still have 1 interesting item. As you
>     can see in the attached png-file I get at the Greenwich line no
>     orography information. I have seen this before but I cant remember
>     how to solve the problem.
>
>     A second but minor question is, how can I resize the drawing, that
>     it fills nearly the complete drawing area. Not having a 20% black
>     border an nearly each side.
>
>     How can this be solved? (I have also attached the ncl-file)
>
>     Thanks in advance
>
>     Frank
>
>     <Globus_MPI_Oro.ncl><Globus_MPI_Oro.png>_______________________________________________
>     ncl-talk mailing list
>     ncl-talk at ucar.edu <mailto: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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160422/313c3eb5/attachment.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

;--open workstation
wks_type                     = "png"
wks_type at wkBackgroundColor   = "grey18"
wks_type at wkForegroundColor   = "white"
wks_type at wkWidth    = 500
wks_type at wkHeight   = 500
wks  = gsn_open_wks(wks_type, "Globus_MPI_Oro")

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

;--map resources
mpres                        = res
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 mpOutlineOn            = True
mpres at mpOutlineDrawOrder     = "PostDraw"
mpres at mpFillDrawOrder        = "PreDraw"
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           = 15. 
mpres at mpCenterLonF           = 15.

mpres at mpGridLatSpacingF      = 2.
mpres at mpGridLonSpacingF      = 2.
map   = gsn_csm_map(wks,mpres)



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

cnres at cnFillOn = True
cnres at cnFillMode                    = "RasterFill"       ; Raster Mode
cnres at cnMissingValFillColor = "steelblue1" 
cnres at cnLinesOn = False 
cnres at cnLineLabelsOn = False 
cnres at cnLevelSelectionMode = "ManualLevels" 
cnres at cnMinLevelValF = -100.0 
cnres at cnMaxLevelValF = 3000. 
cnres at cnLevelSpacingF = 50. 
cnres at cnFillPalette = "OceanLakeLandSnow" 
cnres at gsnRightString = "["+var1 at units+"]" 
cnres at gsnRightStringFontHeightF = 0.013 
cnres at gsnRightStringParallelPosF = 1.19 
cnres at gsnRightStringOrthogonalPosF = -0.007

cnres at tiXAxisString = "" 
cnres at tiYAxisString = "" 
cnres at gsnLeftString = "" 

cnres at lbOrientation = "vertical" 
cnres at lbLabelFontHeightF = 0.013 

;-- overlay Europe 
plot1 = gsn_csm_contour(wks,land_only1,cnres) 

overlay(map,plot1) 
;--draw the frame

draw(map)

frame(wks)

end




More information about the ncl-talk mailing list