comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Array subscript for VECTOR must have same size as source expression
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Array subscript for VECTOR must have same size as source expression [message #76745 is a reply to message #76661] Sun, 26 June 2011 07:22 Go to previous messageGo to previous message
Rohit Deshpande is currently offline  Rohit Deshpande
Messages: 6
Registered: June 2011
Junior Member
On Jun 24, 3:27 pm, Paolo <pgri...@gmail.com> wrote:
> Well,
>
> this is a typical errors that you will encounter many times
> in your idl career.
>
> The line
>
> all_barytimes[i,*] = im.BARYTIME
>
> tries to assign a variable im.BARYTIME into an array all_barytimes,
> specifically into a particular column of the array.
>
> The error specifies that im.BARYTIME does not fit into
> all_barytimes[i,*]
> (likely because it has a different number of elements and/or
> dimensions).
>
> Here's an example showing the problem
>
> IDL> a=fltarr(4,4)
> IDL> b=fltarr(5)
> IDL> a[1,*]=b
> % Array subscript for A must have same size as source expression.
> % Execution halted at: $MAIN$
>
> see? can't fit the 5 elements of b into a column of a.
>
> Ciao,
> Paolo
>
> On Jun 24, 11:27 am, Rohit Deshpande <singlebin...@gmail.com> wrote:
>
>
>
>
>
>
>
>> Hello Everyone,
>
>> I am a beginner in IDL and I have been working on a project. I explain
>> it below:
>
>> 1. The Idea: Read a bunch of FITS files in IDL. They have structure so
>> I use MRDFITS. I would like to read each one of them in a separate
>> variable and plot them. Given that each file has X by Y dimension,
>> where X is always = 19 while Y changes but is mostly 1636.
>
>> 2. The Code:
>
>> im = fltarr(n)
>> all_barytimes = dblarr(19,4000)
>> all_normflux = dblarr(19,4000)
>
>> FOR i = 0, n-1 DO BEGIN
>>          ; where filenames are the list of fits files I am reading
>> it.
>>         im = mrdfits(file+'raw_test/'+string(filenames[i]),1,head)
>>         all_barytimes[i,*] = im.BARYTIME
>>         all_normflux[i,*] = im.AP_CORR_FLUX
>> ENDFOR
>
>> 3. The Error:
>
>> IDL> lcs1
>> % READCOL: 21 valid lines read
>> MRDFITS: Binary table.  19 columns by  1639 rows.
>> % Array subscript for ALL_BARYTIMES must have same size as source
>> expression.
>> % Execution halted at: LCS1
>
>> Please let me know how to make it work.
>
>> Thanks!

Thank you so much. I have now created a double array outside the FOR
loop in the following way. This help and I have no errors:

all_barytimes = dblarr(n,4450)
all_normflux = dblarr(n,4450)

FOR i = 0, n-1 DO BEGIN
im = mrdfits(file+'raw_test/'+string(filenames[i]+'.fits'),1,head )
arrayend=n_elements(im.BARYTIME)-1
all_barytimes[i,0:arrayend] = im.BARYTIME
all_normflux[i,0:arrayend] = im.AP_CORR_FLUX
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: "gridPositions" not work correct with "Z" device?
Next Topic: Latitude longitude and Image Navigation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:19:20 PDT 2025

Total time taken to generate the page: 0.00226 seconds