Skip to content

wcs_project FITS header not updated #648

@mdecleir

Description

@mdecleir

Hi,

I am using wcs_project from ccdproc to reproject an image to another one (in order to make them the same size).

First, I make a CCDData object from a numpy array (data) and a header:

from ccdproc import wcs_project, CCDData
data_ccd = CCDData(data,header=header,unit="count",wcs=wcs.WCS(header).celestial)

Then, I reproject the CCDData object to a different wcs (from another image) and write the new CCDData object to a FITS file:

new = wcs_project(data_ccd,wcs.WCS(ref_header).celestial)
new.write("test.fits")

This file indeed has the correct WCS information and the header is updated accordingly.
However, if I print a keyword from the header of the new CCDData object, this keyword value is still the same as the old value and has not been updated, e.g.:

print(data_ccd.header['CRVAL1'])
24.208266
print(ref_header['CRVAL1'])
24.222459
print(new.header['CRVAL1'])
24.208266

I would expect the new header to return the new CRVAL1 value, which is 24.222459. Instead it returns the original value, which I don't understand.
However:

hdu = fits.open("test.fits")
print(hdu[0].header['CRVAL1'])
24.222459

I am puzzled why writing the CCDData object to a FITS file updates the header, while the header is not updated just before writing the FITS file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions