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

Home » Public Forums » archive » Re: IDL 8.0 questions
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: IDL 8.0 questions [message #71814 is a reply to message #71813] Sun, 25 July 2010 12:11 Go to previous messageGo to previous message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Jul 25, 3:15 pm, Mike Potter <m...@orionsound.com> wrote:
> Thanks for the confirmation.  You know, I've been trying the things
> you suggested and in the past hour or so have been unable to get it to
> misbehave!  That is, it's working fine right now.  I have no clue as
> to why.  But note that in the line "% READFITS:  ERROR - Unable to
> locate file ts" note that, like in my case, the two characters
> remaining are the last two in the file name.  My files are ".fit" so I
> was getting "it" as the remaining characters after going to
> readfits().

Indeed. And I confirmed it is not readfits()'s fault, as I found where
filename gets changed. In my version, it is in line 251 of readfits:

ext = strlowcase(strmid(filename,len-3,3))

I found it to be strmid that causes the problem. When I put a
breakpoint in that line:

% Breakpoint at: READFITS 251 /software/idl/idlastro/pro/
readfits.pro
IDL> help,filename
FILENAME STRING = 'dec18i0001.fits'
IDL> help,filename,strmid(filename,len-3,3)
FILENAME STRING = 'its'
<Expression> STRING = 'its'

So I made a much simpler test case that manifests the bug:

IDL> s='abc_'+strtrim(sindgen(2),2)
IDL> for i=0,n_elements(s)-1 do help,i,s[i],strmid(s[i],0,1)
I INT = 0
<Expression> STRING = 'abc_0'
<Expression> STRING = 'a'
I INT = 1
<Expression> STRING = 'abc_1'
<Expression> STRING = 'a'

So far, all is well. But:

IDL> foreach el,s,i do help,i,el,strmid(el,0,1)
I LONG = 0
EL STRING = 'a'
<Expression> STRING = 'a'
I LONG = 1
EL STRING = 'a'
<Expression> STRING = 'a'

So el is getting changed, it is receiving the output of strmid.

To make things more confusing, a print to el makes the problem go
away:

IDL> foreach el,s,i do begin & print,i,':',el & help,i,strmid(el,
0,1),el & endforeach
0:abc_0
I LONG = 0
<Expression> STRING = 'a'
EL STRING = 'abc_0'
1:abc_1
I LONG = 1
<Expression> STRING = 'a'
EL STRING = 'abc_1'


And to show that is is not just a case of strmid putting its output
into its input variable (which could not happen in the array element
in the for loop, since it is passed by value):

IDL> a='abcd'
IDL> help,strmid(a,0,1)
<Expression> STRING = 'a'
IDL> help,a
A STRING = 'abcd'

Maybe el is getting one of its metadata fields wrong when it is
created?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Writing in IDL at the same line in the screen
Next Topic: Extract pixel values from HDF-EOS file

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

Current Time: Sat Oct 11 15:07:28 PDT 2025

Total time taken to generate the page: 0.40302 seconds