View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

String manipulation in IRAF

grayro wrote on Jan 20, 2017


Hi, I am having problems with some RA and DEC keywords in fxcor. fxcor wants the values to be delimited with colons, such as "12:30:56", but I have some spectra which have spaces instead: "12 30 56" and fxcor chokes on those. I want to be able to edit the header to correct those strings (by simple character replacement: replace " " with ":"), but I cannot find a string function in IRAF that will do that replacement. I could do this easily in "C", but do not see how to do this within IRAF. Can you help?

Richard

Mike Fitzpatrick wrote on Jan 20, 2017



You can wrap it up in a script to process lists of images, but the basic steps would make use of the 'sed' foreign command in something like:

hselect ("foo.fits", "RA", yes) | sed("-e 's/ /:/g'") | scan (s1)

hedit ("foo.fits", "RA", s1, update+, verify-)

and then the same for the 'DEC" keyword. Unfortunately there isn't a string replacement function built directly into any of the header tasks.

Last post on Jan 20, 2017