Welcome to iraf.net Monday, May 20 2024 @ 01:21 PM GMT


 Forum Index > Help Desk > Systems New Topic Post Reply
 Is this a memory ambush?
   
figueira
 01/19/2007 01:17PM (Read 8640 times)  
++---
Junior

Status: offline


Registered: 11/29/2006
Posts: 16
Hello to all!I'm creating an iraf package and I'm having a few problems when I use functions that summon other functions.I have a base function that uses 2 other functions. The first, called "test" receives 2 parameters and passes it to the others. The fist of these - "head_time" - uses one of the 2 and the second - "head_imtype" - uses both.
When the task is run and the 2 parameters are passed to the second function I get an error such as:
ERROR: too many positional arguments for `head_imtype'
"head_imtype(list_file, image_type)"
line 17: /Users/pedrofigueira/iraf/scripts/DRACS/test.cl
called as: `test (list_file=stuff.txt, image_type=object)'Oddly, there is nothing wrong with this file or parameters transmission. If I try to use it, it gives me the sange mesage. However, if I re-edit the file, add or remove a comment line, and redefine the function with the redefine command, the task is accepet again, working properly without errors. On the other hand, the first (internal) function cease to work.ERROR: parameter `list_all' not found
"flist=list_all"
line 16: /Users/pedrofigueira/iraf/scripts/DRACS/head_time.cl
called as: `head_time (list_file=stuff.txt)'
"head_time(list_file)"
line 16: /Users/pedrofigueira/iraf/scripts/DRACS/test.cl
called as: `test (list_file=stuff.txt, image_type=object)'It seems the same kind of error: a variable is no longer recognized. Thse seems to me some kind of memory ambush. What do you think? Please tell me your opinion.Now two minor, kid of "fancy" questions:- when I load my package, how can I make it display only the tasks of the package and not the tasks of other preloaded packages (that are required and thus have to be loaded)?
- how can I put the name of my task on the prompt instead of the last iraf package loaded?All the best and thank you for the go(o)d work.Yours truly,Pedro Figueira

 
Profile Email
 Quote
fitz
 01/19/2007 01:17PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Hi Pedro,Please post (or email me) the scripts in question. I can't tell for instance from your second error whether 'list_all' is supposed to be the 'list_file' parameter or is simply any uninitialized/undeclared variable. Remember that every variable appearing before the 'begin' statement in a procedure script is a parameter, those declared as argument in the procedure statement itself are "query parameter" you will be prompted for if they aren't supplied on the command line. I think this is more likely a minor scripting confusion than a memory corruption.As for your other questions: The CL prompt is always the last package loaded (the full name of the package in V2.13/ECL or the first 2-chars in earlier versions), you cannot change it as a user but simply typing your package name again should change the prompt when your package becomes the "current" package. Packages like STSDAS/TABLES have an 'motd' parameter you can set to turn off the welcome banner (see eg noao$digiphot/daophot.cl) but otherwise you shouldn't normally see package menus in the <package>.cl loading script. Could you post/send that as well?Cheers,
-Mike

 
Profile Email
 Quote
figueira
 01/19/2007 01:17PM  
++---
Junior

Status: offline


Registered: 11/29/2006
Posts: 16
First of all, thanks for the fast reply. You are correct, I do not fully understand all the trickeries of list redirections and I might have done something wrong. Note that in the scripts below I assign "list_file" to a string with the name of my list file. But what I found strange was that after the functions redefinition, they worked again...Well, here are the files.FILE: test.clprocedure test(list_file, image_type)#######################################################################
# start procedure with
# task test ="/Users/pedrofigueira/iraf/scripts/DRACS/test.cl"
#######################################################################string list_file
string image_type
struct* flistbegin
flist = list_file
head_time(list_file)
head_imtype(list_file, image_type)end
EOF
FILE: head_time.clprocedure head_time(list_all)
#######################################################################
# start procedure with
# task head_time ="/Users/pedrofigueira/iraf/scripts/DRACS/head_time.cl"
#######################################################################string list_all
struct* flistbegin
struct spectrum
string dum
real dit
real ndit

flist=list_all

while(fscan(flist, spectrum) != EOF) {
imhead (spectrum, longheader=yes) | match " DIT " | scan (dum,dum,dum,dum,dum, dit)
imhead (spectrum, longheader=yes) | match " NDIT " | scan (dum,dum,dum,dum,dum, ndit)
hedit (spectrum, "EXPTIME", (dit*ndit), add+, update+, show+, ver-)
hedit( spectrum, "MJD-N", '(int(@"MJD-OBS"))', add+, update+, show+, ver-)
}
end EOF
FILE: head_imtype.clprocedure head_imtype(list_file, image_type)################################################################################
# start procedure with
# task head_imtype ="/Users/pedrofigueira/iraf/scripts/DRACS/head_imtype.cl"
################################################################################string list_file
string image_type
struct* flistbegin
struct spectrum
string keyword

flist=list_file
keyword=image_type

