[ncl-talk] Help

nelson mateus nelsonbuchinho1992 at gmail.com
Fri Mar 22 19:58:34 MDT 2019


Hello .

I'm trying to use the mjo_clivar 16 script, and I'm trying to run the wind
fields "without being anomaly", and it's giving me the following error:


fatal:["NclVar.c":1390]:Assignment type mismatch, right hand side can't be
coerced to type of left hand side
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 80 in file
mjoc_anom.ncl



can anybody help me ?
##########################SCRIPT ########################

;***********************************************************
; Generate life cycle composites based upon daily phase space
; If the MJO_INDEX is < 1.0 it is not included
;***********************************************************
load "/usr/local/ncarg/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "/usr/local/ncarg/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "/usr/local/ncarg/lib/ncarg/nclscripts/csm/contributed.ncl"
load "/usr/local/ncarg/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl"
begin
   latS    = -60
   latN    =  20


   lonE    = 0
   lonW    = 270


   ymdStrt = 19800101                         ; começo yyyymmdd
   ymdLast = 19800102                         ; término

   yrStrt  = ymdStrt/10000
   yrLast  = ymdLast/10000

   pltSubTitle = "Anomalia: OLR, U850, V850x "

   pltDir  = "./"                             ; plot directory
   pltType = "pdf"
   pltName = "mjoclivar200uv"                      ; yrStrt+"_"+yrLast

   diri    = "./"       ; input directory

 filo    = "olr.anomalia.1979-2017.nc"
 filu    = "uwnd1979_2017.nc"
 filv    = "vwnd1979_2017.nc"

;************************************************
; create BandPass Filter
;************************************************
  ihp      = 2                             ; bpf=>band pass filter
  nWgt     = 201
  sigma    = 1.0                           ; Lanczos sigma
  fca      = 1./100.
  fcb      = 1./20.
  wgt      = filwgts_lanczos (nWgt, ihp, fca, fcb, sigma )

;***********************************************************
; Find the indicies (subscripts) corresponding to the start/end times
;      on the source data files.
;***********************************************************

   f       = addfile (diri+filu , "r")
   TIME    = f->time                          ; days since ...
   YMD     = cd_calendar(TIME, -2)            ; entire (time,6)

   iStrt   = ind(YMD.eq.ymdStrt)              ; index start
   iLast   = ind(YMD.eq.ymdLast)              ; index last
   delete(TIME)
   delete(YMD )

    time    = f->time            ; days since ...
    u       = f->uwnd(:,0,:,:)
;delete(u)
;***********************************************************
; Read anomalies frpm other fields
;***********************************************************
      f       = addfile (diri+filv , "r")
    v       = f->vwnd(:,0,:,:)
;delete(v)

   f       = addfile (diri+filo , "r")
   x       = f->olr_anom(:,:,:)

   dimx    = dimsizes( x )
   ntim    = dimx(0)
   nlat    = dimx(1)
   mlon    = dimx(2)
;************************************************
; Apply the band pass filter to the original anomalies
;************************************************

  x   = wgt_runave_n (x, wgt, 0, 0)      ; better
  ;u   = wgt_runave_n (u, wgt, 0, 0)
  ;v   = wgt_runave_n (v, wgt,0, 0)

;***********************************************************
; Open PC components file created in 'mjo_14.ncl'
;***********************************************************
  diri    = "./"       ; input directory
  fMJO    = "MJO_PC_INDEX.nc"                ; created in mjo_14.ncl
  f       = addfile (diri+fMJO, "r")

;***********************************************************
; Find the indices corresponding to the start/end times
;      on the MJO_PC_INDEX.nc file
;***********************************************************
  TIME    = f->time                          ; days since ...
  YMD     = cd_calendar(TIME, -2)            ; entire (time,6)

  iStrt   = ind(YMD.eq.ymdStrt)              ; index start
  iLast   = ind(YMD.eq.ymdLast)              ; index last
  delete(TIME)
  delete(YMD )

