Re: How to fix this image

From: Brammer, Alan P <abrammer_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 22 2014 - 10:47:01 MDT

To add to Karens resposne, the black box is because you have it set to plot=
 no_snow pixels black. If you don’t want them black, then set that color =
to something else ( e.g below)


No_snow set to white;

res@cnLevelSelectionMode = "ExplicitLevels"
res@cnLevels = (/ 0.5 /) ;;;; Only have 2 levels so only need 1 contou=
r between them.
res@cnFillColors = (/ 0, 4 /) ;;;; 0 = “White”
res@lbLabelStrings = (/"no_snow" , "snow_covered"/)


No_snow set to transparent;

res@cnLevelSelectionMode = "ExplicitLevels"
res@cnLevels = (/ 0.5 /) ;;;; Only have 2 levels so only need 1 contou=
r between them.
res@cnFillColors = (/ -1, 4 /) ;;;;;; -1 = "Transparent"
res@lbLabelStrings = (/"no_snow" , "snow_covered”/)


The land/water type is a separate variable in the file, if you want that as=
 well then you’ll have to add that to the mix somehow.



To get into the lat / lon region extraction, take a look at the numerous fu=
nctions and try and find one that fits your requirements.

http://www.ncl.ucar.edu/Document/Functions/latlon_funcs.shtml




Alan.




On Jul 22, 2014, at 4:38, Karin Meier-Fleischer <meier-fleischer@dkrz.de<ma=
ilto:meier-fleischer@dkrz.de>> wrote:

;*******************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

a =addfile("~/Documents/Snow_cover_IMS/nhsce_v01r01_19661004_20140602.nc"=
,"r")
sce=a->snow_cover_extent(0,:,:)

lat=a->latitude ;-- if you want the complete array you don=
't have to use (:,:)

print(lat(:,1))

lon=a->longitude ;-- if you want the complete array you don=
't have to use (:,:)

;print(sce)
;print("Hello")
;printVarSummary(sce)
;printVarSummary(lat)
;printVarSummary(lon)

;;; delete_VarAtts(sce, -1) ;-- why are you deleting all variable attrib=
utes??

;Attaching variables
;;sce!0="lat2d" ;-- no
;;sce!1="lon2d" ;-- no

sce@lat2d=lat
sce@lon2d=lon

printVarSummary(sce)

; Plotting code

wks = gsn_open_wks("ps","sce_ims")
gsn_define_colormap(wks,"default")

res = True
res@cnFillOn = True
res@cnLinesOn = False
res@cnLineLabelsOn = False
res@cnFillMode = "rasterfill"
res@cnMissingValFillColor = 28 ; "gray"
;
; Since the data is categorical, values between the categories need to be
; excluded. Use Explicit level selection to accomplish this.
;
res@cnLevelSelectionMode = "explicitlevels"
res@cnLevels = (/ 0.99,1.99, 2.99, 3.99, 4.99 /)
res@cnFillColors = (/ 1, 4, 19, 6, 0, 1 /) ; (/"black", "blue", "green", =
"yellow", "white", "black" /)
res@lbLabelAlignment = "boxcenters"
res@lbLabelStrings = (/ "water", "land", "ice", "snow" /)
;
; First draw the plot without projecting into map coordinates.
; This has the drawback that only index values are used as tick marks
; but it is fast
;
res@gsnPolar = "NH" ; specify the hemisphere
 plot = gsn_csm_contour_map_polar(wks,sce,res) ; create the plot
;*******************************************



_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk


Received on Tue Jul 22 04:47:10 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT