Status: offline
Registered: 11/28/2006
Posts: 21
|
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
let set=$set+1
cname=coord.dat
imout=$set"_imcat"
coords="imagecur="$cname
log="logfile="$imout
cmd=$(echo $iname $coords use_display-)
imexam.cl $cmd > $imoutwhere imexam.cl is:
a whole mess of stuff from login.cl; packages to load, etc.
then, {
set clobber=yes
printf ("imexam %s\n",args) | cl()
logout
}
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
do
.
.
done < name of file listeverthing 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?
Thanks
Jim
|
Status: offline
Registered: 11/28/2006
Posts: 21
|
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,
Jim
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
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.[code:1:7df84c74e9]
/iraf/iraf/bin.linux/x_images.e -d /dev/null imexamine ......
[/code:1:7df84c74e9]where the '-d /dev/null' says to run as a detached (i.e. background) process. Using the sort of script you have the task is still reading from the parent CL process as a connected subprocess.I'd also suggest you have a look at the notes on writing host-level CL scripts, this may do what you as well:http://iraf.noao.edu/iraf/web/new_stuff/cl_host.html
|