[ncl-talk] change in vector spacing when taking difference of two wind fields

mberdahl at envsci.rutgers.edu mberdahl at envsci.rutgers.edu
Mon Jun 8 20:12:26 MDT 2015


Hi all,
I have a 3 panel plot which shows the winds over a region.  The first two
panels show averages for selected years, and the third panel shows the
difference between the top 2 panels.  My problem is that the spacing of
wind vectors is much denser in the first two plots than the third
"difference" plot.  Is there a reason why the grid spacing would suddenly
be different (more sparse) when displaying the difference of two wind
fields?  The sizes (dimensions) of the u and v fields remain the same for
each panel.
My script and the VarSummaries for some of the variables are below.
I will try to attach the pdf of the figure here if possible.
Thanks very much for any help.
Mira

************************************************************


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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
;************************************************
begin
;************************************************
; read in netCDF file
;************************************************
a = addfile("uwnd.mon.mean.nc","r")
print(a)
b = addfile("vwnd.mon.mean.nc","r")

;************************************************
; read in zonal [u] and meridional [v] winds (July)
;************************************************

u = a->uwnd(0:803,{45:90},{270:357.5})
v = b->vwnd(0:803,{45:90},{270:357.5}) ; Get u, v, time (1),level
(1000hpa),latitude(-90:90) and longitude(0:360) data.

printVarSummary(u)
printVarSummary(v)

; to take the average over the first dimensions (time)
;uAvgTime = dim_avg_n_Wrap(u,0)
;vAvgTime = dim_avg_n_Wrap(v,0)

;printVarSummary(vAvgTime)
;printVarSummary(uAvgTime)

; calculate speed from u and v components
;speed = sqrt(uAvgTime^2+vAvgTime^2)

; Calculate the seasonal averages.
uDJF = month_to_season(u, "DJF")
vDJF = month_to_season(v, "DJF")

printVarSummary(uDJF)
printVarSummary(vDJF)

; from the matlab script i wrote: findExtremeYrs, i pulled out the extreme
years (> or < 1std) that i want to average and plot here.

; for ans =   4 (NAO)
; yearList_hi = 1973        1975        1983        1989        1995      
 2000        2007        2012
; yearList_lo = 1963        1964        1965        1969        1977      
 1979        1996        1997        2010        2011

; ans = 5 (pressure)
;yearList_hi = 1963        1965        1968        1969        1970       
1971        1977        1997        2006        2011
;yearList_lo = 1973        1989        1990        1991        1995       
1999        2000        2007        2012

;ans = 7 (longitude of IL)
;yearList_hi =1966        1967        1968        1969        1974       
1975        1983        1994        1995        2005
;yearList_lo =1963        1964        1985        1987        1991       
1992        1996        2002   2003    2006      2009


; this data starts at 1948 (this is index 0), so 1953=5, 1963=10 etc.

uDJF_NAO_lo = uDJF((/10,11,12,16,24,26,43,44,57,58/),:,:)
uDJF_NAO_hi = uDJF((/20,22,30,36,42,47,54,59/),:,:)

vDJF_NAO_lo = vDJF((/10,11,12,16,24,26,43,44,57,58/),:,:)
vDJF_NAO_hi = vDJF((/20,22,30,36,42,47,54,59/),:,:)

uAvgTime_hi = dim_avg_n_Wrap(uDJF_NAO_hi,0)
uAvgTime_lo = dim_avg_n_Wrap(uDJF_NAO_lo,0)

printVarSummary(uAvgTime_hi)
printVarSummary(uAvgTime_lo)

vAvgTime_hi = dim_avg_n_Wrap(vDJF_NAO_hi,0)
vAvgTime_lo = dim_avg_n_Wrap(vDJF_NAO_lo,0)

printVarSummary(vAvgTime_hi)
printVarSummary(vAvgTime_lo)



;************************************************
; create plot
;************************************************
wks = gsn_open_wks("eps","Panel_NAO") 		; open a ps file
plot = new(3,graphic)				; create a plot array

vcres 			= True
vcres at gsnDraw		= False 		; dont draw
vcres at gsnFrame		= False			; dont advance frame
vcres at cnInfoLabelOn	= False			; trn off cn info label

vcres = True 					; plot mods desired
vcres at gsnAddCyclic = False			; has to do with wrapping the longitude at 0/360
vcres at vcRefAnnoOrthogonalPosF = -1.0 		; move ref vector up
vcres at vcRefMagnitudeF = 10.0 			; define vector ref mag
vcres at vcRefLengthF = 0.045 			; define length of vec ref
vcres at vcGlyphStyle = "CurlyVector" 		; turn on curly vectors
vcres at vcMinDistanceF = 0.017

