Hi,
I would like to iterate over all the cards in the header of an HDU for use in my own tool developed in Rust. From what I can tell the current rust-fitsio API assumes prior knowledge of all header keyword names, something I would like to avoid.
I did not find this in the list of features documented in issue #15.
Iterating over the cards is possible by using fits_get_hdrspace for finding out the total number of cards and then retrieve them by number through fits_read_record or fits_read_keyn, as indicated in section 5.4.1 of the cfitsio documentation.
I have taken a first stab at this, but before creating a PR that respects the contributing guidelines, it would be great if you could provide some initial feedback, specfically:
- Does support for iterating over the header cards in an HDU seem like a reasonable addition to the API?
- In my first attempt I introduced a Card struct to conveniently hold the card data. Given that cards in the Rust
fitsio API are implements as key/value and key / (value, comment) it may be preferable to use tuples, what would you suggest?
- Assuming Cards are a "go", a better idea could be to read the entire card record into one array (using
ffgrec) and use slices to reference the right section in the buffer. (Being a Rust neophyte, I thought the approach of using individual buffers (and ffgkyn) was easier...)
Best regards,
Chris
Hi,
I would like to iterate over all the cards in the header of an HDU for use in my own tool developed in Rust. From what I can tell the current
rust-fitsioAPI assumes prior knowledge of all header keyword names, something I would like to avoid.I did not find this in the list of features documented in issue #15.
Iterating over the cards is possible by using
fits_get_hdrspacefor finding out the total number of cards and then retrieve them by number throughfits_read_recordorfits_read_keyn, as indicated in section 5.4.1 of the cfitsio documentation.I have taken a first stab at this, but before creating a PR that respects the contributing guidelines, it would be great if you could provide some initial feedback, specfically:
fitsioAPI are implements as key/value and key / (value, comment) it may be preferable to use tuples, what would you suggest?ffgrec) and use slices to reference the right section in the buffer. (Being a Rust neophyte, I thought the approach of using individual buffers (andffgkyn) was easier...)Best regards,
Chris