{"id":992910,"date":"2024-12-27T08:41:46","date_gmt":"2024-12-27T00:41:46","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/992910.html"},"modified":"2024-12-27T08:41:48","modified_gmt":"2024-12-27T00:41:48","slug":"python%e5%a6%82%e4%bd%95%e8%af%bb%e5%8f%96fits%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/992910.html","title":{"rendered":"python\u5982\u4f55\u8bfb\u53d6fits\u6587\u4ef6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25070531\/0e5b453e-30dd-47f3-8a37-c9cfbb92738a.webp\" alt=\"python\u5982\u4f55\u8bfb\u53d6fits\u6587\u4ef6\" \/><\/p>\n<p><p> <strong>Python\u8bfb\u53d6FITS\u6587\u4ef6\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528Astropy\u5e93\u7684<code>astropy.io.fits<\/code>\u6a21\u5757\u3001\u901a\u8fc7FITS I\/O\u64cd\u4f5c\u8fdb\u884c\u6570\u636e\u8bfb\u53d6\u3001\u5229\u7528\u6570\u636e\u5904\u7406\u529f\u80fd\u8fdb\u884c\u5206\u6790\u3002<\/strong>\u5176\u4e2d\uff0cAstropy\u5e93\u662f\u5904\u7406FITS\uff08Flexible Image Transport System\uff09\u6587\u4ef6\u7684\u6807\u51c6\u5de5\u5177\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u6765\u8bfb\u53d6\u3001\u4fee\u6539\u548c\u4fdd\u5b58FITS\u6587\u4ef6\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Astropy\u8bfb\u53d6FITS\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001FITS\u6587\u4ef6\u7b80\u4ecb<\/h3>\n<\/p>\n<p><p>FITS\u6587\u4ef6\uff08Flexible Image Transport System\uff09\u662f\u4e00\u79cd\u7528\u4e8e\u5b58\u50a8\u79d1\u5b66\u6570\u636e\u7684\u6807\u51c6\u683c\u5f0f\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5929\u6587\u5b66\u548c\u5176\u4ed6\u79d1\u5b66\u9886\u57df\u3002FITS\u6587\u4ef6\u4e0d\u4ec5\u53ef\u4ee5\u5b58\u50a8\u56fe\u50cf\u6570\u636e\uff0c\u8fd8\u53ef\u4ee5\u4fdd\u5b58\u8868\u683c\u548c\u5176\u4ed6\u5f62\u5f0f\u7684\u6570\u636e\u3002FITS\u683c\u5f0f\u5177\u6709\u7075\u6d3b\u6027\u548c\u6269\u5c55\u6027\uff0c\u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\u548c\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5b89\u88c5\u5fc5\u8981\u7684Python\u5305<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Python\u8bfb\u53d6FITS\u6587\u4ef6\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Astropy\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u901a\u8fc7pip\u5b89\u88c5Astropy\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install astropy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Astropy\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5929\u6587\u5b66\u5e93\uff0c\u63d0\u4f9b\u4e86\u5904\u7406FITS\u6587\u4ef6\u7684\u6a21\u5757<code>astropy.io.fits<\/code>\u3002\u6b64\u5916\uff0cAstropy\u8fd8\u5305\u542b\u4e86\u8bb8\u591a\u7528\u4e8e\u5929\u6587\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u4f7f\u7528Astropy\u8bfb\u53d6FITS\u6587\u4ef6<\/h3>\n<\/p>\n<p><h4>1\u3001\u6253\u5f00FITS\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Astropy\u8bfb\u53d6FITS\u6587\u4ef6\u65f6\uff0c\u9996\u5148\u9700\u8981\u6253\u5f00\u6587\u4ef6\u3002\u53ef\u4ee5\u4f7f\u7528<code>astropy.io.fits.open()<\/code>\u51fd\u6570\u6765\u6253\u5f00\u4e00\u4e2aFITS\u6587\u4ef6\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2aHDUList\u5bf9\u8c61\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from astropy.io import fits<\/p>\n<h2><strong>\u6253\u5f00FITS\u6587\u4ef6<\/strong><\/h2>\n<p>hdulist = fits.open(&#39;example.fits&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>HDUList\u5bf9\u8c61\u662f\u4e00\u4e2a\u5305\u542b\u591a\u4e2aHDU\uff08Header Data Unit\uff09\u7684\u5217\u8868\uff0c\u6bcf\u4e2aHDU\u53ef\u80fd\u5305\u542b\u56fe\u50cf\u6570\u636e\u3001\u8868\u683c\u6570\u636e\u6216\u5176\u4ed6\u5f62\u5f0f\u7684\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u8bbf\u95eeHDU\u6570\u636e<\/h4>\n<\/p>\n<p><p>FITS\u6587\u4ef6\u901a\u5e38\u5305\u542b\u591a\u4e2aHDU\uff0c\u901a\u5e38\u7b2c\u4e00\u4e2aHDU\u5305\u542b\u4e3b\u6570\u636e\uff08Primary HDU\uff09\uff0c\u540e\u7eedHDU\u53ef\u80fd\u5305\u542b\u6269\u5c55\u6570\u636e\u3002\u53ef\u4ee5\u901a\u8fc7\u7d22\u5f15\u6765\u8bbf\u95ee\u7279\u5b9a\u7684HDU\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bbf\u95ee\u7b2c\u4e00\u4e2aHDU<\/p>\n<p>primary_hdu = hdulist[0]<\/p>\n<h2><strong>\u83b7\u53d6\u6570\u636e\u548c\u5934\u90e8\u4fe1\u606f<\/strong><\/h2>\n<p>data = primary_hdu.data<\/p>\n<p>header = primary_hdu.header<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><code>data<\/code>\u5c5e\u6027\u5305\u542b\u4e86HDU\u4e2d\u7684\u6570\u636e\uff0c\u901a\u5e38\u662f\u4e00\u4e2aNumPy\u6570\u7ec4\uff1b<code>header<\/code>\u5c5e\u6027\u5305\u542b\u4e86HDU\u7684\u5934\u90e8\u4fe1\u606f\uff0c\u5b58\u50a8\u4e86\u4e0e\u6570\u636e\u76f8\u5173\u7684\u5143\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u8bfb\u53d6\u56fe\u50cf\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u5982\u679cFITS\u6587\u4ef6\u5305\u542b\u56fe\u50cf\u6570\u636e\uff0c\u53ef\u4ee5\u76f4\u63a5\u4ece\u4e3b\u6570\u636e\u5355\u5143\u4e2d\u63d0\u53d6\u51fa\u6765\uff0c\u5e76\u4f7f\u7528Matplotlib\u8fdb\u884c\u53ef\u89c6\u5316\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u663e\u793a\u56fe\u50cf\u6570\u636e<\/strong><\/h2>\n<p>plt.imshow(data, cmap=&#39;gray&#39;)<\/p>\n<p>plt.colorbar()<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Matplotlib\u662fPython\u4e2d\u7528\u4e8e\u7ed8\u56fe\u548c\u6570\u636e\u53ef\u89c6\u5316\u7684\u5e38\u7528\u5e93\uff0c\u80fd\u591f\u4ee5\u591a\u79cd\u683c\u5f0f\u5c55\u793aFITS\u56fe\u50cf\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h4>4\u3001\u8bfb\u53d6\u8868\u683c\u6570\u636e<\/h4>\n<\/p>\n<p><p>\u5982\u679cFITS\u6587\u4ef6\u5305\u542b\u8868\u683c\u6570\u636e\uff0c\u53ef\u4ee5\u4ece\u9002\u5f53\u7684HDU\u4e2d\u63d0\u53d6\u6570\u636e\uff0c\u5e76\u4f7f\u7528Astropy\u7684Table\u6a21\u5757\u8fdb\u884c\u5904\u7406\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from astropy.table import Table<\/p>\n<h2><strong>\u8bbf\u95ee\u8868\u683c\u6570\u636eHDU<\/strong><\/h2>\n<p>table_hdu = hdulist[1]<\/p>\n<h2><strong>\u5c06\u6570\u636e\u8f6c\u6362\u4e3aAstropy Table\u5bf9\u8c61<\/strong><\/h2>\n<p>table = Table(table_hdu.data)<\/p>\n<h2><strong>\u6253\u5370\u8868\u683c\u5185\u5bb9<\/strong><\/h2>\n<p>print(table)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Astropy\u7684Table\u6a21\u5757\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u529f\u80fd\u6765\u5904\u7406\u8868\u683c\u6570\u636e\uff0c\u5305\u62ec\u6392\u5e8f\u3001\u7b5b\u9009\u3001\u5206\u7ec4\u7b49\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u5904\u7406\u548c\u5206\u6790FITS\u6587\u4ef6\u6570\u636e<\/h3>\n<\/p>\n<p><h4>1\u3001\u4fee\u6539\u548c\u4fdd\u5b58FITS\u6587\u4ef6<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u4fee\u6539FITS\u6587\u4ef6\u7684\u6570\u636e\u6216\u5934\u90e8\u4fe1\u606f\uff0c\u7136\u540e\u5c06\u5176\u4fdd\u5b58\u5230\u65b0\u7684\u6587\u4ef6\u4e2d\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u4fee\u6539\u5934\u90e8\u4fe1\u606f<\/p>\n<p>header[&#39;OBSERVER&#39;] = &#39;Jane Doe&#39;<\/p>\n<h2><strong>\u4fdd\u5b58\u4fee\u6539\u540e\u7684FITS\u6587\u4ef6<\/strong><\/h2>\n<p>hdulist.writeto(&#39;modified_example.fits&#39;, overwrite=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>writeto()<\/code>\u51fd\u6570\u53ef\u4ee5\u5c06\u4fee\u6539\u540e\u7684\u6570\u636e\u4fdd\u5b58\u5230\u65b0\u7684FITS\u6587\u4ef6\u4e2d\uff0c<code>overwrite=True<\/code>\u53c2\u6570\u5141\u8bb8\u8986\u76d6\u5df2\u6709\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u8ba1\u7b97\u548c\u7edf\u8ba1\u5206\u6790<\/h4>\n<\/p>\n<p><p>Astropy\u548cNumPy\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u51fd\u6570\u6765\u5bf9FITS\u6570\u636e\u8fdb\u884c\u8ba1\u7b97\u548c\u7edf\u8ba1\u5206\u6790\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u8ba1\u7b97\u56fe\u50cf\u6570\u636e\u7684\u5e73\u5747\u503c\u3001\u4e2d\u4f4d\u6570\u6216\u6807\u51c6\u5dee\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<h2><strong>\u8ba1\u7b97\u56fe\u50cf\u6570\u636e\u7684\u5e73\u5747\u503c<\/strong><\/h2>\n<p>mean_value = np.mean(data)<\/p>\n<p>print(f&#39;\u5e73\u5747\u503c\uff1a{mean_value}&#39;)<\/p>\n<h2><strong>\u8ba1\u7b97\u56fe\u50cf\u6570\u636e\u7684\u4e2d\u4f4d\u6570<\/strong><\/h2>\n<p>median_value = np.median(data)<\/p>\n<p>print(f&#39;\u4e2d\u4f4d\u6570\uff1a{median_value}&#39;)<\/p>\n<h2><strong>\u8ba1\u7b97\u56fe\u50cf\u6570\u636e\u7684\u6807\u51c6\u5dee<\/strong><\/h2>\n<p>std_value = np.std(data)<\/p>\n<p>print(f&#39;\u6807\u51c6\u5dee\uff1a{std_value}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u7edf\u8ba1\u91cf\u53ef\u4ee5\u5e2e\u52a9\u7814\u7a76\u4eba\u5458\u66f4\u597d\u5730\u7406\u89e3\u6570\u636e\u7684\u5206\u5e03\u548c\u7279\u6027\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u6570\u636e\u53ef\u89c6\u5316<\/h4>\n<\/p>\n<p><p>\u9664\u4e86\u57fa\u672c\u7684\u56fe\u50cf\u663e\u793a\uff0cMatplotlib\u8fd8\u53ef\u4ee5\u7528\u4e8e\u521b\u5efa\u66f4\u590d\u6742\u7684\u6570\u636e\u53ef\u89c6\u5316\u56fe\u8868\uff0c\u4f8b\u5982\u76f4\u65b9\u56fe\u3001\u6563\u70b9\u56fe\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u7ed8\u5236\u76f4\u65b9\u56fe<\/p>\n<p>plt.hist(data.flatten(), bins=50, color=&#39;blue&#39;)<\/p>\n<p>plt.xlabel(&#39;Pixel Value&#39;)<\/p>\n<p>plt.ylabel(&#39;Frequency&#39;)<\/p>\n<p>plt.title(&#39;Histogram of Image Data&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u6570\u636e\u53ef\u89c6\u5316\uff0c\u53ef\u4ee5\u76f4\u89c2\u5730\u89c2\u5bdf\u6570\u636e\u7684\u5206\u5e03\u548c\u8d8b\u52bf\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u4f18\u5316\u548c\u52a0\u901f\u6570\u636e\u5904\u7406<\/h3>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528\u5185\u5b58\u6620\u5c04<\/h4>\n<\/p>\n<p><p>\u5728\u5904\u7406\u5927\u578bFITS\u6587\u4ef6\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u5b58\u6620\u5c04\uff08memory mapping\uff09\u6280\u672f\u6765\u63d0\u9ad8\u6570\u636e\u8bfb\u53d6\u6548\u7387\u3002Astropy\u652f\u6301\u901a\u8fc7<code>memmap=True<\/code>\u9009\u9879\u6765\u542f\u7528\u5185\u5b58\u6620\u5c04\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u6253\u5f00FITS\u6587\u4ef6\u5e76\u542f\u7528\u5185\u5b58\u6620\u5c04<\/p>\n<p>hdulist = fits.open(&#39;large_example.fits&#39;, memmap=True)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5185\u5b58\u6620\u5c04\u5141\u8bb8\u5728\u4e0d\u5c06\u6574\u4e2a\u6587\u4ef6\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u7684\u60c5\u51b5\u4e0b\u8bbf\u95ee\u6587\u4ef6\u6570\u636e\uff0c\u4ece\u800c\u8282\u7701\u5185\u5b58\u8d44\u6e90\u5e76\u63d0\u9ad8\u5904\u7406\u901f\u5ea6\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u5e76\u884c\u8ba1\u7b97<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u9700\u8981\u8fdb\u884c\u5927\u91cf\u8ba1\u7b97\u7684\u4efb\u52a1\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u7684\u591a\u5904\u7406\u6a21\u5757\uff08multiprocessing\uff09\u5b9e\u73b0\u5e76\u884c\u8ba1\u7b97\uff0c\u4ece\u800c\u52a0\u901f\u6570\u636e\u5904\u7406\u8fc7\u7a0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from multiprocessing import Pool<\/p>\n<h2><strong>\u5b9a\u4e49\u8ba1\u7b97\u4efb\u52a1<\/strong><\/h2>\n<p>def compute_statistic(data_chunk):<\/p>\n<p>    return np.mean(data_chunk)<\/p>\n<h2><strong>\u5c06\u6570\u636e\u62c6\u5206\u4e3a\u591a\u4e2a\u5b50\u96c6<\/strong><\/h2>\n<p>data_chunks = np.array_split(data, 4)<\/p>\n<h2><strong>\u521b\u5efa\u8fdb\u7a0b\u6c60\u5e76\u6267\u884c\u5e76\u884c\u8ba1\u7b97<\/strong><\/h2>\n<p>with Pool(processes=4) as pool:<\/p>\n<p>    results = pool.map(compute_statistic, data_chunks)<\/p>\n<h2><strong>\u6c47\u603b\u7ed3\u679c<\/strong><\/h2>\n<p>overall_mean = np.mean(results)<\/p>\n<p>print(f&#39;\u5e76\u884c\u8ba1\u7b97\u5f97\u5230\u7684\u5e73\u5747\u503c\uff1a{overall_mean}&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5e76\u884c\u8ba1\u7b97\u53ef\u4ee5\u5145\u5206\u5229\u7528\u591a\u6838\u5904\u7406\u5668\u7684\u6027\u80fd\uff0c\u63d0\u9ad8\u6570\u636e\u5904\u7406\u6548\u7387\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u6211\u4eec\u8be6\u7ec6\u63a2\u8ba8\u4e86\u5982\u4f55\u4f7f\u7528Python\u548cAstropy\u5e93\u8bfb\u53d6FITS\u6587\u4ef6\uff0c\u5e76\u5bf9FITS\u6570\u636e\u8fdb\u884c\u5904\u7406\u548c\u5206\u6790\u3002<strong>Astropy\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u529f\u80fd\u6765\u6253\u5f00\u3001\u8bfb\u53d6\u3001\u4fee\u6539\u548c\u4fdd\u5b58FITS\u6587\u4ef6\uff0c\u7ed3\u5408NumPy\u548cMatplotlib\u7b49\u5de5\u5177\uff0c\u53ef\u4ee5\u5b9e\u73b0\u590d\u6742\u7684\u6570\u636e\u8ba1\u7b97\u548c\u53ef\u89c6\u5316\u3002<\/strong>\u5728\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u65f6\uff0c\u5185\u5b58\u6620\u5c04\u548c\u5e76\u884c\u8ba1\u7b97\u6280\u672f\u53ef\u4ee5\u6709\u6548\u63d0\u9ad8\u5904\u7406\u6548\u7387\u3002\u8fd9\u4e9b\u6280\u672f\u548c\u5de5\u5177\u4e3a\u79d1\u5b66\u7814\u7a76\u548c\u6570\u636e\u5206\u6790\u63d0\u4f9b\u4e86\u6781\u5927\u7684\u4fbf\u5229\u548c\u652f\u6301\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u8bfb\u53d6FITS\u6587\u4ef6\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u5e93\u6765\u8bfb\u53d6FITS\u6587\u4ef6\uff0c\u6700\u5e38\u7528\u7684\u662fAstropy\u5e93\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5Astropy\uff0c\u7136\u540e\u4f7f\u7528<code>astropy.io.fits<\/code>\u6a21\u5757\u6765\u6253\u5f00\u548c\u8bfb\u53d6FITS\u6587\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-python\">from astropy.io import fits\n\n# \u6253\u5f00FITS\u6587\u4ef6\nwith fits.open(&#39;example.fits&#39;) as hdul:\n    # \u67e5\u770bFITS\u6587\u4ef6\u4e2d\u7684\u6240\u6709\u6570\u636e\u5355\u5143\n    hdul.info()\n    # \u8bfb\u53d6\u7279\u5b9a\u7684\u6570\u636e\u5355\u5143\n    data = hdul[0].data\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u8ba9\u7528\u6237\u8f7b\u677e\u8bbf\u95eeFITS\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u548c\u5934\u4fe1\u606f\u3002<\/p>\n<p><strong>\u8bfb\u53d6FITS\u6587\u4ef6\u65f6\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u4e8b\u9879\uff1f<\/strong><br \/>\u5728\u8bfb\u53d6FITS\u6587\u4ef6\u65f6\uff0c\u7528\u6237\u9700\u8981\u786e\u8ba4\u6587\u4ef6\u7684\u5b8c\u6574\u6027\u548c\u6b63\u786e\u6027\u3002\u786e\u4fdd\u6587\u4ef6\u8def\u5f84\u6b63\u786e\uff0c\u5e76\u4e14\u8be5\u6587\u4ef6\u80fd\u591f\u88ab\u8bfb\u53d6\u3002\u6b64\u5916\uff0cFITS\u6587\u4ef6\u53ef\u80fd\u5305\u542b\u591a\u4e2a\u6570\u636e\u5355\u5143\uff0c\u7528\u6237\u5e94\u4e86\u89e3\u6240\u9700\u6570\u636e\u6240\u5728\u7684\u6570\u636e\u5355\u5143\u7d22\u5f15\u3002\u6b64\u5916\uff0c\u5bf9\u4e8e\u5927\u6587\u4ef6\uff0c\u4f7f\u7528\u5185\u5b58\u6620\u5c04\u53ef\u4ee5\u63d0\u9ad8\u8bfb\u53d6\u6548\u7387\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406FITS\u6587\u4ef6\u4e2d\u7684\u6570\u636e\uff1f<\/strong><br \/>\u8bfb\u53d6FITS\u6587\u4ef6\u540e\uff0c\u7528\u6237\u53ef\u4ee5\u4f7f\u7528NumPy\u7b49\u79d1\u5b66\u8ba1\u7b97\u5e93\u5bf9\u6570\u636e\u8fdb\u884c\u5904\u7406\u3002\u7528\u6237\u53ef\u4ee5\u5bf9\u6570\u636e\u8fdb\u884c\u6570\u7ec4\u64cd\u4f5c\u3001\u7ed8\u56fe\u6216\u7edf\u8ba1\u5206\u6790\u7b49\u3002\u4f8b\u5982\uff0c\u5229\u7528Matplotlib\u5e93\u53ef\u4ee5\u8f7b\u677e\u7ed8\u5236\u56fe\u50cf\uff1a<\/p>\n<pre><code class=\"language-python\">import matplotlib.pyplot as plt\n\nplt.imshow(data, cmap=&#39;gray&#39;)\nplt.colorbar()\nplt.show()\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u66f4\u597d\u5730\u5206\u6790\u548c\u53ef\u89c6\u5316FITS\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u8bfb\u53d6FITS\u6587\u4ef6\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528Astropy\u5e93\u7684astropy.io.fits\u6a21\u5757\u3001\u901a\u8fc7FITS [&hellip;]","protected":false},"author":3,"featured_media":992920,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/992910"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=992910"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/992910\/revisions"}],"predecessor-version":[{"id":992923,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/992910\/revisions\/992923"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/992920"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=992910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=992910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=992910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}