gasdiaf |
02/06/2014 04:02AM (Read 2556 times)
|
|
|
Status: offline
Registered: 02/05/2014
Posts: 3
|
I am using the powerspec task, part of the STSDAS package, to create the power spectrum of several thousand images. Unfortunately, the powerspec task does not take file lists as a parameter and I can't use wildcards because I need output file names as well.
Referencing the "Introductory User's Guide to IRAF Scripts", I wrote a procedure script to run the powerspec task for every image in a file list. It is set up very similar to the example in the guide, but when I run it with the command
PHP Formatted Code bulkpowerspec @in .lis ,
I get the error:
PHP Formatted Code ERROR : may not convert string to other types
"ilist = images"
line 21: scripts $bulkpowerspec.cl
called as: `bulkpowerspec (@in .lis )'
I have tried making "images" a struct and "ilist" a string, but the same error persists. As far as I can tell, I am doing the same thing as the example. I know sometimes IRAF interprets input numbers as real and not string, so I made sure my file names had letters in them and the problem continued.
Any ideas on how to fix this issue? The problem line is "ilist = images".
The script is below:
PHP Formatted Code
procedure bulkpowerspec (images )
string images {prompt ="List of images to be used"}
struct *ilist
begin
int i
string img , outfile
# Make sure necessary packages are loaded
if (! defpac ("stsdas"))
stsdas
if (! defpac ("stsdas"))
bye
if (! defpac ("analysis"))
analysis
if (! defpac ("fourier"))
fourier
# Open the list of images and scan through it
ilist = images
while (fscan (ilist , img ) != EOF ) {
# Remove .fits extension
i = strlen (img )
if (substr (img , i -4, i ) == ".fits")
img = substr (img , 1, i -5)
# Create the output file name. This
# appears in the same directory as
# the input image.
outfile = img // ".power.fits"
# Take the power spectrum
if (access (img // ".fits")) {
powerspec (img // ".fits", outfile)
}
}
end
|
|
|
|
gasdiaf |
02/11/2014 01:24AM
|
|
|
Status: offline
Registered: 02/05/2014
Posts: 3
|
Just for reference, I was able to make it work using the code below. I use a temporary file to store the input image list and only use strings (rather than struct).
PHP Formatted Code procedure bulkpowerspec (images )
string images {prompt ="List of images to be used"}
string *list
begin
int i
string l_images , img , tmpfile, outfile
# Make sure necessary packages are loaded
if (! defpac ("stsdas"))
stsdas
if (! defpac ("stsdas"))
bye
if (! defpac ("analysis"))
analysis
if (! defpac ("fourier"))
fourier
# Create temp file with a list of image names
l_images = images
tmpfile = mktemp ("tmp$tmp")
sections (l_images , opt ="full", > tmpfile)
# Open the list of images and scan through it
list = tmpfile
while (fscan (list, img ) != EOF ) {
# Remove .fits extension
i = strlen (img )
if (substr (img , i -4, i ) == ".fits")
img = substr (img , 1, i -5)
# Create the output file name. This
# appears in the same directory as
# the input image.
outfile = img // ".power.fits"
# Take the power spectrum
if (access (img // ".fits")) {
powerspec (img // ".fits", outfile)
}
}
delete (tmpfile, ver -, >& "dev$null")
end
--Forrest
|
|
|
|
fitz |
02/11/2014 06:47PM
|
|
|
Status: offline
Registered: 09/30/2005
Posts: 4040
|
Sorry for overlooking this. To clarify what's happening, indeed a list-structured parameter is expecting the name of a file and not a string of values. Subsequent calls to fscan() on the list read individual lines in the file. Tasks like SECTIONS and FILES can be used to expand a string of names (comma delimited or an @-file).
I don't quite understand why you're seeing a type conversion error, I would have expected you to be prompted for the 'ilist' parameter value instead. Note that calling the script with 'in.lis' instead of '@in.lis' should also have worked.
|
|
|
|
| |
|