尝试在星座

时间:2017-08-17 04:47:15

标签: python python-2.7 matplotlib astropy fits

我正在尝试使用x和y轴上的WCS制作一个大(~5GB)拟合文件的图像文件(.png)。请参阅here作为示例,这是一个MWE:

from astropy.io import fits
from astropy.wcs import WCS
import matplotlib.pyplot as plt

image = path/to/image/image.fits
hdu = fits.open(image, ignore_missing_end=True)[0]
wcs = WCS(hdu.header)

plt.figure(figsize=(20,10))
plt.subplot(projection=wcs)
plt.imshow(hdu.data, origin='lower')
plt.grid(color='white', ls='solid')
plt.xlabel('Longitude')
plt.ylabel('Latitude')

plt.savefig('figure.png')

这一直给我下面的错误,甚至认为我正在使用至少16GB内存的节点。有谁知道如何解决这个问题,或者如何在保留WCS的同时降级图像的分辨率?谢谢!

Traceback (most recent call last):
File "map.py", line 30, in <module>
plt.savefig('figure.png')
File "/hpc/c/anaconda2-4.1.1/lib/python2.7/site-packages/matplotlib/pyplot.py", line 688, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/hpc/c/anaconda2-4.1.1/lib/python2.7/site-packages/matplotlib/figure.py", line 1565, in savefig
    self.canvas.print_figure(*args, **kwargs)

  ... 

  im = self.make_image(renderer.get_image_magnification())
  File "/hpc/c/anaconda2-4.1.1/lib/python2.7/site-packages/matplotlib/image.py", line 624, in make_image
    transformed_viewLim)
  File "/hpc/c/anaconda2-4.1.1/lib/python2.7/site-packages/matplotlib/image.py", line 238, in _get_unsampled_image
    x = (x * 255).astype(np.uint8)
MemoryError

0 个答案:

没有答案