Notebook

これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。

HTML ファイル生成日時: 2024/11/24 14:07:03.493 (台灣標準時)

astroplan の使い方 (6): 観測可能な時間を調べる

astroplan を使って、薄明の終了と開始の時間を調べ、観測可能な時間を知る には以下のようにすればよいようでござる。


#!/usr/pkg/bin/python3.9

#
# Time-stamp: <2022/07/03 11:18:30 (CST) daisuke>
#

# importing argparse module
import argparse

# importing astropy module
import astropy.units
import astropy.time
import astropy.coordinates

# importing astroplan module
import astroplan

# units
unit_m = astropy.units.m

# constructing parser object
desc   = "finding length of observable time on a night"
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')

# 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)
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')

# end of twilight
twilight_civil_end        = observer.twilight_evening_civil \
    (datetime, which="nearest")
twilight_nautical_end     = observer.twilight_evening_nautical \
    (datetime, which="nearest")
twilight_astronomical_end = observer.twilight_evening_astronomical \
    (datetime, which="nearest")

# start of twilight
twilight_civil_start        = observer.twilight_morning_civil \
    (datetime, which="nearest")
twilight_nautical_start     = observer.twilight_morning_nautical \
    (datetime, which="nearest")
twilight_astronomical_start = observer.twilight_morning_astronomical \
    (datetime, which="nearest")

# printing results
print ("end of evening twilight nearest to %s" % datetime)
print ("  civil twilight:        %s" % twilight_civil_end.isot)
print ("  nautical twilight:     %s" % twilight_nautical_end.isot)
print ("  astronomical twilight: %s" % twilight_astronomical_end.isot)
print ("start of morning twilight nearest to %s" % datetime)
print ("  civil twilight:        %s" % twilight_civil_start.isot)
print ("  nautical twilight:     %s" % twilight_nautical_start.isot)
print ("  astronomical twilight: %s" % twilight_astronomical_start.isot)

# calculating observable time
obs_time = twilight_astronomical_start.mjd - twilight_astronomical_end.mjd

print ("length of observable time on %s" % datetime)
print ("  observable time = %6.4f [day]" % obs_time)
print ("                  = %5.2f [hour]" % (obs_time * 24.0) )

実行してみると、以下のようになるでござる。


% ./astroplan_sample_07.py -h
usage: astroplan_sample_07.py [-h] [-l LONGITUDE] [-b LATITUDE] [-a ALTITUDE]
                              [-t DATETIME]

finding length of observable time on a night

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_07.py -t 2022-07-03T16:00:00
#
# input parameters
#
#  Location:
#   longitude = +121d11m12s
#   latitude  = +24d58m12s
#   altitude  = 151.6 m
#  Date/Time:
#   date/time (UT) = 2022-07-03T16:00:00
#
end of evening twilight nearest to 2022-07-03T16:00:00.000
  civil twilight:        2022-07-03T11:14:44.574
  nautical twilight:     2022-07-03T11:45:31.111
  astronomical twilight: 2022-07-03T12:17:44.886
start of morning twilight nearest to 2022-07-03T16:00:00.000
  civil twilight:        2022-07-03T20:44:29.544
  nautical twilight:     2022-07-03T20:13:43.255
  astronomical twilight: 2022-07-03T19:41:29.051
length of observable time on 2022-07-03T16:00:00.000
  observable time = 0.3082 [day]
                  =  7.40 [hour]
% ./astroplan_sample_07.py -t 2023-01-03T16:00:00
#
# input parameters
#
#  Location:
#   longitude = +121d11m12s
#   latitude  = +24d58m12s
#   altitude  = 151.6 m
#  Date/Time:
#   date/time (UT) = 2023-01-03T16:00:00
#
end of evening twilight nearest to 2023-01-03T16:00:00.000
  civil twilight:        2023-01-03T09:43:17.242
  nautical twilight:     2023-01-03T10:11:40.621
  astronomical twilight: 2023-01-03T10:39:37.093
start of morning twilight nearest to 2023-01-03T16:00:00.000
  civil twilight:        2023-01-03T22:15:59.023
  nautical twilight:     2023-01-03T21:47:36.570
  astronomical twilight: 2023-01-03T21:19:40.929
length of observable time on 2023-01-03T16:00:00.000
  observable time = 0.4445 [day]
                  = 10.67 [hour]

参考文献



Frequently accessed files

  1. Computer___Python/20220518_0.html
  2. Computer___Network/20230726_00.html
  3. Misc___Taiwan/20240207_00.html
  4. Computer___Network/20230516_00.html
  5. Computer___FreeBSD/20220621_0.html
  6. Computer___Python/20220715_0.html
  7. Computer___Network/20230508_00.html
  8. Food___Taiwan/20220429_0.html
  9. Computer___NetBSD/20220817_3.html
  10. Computer___Python/20220410_0.html
  11. Computer___Network/20240416_00.html
  12. Computer___Network/20240130_00.html
  13. Computer___Debian/20210223_1.html
  14. Computer___NetBSD/20230119_00.html
  15. Computer___Python/20210124_0.html
  16. Computer___Python/20221013_0.html
  17. Computer___NetBSD/20220818_1.html
  18. Computer___NetBSD/20220428_0.html
  19. Science___Math/20220420_0.html
  20. Computer___NetBSD/20240101_02.html
  21. Computer___NetBSD/20220808_0.html
  22. Computer___TeX/20230503_00.html
  23. Computer___NetBSD/20230515_00.html
  24. Science___Astronomy/20220503_0.html
  25. Computer___NetBSD/20210127_0.html
  26. Computer___Python/20240101_00.html
  27. Computer___Network/20220413_1.html
  28. Computer___Python/20220816_1.html
  29. Computer___NetBSD/20210204_0.html
  30. Travel___Taiwan/20220809_2.html


HTML file generated by Kinoshita Daisuke.