Oops... yes now I remember! I forgot how brilliant Astro::FITS::Header is!  But 
my 1990's hack worked :)

- Karl


> On 29 Apr 2017, at 9:13 pm, Craig DeForest <[email protected]> wrote:
> 
> rfits and edits have two branches each: one that uses Astro::FITS::Header and 
> one that doesn't.  If Astro::FITS::Header is installed it *should* support 
> duplicate fields and multiple lines as you want -- though  there are some 
> gotchas (A::F::H merges COMMENT fields into one block in the output, for 
> example).  
> 
> A::F::H turns multiple COMMENT cards into a single multi-line string in a 
> single COMMENT hash field, on read.  On write the string is broken back up 
> into COMMENT cards.  Same for HISTORY..  You can achieve finer granularity of 
> control using the non-tied interface: with A::F::H installed the hashref used 
> as your PDL's header field is a pointer to the tied hash, and you can back 
> out the underlying object in the usual way (with the "tied" operator).
> 
> It sounds as if you might be using the legacy interface that uses Perl hashes 
> alone...?
> 
> 
> (Mobile)
> 
>> On Apr 29, 2017, at 12:54 AM, Karl Glazebrook <[email protected]> wrote:
>> 
>> Yes, the FITS standard allows these particular special case duplicate 
>> fields, but the PDL FITS readers has never supported them. It was done by 
>> hashes and of course hashes can only have one key. I imagine to get what you 
>> want you would have to modify Astro::FITS::Header either with special code 
>> our to use  Tie::DxHash (which is probably overkill)
>> 
>> Karl
>> 
>> 
>>> On 29 Apr 2017, at 3:20 am, ejm <[email protected]> wrote:
>>> 
>>> Hi all,
>>> 
>>> I have a question about PDL::IO::FITS and in particular the methods hdr & 
>>> gethdr.
>>> 
>>> I've got a Moose script that works fine with PDL::IO::FITS and adds fine 
>>> the usual FITS fields to a FITS 
>>> header. The resulting FITS file is read fine by SAOImage and the FITS 
>>> fields are in the order I want.
>>> 
>>> The problem is with fields that are potential duplicates such as COMMENT 
>>> and HISTORY.
>>> 
>>> I noticed that PDL::IO::FITS doesn't make use of Tie::DxHash which 
>>> specifically handles duplicate keys in tied hashes. Nor does 
>>> Astro::FITS::Header.
>>> 
>>> I also don't see exported in PDL::IO::FITS the methods insert or index from 
>>> Astro::FITS::Header which might be the right methods to call for adding 
>>> COMMENT fields.
>>> 
>>> When I create a tied hash using Tie::DxHash and copy over the data returned 
>>> by gethdr, I get a tied hash with duplicate COMMENT fields in the order I 
>>> want.
>>> 
>>> I then save the resultant updated FITS header hash using sethdr.
>>> 
>>> But when I view the FITS file in SAOImage for example I see the added 
>>> fields in alphabetical order, not the tied order they were saved in. I also 
>>> don't see any COMMENT fields.
>>> 
>>> If I don't use Tie::DxHash, but just add the COMMENT field directly to the 
>>> tied hash returned by gethdr, I get only 1 COMMENT field in the header, 
>>> with the last value assigned to it, which makes sense since Tie::DxHash 
>>> isn't being used. Hence no duplicate keys allowed.
>>> 
>>> What is the recommended way to add multiple COMMENT fields using 
>>> PDL::IO::FITS ?
>>> 
>>> Thanks, 
>>> 
>>> --Ed
>>> 
>>> 
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> _______________________________________________
>>> pdl-general mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/pdl-general
>> 
>> 
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> pdl-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/pdl-general
>> 
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to