[ncl-talk] How to read files having different dimension sizes

Wang, Jiali jialiwang at anl.gov
Fri Mar 20 09:42:07 MDT 2015


Thank you Wei and Dennis. I am using 6.0.0, that’s why the easy way [ := ] does not work, but the “delete” works. Thanks again!

From: Wei Huang [mailto:huangwei at ucar.edu]
Sent: Friday, March 20, 2015 10:34 AM
To: Wang, Jiali
Cc: ncl-talk at ucar.edu
Subject: Re: [ncl-talk] How to read files having different dimension sizes

Jiali,

There are two ways to do it:
1. The traditional way

county = (/"Delaware","Sioux","Lincoln"/)

do k = 0, 2
   f1  = addfile("CDL_2010_"+county(k)+".nc","r")
   u1  = f1->Band1(:,:)

 ;do some work with u1

  delete(u1)
end do


2. the easy way

county = (/"Delaware","Sioux","Lincoln"/)

do k = 0, 2
   f1  := addfile("CDL_2010_"+county(k)+".nc","r")
   u1  := f1->Band1(:,:)
end do


Where the second way uses ":=", which we call it re-assign.
It works as, if u1 exists at this time, delete it first, if not, do nothing, and then create a new u1.

You may want to read:
http://www.ncl.ucar.edu/Document/Language/varb_assign.shtml

Regards,

Wei

================================================
1850 Table Mesa Dr.
Boulder, CO 80307
Phone: 303-497-8924

On Fri, Mar 20, 2015 at 9:21 AM, Wang, Jiali <jialiwang at anl.gov<mailto:jialiwang at anl.gov>> wrote:
Dear NCL users,

I am trying to read in files which have different dimension sizes, and get fatal error: Dimension sizes of left hand side and right hand side of assignment do not match.

Here is my ncl script:
==============
county = (/"Delaware","Sioux","Lincoln"/)

do k = 0, 2
   f1  = addfile("CDL_2010_"+county(k)+".nc","r")
   u1  = f1->Band1(:,:)
end do
===============

Since the dimension sizes of the three data sets are totally different, the script works only for k=0,0 or k=1,1 or k=2,2. Is there a way to address this problem? Something like, make it forgets the dimension of last loop (say, k=0) and starts the next loop (say, k=1)? I have much more than three data sets needed to be read in.

Thanks!

Jiali


Jiali Wang, Ph. D
Environmental Science Division
Argonne National Laboratory
Tel: 630-252-2848<tel:630-252-2848>
http://www.evs.anl.gov/about-evs/staff/detail/index.cfm?/Wang/Jiali



_______________________________________________
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/20150320/206dfc9f/attachment.html 


More information about the ncl-talk mailing list