[ncl-talk] reshape error

Maria Gehne - NOAA Affiliate maria.gehne at noaa.gov
Thu Jul 24 11:31:39 MDT 2014


Hi Sunmin,

I believe you are trying to reshape a string. varname = "ec550aer” which is
one dimensional. Don't you want to reshape the actual data array? Reshape
only works on numerical data (of any type though), so maybe that's the
cause of your error.

So try something like this:

ecreshape = reshape(data,(/nyears,12,nlev,nlat,nlon/))

Hope this helps,

Maria





On Thu, Jul 24, 2014 at 11:26 AM, Sunmin Park <mireiyue at gmail.com> wrote:

> Dear all nil users
>
> I am trying to get plots from each month and year. One file contains all 7
> years and 12 months values. So, I used reshape but I got a problem. I try
> to follow the reshape example in the website but it is not working. How can
> I fix it?
>
> Thank you for any help
> Sun-
>
> This is what I got
>
> fatal:Argument type mismatch on argument (0) of (reshape) can not coerce
> fatal:["Execute.c":7743]:Execute: Error occurred at or near line 53 in
> file CMIP5_ec.ncl
>
>
> ; ==============================================================
> ; Open the file:
> ; ==============================================================
>   fili    = "ec550aer_aero_NorESM1-M_historicalExt_"+version(ii)+"
> i1p1_200601-201212.nc"
>   varname = "ec550aer”
>  filenc       = addfile (diri+fili+".nc", "r")      ; entire file
> ;  print (varname)
> ;  print (filenc)
>
>   data   = filenc->$varname$                          ; (time, ver, lat,
> lon)
> ;  print (dimsizes(data))
>   time =filenc->time
>   lev =filenc->lev
>   lat =filenc->lat
>   lon =filenc->lon
>   data at _FillValue= 0
>
> ;  printVarSummary(data)
> ;  print(dimsizes(time))
> ;  return
>
>   ntim = dimsizes(time)
>   nlev = dimsizes(lev)
>   nlat = dimsizes(lat)
>   nlon = dimsizes(lon)
>   nyears = ntim/12
>
> ;  printVarSummary(ntim)
> ;  printVarSummary(nyears)
> ;  print(ntim)
> ;  print(nyears)
>
>   ecreshape = reshape(varname,(/nyears,12,nlev,nlat,nlon/))
> ;  reec550nm = reshape(ecreshape(:,0:2,:,:,:),(/nyears*12,nlev,nlat,nlon/))
>   printVarSummary(ecreshape)
> ;  printVarSummary(ec550nm)
>   return
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140724/b7df964f/attachment.html 


More information about the ncl-talk mailing list