while(fscan(flist, spectrum) != EOF) {
hedit (spectrum, "IMAGETYP", keyword, add+, update+, show+, ver-)
}
endEOF
and for the package questions, here is the package master file, named DRACS.clFILE: DRACS.cl# Package script task for the DRACS package# load of the requested packagesimages
imutil
noao
imred
ccdred
twodspec
longslit
specredtask $start_check ="/Users/pedrofigueira/iraf/scripts/DRACS/start_check.cl" # Header correction taskstask head_time ="/Users/pedrofigueira/iraf/scripts/DRACS/head_time.cl"
task head_imtype ="/Users/pedrofigueira/iraf/scripts/DRACS/head_imtype.cl"# Separation of images in different CCDstask slicer ="/Users/pedrofigueira/iraf/scripts/DRACS/slicer.cl"
task list_creator ="/Users/pedrofigueira/iraf/scripts/DRACS/list_creator.cl"# Phase 1 reduction: dark subtraction and flatfieldingtask proc_dark ="/Users/pedrofigueira/iraf/scripts/DRACS/proc_dark.cl"
task sub_dark ="/Users/pedrofigueira/iraf/scripts/DRACS/sub_dark.cl"
task proc_flat ="/Users/pedrofigueira/iraf/scripts/DRACS/proc_flat.cl"task trimmer ="/Users/pedrofigueira/iraf/scripts/DRACS/trimmer.cl" task test ="/Users/pedrofigueira/iraf/scripts/DRACS/test.cl" print("\n\tAnd the crowd goes wild...\n")clbye()
EOFWhen I load the package I get:ecl> dracs And the crowd goes wild... aidpars@ aptrace head_time sarith specshift
apall autoidentify identify scombine splot
apdefault@ background illumination scopy standard
apedit bplot list_creator sensfunc start_check
apfind calibrate lscombine setairmass sub_dark
apfit continuum msresp1d setjd telluric
apflatten deredden odcombine sfit test
apmask dispcor proc_dark sflip transform
apnormalize dofibers proc_flat skysub trimmer
aprecenter dopcor refspectra skytweak
apresize doslit reidentify slicer
apscatter fitprofs response slist
apsum head_imtype sapertures specplot specred> The prompt shows, specred, the last package loaded in the "dracs.cl" file. Thank you for the help!Pedro

 
Profile Email
 Quote
figueira
 01/19/2007 01:17PM  
++---
Junior

Status: offline


Registered: 11/29/2006
Posts: 16
Hello!I'm sorry to be so annoying but I didn't find any solution to my problem. However, I did a "cleaner" "test.cl" package that shows that the problem is not in the transfer of variables from one function to the other, at least in what concerns type problems. This means that the variables have the required type (string or list-oriented) and it can be proven by making the "test.cl" file call only one of the functions. It works perfectly. I am really puzzled.FILE: test.clprocedure test(list_file, image_type)#######################################################################
# start procedure with
# task test ="/Users/pedrofigueira/iraf/scripts/DRACS/test.cl"
#######################################################################string list_file
string image_typebegin
string list
string img_type

list = list_file
img_type = image_type

head_time(list)
head_imtype(list, img_type)endEOF
I really apreciate all help, comments, suggestions and workarounds.My best regards,Pedro Figueira

 
Profile Email
 Quote
fitz
 01/19/2007 01:17PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Hi Pedro,This indeed appears to be a bug, and one that is caused somehow by the use of underscores in the task name. As for a quick workaround, rename the tasks so they don't include the underscore. I suspect one of the task parameter lookup procedures isn't expecting the char and either using the params from head_time or overflowing a buffer or something.Anyway, let me know if the workaround still fails for you. I'll post a followup once I track down the bug. Thanks for the report!Cheers,
-Mike

 
Profile Email
 Quote
fitz
 01/19/2007 01:17PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Okay, so not a bug, but still obscure: What's happening is that the task name 'head_time' and 'head_imtype' are mapping to the same uparm filename, i.e. 'drshead_e.par' (a 3-char package made up of the first 2+last and the task made up of the first 5+last chars). When head_imtype is called the uparm file for the other task is seen and since it doesn't have the same parameters you get the error. This will happen with any two tasks in the same package where the mapping isn't unique, by removing the underscore earlier all I did was change the mapping. Note that you can also use the CACHE command to have the cl keep an in-memory cache of the params and this will also avoid the uparm problem.Cheers,
-Mike

 
Profile Email
 Quote
figueira
 01/19/2007 01:17PM  
++---
Junior

Status: offline


Registered: 11/29/2006
Posts: 16
Excellent, it's working! Thank you very much! I removed the underscores from the name of the functions and it's now working perfecly. Once again, Thank you very much.
Do you have any ideia about the package loading (minor) issue? If not, no problem at all. I noticed my help calls doesn't work and I think this migth be related. I followed the procedure presented in "An introductory User's Guide to IRAF Scripts", Anderson, 89, in order to create the help database.
Anyway, thanks for the excellent advices!"May the Gods follow your steps, may you follow theirs."Pedro Figueira

 
Profile Email
 Quote
fitz
 01/19/2007 01:17PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
Pedro,Sorry, forgot to answer this: Try declaring your package with a .pkg extension to shut up the package menus, e.g.[code:1:c061c72164]task foo.pkg = /path/foo.cl[/code:1:c061c72164]This sets an internal flag in the CL, otherwise it just executes as any other script. Also, it is traditional to have a 'package' statement in a package loading script, e.g. "package dracs" before you begin the task declarations.Cheers,
-Mike

 
Profile Email
 Quote
figueira
 01/19/2007 01:17PM  
++---
Junior

Status: offline


Registered: 11/29/2006
Posts: 16
Thank you! The menu problem is solved by including the "package name_of_package" statement. Even without the .pkg extension in the package declaration the prompt and menu display the right values.
I assume that the examples I followed, being rather incomplete, also led to the problems in the help file definitions I'm experiencing. However, I'll try to work this out by myself, I've been buzzing around for too long. If I cannot overcome this, I'll make a new post in a few days.My most sincere thanks and wishes of all the best to you,Pedro Figueira

 
Profile Email
 Quote
   
Content generated in: 0.39 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 
dog allergies remedies cialis 20 mg chilblain remedies


Privacy Policy
Terms of Use

User Functions

Login