Created
November 13, 2012 15:35
-
-
Save Cadair/4066376 to your computer and use it in GitHub Desktop.
Save a massive FITS file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Nov 13 15:05:36 2012 | |
@author: stuart | |
Problem from SunPy mailing list. Save a MASSIVE array to a fits file | |
""" | |
import numpy as np | |
import numpy.lib as nplib | |
from glob import glob | |
import pyfits | |
save_dir = '/data/AIA/2010_05_29/' | |
files = glob(save_dir+"*fits")[:50] | |
n = len(files) | |
save_tmp = nplib.format.open_memmap(save_dir+"massive file.npy", mode='w+', | |
shape=(n,4096,4096)) | |
for i,fname in enumerate(files): | |
print i | |
fits = pyfits.open(fname) | |
save_tmp[i] = fits[1].data | |
fits.close() | |
print "saving" | |
hdu = pyfits.PrimaryHDU() | |
hdu.writeto('new.fits') | |
print "here we go" | |
pyfits.append('new.fits',save_tmp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment