Unwanted prompt for list-directed parameter
JanRap wrote on Jun 01, 2010
Hi
I am suddenly getting prompts for my list-directed structs. Does this have anything to do with the tasks being in a package? Below is the relevant code:
When running main the following happens:
$wium> main
file containing filenames of FITS frames (list.txt):
imagenames_list: <---- NOO, WHY?
list.txt contains the name of one FITS frame and the file + the frame itself is in the same directory as the main task. The task definition in the extern.pkg file reads:
and wium.cl contains:
Thanks in advance for any help.
-Daniel
I am suddenly getting prompts for my list-directed structs. Does this have anything to do with the tasks being in a package? Below is the relevant code:
# The main task for the pipeline, from which
# other tasks are called
procedure main (imagenames)
# PROMPTS #
string imagenames {prompt="file containing filenames of FITS frames"}
#---------#
# LIST-DIRECTED STRUCTS #
struct *imagenames_list
#-----------------------#
begin
# DECLARATIONS #
string dummy, filename
#--------------#
imagenames_list = imagenames
dummy = fscan(imagenames_list, filename)
display(filename,1)
end
When running main the following happens:
$wium> main
file containing filenames of FITS frames (list.txt):
imagenames_list: <---- NOO, WHY?
list.txt contains the name of one FITS frame and the file + the frame itself is in the same directory as the main task. The task definition in the extern.pkg file reads:
reset wium = /iraf/extern/wium/
task $wium.pkg = wium$wium.cland wium.cl contains:
# Package script task for WIUM package
# Load the neccesary packages
noao
astutil
imred
ccdred
ccdtest
vtel
digiphot
daophot
photcal
ptools
obsutil
images
imutil
set wium = "/iraf/extern/wium/"
package $wium # Define package
task main = "wium$main.cl"
task prepare = "wium$prepare.cl"
task do_daoedit = "wium$do_daoedit.cl"
task getsources = "wium$getsources.cl"
clbye()Thanks in advance for any help.
-Daniel
Mike Fitzpatrick wrote on Jun 01, 2010
Basically you get the list prompt when there's nothing that can be read from the file. If I had to guess, I'd say 'list.txt' is in the directory where the script lives, but isn't in the directory where you're running the task.
JanRap wrote on Jun 01, 2010
Thanks. "list.txt" was in the correct folder. I simply ran the main task again and didn't get the prompt (I must be going crazy :shock: ) However, I immediately ran into another problem. I am calling another task, getsources, which is in the same package, from the 'main' task. First I got the "Error: Cannot read paramater file..." error I asked about last week, so I added a "$" in front of the task definition for getsources in wium.cl. That works fine. However, in the next line, when I try to access a variable declared in getsources (getsources.daoeditfile), I get "Error: task 'getsources' has no param file". Here's the code:
- Daniel
# The main task for the pipeline, from which
# other tasks are called
procedure main (imagenames)
# PROMPTS #
string imagenames {prompt="file containing filenames of FITS frames"}
#---------#
# LIST-DIRECTED STRUCTS #
struct *imagenames_list
#-----------------------#
begin
# DECLARATIONS #
string dummy, filename
#--------------#
imagenames_list = imagenames # Makes the list of image names list-directed
dummy = fscan(imagenames_list, filename) # Assigns the first image name to filename
display(filename,1) # Displays the frame with name filename in ds9
getsources()
print (getsources.daoeditfile)
endprocedure getsources()
begin
string wcs, key, command, sourcefile, daoeditfile
real x, y
sourcefile = mktemp("tmp$source") # Prepares the file containing the sources of interest
daoeditfile = mktemp("tmp$daoedit") # Prepares the daoedit.icommands file
while (fscan (imcur, x, y, wcs, command) != EOF)
{
key = substr (command, 1, 1)
if ((key == "t") || (key == "c") || (key == "s"))
{
print(x," ",y," ",wcs," ",command, >> sourcefile)
print(x," ",y," ",wcs," ","a", >> daoeditfile)
}
else if (key == "q")
break
else
beep
}
end- Daniel
Mike Fitzpatrick wrote on Jun 01, 2010
Since your getsources() task has no parameters (i.e. nothing declared in the procedure statement or before the 'begin'), declaring it with the '$' is the correct thing to do.
However, the 'getsources.daoeditfile' is the syntax used to reference a parameter of the given task, it cannot be used to access a variable in the script (which no longer exists once the task completes anyway). You'll need to save the value to a parameter (and then declare without the '$') in order to access it from another script.
However, the 'getsources.daoeditfile' is the syntax used to reference a parameter of the given task, it cannot be used to access a variable in the script (which no longer exists once the task completes anyway). You'll need to save the value to a parameter (and then declare without the '$') in order to access it from another script.
JanRap wrote on Jun 01, 2010
Thank you. I should have known that :oops: I struggled a bit and finally got it working yesterday. Unfortunately I decided to change the name of the 'daoeditfile' variable/parameter, and got an error. I then changed it back to the way it was when it worked, and got the same error. Unlearning the parameters for the tasks involved didn't fix it either. Below is the code and the error message:
$wium> main
file containing filenames of FITS frames (list.txt):
z1=2325.564 z2=8213.384
ERROR: Required parameter 'daoeditfile' not defined.
"getsources(sourcefile,daoeditfile)"
line 31: wium$main.cl
called as: 'main ()'
$wium>
# The main task for the pipeline, from which
# other tasks are called
procedure main (imagenames)
# PARAMETER DECLARATIONS #
string imagenames {prompt="file containing filenames of FITS frames"}
# LIST-DIRECTED STRUCTS #
struct *imagenames_list
#-------------------------------------------------------#
begin
# VARIABLE DECLARATIONS #
string dummy, filename, sourcefile, daoeditfile
#-------------------------------------------------------#
imagenames_list = imagenames # Makes the list of image names list-directed
dummy = fscan(imagenames_list, filename) # Assigns first image name to filename
display(filename,1) # Displays the frame with name filename in ds9
sourcefile = mktemp("tmp$source")
daoeditfile = mktemp("tmp$daoedit")
getsources(sourcefile,daoeditfile)
daoedit.icommands = daoeditfile
#-------------------------------------------------------#
# DELETE TEMPORARY FILES #
delete(sourcefile, ver-, >& "dev$null")
delete(daoeditfile, ver-, >& "dev$null")
end
# Task getsources allows the user to select
# sources of interest through ds9 and to
# assign a flag to each one, indicating whether
# it is a target, comparison or standard. In
# the 'daoeditfile', the flags are replaced
# with an 'a', allowing this file to be passed
# to daoedit.icommands
procedure getsources(sourcefile,daoeditfile)
begin
# VARIABLE DECLARATIONS #
string wcs, key, command
real x, y
#----------------------------------------------------------#
while (fscan (imcur, x, y, wcs, command) != EOF)
{
key = substr (command, 1, 1)
if ((key == "t") || (key == "c") || (key == "s"))
{
print(x," ",y," ",wcs," ",command, >> sourcefile)
print(x," ",y," ",wcs," ","a", >> daoeditfile)
}
else if (key == "q")
break
else
beep
}
end
$wium> main
file containing filenames of FITS frames (list.txt):
z1=2325.564 z2=8213.384
ERROR: Required parameter 'daoeditfile' not defined.
"getsources(sourcefile,daoeditfile)"
line 31: wium$main.cl
called as: 'main ()'
$wium>
Mike Fitzpatrick wrote on Jun 01, 2010
If you declare a script parameter, run the script, and then delete the parameter, the CL might still be using the parameter file from the uparm directory. You need to unlearn the task to reset the parameters. Anything declared in the procedure statement must be declared before the 'begin', your getsources script appears to be passing in parameters that aren't defined.
Last post on Jun 01, 2010