Welcome to iraf.net Tuesday, May 21 2024 @ 06:28 PM GMT


 Forum Index > Help Desk > Applications New Topic Post Reply
 programming nuances
   
Sean
 09/19/2007 02:22AM (Read 4402 times)  
+----
Newbie

Status: offline


Registered: 07/10/2007
Posts: 13
Hello,
I have been writing a procedure script to automatically reduce some optical data, and I have a few questions about the iraf programming language which don't seem to be addressed in "An Introductory Guide to IRAF Scripts". First of all, I have many coordinate files (text files) that I would like to input into psfmeasure. However, not all of the coordinate files necessarily have coordinates in them (some are blank because there was nothing in the frame of interest). So, I was wondering if there is an easy way of checking if a file is blank before inputting it into a task?
A related question is, is there a way of calling fscan on a file/parameter that is not stored as a list parameter? And finally, also kind of related, is there a way to manually define the scope of your variables in the iraf programming language? I know that it is not possible to define a list variable locally, but is there a way to access a global list variable from inside a local block of code without the list variable being included in the function call that creates the block?Thank you very much for your time.~Sean

 
Profile Email
 Quote
fitz
 09/19/2007 02:22AM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
[quote:6e8897e86b] So, I was wondering if there is an easy way of checking if a file is blank before inputting it into a task?[/quote:6e8897e86b]You might try the COUNT task, e.g. "count (filename) | scan (nlines)" and see whether 'nlines' is then zero.[quote:6e8897e86b]A related question is, is there a way of calling fscan on a file/parameter that is not stored as a list parameter? [/quote:6e8897e86b]If I understand your question correctly, then no. Could you elaborate on what you're trying to do?[quote:6e8897e86b]And finally, also kind of related, is there a way to manually define the scope of your variables in the iraf programming language? I know that it is not possible to define a list variable locally, but is there a way to access a global list variable from inside a local block of code without the list variable being included in the function call that creates the block? [/quote:6e8897e86b]Sort of. You can use package parameters or the CL 'list' parameter as a type of global variable and use it within the script, but within the script it isn't possible to define a local scope. Hope this helps.Cheers,
-Mike[/quote]

 
Profile Email
 Quote
Sean
 09/19/2007 02:22AM  
+----
Newbie

Status: offline


Registered: 07/10/2007
Posts: 13
That does help a bunch, thank you. I do have one more question, though (just came up). Contrary to what is says in the manual, the task psfmeasure prints the average fwhm at the end of its logfile. I have been redirecting the output from psfmeasure to a text file, and then using a while(fscan != EOF) style loop to try and get the last number (the average) out of the file. However, the loop always terminates before it gets there. Am I doing something wrong, or does psfmeasure print an EOF before the actual end of file? Is there some other way to get the last number from a file easily? I am trying to get that number for direct input into another task (phot).Thank you so very much
~Sean

 
Profile Email
 Quote
fitz
 09/19/2007 02:22AM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
It may just be your usage but you didn't post the code snippet. Are you scanning individual words or the entire line?In any case, a simpler method is to use the 'logfile' directly, e.g.[code:1:183ae9e577] match ("Average", "logfile") | fields ("STDIN", 9) | scan (avg_fwhm)[/code:1:183ae9e577]and the variable 'avg_fwhm' will have the value.Cheers,
-Mike

 
Profile Email
 Quote
Sean
 09/19/2007 02:22AM  
+----
Newbie

Status: offline


Registered: 07/10/2007
Posts: 13
I see what that code is supposed to do, but when I put it in, I get the message:
ERROR: Error in line specification
"match("Average", "log")|fields("STDIN",9)|scan(y)"Here is the code:
1:F0F9DB704D Formatted Code

procedure ulttask (filterlist)

string filterlist
struct *flist

begin
        struct line
        file coords
        flist = filterlist
        while(fscan(flist, line) != EOF)
        {
                i = 0
                coords = line//".coo.3"
                count(coords)|scan(i)
                if(i > 1)
                {
                        y = 0
                        psfmeasure.imagecur = coords
                        psfmeasure(line)
                        match("Average","log")|fields("STDIN",9)|scan(y)
                        photpars.aperture = y
                        datapars.fwhmpsf = y
                        phot.image = line
                        phot(mode='h')
                        delete("log")
                }
                else
                {
                        print("No PSF for ",line, >> "errors.txt")
                }
        }
end
[/code:1:f0f9db704d]

I think this is somehow related to the other problem.  Maybe psfmeasure isn't storing its files correctly?

~Sean

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