Welcome to iraf.net Friday, May 03 2024 @ 07:35 AM GMT


 Forum Index > Help Desk > Applications New Topic Post Reply
 read & write in file
   
ranisb
 12/02/2008 11:55AM (Read 4508 times)  
++---
Junior

Status: offline


Registered: 05/26/2008
Posts: 17
Hi,
I am writing following procedure script.I have 3 science frames and one masterbias.this script will subtract biasmaster from each science frame and change file name "sci_bs_%d.fits and save in file 'objfile'.
The script is as following;
procedure trial(sciframes)
string sciframes {prompt = "images tobe reduce"}
struct *objlistbegin
int n
string objfile,filename,biasmaster
objlist = sciframes
biasmaster = "biasmaster.fits"
for (n=1;n<=3;n=n+1)
{
printf("sci_bs_%d.fits\n",n, > objfile)
}
objlist = objfile
while(fscan(objlist,filename) !=EOF)
{ print(filename) }
imarith(operand1=objlist,op="-",operand2=biasmaster,result="@"//objfile,verbose=no)
endBut it is giving following error,
cc> trial
images tobe reduce: sciimage_lis
ERROR on line 19: Attempt to access undefined local variable `objfile'.
trial ()
trial ()Where I am wrong? I would be thankful for any solution as I 'm pretty stuck.Regards,
Rani

 
Profile Email Website
 Quote
jturner
 12/02/2008 11:55AM  
+++++
Active Member

Status: offline


Registered: 12/29/2005
Posts: 165
When you do
[code:1:445f15eb13]printf("sci_bs_%d.fits\n",n, > objfile)[/code:1:445f15eb13]
the variable objfile hasn't actually been assigned a value (filename) yet, it has just been defined as a variable. Did you mean to declare it as a parameter?Cheers,James.

 
Profile Email
 Quote
ranisb
 12/02/2008 11:55AM  
++---
Junior

Status: offline


Registered: 05/26/2008
Posts: 17
Hi James,
you are right,I decleared 'objfile' as local string variable.
It will be great if you will give suggestions in my small script to get required output ,which I mention in my first post .
Frown
regards,
Rani

 
Profile Email Website
 Quote
ranisb
 12/02/2008 11:55AM  
++---
Junior

Status: offline


Registered: 05/26/2008
Posts: 17
hi,
Waiting for your reply and still didn't found any solution .
Cry
I am sending my small script which will subtract biasmaster from each science frame and change file name "sci_bs_%d.fits and save in file 'objfile'. procedure trial(sciframes)
string sciframes {prompt = "images tobe reduce"}
struct *objlist
#string objfile
begin
int n
string filename, biasmaster, objfile
# objlist = objfile
biasmaster = "biasmaster.fits"
for (n=1;n<=3;n=n+1)
{
printf("sci_bs_%d.fits\n",n, > "objfile")
}
objlist = objfile
while(fscan(objlist,filename) !=EOF)
{ print(filename) }
imarith(operand1=sciframes,op="-",operand2=biasmaster,result="@"//objfile,verbose=no)
end Kindly write me solutions as eraly as possible. Also if you have any suggestion to do this task, write to me.
Frown
Thanks and regards,
Rani

 
Profile Email Website
 Quote
jturner
 12/02/2008 11:55AM  
+++++
Active Member

Status: offline


Registered: 12/29/2005
Posts: 165
I think your problem is essentially the same as before. You are mixing up the variable name objfile with the filename "objfile". The value of the variable is still undefined when you do objlist = objfile. Maybe you meant to do objfile="objfile" somewhere?Cheers,James.

 
Profile Email
 Quote
ranisb
 12/02/2008 11:55AM  
++---
Junior

Status: offline


Registered: 05/26/2008
Posts: 17
thanks for reply
Now I am confused with this variable and parameter declaration
Confused
Can you please suggest me what changes should i do in my script which will subtract biasmaster from each science frame and change file name "sci_bs_%d.fits and save in file 'objfile'.
or do you have any other suggestion?
Please reply quick.regards,

 
Profile Email Website
 Quote
jturner
 12/02/2008 11:55AM  
+++++
Active Member

Status: offline


Registered: 12/29/2005
Posts: 165
Hi Rani,I don't really have time to write the script for you, but try putting [code:1:1aa0a412be]objfile="objfile"[/code:1:1aa0a412be] after the line 'biasmaster = "biasmaster.fits"' and remove the quotation marks around '"objfile"' in the printf statement.This will only work as written if you have 3 images, of course. To make it more general, you might want to count the number of images in the input list by adding something like
[code:1:1aa0a412be]l_sciframes = sciframes
files l_sciframes > "sciframelist"
[/code:1:1aa0a412be]
after ' biasmaster = "biasmaster.fits" and then using a "while(fscan..." like the one you already have to loop through the input images, instead of using the for loop over the output images with a fixed number of (3) iterations.You'll need to verify that this works, since I'm just looking at the code and commenting on it without trying it out. If you are still unsure about the CL syntax, there is an introduction to writing scripts here:https://iraf.net/irafdocs/script/Hope that helps.James.

 
Profile Email
 Quote
ranisb
 12/02/2008 11:55AM  
++---
Junior

Status: offline


Registered: 05/26/2008
Posts: 17
Dear James,Thank you very much for stolen time from your busy schedule ,for my script problem.I did the chages you suggested but still the following error occuring,
cc> trial4
ERROR on line 19: cannot open `objfile' for writing
trial4 ()
trial4 ()I am trying to resolve it.
I am greatly appreciated your help.Regards,
Rani

 
Profile Email Website
 Quote
jturner
 12/02/2008 11:55AM  
+++++
Active Member

Status: offline


Registered: 12/29/2005
Posts: 165
[quote:6666d10dc1="ranisb"]
ERROR on line 19: cannot open `objfile' for writing
trial4 ()
trial4 ()
[/quote:6666d10dc1]
Isn't that because objfile already exists? You have to delete it first.When I suggested doing "l_sciframes = sciframes" last time, I forgot to say to change "sciframes" to "l_sciframes" inside the imarith. Using "sciframes" just once in the script by copying it to a local variable prevents IRAF from prompting you for the variable several times if you haven't specified it on the command line.Cheers,James.

 
Profile Email
 Quote
   
Content generated in: 0.14 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