Re: Need Help Resolving ENDIF Errors [message #65536 is a reply to message #65535] |
Tue, 10 March 2009 14:21   |
ben.bighair
Messages: 221 Registered: April 2007
|
Senior Member |
|
|
On Mar 10, 4:41 pm, einszweil...@gmail.com wrote:
> On Mar 10, 3:38 pm, einszweil...@gmail.com wrote:
>
>
>
>> I'm trying to run a procedure in IDL. The procedure has a series of
>> IF LOOPS, each of minimal complexity - they are fairly simple.
>
>> For example:
>
>> XX=readfits('/home/kphil/img/img213.fits')
>> YY=readfits('/home/kphil/img/img213.fits', EXTEN_NO=1)
>> ZZ =YY
>
>> G = where(ZZ ne 0)
>> invarmap= ZZ * 0.0
>> invarmap[G] = (1./(ZZ[G])^2)
>
>> if ((where(XX ne XX))(0) ne -1) then begin
>> ZZ[where(XX ne XX)] = 0
>> XX[where(XX ne XX)] = 0
>> endif
Hi,
Do you really mean where(XX ne XX)? XX ne XX should give you and
array the size of XX filled with zeroes.
IDL> xx = INDGEN(10)
IDL> print, xx ne xx
0 0 0 0 0 0 0 0 0 0
I have no idea how to resolve the endif error or if the above is
related. However, in general (regardless of the comparison you are
making) you want to do the WHERE search just once.
index = WHERE(something NE somethingElse, count)
if (count NE 0) then begin
aThirdThing = ZZ[index]
endif
No point in searching your array repeatedly if you don't need to.
Ben
|
|
|