MacBook如何用python新建一个名叫50Myr_interp的fits文件
以下是在MacBook上使用Python新建一个名为50Myr_interp的fits文件的示例代码:
import numpy as np
from astropy.io import fits
# 创建一个空的fits数组
data = np.zeros((100, 100))
# 添加数据到数组中
for i in range(100):
for j in range(100):
data[i][j] = i*j
# 创建一个fits文件并保存
hdu = fits.PrimaryHDU(data)
hdu.writeto('50Myr_interp.fits')
这个示例代码创建了一个100x100的空的fits数组,然后循环遍历数组并将数据添加到数组中。最后,它使用hdu.writeto方法将数组保存为名为50Myr_interp的fits文件。你可以使用你自己的数据来替换这个示例代码中的数据。
原文地址: https://www.cveoy.top/t/topic/fdJX 著作权归作者所有。请勿转载和采集!