Saving an array to a fits file

I have an array called frames_out. It's a 100x100x3000 array of images (3000 images, each image 100x100 pixels). I want to save this array as a FITS file. I've tried using the fitswrite function:
%%%%%%%%%
A = frames_out(:,:,1);
fitswrite(A,'fitsfile.fits')
for i = 2:size(frames_out,3)
A = frames_out(:,:,i);
fitswrite(A,'fitsfile.fits','writemode','append');
end
%%%%%%%%
But when I use the "fitsread" function on the FITS file I've created, that gives me an array with just one frame (the first frame of the original array), and I want all the images to be there. The weird thing is that if I use the code on just one frame, like this:
%%%%%%%%%
A = frames_out(:,:,1);
fitswrite(A,'fitsfile.fits')
%%%%%%%%
I get a FITS file whose size is a few hundred KB, and with the first code I get a much bigger file. So there's more information on the file from all the frames, but I can't seem to "extract" or see it anywhere.
Thanks a lot for your help,
Yael.

1 comentario

Kelly Miller
Kelly Miller el 15 de Abr. de 2016
Did you ever find a way around this issue? I am having the same problem, and can't find anything online. I'm running Matlab R2015a. Thanks!

Iniciar sesión para comentar.

Respuestas (1)

Thorsten
Thorsten el 20 de Nov. de 2014
Reading the ith image: (adapted from the Mathwork's help for fitsread)
info = fitsinfo('fitsfile.fits');
rowend = info.Image.Size(1);
colend = info.Image.Size(2);
frames_in(:,:,i) = fitsread('fitsfile.fits','image',...
'Info', info,...
'PixelRegion',{[1 rowend], [1 colend], i });

1 comentario

yael
yael el 21 de Nov. de 2014
Editada: yael el 21 de Nov. de 2014
First of all, Thank you very much for your help. But using this code, I get an error:
"The given 'PixelRegion' value specifies 3 dimensions, but the data has 2 dimensions."
As though it still won't acknowledge the fact that there are multiple frames in fitsfile.

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 20 de Nov. de 2014

Editada:

el 16 de Abr. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by