;***********************************************************
; Read the data for the desired period
;***********************************************************
  pc1     = f->PC1
  pc2     = f->PC2
  mjo_indx= f->MJO_INDEX

  time    = f->time
  ymdhms  = cd_calendar(time, 0)

  imon    = floattoint( ymdhms(:,1) )   ; convenience
  iday    = floattoint( ymdhms(:,2) )   ; subscripts must be integer
;***********************************************************
; Place each array into an appropriate array
;;***********************************************************
  ;phase       = (/ 202.5, 247.5, 292.5, 337.5 \   ; phi: Matt Wheeler's
f77 code
  ;               ,  22.5,  67.5, 112.5, 157.5 /)


 phase       =(/ 112.5, 67.5,22.5 \
               , 337.5, 292.5, 247.5, 202.5, 157.5  /)
  nPhase      = dimsizes(phase)
  phaBnd      = 180.0/nPhase
  angBnd      = new( (/2,nPhase/), "float")
  angBnd(0,:) = phase-phaBnd
  angBnd(1,:) = phase+phaBnd
 ;print("phase: "+phase+"   angBnd: "+angBnd(0,:)+" - "+angBnd(1,:))

  r2d         = 180./(4.*atan(1.0))
  ang         = atan2(pc2,pc1)*r2d     ; phase space
  nn          = ind(ang.lt.0)
  ang(nn)     = ang(nn) + 360          ; make 0 to 360
  print(ang)

  nDays       = new (nPhase, "integer")
  pLabel      = "P"+ispan(1,nPhase,1)+": "

;------------------------------------------------------------
; PLOTS
;------------------------------------------------------------
  pltPath = pltDir+pltName

  wks  = gsn_open_wks(pltType,pltPath)
  gsn_define_colormap(wks,"ViBlGrWhYeOrRe")
  plot = new(nPhase,graphic)              ; create graphic array

  res                      = True
  res at gsnDraw              = False        ; don't draw yet
  res at gsnFrame             = False        ; don't advance frame yet
  res at gsnSpreadColors      = True         ; spread out color table

  res at mpFillOn             = False        ; turn off map fill
  res at mpMinLatF            = latS         ; zoom in on map
  res at mpMaxLatF            = latN
  res at mpCenterLonF         = 220.
  res at cnFillOn             = True         ; turn on color fill
  res at cnLinesOn            = False        ; True is default
  res at cnLineLabelsOn       = False        ; True is default
  res at lbLabelBarOn         = False        ; turn off individual lb's
  res at gsnScalarContour     = True         ; contour 3rd array
  res at gsnMajorLatSpacing   = 15
  res at gsnMajorLonSpacing   = 60
  res at tmXBLabelFontHeightF = 0.01
  res at tmYLLabelFontHeightF = 0.01

                                          ; common contours
 ;mnmxint = nice_mnmxintvl( min(x) , max(x), 16, False)
  res at cnLevelSelectionMode = "ManualLevels"
  res at cnMinLevelValF       =  -20         ; -100; mnmxint(0)
  res at cnMaxLevelValF       =   20         ;   80; mnmxint(1)
  res at cnLevelSpacingF      =    5         ;   20; mnmxint(2)
;print(res)

  res at vcMinDistanceF            = 0.01 ;0.01           ; thin the vector
density
  res at vcRefMagnitudeF           = 3 ;1.0            ; define vector ref
mag,aqui era 2
  res at vcRefLengthF              = 0.025 ;0.025           ; define length of
vec ref
  res at vcRefAnnoOrthogonalPosF   = -1.0            ; move ref vector
  res at vcRefAnnoArrowLineColor   = "black"         ; change ref vector color
  res at vcRefAnnoArrowUseVecColor = False           ; don't use vec color for
