astropy: Fits memmap, "buffer is too small for requested array" Error

Hi Astropy developers, I am reading a big fits file using memmap method. However, I got a TypeError. has anyone seen this before? What is the correct way to read a big file (> 2GB)?

Thank you. Useage:

>>> x = fits.open("big_fits_file.fits", memmap=True)
>>> x
[<astropy.io.fits.hdu.image.PrimaryHDU object at 0x7fc1830c9908>, <astropy.io.fits.hdu.table.BinTableHDU object at 0x7fc1830cf128>]
>>> x[1].data[0]
TypeError                                 Traceback (most recent call last)
<ipython-input-87-2cd5f5ec1899> in <module>()
----> 1 x[1].data[0]

~/Projects/astropy/astropy/utils/decorators.py in __get__(self, obj, owner)
    742                 return val
    743             else:
--> 744                 val = self.fget(obj)
    745                 obj.__dict__[self._key] = val
    746                 return val

~/Projects/astropy/astropy/io/fits/hdu/table.py in data(self)
    404     @lazyproperty
    405     def data(self):
--> 406         data = self._get_tbdata()
    407         data._coldefs = self.columns
    408         data._character_as_bytes = self._character_as_bytes

~/Projects/astropy/astropy/io/fits/hdu/table.py in _get_tbdata(self)
    170         else:
    171             raw_data = self._get_raw_data(self._nrows, columns.dtype,
--> 172                                           self._data_offset)
    173             if raw_data is None:
    174                 # This can happen when a brand new table HDU is being created

~/Projects/astropy/astropy/io/fits/hdu/base.py in _get_raw_data(self, shape, code, offset)
    473                               offset=offset)
    474         elif self._file:
--> 475             return self._file.readarray(offset=offset, dtype=code, shape=shape)
    476         else:
    477             return None

~/Projects/astropy/astropy/io/fits/file.py in readarray(self, size, offset, dtype, shape)
    332 
    333                 return np.ndarray(shape=shape, dtype=dtype, offset=offset,
--> 334                                   buffer=self._mmap)
    335             else:
    336                 count = reduce(operator.mul, shape)

TypeError: buffer is too small for requested array

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

It was indeed corrupted. Sorry for the noise.