Python——astroplan庫入門例項(二)

麻辣芒果魚發表於2020-12-13

1.class astropy.FixedTarget(coord, name=None)

①建立一個FixedTarget物件表示天體的物件,例如恆星(如果忽略適當的運動,它們固定在天球上)

from astropy.coordinates import SkyCoord
from astroplan import FixedTarget

coordinates = SkyCoord('19h50m47.6s', '+08d52m12.0s', frame='icrs')
altair = FixedTarget(name='Altair', coord=coordinates)

print(altair)
print(altair.coord)
print(altair.name)

輸出結果:
<FixedTarget "Altair" at SkyCoord (ICRS): (ra, dec) in deg (297.69833333, 8.87)>
<SkyCoord (ICRS): (ra, dec) in deg
    (297.6958273, 8.8683212)>
Altair
#其中,SkyCoord是目標座標,name是目標的名稱,是個str

②對於CDS名稱解析器已知的物件,可以使用 from_name 命令快速檢索其座標:

altair = FixedTarget.from_name('Altair')
print(altair)

#from_name是FixedTarget物件的方法
#from_name(query_name,name = None)
#query_name:str,用於查詢座標的目標名稱。
#name:字串或None,在astroplan中使用的目標名稱。如果使用None,則將query_name用作name

2.class astroplan.Observer(location=None, timezone='UTC', name=None, latitude=None, longitude=None, elevation=<Quantity 0. m>, pressure=None, relative_humidity=None, temperature=None, description=None)

①建立一個Observer物件,用於提供有關觀察者的位置和環境的資訊。

#可以通過2種方式來建立Observer物件,引數介紹參考官方文件

#第一種:某些天文臺的位置儲存在astroplan中,可以按名稱訪問它們
from astroplan import Observer
subaru = Observer.at_site("Subaru", timezone="US/Hawaii")
print(subaru)

輸出結果:
<Observer: name='Subaru',
    location (lon, lat, el)=(-155.47611111111112 deg, 19.825555555555564 deg, 4139.000000000389 m),
    timezone=<DstTzInfo 'US/Hawaii' LMT-1 day, 13:29:00 STD>>


#第二種:可以通過使用EarthLocation指定位置來初始化Observer
from astropy.coordinates import EarthLocation
import astropy.units as u
location = EarthLocation.from_geodetic(-155.4761*u.deg, 19.825*u.deg,
                                       4139*u.m)
subaru = Observer(location=location, name="Subaru", timezone="US/Hawaii")
#EarthLocation.from_geodetic()方法內的引數是x,y,z的座標,即經度、維度和海拔。


#也可以建立不帶EarthLocation的Observer
from astroplan import Observer
import astropy.units as u
subaru = Observer(longitude=-155.4761*u.deg, latitude=19.825*u.deg,
                  elevation=0*u.m, name="Subaru", timezone="US/Hawaii")

②一個引數較完整的例子:

import astropy.units as u
from astropy.coordinates import EarthLocation
from pytz import timezone
from astroplan import Observer

longitude = '-155d28m48.900s'
latitude = '+19d49m42.600s'
elevation = 4163 * u.m
location = EarthLocation.from_geodetic(longitude, latitude, elevation)

observer = Observer(name='Subaru Telescope',
               location=location,
               pressure=0.615 * u.bar,
               relative_humidity=0.11,
               temperature=0 * u.deg_C,
               timezone=timezone('US/Hawaii'),
               description="Subaru Telescope on Maunakea, Hawaii")

3.class astropy.time.Time(val,val2 = None,format = None,scale = None,precision = None,in_subfmt = None,out_subfmt = None,location = None,copy = False)

from astropy.time import Time
time = Time(['2015-06-16 06:00:00'])

 

 

相關文章