;************************************************
; Choose a subregion
;************************************************
vcres at mpFillOn = False 				; turn off gray fill
vcres at mpOutlineBoundarySets = "National" 	; turn on country boundaries
vcres at mpGeophysicalLineColor = "Navy" 		; color of cont. outlines
vcres at mpGeophysicalLineThicknessF = 1.5 	; thickness of outlines

vcres at mpMaxLatF = 90 				;maximum latitude
vcres at mpMinLatF = 45 				;minimum latitude
vcres at mpMaxLonF = 357.5 			;maximum longitude
vcres at mpMinLonF = 270 				;minimum longitude

diff_u = uAvgTime_hi - uAvgTime_lo
diff_v = vAvgTime_hi - vAvgTime_lo

printVarSummary(diff_u)
printVarSummary(diff_v)

vcres at gsnLeftString = "DJF High NAO"
plot(0) = gsn_csm_vector_map_ce(wks,uAvgTime_hi,vAvgTime_hi,vcres)

vcres at gsnLeftString = "DJF Low NAO"
plot(1) = gsn_csm_vector_map_ce(wks,uAvgTime_lo,vAvgTime_lo,vcres)


vcres at vcRefMagnitudeF = 1.0 			; define vector ref mag
vcres at vcRefLengthF = 0.045 			; define length of vec ref
vcres at gsnLeftString = "Difference of High - Low"
plot(2) = gsn_csm_vector_map_ce(wks, diff_u, diff_v,vcres)

;************************************************
; create panel
;************************************************
resP = True					; modify the panel plot
resP at txString = "NAO"
gsn_panel(wks,plot,(/3,1/),resP)		; now draw as one plot



end



OUTPUT
*******************************************************
Variable: vAvgTime_hi
Type: float
Total Size: 2736 bytes
            684 values
Number of Dimensions: 2
Dimensions and sizes:   [lat | 19] x [lon | 36]
Coordinates:
            lat: [45..90]
            lon: [270..357.5]
Number Of Attributes: 17
  NMO : 0
  _FillValue :  -9.96921e+36
  actual_range :        ( -15.43516, 19.79167 )
  parent_stat : Other
  statistic :   Mean
  level_desc :  Surface
  dataset :     CDC Derived NCEP Reanalysis Products
  var_desc :    v-wind
  least_significant_digit :     1
  precision :   2
  missing_value :       -9.96921e+36
  scale_factor :         1
  add_offset :   0
  units :       m/s
  valid_range : ( -102.2, 102.2 )
  long_name :   DJF: Monthly Mean Meridional Wind at sigma level 0.995
  average_op_ncl :      dim_avg_n over dimension(s): time

Variable: vAvgTime_lo
Type: float
Total Size: 2736 bytes
            684 values
Number of Dimensions: 2
Dimensions and sizes:   [lat | 19] x [lon | 36]
Coordinates:
            lat: [45..90]
            lon: [270..357.5]
Number Of Attributes: 17
  NMO : 0
  _FillValue :  -9.96921e+36
  actual_range :        ( -15.43516, 19.79167 )
  parent_stat : Other
  statistic :   Mean
  level_desc :  Surface
  dataset :     CDC Derived NCEP Reanalysis Products
  var_desc :    v-wind
  least_significant_digit :     1
  precision :   2
  missing_value :       -9.96921e+36
  scale_factor :         1
  add_offset :   0
  units :       m/s
  valid_range : ( -102.2, 102.2 )
  long_name :   DJF: Monthly Mean Meridional Wind at sigma level 0.995
  average_op_ncl :      dim_avg_n over dimension(s): time


Variable: diff_u
Type: float
Total Size: 2736 bytes
            684 values
Number of Dimensions: 2
Dimensions and sizes:   [19] x [36]
Coordinates:
Number Of Attributes: 1
  _FillValue :  -9.96921e+36

Variable: diff_v
Type: float
Total Size: 2736 bytes
            684 values
Number of Dimensions: 2
Dimensions and sizes:   [19] x [36]
Coordinates:
Number Of Attributes: 1
  _FillValue :  -9.96921e+36




-------------- next part --------------
A non-text attachment was scrubbed...
Name: Panel_NAO.pdf
Type: application/pdf
Size: 111876 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150608/52efb2b7/attachment.pdf 


More information about the ncl-talk mailing list