ref

                                          ; panel plot only resources
  resP                     = True         ; modify the panel plot
  resP at gsnMaximize         = True         ; large format
  resP at gsnPanelLabelBar    = True         ; add common colorbar
  resP at lbLabelAutoStride   = True         ; auto stride on labels
  resP at lbLabelFontHeightF  = 0.01
  resP at gsnPanelBottom      = 0.05         ; add some space at bottom
  resP at pmLabelBarWidthF    = 0.47          ; label bar width
  resP at pmLabelBarHeightF   = 0.05
  resP at gsnPanelFigureStringsFontHeightF = 0.0125  ; bit larger than default
 ;resP at pmLabelBarOrthogonalPosF = 0.015   ; move labelbar up a bit

  txres                  = True
  txres at txFontHeightF    = 0.01
  txid = gsn_create_text(wks, pltSubTitle, txres)

  amres                  = True
 ;amres at amParallelPosF   =  0.575
  amres at amOrthogonalPosF =  0.75
  amres at amJust           = "CenterCenter"
 ;amres at amResizeNotify   = True

;*******************************************
; Loop over each phase
;*******************************************

 res at gsnLeftString   = ""
 res at gsnRightString  = ""
 do nSeason=1,2
    if (nSeason.eq.1) then
        resP at txString  = yrStrt+"-"+yrLast+": Maio a Outubro"
    else
        resP at txString  = yrStrt+"-"+yrLast+": Novembro a Abril"
    end if
  do n=0,nPhase-1

     ; All times where the following criteria are met
     if (nSeason.eq.1) then

             nt = ind(mjo_indx.gt.2.5   .and.                     \
         ;nt = ind((mjo_indx.gt.1.0 .and.  mjo_indx.lt. 2.5)  .and.     \
                 (imon.ge.5          .and. imon.le.10).and.    \
                  ang.ge.angBnd(0,n) .and. ang.lt.angBnd(1,n))
     else
         nt = ind(mjo_indx.gt.2.5    .and.                     \
          ;nt = ind((mjo_indx.gt.1.0 .and.  mjo_indx.lt. 2.5)  .and.     \
                 (imon.ge.12         .or.  imon.le. 2).and.    \
                  ang.ge.angBnd(0,n) .and. ang.lt.angBnd(1,n))
     end if
     if (.not.all(ismissing(nt))) then
       ;;xAvg = dim_avg_Wrap( x(lat|:,lon|:,time|nt) )  ; original
       ;;uAvg = dim_avg_Wrap( u(lat|:,lon|:,time|nt) )
       ;;vAvg = dim_avg_Wrap( v(lat|:,lon|:,time|nt) )

         xAvg = dim_avg_n_Wrap( x(nt,:,:), 0)           ; better
         ;uAvg = dim_avg_n_Wrap( u(nt,:,:), 0)
         ;vAvg = dim_avg_n_Wrap( v(nt,:,:), 0)

         nDays(n) = dimsizes(nt)

         res at tmXBLabelsOn         = False    ; do not draw lon labels
         res at tmXBOn               = False    ;             lon tickmarks
         if (n.eq.(nPhase-1)) then           ;
             res at tmXBLabelsOn     = True     ; draw lon labels
             res at tmXBOn           = True     ;          tickmarks
         end if

         plot(n) = gsn_csm_vector_scalar_map_ce(wks,uAvg,vAvg,xAvg,res)
        ;plot = gsn_csm_contour_map_ce(wks,uAvg,vAvg,xAvg,res)

     end if
     delete(nt)                  ; will change next iteration
  end do

;;ann3  = gsn_add_annotation(plot(0), txid, amres)
  resP at gsnPanelFigureStrings= pLabel+nDays
  gsn_panel(wks,plot,(/nPhase,1/),resP)     ; now draw as one plot
 end do

;system("gv "+pltPath+"."+pltType)
end


can anybody help me ?
-- 
Nelson Pedro António  Mateus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190322/dc6e3f45/attachment.html>


More information about the ncl-talk mailing list