View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Sexagesimal format conversion ?

Linas Petras wrote on Apr 20, 2009

I have some FITS image files that have their RA and DEC keywords in a format that IRAF tasks do recognize as being in sexagesimal format and wondered if their was a task that would take the string and convert it back to one that is understood by IRAF.

I could do this with HEDIT I suppose (reading and converting by hand) but I was after something that I could run for a script..

The format is "HH MM SS.SSS" for RA and "+/-DD MM SS.SS" for DEC .

Any suggestions welcome..

Linas

Mike Fitzpatrick wrote on Apr 20, 2009

The good news is that changes have already been made for the next release to allow sexagesimal formats such as you describe to be recognized automatically. Since this is in a core procedure you'd need a complete set of new binaries to take advantage of it so I haven't got a quick patch you could use.

Until then, all the pieces you need to script a fix are already in place: HSELECT to get the value, the trim() and TR to edit the string and HEDIT to replace the value. For example,


hselect ("foo.fits", "RA", yes) | scan (line)
print (trim(line)) | tr ("STDIN", " ", ":") | scan (s1)
hedit ("foo.fits", "RA", s1)


The 'line' and 's1' are builtin script variables, trim() removes leading/trailing whitespace and so the TR will replace the spaces only within the sexagesimal value. A quick procedure script could be writen to loop over a list of images and automatically change the RA/DEC keywords.

-Mike

Linas Petras wrote on Apr 20, 2009

Hi Mike,

Many thanks for the tip and looking forward to the new release :D

Linas

Last post on Apr 20, 2009