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 件のコメント

Kelly Miller
Kelly Miller 2016 年 4 月 15 日
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!

サインインしてコメントする。

回答 (1 件)

Thorsten
Thorsten 2014 年 11 月 20 日

0 投票

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 件のコメント

yael
yael 2014 年 11 月 21 日
編集済み: yael 2014 年 11 月 21 日
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.

サインインしてコメントする。

タグ

質問済み:

2014 年 11 月 20 日

編集済み:

2016 年 4 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by