これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。
HTML ファイル生成日時: 2024/11/21 17:40:55.112 (台灣標準時)
astropy を使って、与えられた場所での与えられた時間での月の座標を調べる には、以下のようにすればよいようでござる。
#!/usr/pkg/bin/python3.9 # # Time-stamp: <2022/07/03 11:24:41 (CST) daisuke> # # importing argparse module import argparse # importing astropy module import astropy.units import astropy.time import astropy.coordinates # units unit_m = astropy.units.m # constructing parser object desc = "finding position of the Moon" parser = argparse.ArgumentParser (description=desc) # adding arguments parser.add_argument ('-l', '--longitude', default='+120d52m25s', \ help='longitude of observing site in format "+121d11m12s"') parser.add_argument ('-b', '--latitude', default='+23d28m07s', \ help='latitude of observing site in format "+24d58m12s"') parser.add_argument ('-a', '--altitude', type=float, default=2862.0, \ help='altitude above sea-level in metre') parser.add_argument ('-t', '--datetime', default='2000-01-01T12:00:00.000', \ help='date/time in UT in "YYYY-MM-DDThh:mm:ss.sss" format') # command-line argument analysis args = parser.parse_args () # input parameters site_lon = args.longitude site_lat = args.latitude site_alt = args.altitude * unit_m datetime_str = args.datetime # printing input parameters print ("#") print ("# input parameters") print ("#") print ("# Location:") print ("# longitude =", site_lon) print ("# latitude =", site_lat) print ("# altitude =", site_alt) print ("# Date/Time:") print ("# date/time (UT) =", datetime_str) # location object location = astropy.coordinates.EarthLocation.from_geodetic \ (site_lon, site_lat, site_alt) # time object datetime = astropy.time.Time (datetime_str, scale='utc') # using DE430 astropy.coordinates.solar_system_ephemeris.set ('de430') # position of the Moon moon = astropy.coordinates.get_body ('moon', datetime, location) (moon_ra, moon_dec) = moon.to_string ('hmsdms').split () # conversion from equatorial into ecliptic moon_ecliptic = moon.transform_to \ (astropy.coordinates.GeocentricMeanEcliptic (obstime=datetime) ) moon_lambda = moon_ecliptic.lon moon_beta = moon_ecliptic.lat # conversion from equatorial into horizontal moon_altaz = moon.transform_to \ (astropy.coordinates.AltAz (obstime=datetime, location=location) ) moon_alt = moon_altaz.alt moon_az = moon_altaz.az # printing position of the Moon print ("Moon:") print (" Equatorial: (RA, Dec) = (%s, %s)" % (moon_ra, moon_dec) ) print (" Ecliptic: (lambda, beta) = (%s, %s)" % (moon_lambda, moon_beta) ) print (" AltAz: (Az, Alt) = (%s, %s)" % (moon_az, moon_alt) )
実行してみると、以下のようになるでござる。
% ./astroplan_sample_08.py -h usage: astroplan_sample_08.py [-h] [-l LONGITUDE] [-b LATITUDE] [-a ALTITUDE] [-t DATETIME] finding position of the Moon optional arguments: -h, --help show this help message and exit -l LONGITUDE, --longitude LONGITUDE longitude of observing site in format "+121d11m12s" -b LATITUDE, --latitude LATITUDE latitude of observing site in format "+24d58m12s" -a ALTITUDE, --altitude ALTITUDE altitude above sea-level in metre -t DATETIME, --datetime DATETIME date/time in UT in "YYYY-MM-DDThh:mm:ss.sss" format % ./astroplan_sample_08.py -t 2022-07-03T12:00:00 # # input parameters # # Location: # longitude = +120d52m25s # latitude = +23d28m07s # altitude = 2862.0 m # Date/Time: # date/time (UT) = 2022-07-03T12:00:00 Moon: Equatorial: (RA, Dec) = (10h10m14.3467305s, +16d08m05.88009171s) Ecliptic: (lambda, beta) = (149d25m25.93907872s, 5d03m08.39617037s) AltAz: (Az, Alt) = (277d32m34.21267336s, 24d44m52.48131149s)