[ncl-talk] How to read files having different dimension sizes
Wei Huang
huangwei at ucar.edu
Fri Mar 20 09:34:14 MDT 2015
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> 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
>
> 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/99849d6e/attachment.html
More information about the ncl-talk
mailing list