Astropy

来自Shiyin's note
Shen讨论 | 贡献2017年9月15日 (五) 14:15的版本
跳到导航 跳到搜索

astropy.io.fits

[1]

>>> hdulist = fits.open('input.fits')
>>> hdulist.info()
  • each element of an HDUList is an HDU object with .header and .data attributes, which can be used to access the header and data portions of the HDU.
>>> hdulist[0].header['targname']
  • To see the entire header as it appears in the FITS file (with the END card and padding stripped), simply enter the header object by itself, or print(repr(header)):
  • It’s also possible to view a slice of the header:
>>> header[:2]
  • Another way to either update an existing card or append a new one is to use the Header.set() method:
>>> prihdr.set('observer', 'Edwin Hubble')

宇宙学

    1. 从红移到年龄
>>>from astropy.cosmology import FlatLambdaCDM 
>>>cosmo = FlatLambdaCDM(H0=70, Om0=0.3)
  • 从年龄到红移
>>> import astropy.units as u
>>> from astropy.cosmology import  z_at_value
>>> z_at_value(cosmos.age, 2 * u.Gyr)