これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。
HTML ファイル生成日時: 2024/12/21 11:44:57.596 (台灣標準時)
astroplan を使って、与えられた場所と時刻における天体の出没時刻を調べる には以下のようにすればよいようでござる。
#!/usr/pkg/bin/python3.9 # # Time-stamp: <2022/07/03 12:13:03 (CST) daisuke> # # importing argparse module import argparse # importing numpy module import numpy # importing astropy module import astropy.units import astropy.time import astropy.coordinates # importing astroplan module import astroplan # units unit_m = astropy.units.m unit_rad = astropy.units.rad unit_deg = astropy.units.deg # constructing parser object desc = "finding rise and set time of targets at given location" parser = argparse.ArgumentParser (description=desc) # adding arguments parser.add_argument ('-l', '--longitude', default='+121d11m12s', \ help='longitude of observing site in format "+121d11m12s"') parser.add_argument ('-b', '--latitude', default='+24d58m12s', \ help='latitude of observing site in format "+24d58m12s"') parser.add_argument ('-a', '--altitude', type=float, default=151.6, \ 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') parser.add_argument ('target', nargs='+', default='Vega', \ help='names of targets') # 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 list_target = args.target # 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) print ("# Targets:") for target in list_target: print ("# %s" % target) print ("#") # location object location = astropy.coordinates.EarthLocation.from_geodetic \ (site_lon, site_lat, site_alt) # observer object observer = astroplan.Observer (location=location, name="observer", \ timezone="UTC") # time object datetime = astropy.time.Time (datetime_str, scale='utc') # processing each target for target in list_target: # object obj = astroplan.FixedTarget.from_name (target) # rise time time_rise = observer.target_rise_time (datetime, obj, which="nearest") # set time time_set = observer.target_set_time (datetime, obj, which="nearest") # printing results print ("rise and set of %s around %s:" % (target, datetime) ) print (" rise time: %s" % time_rise.isot) print (" set time: %s" % time_set.isot)
実行してみると、以下のようになるでござる。
% ./astroplan_sample_13.py -h usage: astroplan_sample_13.py [-h] [-l LONGITUDE] [-b LATITUDE] [-a ALTITUDE] [-t DATETIME] target [target ...] finding rise and set time of targets at given location positional arguments: target names of targets 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_13.py -t 2022-07-03T16:00:00 Arcturus # # input parameters # # Location: # longitude = +121d11m12s # latitude = +24d58m12s # altitude = 151.6 m # Date/Time: # date/time (UT) = 2022-07-03T16:00:00 # Targets: # Arcturus # rise and set of Arcturus around 2022-07-03T16:00:00.000: rise time: 2022-07-03T04:50:05.418 set time: 2022-07-03T18:02:05.571 % ./astroplan_sample_13.py -t 2022-07-03T16:00:00 Arcturus Vega Antares # # input parameters # # Location: # longitude = +121d11m12s # latitude = +24d58m12s # altitude = 151.6 m # Date/Time: # date/time (UT) = 2022-07-03T16:00:00 # Targets: # Arcturus # Vega # Antares # rise and set of Arcturus around 2022-07-03T16:00:00.000: rise time: 2022-07-03T04:50:05.418 set time: 2022-07-03T18:02:05.571 rise and set of Vega around 2022-07-03T16:00:00.000: rise time: 2022-07-03T08:19:37.261 set time: 2022-07-03T23:13:07.488 rise and set of Antares around 2022-07-03T16:00:00.000: rise time: 2022-07-03T08:34:18.145 set time: 2022-07-03T18:45:18.418