Posted: Wed Aug 29, 2012 11:32 pm Post subject: help with imexam script
I have a BASH script I have used for 1.5 years to use imexamine to find fluxes on images. The images are in one directory and are called in bash by a "for file in *fits" syntax. One at a time the ra & dec are converted to x,y coords and written to a file. Then a command variable is prepared by the code:
iname=image file name
cmd=$(echo $iname $coords use_display-)
imexam.cl $cmd > $imout
where imexam.cl is:
a whole mess of stuff from login.cl; packages to load, etc.
printf ("imexam %s\n",args) | cl()
This has worked for some time, and testing it today it still worked on the data for which it is intended.
However, I tried to make a small variation, in which I have a file containing a list of image names, these images all containing the object of interest. so basically all I did was change the way I get the image name. I used a
while read line
done < name of file list
everthing seems to work, the x,y coords are correctly computed and written to a file. However, the prog only reads the first file name, and computes the flux fine, over and over. If I disable the call to imexam.cl, all image names are read correctly for the file list and the coords all computed ok. Of course no fluxes, snice imexam is never called.
I am at a loss to understand this behavior. The original
code operated on multiple images in a serial manner. Somehow calling imexam fouls up reading the file list.
Anyone have any ideas?
I would like to post an addendum to my original msg. I copied several of the images in my list to a "working" directory. Instead of using the "while read line" syntax, I used the
"for line in *fits" syntax to get the file names.
Making this change only, the script ran perfectly. So in some way, the call to imexamin seems to interfere with the
"while read line" syntax,
This isn't really a bug, it is a funny interaction with the way the bash shell handles the stdin/stdout streams. Specifically what's happening is that on process-startup the IRAF main issues a F_CANCEL on the input stream to cancel any pending input coming from the CL (e.g. from an earlier interrupted task). The effectively causes a rewind on stdin when using the redirection in a bash shell.
When you run the binary directly you can workaround this by calling the task as e.g.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum