def imread_collection(load_pattern, conserve_memory=True):
 intype = type(load_pattern)
 if ((intype is not list) and (intype is not str)):
  raise TypeError('Input must be a filename or list of filenames')
 if (intype is not list):
  load_pattern = [load_pattern]
 ext_list = []
 for filename in load_pattern:
  hdulist = pyfits.open(filename)
  for (n, hdu) in zip(range(len(hdulist)), hdulist):
   if (isinstance(hdu, pyfits.ImageHDU) or isinstance(hdu, pyfits.PrimaryHDU)):
    try:
     data_size = hdu.size()
    except TypeError:
     data_size = hdu.size
    if (data_size > 0):
     ext_list.append((filename, n))
  hdulist.close()
 return io.ImageCollection(ext_list, load_func=FITSFactory, conserve_memory=conserve_memory)

def imread_collection ( load_pattern , conserve_memory = True ) : intype = type ( load_pattern ) if ( ( intype is not list ) and ( intype is not str ) ) : raise TypeError ( 'Input must be a filename or list of filenames' ) if ( intype is not list ) : load_pattern = [ load_pattern ] ext_list = [ ] for filename in load_pattern : hdulist = pyfits . open ( filename ) for ( n , hdu ) in zip ( range ( len ( hdulist ) ) , hdulist ) : if ( isinstance ( hdu , pyfits . ImageHDU ) or isinstance ( hdu , pyfits . PrimaryHDU ) ) : try : data_size = hdu . size ( ) except TypeError : data_size = hdu . size if ( data_size > 0 ) : ext_list . append ( ( filename , n ) ) hdulist . close ( ) return io . ImageCollection ( ext_list , load_func = FITSFactory , conserve_memory = conserve_memory )
load a collection of images .