Submit a Story  :  IRAF Links  :  Past Polls  :  Calendar  :  Advanced Search  
     iraf.net
FAQ
 Forum FAQForum FAQ   Forum SearchForum Search   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help with imexam script

 
Post new topic   Reply to topic    iraf.net Forum Index -> Applications
View previous topic :: View next topic  
Author Message
jcadien1



Joined: 28 Nov 2006
Posts: 12

PostPosted: Wed Aug 29, 2012 11:32 pm    Post subject: help with imexam script Reply with quote

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 > $imout

where 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 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?
Thanks
Jim
Back to top
View user's profile Send private message
jcadien1



Joined: 28 Nov 2006
Posts: 12

PostPosted: Thu Aug 30, 2012 3:26 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
fitz
Site Admin


Joined: 30 Sep 2005
Posts: 3255
Location: Tucson

PostPosted: Fri Aug 31, 2012 2:31 am    Post subject: Reply with quote

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:

/iraf/iraf/bin.linux/x_images.e -d /dev/null imexamine ......


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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    iraf.net Forum Index -> Applications All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2009 phpBB Group
 Copyright © 2005-2011 iraf.net
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.10 seconds