[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ASSOC
- Subject: Re: ASSOC
- From: davidf(at)dfanning.com (David Fanning)
- Date: Fri, 22 Sep 2000 21:15:51 -0600
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- References: <8qh1i6$dud$1@nnrp1.deja.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:21508
yu175372@yorku.ca (yu175372@yorku.ca) writes:
> hello people this is not clear to me but i figure some of the IDL GURU's
> can help me out.
Humm. Maybe. But the IDL GURU's prefer to know WHO
they are helping out. I'm guessing a name would provide
better service in the future. :-)
> i have an bsq file with the dimensions of 554*521*42 and
> tried to use the ASSOC function since i knew the dimensions and so
> created a structure :
> 2 variables of x=FLTARR(554) and y=FLTARR(521) and REPLICATED the
> structure 42 times into a third variable and then tried the ASSOC
> function with it and it ran fine except for when i tried to access any
> data it would give me the error of
> "File expression not allowed in this context: RESULT."
> and if i peaked into it using the variable watch it would crash IDL
> every time. Kinda makes me wish that anything in IDL work as it's
> designed to.
> I'm using IDL 5.2
> PRO Profiles
> ;dealing with a 3D array of sorts.
> z= 42 ;depth of the array
> data={mo,x:FLTARR(554),y:FLTARR(521)}
> data_cube=REPLICATE(data,z) ;this is to hold the bsq
> help,data_cube
> help,data
>
> filepath=DIALOG_PICKFILE(/MUST_EXIST,TITLE='SELECT DATA FILE')
> GET_LUN,unit
> OPENR,unit,filepath
> result=ASSOC(unit,data_cube)
> ;READU,unit,data_cube,TRANSFER_COUNT=count
> CLOSE,unit
> FREE_LUN,unit
>
> a=result(0).y[0:6]
> print,a
> print,result.(0).x[*]
> END
Unfortunately, I think you have misinterpreted just about
everything you have read about the IDL associated variable
method. In the first place, it is not designed to read
in an entire data cube like this. If this is what you
want to do, you would be much better off just doing this:
OpenR, unit, filepath, /Get_Lun
data_cube = FltArr(554, 521, 42)
ReadU, unit, data_cube
Free_Lun, unit
If you wanted to read just one of the 554 by 551 arrays,
then the associated variable method would allow you to
do that without reading the entire data set. (Not reading
the entire data set is pretty much the point of the
associated variable method.) Then you would do it like
this:
OpenR, unit, filepath, /Get_Lun
array = Assoc(unit, FltArr(554, 521))
What you do in the associated variable method is map a
virtual data structure onto the data file. Another way of
saying this is that you associate a variable organization onto the
bytes in the file. The reading of the data occurs when
the data is needed. For example, suppose you want to display
the 25th image in the file. Then you would type this:
TV, array(24)
The ability to read only a portion of the file, and then
only when that data is needed, makes the file I/O efficient.
IDL does tend to work as it is designed to. Even if
it doesn't always work as we expect it to. The discrepancy
can be especially large if we haven't taken the time to
read the documentation.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155