Re: Problem with evans plot

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Oct 03 2013 - 16:08:17 MDT

AT the end of the do loop

> print("lat_i: " + lat + " lon_j: " + lon + " valor: " +
> max_var + " estacao: " + index)

         delete(index) ;< *********************
> end do
> end do

====
NCL is a strongly typed language. It puts constraints on what
users can do.

    do ...
        :
      x = ...
        :
        :
      delete(x)
    end do

if 'x' never changes size or shape the above is ok.

However, if [say] x(10) on some inetartion and the next iteration
it was x(12) ... NCL will not let you place a variable of size
12 into a pre-existing variable of size 10. That is what

fatal:Number of dimensions on right hand side do not match number of
dimension in left hand side
fatal:Execute: Error occurred at or near line 61 in file
seasonal_prec_model.ncl

The solution is to delete the variable before the next iteration.

NCL v5.2 is a very old version. We suggest updating.

In fact in NCL version 6.2.1, a new syntax will allow overwrite and the
delete is not needed.

     x := ...

On 10/3/13 3:52 PM, Graziela Luzia wrote:
> oad "$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"
> load "evans_plot.ncl"
>
> arquivo ="prec_mensal1998_2011s.nc"
> a = addfile(arquivo,"r")
> ylat = a->lat
> xlon = a->lon
> u = a->precip
> ;print(u)
>
> ny = dimsizes(ylat)
> nx = dimsizes(xlon)
>
> var_new = new((/ny,nx/),"float",getFillValue(u))
>
> var_new!0 = "lat"
> var_new!1 = "lon"
> var_new&lat = fspan(-88.57217,88.57217,ny)
> var_new&lon = fspan(0,358.125,nx)
> var_new&lat@units = "degrees_north"
> var_new&lon@units = "degrees_east"
>
> tempo = new((/ny,nx/),"float",getFillValue(u))
>
> tempo!0 = "lat"
> tempo!1 = "lon"
> tempo&lat = fspan(-88.57217,88.57217,ny)
> tempo&lon = fspan(0,358.125,nx)
> tempo&lat@units = "degrees_north"
> tempo&lon@units = "degrees_east"
>
> do lat = 0,ny-1
> do lon = 0,nx-1
> var = u(:,lat,lon)
> max_var = max(var)
> indMax = ind(var .eq. max_var )
> ---------------> line 61
> index = indMax(0) + 1
> ; index = mod(get1Dindex(var,max_var),4)+1 ; Does
> not work with repeating data
> var_new(lat,lon) = max_var
> tempo(lat,lon) = index
>
> if (dimsizes(indMax).gt.1) then ; are there multiple places
> where var(:).eq.max_var?
> print("The following had "+dimsizes(indMax)+" index values = max_var")
> end if
>
> print("lat_i: " + lat + " lon_j: " + lon + " valor: " +
> max_var + " estacao: " + index)
> end do
> end do
>
> printMinMax (var_new, True)
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Oct 3 16:08:45 2013

This archive was generated by hypermail 2.1.8 : Fri Oct 04 2013 - 16:45:17 MDT