def FITSFactory(image_ext):
 if (not isinstance(image_ext, tuple)):
  raise TypeError('Expected a tuple')
 if (len(image_ext) != 2):
  raise ValueError('Expected a tuple of length 2')
 filename = image_ext[0]
 extnum = image_ext[1]
 if ((type(filename) is not str) or (type(extnum) is not int)):
  raise ValueError('Expected a (filename, extension) tuple')
 hdulist = pyfits.open(filename)
 data = hdulist[extnum].data
 hdulist.close()
 if (data is None):
  raise RuntimeError(('Extension %d of %s has no data' % (extnum, filename)))
 return data

def FITSFactory ( image_ext ) : if ( not isinstance ( image_ext , tuple ) ) : raise TypeError ( 'Expected a tuple' ) if ( len ( image_ext ) != 2 ) : raise ValueError ( 'Expected a tuple of length 2' ) filename = image_ext [ 0 ] extnum = image_ext [ 1 ] if ( ( type ( filename ) is not str ) or ( type ( extnum ) is not int ) ) : raise ValueError ( 'Expected a (filename, extension) tuple' ) hdulist = pyfits . open ( filename ) data = hdulist [ extnum ] . data hdulist . close ( ) if ( data is None ) : raise RuntimeError ( ( 'Extension %d of %s has no data' % ( extnum , filename ) ) ) return data
load an image extension from a fits file and return a numpy array parameters image_ext : tuple fits extension to load .