acard |
06/21/2007 04:05PM (Read 6413 times)
|
|
|
Status: offline
Registered: 01/18/2007
Posts: 27
|
Hi, this is my problem:
I would like to write a script which allows me to use rimcursor, with the output in a file, different each time I use the script... (the script will do other operation too)
If I write, in command line:rimcursor > filenameit does work.
I want to do something like this, in the script:
[...]
string TABB = "" {prompt='the name of the output file'}
begin
[...]
rimcursor > TABB
[...]but in this way rimcursor creates the output named TABB, and doesn't use the filename I put as parameter... How to do??
|
|
|
|
fitz |
06/21/2007 04:05PM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
You need to use the "program mode" syntax, i.e. with the parenthesis. For example,[code:1:4bb5bfdc0f]
procedure rcur ()string curfile = "" { prompt="cursor filename" }begin
string fname # save param to local variable so we're not prompted each time
# we use it.
fname = curfile # Read image cursor, append result to filename. Delete existing
# file first.
if (access (fname) == yes)
delete (fname, verify-)
rimcursor (>> fname)
end
[/code:1:4bb5bfdc0f]Note the use of '>>' to append results instead of '>' that would overwrite.
-Mike
|
|
|
|
acard |
06/21/2007 04:05PM
|
|
|
Status: offline
Registered: 01/18/2007
Posts: 27
|
Perfect, now it works!!
Thanks a lot!
Only a doubt:
if I delete the file every time, why I use >> to append? I just create a new file every time... or not?
Also I have another question:
if I would like to execute a command outside iraf, but using a variable defined in iraf...?
for example:
I need to open an image in ds9 but I can't use 'disp' because i need the world coordinate, so I'm interested if exists something like this, in a script:[...]
string filename = "" {prompt = " the name of the file to be opened"}
[...]
!ds9 filename
[...]
|
|
|
|
fitz |
06/21/2007 04:05PM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
[quote:9ae02ea7f9]if I delete the file every time, why I use >> to append? I just create a new file every time... or not?[/quote:9ae02ea7f9]In this example, the '>>' isn't strictly needed. In real scripts however, you may be looping over multiple images and marking the same star in each image (so you'd delete the file before this loop). Anyway, it was just to point out the difference between > and >> for redirection[quote:9ae02ea7f9]
Also I have another question:
if I would like to execute a command outside iraf, but using a variable defined in iraf...?
for example:
I need to open an image in ds9 but I can't use 'disp' because i need the world coordinate, so I'm interested if exists something like this, in a script: [/quote:9ae02ea7f9]You could create a command string and pipe it to the CL for execution, e.g.[code:1:9ae02ea7f9]printf ("!ds9 %s &\n", filename) | cl()[/code:1:9ae02ea7f9]Note the '&' so it runs in the background and won't block the script.-Mike
|
|
|
|
acard |
06/21/2007 04:05PM
|
|
|
Status: offline
Registered: 01/18/2007
Posts: 27
|
Thank you very much!!!!
Exactly what I was looking for!!
Now I have just a little problem:
the script is faster than the ds9 startup...
in the script first I open the ds9 with the image to be loaded (if is it not open yet), and then I run rimcurs. But rimcurs try to work earlier, when the ds9 is not yet opened, so it gives me the error:ERROR: Cannot open device (node!imtool,,2048,2048)
called as: `rimcursor ()'How can I solve this problem? (Insterting a pause, how??)
|
|
|
|
fitz |
06/21/2007 04:05PM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
You can either start DS9 manually before running the script, or else use the sleep() command to wait a specified number of seconds, e.g.[code:1:dd14fc0307]
print ("ds9 &") | cl() # start ds9
sleep (5) # wait for it
rimcur( .....) # read the cursor
[/code:1:dd14fc0307]Just be sure the sleep is "long enough".....-Mike
|
|
|
|
acard |
06/21/2007 04:05PM
|
|
|
Status: offline
Registered: 01/18/2007
Posts: 27
|
Mike, you are the best!
|
|
|
|
Radom |
06/21/2007 04:05PM
|
|
|
Status: offline
Registered: 04/28/2007
Posts: 7
|
[quote:e96b1e2bbf="fitz"]You can either start DS9 manually before running the script, or else use the sleep() command to wait a specified number of seconds, e.g.[code:1:e96b1e2bbf]
print ("ds9 &") | cl() # start ds9
sleep (5) # wait for it
rimcur( .....) # read the cursor
[/code:1:e96b1e2bbf]Just be sure the sleep is "long enough".....-Mike[/quote:e96b1e2bbf]
I think I have similar problem. I want to edit some regions on image. I Load image and regions properly but I don't know how to edit them and save inside cl script. Is it possible?
|
|
|
|
fitz |
06/21/2007 04:05PM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
Could you say a little more about what kind of regions you're loading and what kind of editing? Tasks like IMEDIT and FIXPIX could be used to edit an image and would either use the display directly, or you could construct image sections using the cursor readback. Do you want to save the edited image, or the region, or both???-Mike
|
|
|
|
Radom |
06/21/2007 04:05PM
|
|
|
Status: offline
Registered: 04/28/2007
Posts: 7
|
NVMD I've write a walkaround. Thanks
|
|
|
|