Re: Errors in plotting time-averaged wind fields

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Mar 26 2013 - 11:50:50 MDT

I saw that Dave already responded. I had started to
respond with essentially the same information.

Still your script will not work because the way you are
getting the dates is not correct. See the end of the reply.

If you are a "novice in NCL", please read the Mini-Language
Manual at: http://www.ncl.ucar.edu/Document/Manuals/

Also:
  http://www.ncl.ucar.edu/Document/Manuals/Getting_Started
Look at the Examples.

===

The variable your are plotting 'wsAvg' is 3D. Use
printVarSummary(wsAVG) to examine the variable:

      wsAvg(height,rlat,rlon)

The specific error message

"gsn_csm_contour_map_ce: Fatal: the input data must be 1D or 2D"

The documentation for

function gsn_csm_contour_map_ce (
                wks [1] : graphic,
                data : numeric,
                res [1] : logical
        )

Specifically, state that 'data' (the variable to be contoured)
must be one or two-dimensional.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

you are passing a 3D array. Do a printVarSummary(wsAvg)
prior to the function call.

wsAvg(0,:,:) is 2D printVarSummary( wsAvg(0,:,:) )

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   beg_year = 2000
   end_year = 2000
   beg_month = 12
   end_month = 12
   beg_day = 29
   end_day = 31
             ; indices (subscripts) for above date
   itime = ind(year.ge.beg_year .and. year.le.end_year .and. \
                   month.ge.beg_month .and. month.le.end_month .and. \
                   day .ge.beg_day .and. month.le.end_day )
   ibeg = day_of_year(beg_year,beg_month,beg_day)
   iend = day_of_year(end_year,end_month,end_day)

later

   wsAvg = dim_avg_n_Wrap(ws(itime,:,jStrt:jLast,iStrt:iLast), 0)
   printVarSummary(wsAvg)

Good luck

