[AstroPy] Re: HIERARCH

Joe Harrington jh at oobleck.astro.cornell.edu
Wed Mar 30 16:15:49 CST 2005


>We had a case that there were tens of thousands keywords and that forced 
>us to come up with a more efficient but somewhat limiting scheme.

I'm a bit worried that you're so quick to abandon maintainable and
extensible code for efficiency, given just one pathological case.
Since HIERARCH is used by all ESO headers, we lose a substantial
fraction of European astronomers if we don't support it.  FITS is such
a broken standard that it's going to be possible to construct FITS
files that are hard or slow to process.  For those cases, the user is
advised try a better format, like HDF.

> I am confident that if we just 
> implement the read, someone else will come around and ask for the
> write.

Perhaps.  So give them a simple string write.  It should be equally
easy to implement.  The hard thing is to actually implement a data
structure read/write from the hierarchy, with all the elements typed
correctly, and then more functions to parse and get info out of that.
But, relatively few people will want to do that, compared to the many
(thousands?) like me who just want to get and set individual values in
the header, and who are happy giving the whole HIERARCH ESO... string
as a keyword.

Mind you I don't object to your implementing the whole thing, but
implementing even just a stop-gap read in the very near future is
important if we want to get Europeans to use Python.  Perhaps ESO
could be contacted to provide code to support their keywords.  If you
publicize the need, someone who needs the capability will step
forward.  Use the open source development model to your advantage.

>But shouldn't the "keyword" in this 
>be "ESO TEL AIRM START" without the "HIERARCH" (or maybe even without 
>the "ESO")?

I don't care, I just wanna read the sucker so I can analyze my
data. ;-) I'm playing a little naiive here, but that's the user
perspective.  I'd *rather* deal with these keywords as single strings
that give me one value back, instead of extracting a large data
structure and addressing it in an OO way.  OO notation is cumbersome
to type interactively.

In sxpar, I implemented it as a single long keyword string.  I had to
special-case the regex to allow only max-8-char keywords and HIERARCH
keywords, plus COMMENT, HISTORY, END, and 8 blanks.  But, it was all
done in one regex.  Here's the code to read all the keywords in the
header, sans trailing spaces or equals, and without loops:

        keyword = stregex(hdr[mn:mx], /extract, /subexpr, $
'^(........)=|^(HIERARCH[^=]*)|^(COMMENT )|^(HISTORY )|(^        )|(^END     )')
        keyword = keyword[1:*, *]
        keyword = keyword[where(keyword ne '')]
        keyword = strtrim(keyword)

Then, you just search for a keyword that matches your string, pull the
matching line from the header, and parse the value.

--jh--



More information about the AstroPy mailing list