View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Documents on CL language and scripting

Andrew Staunton wrote on Nov 20, 2010

Hi all

I am attempting to learn scripting in IRAF and as a first project I want to create a script that when presented with a set of flat, bias and science frames will group them, process the bias and flats and then apply them to science frames and finally coadd the reduced science frames.

I was hoping that someone could recommend the most up-to-date documentation available on both the CL language and scripting. For example "A User's introduction to the IRAF Command Language" recommends reading "CL Programmer's Guide" for more information on scripting but I believe this was written for IRAF v1.0 and so perhaps much of it is obselete?
To sum up, my question is what documents provide the most recent syntax and methods etc for both the command language and scripting?

Also if someone could advise me on where I can download sample scripts for studying, that would also be helpful.

Thanks

Andrew

Mike Fitzpatrick wrote on Nov 20, 2010

What you see is the (unfortunately) most recent documentation we have. I would recommend you read the 'Introductory CL Script Programmer's Guide' (http://iraf.net/irafdocs/script/), there are also various user-written tutorials and intro guides available from a Google search. As for example programs....roughly half the tasks in the system are script tasks so you can browse almost any package to find examples. If you have specific questions about how to do something just post it here.

Andrew Staunton wrote on Nov 20, 2010

Thanks for your reply

Can you please tell me how to use the "grep" task within a script?
I find it easiest to insert tasks into a script using mkscript however I am not able to do this with grep, I think the reason being that eparam cannot be used on grep..

I want grep for the following type of operation:
imhead *.fits long+ | grep <whatever keyword> | sort | unique

Mike Fitzpatrick wrote on Nov 20, 2010

'Grep' is a so-called foreign command, i.e. a host command declared for use in the system but without iraf parameters. Within a script the syntax for using it is the same as for any other command, but foreign commands can't be used from MKSCRIPT (just edit it in by hand).


I want grep for the following type of operation:
imhead *.fits long+ | grep <whatever keyword> | sort | unique


The task you want is HSELECT, see the help page.

Andrew Staunton wrote on Nov 20, 2010

Thanks -

I am still unable to get it working..the relevant line from the script is:

imheader ("@all.txt",imlist="*.imh,*.fits,*.pl,*.qp,*.hhh", longheader=yes,
userfields=yes) |grep IMAGETYP | sort (column=0, ignore_white=no, numeric_sort=no,
reverse_sort=no) | unique(>"unique.txt" )

where all.txt as a list of fits files.

it works if I remove the grep part (it inserts a unique instance of everything into unique.txt) of course i want grep so only one instance of certain keyword value is added to unique.txt.

when I try it with grep as in the above example and also putting IMAGETYP in parentheses - it does not work. without parentheses, the CL freezes and I have to use ctrl-c to exit and with parentheses the following is returned:
ERROR: parameter 'IMAGETYP' not found called as 'cl ()'

I'm sure it is a silly thing I am doing wrong, but I don't what it is!

Mike Fitzpatrick wrote on Nov 20, 2010

Try using

grep ("IMAGETYP")


The quotes are needed to keep the word IMAGETYP from being interpreted as a script variable.

Last post on Nov 20, 2010