Closed evgenyneu closed 5 years ago
This should be possible by opening the file in read-write mode, and then writing the image data to the appropriate extension. However, it is not currently possible. We need to create a new method write(::ImageHDU, ::Array)
to write to an existing Image HDU instead of creating a new one.
@kbarbary thank you, that's good to know. Can I attempt to submit a pull request with this addition?
That would be great! If you need a starting place, look at the write(::FITS, ::Array, ...)
method in image.jl
. the implementation should be similar, just without the creation of the new extension.
Fixed by #117
Is there a way to modify image data in a .fits file without touching anything else?
I have a .fits file that contains image data as well as several extensions (tables). I want to replace the image data while keeping everything else (headers/extensions etc.) unchanged. Is there a way to do it?
Right now, I'm creating a new file and copying all the extensions to it:
This is not ideal, because I'm not sure if the new file will be exactly the same as the old one (except for the changed image). I would prefer to just modify the image data. These are example of how this could be done in Python and Fortran.
Python example:
Fortran example (cfitsio):