astropy

开启天文之路的 4 个 Python 工具

本小妞迷上赌 提交于 2020-08-04 17:54:51
使用 NumPy、SciPy、Scikit-Image 和 Astropy 探索宇宙 天文学与 Python 对科学界而言,尤其是对天文学界来说,Python 是一种伟大的语言工具。各种软件包,如 NumPy 、 SciPy 、 Scikit-Image 和 Astropy ,(仅举几例) ,都充分证明了 Python 对天文学的适用性,而且有很多用例。(NumPy、Astropy 和 SciPy 是 NumFOCUS 提供资金支持的项目;Scikit-Image 是个隶属项目)。我在十几年前脱离天文研究领域,成为了软件开发者之后,对这些工具包的演进一直很感兴趣。我的很多前天文界同事在他们的研究中,使用着前面提到的大部分甚至是全部工具包。以我为例,我也曾为位于智利的超大口径望远镜(VLT)上的仪器编写过专业天文软件工具包。 最近令我吃惊的是,Python 工具包竟然演进到如此好用,任何人都可以轻松编写 数据还原 data reduction 脚本,产生出高质量的数据产品。天文数据易于获取,而且大部分是可以公开使用的,你要做的只是去寻找相关数据。 比如,负责 VLT 运行的 ESO,直接在他们的网站上提供数据下载服务,只要访问 www.eso.org/UserPortal 并在首页创建用户就可以享有数据下载服务。如果你需要 SPHERE 数据

Plotting Idealized Blackbody Spectra

天涯浪子 提交于 2020-06-01 06:44:46
问题 So I am getting a couple errors RuntimeWarning: overflow encountered in exp intensity = a/ ( (wav**5) * (np.exp(b) - 1.0) ) and RuntimeWarning: invalid value encountered in multiply intensity = a/ ( (wav**5) * (np.exp(b) - 1.0) ) Even with these errors (and one more about dividing by zero that I ignore lol) my graph gets produced correctly either way. I am just wondering if anyone can help me clear up these errors? Please and thanks. Here is the full code: import numpy as np import matplotlib

Getting error “Can only apply 'exp' function to dimensionless quantities”, Not sure how to fix this

守給你的承諾、 提交于 2020-05-17 08:46:38
问题 I have been working on converting some MatLab code over to python for one of my professors (not an assignment just working on putting together some stuff) and I am stuck on this one part. When I run the code I am getting UnitTypeError: "Can only apply 'exp' function to dimensionless quantities", all of the methods I have tried to fix this won't work. I imagine the error is caused by the linspace command but am not sure. Any help with this would be great. here is the line IM0 = ((2*h*c**2)/(l*

Getting error “Can only apply 'exp' function to dimensionless quantities”, Not sure how to fix this

ぐ巨炮叔叔 提交于 2020-05-17 08:46:27
问题 I have been working on converting some MatLab code over to python for one of my professors (not an assignment just working on putting together some stuff) and I am stuck on this one part. When I run the code I am getting UnitTypeError: "Can only apply 'exp' function to dimensionless quantities", all of the methods I have tried to fix this won't work. I imagine the error is caused by the linspace command but am not sure. Any help with this would be great. here is the line IM0 = ((2*h*c**2)/(l*

Getting error “Can only apply 'exp' function to dimensionless quantities”, Not sure how to fix this

本秂侑毒 提交于 2020-05-17 08:46:06
问题 I have been working on converting some MatLab code over to python for one of my professors (not an assignment just working on putting together some stuff) and I am stuck on this one part. When I run the code I am getting UnitTypeError: "Can only apply 'exp' function to dimensionless quantities", all of the methods I have tried to fix this won't work. I imagine the error is caused by the linspace command but am not sure. Any help with this would be great. here is the line IM0 = ((2*h*c**2)/(l*

Astropy complaining about Numpy version

南楼画角 提交于 2020-05-16 13:34:34
问题 I just updated Astropy to version 3.1.2. Now I'm trying to run a (previously working) Python 3 script that uses it, and it's failing with the following message: Traceback (most recent call last): File "./body-local.py", line 3, in <module> from astropy.time import Time File "/home/jimc/.local/lib/python3.6/site-packages/astropy/__init__.py", line 121, in <module> _check_numpy() File "/home/jimc/.local/lib/python3.6/site-packages/astropy/__init__.py", line 115, in _check_numpy raise

Astropy complaining about Numpy version

╄→гoц情女王★ 提交于 2020-05-16 13:33:00
问题 I just updated Astropy to version 3.1.2. Now I'm trying to run a (previously working) Python 3 script that uses it, and it's failing with the following message: Traceback (most recent call last): File "./body-local.py", line 3, in <module> from astropy.time import Time File "/home/jimc/.local/lib/python3.6/site-packages/astropy/__init__.py", line 121, in <module> _check_numpy() File "/home/jimc/.local/lib/python3.6/site-packages/astropy/__init__.py", line 115, in _check_numpy raise

Cutout2D not centering on galaxies

牧云@^-^@ 提交于 2020-03-05 00:31:14
问题 I'm running Cutout2D on a .fits image I have and despite specifying the pixel values of the centre of my object it's cutting out a completely different galaxy. My code is as follows: from astropy.io import fits import numpy as np from astropy.table import Table import os from astropy.nddata.utils import Cutout2D def merge(list1, list2): #merges to lists into pairs so you can have list of corresponding coordinates matched together merged_list =[(list1[i], list2[i]) for i in range(0, len(list1)

How to conserve header when saving an edited .fits file with Astropy?

≡放荡痞女 提交于 2020-02-06 08:22:45
问题 I'm editing a .fits file I have in python but I want the header to stay the exact same. This is the code: import numpy as np from astropy.io import fits import matplotlib.pyplot as plt # read in the fits file im = fits.getdata('myfile.fits') header = fits.getheader('myfile.fits') ID = 1234 newim = np.copy(im) newim[newim == ID] = 0 newim[newim == 0] = -99 newim[newim > -99] = 0 newim[newim == -99] = 1 plt.imshow(newim,cmap='gray', origin='lower') plt.colorbar() hdu = fits.PrimaryHDU(newim)

How to conserve header when saving an edited .fits file with Astropy?

▼魔方 西西 提交于 2020-02-06 08:21:46
问题 I'm editing a .fits file I have in python but I want the header to stay the exact same. This is the code: import numpy as np from astropy.io import fits import matplotlib.pyplot as plt # read in the fits file im = fits.getdata('myfile.fits') header = fits.getheader('myfile.fits') ID = 1234 newim = np.copy(im) newim[newim == ID] = 0 newim[newim == 0] = -99 newim[newim > -99] = 0 newim[newim == -99] = 1 plt.imshow(newim,cmap='gray', origin='lower') plt.colorbar() hdu = fits.PrimaryHDU(newim)