MATLAB Answers

Copy header file from a fits image to a new one.

17 views (last 30 days)
Gaetano Zarcone
Gaetano Zarcone on 21 Jan 2020
Hello everybody.
I have a problem with fits header file. In particular, after I read my fits image, maipulate it and so on I woul'd like to save the new image in a new fits file but with the header of the original one. Is it possible to copy the old header in the new image?
fitswrite(img_corr,'img_corr.fits'); % image modified
import matlab.io.*
Y = fits.openFile('SAT.00022692.fit','readwrite');
Z = fits.openFile('img_corr.fits','readwrite');
% Z = fits.createFile('img_corr.fits');
info = fitsinfo('SAT.00022692.fit');
header = info.PrimaryData.Keywords;
[r1,c1] = size(header);
for i = 1:r1
fits.writeKey(Z,header{i,1},header{i,2},header{i,3}); %keyname,value,comment
end
% fits.copyHDU(Y,Z);
% fits.movAbsHDU(Y,1);
fits.closeFile(Y);
fits.closeFile(Z);
I also tried to use the commented part but it doesn't work.
What is worng?
Thank you

  0 Comments

Sign in to comment.

Answers (0)

Sign in to answer this question.

Tags