Feature #37
Support removing and updating of an existing HDU
Status: | In Progress | Start date: | 02/20/2012 | ||
---|---|---|---|---|---|
Priority: | Urgent | Due date: | |||
Assigned To: | Knödlseder Jürgen | % Done: | 50% | ||
Category: | - | ||||
Target version: | - | ||||
Duration: |
Description
The actual code does not support removing and updating of an existing HDU. Code should be added to implement this functionality.
Recurrence
No recurrence.
History
#1 Updated by Knödlseder Jürgen almost 13 years ago
- Priority changed from Normal to Low
#2 Updated by Knödlseder Jürgen about 11 years ago
- Assigned To set to Knödlseder Jürgen
- Priority changed from Low to Urgent
I stumbled over this again while implementing the GFits class as a container class. The container class now allows replacing for example an image by a table, the actual code does however not change the FITS file accordingly.
For example, replacing an image by a table leads to a status code of 235 when the number of columns is determined, saying that the HDU is not a table.
Some code is needed, probably at the level of GFits::save()
to handle this. The int fits_delete_hdu / ffdhdu (fitsfile *fptr, > int *hdutype, int *status)
function can be used to delete a HDU form a FITS file, moving all other headers forward. This means that a FITS file gets “scrambled” when selected HDUs are deleted.
- If any of the HDU may have changed, delete the file and save it from scratch. This is savest, but time and resource consuming
- Remove all HDUs that may have changed, re-attribute extension numbers, and save new HDUs at the end. This removes control from the client and may lead to a unclear structure of the FITS file
The first approach is thus favored. If any HDU has changed, delete the file and write it from scratch.
#3 Updated by Knödlseder Jürgen about 11 years ago
- Status changed from New to In Progress
- % Done changed from 0 to 50
The problem has been solved at least for HDU changes between images and tables.
In fact, cfitsio provides an insert function that allows insertion of an extension in a specific slot. By deleting a HDU in a given slot and inserting another HDU into this slot, the FITS file can be made compliant with the GFits structure and the order of the extension can be kept. This has been implemented and tested.
What is now missing (or at least should be tested) is the insertion or removal of columns.
In addition, it should be tested whether replacing one table against another works (there is a good chance that this is not operational).