[AstroPy] PyFITS Too many open files

JJ Kavelaars jjk@uvic...
Sat Jun 15 09:19:20 CDT 2013


Shouldn't the 'with' achieve that?

JJ 

On 2013-06-14, at 10:08 PM, Nico Nell <nico.nell@gmail.com> wrote:

> You need to close the files once you have retrieved the data...
> 
> See here: http://pythonhosted.org/pyfits/api_docs/api_hdulists.html#pyfits.HDUList.close
> 
> ~Nick
> 
> 
> On Fri, Jun 14, 2013 at 10:51 PM, Nicholas Earl <nchlsearl@gmail.com> wrote:
>> Hello everyone,
>> 
>> I'm having an issue with opening and retrieving information for a large amount of fits files. Mainly, I keep running into a mmap.error: [Errno 24] Too many open files error. The code I'm using is:
>> 
>> import pyfits
>> 
>> for filename in os.listdir(directory):
>> 	kep_id = filename[4:13]
>> 
>> 	with pyfits.open(directory + "/" + filename, ignore_missing_end=True) as fits:
>> 		time = fits[1].data["TIME"]
>> 		energy = fits[1].data["ENERGY"]
>> 
>> Any ideas would be greatly appreciated!
>> 
>> Nicholas Earl
>> Graduate Research Assistant
>> San Diego State University
>> 
>> _______________________________________________
>> AstroPy mailing list
>> AstroPy@scipy.org
>> http://mail.scipy.org/mailman/listinfo/astropy
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy@scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/astropy/attachments/20130615/ccd2af71/attachment.html 


More information about the AstroPy mailing list