On 3/26/13 4:13 AM, Ioannis Koletsis wrote:
> Hello all,
>
> I am novice in NCL and I have some questions.
>
> Firstly, I work on NCL version 6.0.0-beta
>
> I handle with wind data .nc files (ws(time, height, lat, lon)).
>
> I would like to plot the wind fields but for a specific time period and
> area.
>
> I tried to achieve it making the attached script.
>
> The dim_avg function as well as the dimensions re-ordering of my variable
> has been already done, but I have faced up a serious problem plotting the
> wind field.
>
> When I run the script the following error messages has been displayed on my
> screen:
>
> "(0) gsn_csm_contour_map_ce: Fatal: the input data must be 1D or 2D"
>
> "Fatal: Illegal right-hand side type for assignment"
>
> "Fatal: Execute: Error occurred at or near line 158 in file"
>
> Any help would be appreciated..
>
>
>
> John
>
>
>
>
>
> Attached script:
>
> ;*************************************************
>
> ; Time-Averaged and Plot wind speed fields
>
> ;*************************************************
>
> 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"
>
>
>
> begin
>
>
>
> f1 = addfile("C4IRCA3_A2_ECHAM5_DM_25km_1991-2000_wss.nc","r")
>
> time = f1->time
>
> ws = f1->wss
>
> lat2d = f1->lat
>
> lon2d = f1->lon
>
> pollat = 39.25
>
> pollon = -162.0
>
>
>
> time2 = ut_calendar(time, 0)
>
>
>
> year = tointeger(time2(:,0)) ; Convert to integer for
>
> month = tointeger(time2(:,1)) ; use sprinti
>
> day = tointeger(time2(:,2))
>
>
>
> beg_year = 2000
>
> end_year = 2000
>
> beg_month = 12
>
> end_month = 12
>
> beg_day = 29
>
> end_day = 31
>
>
>
> ibeg = day_of_year(beg_year,beg_month,beg_day)
>
> iend = day_of_year(end_year,end_month,end_day)
>
>
>
>
>
> ;======================================================================
>
> ; Select the subregion (Mediterranean Area)
>
> ;======================================================================
>
>
>
> latS = 30
>
> latN = 46
>
> lonW = -10
>
> lonE = 41
>
>
>
> ji = region_ind(lat2d,lon2d,latS,latN,lonW,lonE)
>
>
>
> jStrt = ji(0)
>
> jLast = ji(1)
>
> iStrt = ji(2)
>
> iLast = ji(3)
>
>
>
> llat2d = lat2d(jStrt:jLast,iStrt:iLast)
>
> llon2d = lon2d(jStrt:jLast,iStrt:iLast)
>
>
>
> nlat = dimsizes(llat2d(:,iStrt))
>
> nlon = dimsizes(llon2d(jStrt,:))
>
>
>
> wsNew = ws(height|:,rlat|jStrt:jLast,rlon|iStrt:iLast,time|ibeg:iend)
>
> wsAvg = dim_avg_Wrap(wsNew)
>
>
>
> ; wsm = f1->wss
>
>
>
>
>
> ;======================================================================
>
> ; Start graphic section
>
> ;======================================================================
>
>
>
> wks = gsn_open_wks("png", "Aveg_C4IRCA3_Med_Sea_A2") ; make png image
>
> gsn_define_colormap(wks,"BlAqGrYeOrRe") ; choose color map
>
>
>
> res = True ; plot mods desired
>
>
>
> res@gsnMaximize = True ; maxmize plot in frame
>
> res@cnFillOn = True ; turn on color
>
> res@gsnSpreadColors = True ; automatically choose the
> fill colors
>
> res@cnLinesOn = False ; no contour lines
>
> res@cnLevelSpacingF = 0.2 ; contour spacing
>
> res@cnLineLabelsOn = False ; no contour labels
>
>
>
>
>
> ; =====================================================================
>
> ; Create Map and Mask Land
>
> ; =====================================================================
>
>
>
> res@mpDataBaseVersion = "MediumRes" ; use finer database
>
> res@mpDataSetName = "Earth..4"
>
> res@mpProjection = "CylindricalEquidistant"
>
> res@mpOutlineBoundarySets = "National"
>
> res@mpFillOn = True ; true for masking
>
> res@mpGeophysicalLineThicknessF = 1.5
>
>
>
> res@mpAreaMaskingOn = True ; masking land
>
> res@mpMaskAreaSpecifiers = "Ocean"
>
> res@mpLandFillColor = 0
>
> res@mpFillDrawOrder = "PostDraw"
>
>
>
> ;=====================================================================
>
> ; Laber Bar
>
> ;=====================================================================
>
>
>
> res@lbLabelAngleF = 0 ; angle labels
>
> res@lbLabelFontHeightF =.001 ; make labels larger
>
> res@lbTitleOn = True ; turn on title
>
> res@lbTitleString = "Wind Speed in m/s"
>
> res@lbTitleFontHeightF = .010 ; make title smaller
>
> res@pmLabelBarOrthogonalPosF = .10 ; move whole thing down
>
>
>
> res@cnInfoLabelOn = False ; turn off contour info
> label
>
>
>
> res@lbAutoManage = False ; we control label bar
>
> res@pmLabelBarDisplayMode = "Always" ; turns on label bar
>
> res@lbOrientation = "Horizontal" ; ncl default is vertical
>
> res@pmLabelBarSide = "Bottom" ; default is right
>
> res@lbLabelStride = 1 ; skip every other label
>
> res@pmLabelBarWidthF = 0.4 ; default is shorter
>
> res@pmLabelBarHeightF = 0.1 ; default is taller
>
> res@lbLabelFontHeightF = .010 ; default is HUGE
>
> res@lbPerimOn = False ; default has box
>
> res@lbBoxLinesOn = False
>
>
>
> res@pmTickMarkDisplayMode = "conditional"
>
>
>
> res@gsnAddCyclic = False
>
>
>
>
>
> ; ====================================================================
>
> ; Set titles
>
> ; ====================================================================
>
>
>
> res@gsnRightString = "A2 SRES (1991-2000)" ; write a text
> up&right below title
>
> res@gsnRightStringFontHeightF = .010 ; right title font size
>
> res@gsnLeftStringFontHeightF = .015 ; left title font size
>
> res@tiMainString = "C4IRCA3 driven by ECHAM5" ; set the main title
>
> res@tiMainFontHeightF = .020 ; main title font size
>
>
>
> ; Setting tfDoNDCOverlay to True means you have specified the
>
> ; exact projection that your data is on, and thus no data
>
> ; transformation takes place when the contours are overlaid
>
> ; on the map.
>
> ;
>
> res@tfDoNDCOverlay = True
>
>
>
>
>
> ; ====================================================================
>
> ; Zoom in on map
>
> ; ====================================================================
>
>
>
> res@mpLimitMode = "Corners"
>
>
>
> res@mpLeftCornerLatF = llat2d(0,0)
>
> res@mpLeftCornerLonF = llon2d(0,0)
>
> res@mpRightCornerLatF = llat2d(nlat-1,nlon-1)
>
> res@mpRightCornerLonF = llon2d(nlat-1,nlon-1)
>
> res@mpCenterLonF = 180.0 + pollon
>
> res@mpCenterLatF = 90.0 - pollat
>
>
>
>
>
>
>
> plot = gsn_csm_contour_map (wks,wsAvg,res) ; Draw plot
>
>
>
>
>
>
>
> end
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Mar 26 11:51:04 2013

This archive was generated by hypermail 2.1.8 : Tue Apr 02 2013 - 21:23:48 MDT