View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Problem with for loop

ofwolf42 wrote on Dec 24, 2010

Hi, I'm new to the forums and fairly new to IRAF as well. I'm using it for a college project and I'm trying to set up a basic script to find the pixel position of a source on a series of fit images.

I've set up a for loop that essentially looks like this:
{ for(i=1; i<10; i+=1)
{ 
s1= "0"//i
s2= s1//".fit"
minmax s2 >> data.txt
}}


To my knowledge this should get the min and max positions of a series of images with the names: "01.fit", "02.fit", "03.fit" etc and output the information to data.txt.
But each time I run the for loop it says "Warning: could not open image (s2)" Whereas when I replace the minmax call with print(s2) it ouputs the file names perfectly. There must be some basic syntax error I'm making but I don't know what it is.

Also I will point out that the file names do exist, I can call them outside the for loop with out issue.

Any help would be greatly appreciated, thank you

Mike Fitzpatrick wrote on Dec 24, 2010

Your last line needs to be written in "program mode" so the script variables aren't confused with literal names, e.g.

minmax (s2, >> "data.txt")


Note the literal name 'data.txt' needs to be quoted. You can also just combine all the concatenation operators as needed, e.g.

minmax ("0"//i//".fit", >> "data.txt")

ofwolf42 wrote on Dec 24, 2010

That worked perfectly! Thank you, fitz! But I just looked at the data.txt file and for some outputs it had given the value of the min and max for the image but not the pixel position of these values, which is what I need. Any idea what would cause this?

Mike Fitzpatrick wrote on Dec 24, 2010

Try turning on the 'force' parameter (e.g. "force=yes" or "force+" in the argument list), some image may already have min/max keywords defined as a result of processing.

ofwolf42 wrote on Dec 24, 2010

Again, worked perfectly. Thank you so much fitz! You saved me a lot of time and effort.

Last post on Dec 24, 2010