View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Procedure script problem

smp wrote on Jul 28, 2008

hi,

I am writing a small procedure script. If I run the script
I get Error message. The message is given after the script below.

I want to get the mean of the image "fsele" (a variable, not image name)
and store it in variable "m".

(This part I have not added to script but want to add after the Error is
rectified: I want to divide the image "fsele" by this mean i.e. by
variable "m".)

---------------------------------------------------------------------
procedure swapnil (filename,select_file)

string filename {prompt="The list of images"}
string select_file {prompt="Image to be divided by its mean"}
struct *flist
struct *fsele

begin

real m
struct line

flist = filename
while (fscan(flist, line) != EOF)
print (line)

fsele = select_file

imstat(fsele,"m", >> stat.txt)

end

---------------------------------------------------------------
Command I had given:

im> task swapnil = swapnil.cl
im> swapnil
The list of images (images.txt):
bias_1.0.fits
bias_2.0.fits
bias_3.0.fits
Image to be divided by its mean (bias_2.0.fits):

ERROR on line 22: too many positional arguments for `imstatistics'
swapnil ()
swapnil ()

-----------------------------------------------------------------

Also, if I do "lpar swapnil" it shows:

im> lpar swapnil
filename = "images.txt" The list of images
select_file = "bias_2.0.fits" Image to be divided by its mean
(flist = "images.txt")
(fsele = "bias_2.0.fits")
(mode = "ql")

So required parameters are repeated as hidden parameters. I want to get
rid of this repetition.

---------------------------------------------------------------------

Please help me in this regard.

Thank You
Swapnil :D

Mike Fitzpatrick wrote on Jul 28, 2008


ERROR on line 22: too many positional arguments for `imstatistics'
swapnil ()
swapnil ()


The problem is that the system think the "m" argument is a parameter to the task. What you want to do is use IMSTAT to compute the means and store the result in the variable 'm', for example:


imstat (fsele, field="mean", format-) | scan (m)


Here the IMSTAT command computes the value for a specific field and prints it to the stdout, this is piped to the scan() to store it in the variable. Afterwards, you can use the variable 'm' as an argument to e,g. IMARITH to do the division.


Also, if I do "lpar swapnil" it shows:

im> lpar swapnil
filename = "images.txt" The list of images
select_file = "bias_2.0.fits" Image to be divided by its mean
(flist = "images.txt")
(fsele = "bias_2.0.fits")
(mode = "ql")

So required parameters are repeated as hidden parameters. I want to get
rid of this repetition.


Anything declared between the 'procedure' and 'begin' statements is considered to be a parameter, arguments in the procedure declaration are query params. Since the default mode is to learn the parameters, all you are seeing here is that after executing the script once the value of 'flist' has already been set. They do no harm, if you just don't want to see them you can use the CL builtin parameters 'list' (instead of 'flist') and one of the string parameters 's1', 's2', or 's3' for the filename.

Lastly, if you haven't already read it, I would recommend the CL Script Programmer's doc available at http://iraf.net/irafdocs/script/

Cheers,
-Mike[/quote]

smp wrote on Jul 28, 2008

hi Mike,

I changed my procedure script as you told:

-----------------------------------------------------------------------------------
procedure swapnil (filename,select_file)
string filename {prompt="The list of images"}
string select_file {prompt="Image to be divided by its mean"}
struct *flist
struct *fsele

begin
real m
struct line
flist = filename
while (fscan(flist, line) != EOF)
print (line)
fsele = select_file

imstat(fsele, fields="mean", format-) | scan(m)

end
-------------------------------------------------------------------------------------

Now if I run the script for the first time, following is displayed:

cl> task swapnil = swapnil.cl
cl> swapnil
The list of images: images.txt
bias_1.0.fits
bias_2.0.fits
bias_3.0.fits
Image to be divided by its mean: bias_2.0.fits
*** glibc detected *** /opt/iraf/iraf/bin.redhat/x_images.e: free(): invalid next size (normal): 0x0846a910 ***
======= Backtrace: =========
/lib/libc.so.6[0x8bef5d]
/lib/libc.so.6(cfree+0x90)[0x8c25b0]
/opt/iraf/iraf/bin.redhat/x_images.e[0x82a8f68]
/opt/iraf/iraf/bin.redhat/x_images.e[0x827cbb1]
/opt/iraf/iraf/bin.redhat/x_images.e[0x827cf43]
/opt/iraf/iraf/bin.redhat/x_images.e[0x82777d0]
/opt/iraf/iraf/bin.redhat/x_images.e[0x81cb51c]
/lib/libc.so.6(__libc_start_main+0xdc)[0x86edec]
/opt/iraf/iraf/bin.redhat/x_images.e(sinh+0x5d)[0x804a341]
======= Memory map: ========
004e8000-004f3000 r-xp 00000000 08:05 778218 /lib/libgcc_s-4.1.1-20070105.so.1
004f3000-004f4000 rwxp 0000a000 08:05 778218 /lib/libgcc_s-4.1.1-20070105.so.1
0083c000-00855000 r-xp 00000000 08:05 1073676 /lib/ld-2.5.so
00855000-00856000 r-xp 00018000 08:05 1073676 /lib/ld-2.5.so
00856000-00857000 rwxp 00019000 08:05 1073676 /lib/ld-2.5.so
00859000-00990000 r-xp 00000000 08:05 1069745 /lib/libc-2.5.so
00990000-00992000 r-xp 00137000 08:05 1069745 /lib/libc-2.5.so
00992000-00993000 rwxp 00139000 08:05 1069745 /lib/libc-2.5.so
00993000-00996000 rwxp 00993000 00:00 0
00998000-009bd000 r-xp 00000000 08:05 1069752 /lib/libm-2.5.so
009bd000-009be000 r-xp 00024000 08:05 1069752 /lib/libm-2.5.so
009be000-009bf000 rwxp 00025000 08:05 1069752 /lib/libm-2.5.so
08048000-082c0000 r-xp 00000000 08:05 2303589 /opt/iraf/irafbin/bin.redhat/x_images.e
082c0000-0830f000 rwxp 00277000 08:05 2303589 /opt/iraf/irafbin/bin.redhat/x_images.e
0830f000-0848b000 rwxp 0830f000 00:00 0 [heap]
55555000-55556000 rwxp 55555000 00:00 0
5557e000-5557f000 rwxp 5557e000 00:00 0
55600000-55621000 rwxp 55600000 00:00 0
55621000-55700000 ---p 55621000 00:00 0
ff985000-ff98a000 rwxp ff985000 00:00 0 [stack]
ffffe000-fffff000 r-xp ffffe000 00:00 0

At this stage, cl prompt did not appear; execution hanged. So I pressed ctrl+C. Then following message came:

PANIC in `/opt/iraf/iraf/bin.redhat/x_images.e': interrupt

Then I ran the script second time, then it showed following message:


----------------------------------------------------------------------
cl> swapnil
The list of images (images.txt):
bias_1.0.fits
bias_2.0.fits
bias_3.0.fits
Image to be divided by its mean (bias_2.0.fits):
ERROR on line 22: segmentation violation
swapnil ()
swapnil ()
------------------------------------------------------------------------

Please let me know how to resolve this.

Regards
Swapnil </div> --- *Last post on Jul 28, 2008*