Notebook

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

HTML ファイル生成日時: 2024/12/21 11:44:57.596 (台灣標準時)

astroplan の使い方 (13): ファインディングチャートを作る

astroplan を使って、ファインディングチャートを作るには以下のようにすれ ばよいようでござる。


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

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

# importing argparse module
import argparse

# importing pathlib module
import pathlib

# importing sys module
import sys

# importing astropy module
import astropy.units

# importing astroplan module
import astroplan
import astroplan.plots

# importing matplotlib module
import matplotlib.pyplot

# importing ssl module
import ssl

# allow insecure downloading
ssl._create_default_https_context = ssl._create_unverified_context

# units
unit_arcmin = astropy.units.arcmin

# constructing parser object
desc   = "making a finding chart"
parser = argparse.ArgumentParser (description=desc)

# adding arguments
parser.add_argument ('-t', '--target', default='M1', help='target name')
parser.add_argument ('-f', '--fov', type=float, default=15.0, \
                     help='field-of-view in arcmin (default: 15 arcmin)')
parser.add_argument ('-o', '--output', default='chart.png', \
                     help='output file name (EPS, PDF, PNG, or PS file)')

# command-line argument analysis
args = parser.parse_args ()

# input parameters
target      = args.target
fov         = args.fov * unit_arcmin
file_output = args.output

# making pathlib object
path_output = pathlib.Path (file_output)
if (path_output.exists ()):
    # printing message
    print ("ERROR: output file '%s' exists." % file_output)
    # exit
    sys.exit ()
if not ( (path_output.suffix == '.eps') or (path_output.suffix == '.pdf') \
         or (path_output.suffix == '.png') or (path_output.suffix == '.ps') ):
    # printing message
    print ("ERROR: output file must be either EPS, PDF, PNG, or PS.")
    # exit
    sys.exit ()

# target
obj = astroplan.FixedTarget.from_name (target)

# image
ax, hdu = astroplan.plots.plot_finder_image (obj, fov_radius=fov)

# saving the image to file
matplotlib.pyplot.savefig (file_output, dpi=225)

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


% ./astroplan_sample_16.py -h
usage: astroplan_sample_16.py [-h] [-t TARGET] [-f FOV] [-o OUTPUT]

making a finding chart

optional arguments:
  -h, --help            show this help message and exit
  -t TARGET, --target TARGET
                        target name
  -f FOV, --fov FOV     field-of-view in arcmin (default: 15 arcmin)
  -o OUTPUT, --output OUTPUT
                        output file name (EPS, PDF, PNG, or PS file)

% ./astroplan_sample_16.py -t M1 -o m1.png
Downloading https://skyview.gsfc.nasa.gov/tempspace/fits/skv11085880335151.fits
|==========================================| 374k/374k (100.00%)         1s
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-daisuke'
% ls -lF *.png
-rw-r--r--  1 daisuke  taiwan  174496 Jul  3 12:27 airmass_20220703.png
-rw-r--r--  1 daisuke  taiwan  127678 Jul  3 12:39 m1.png
-rw-r--r--  1 daisuke  taiwan  175140 Jul  3 12:33 sky_20220703.png
% feh -dF m1.png

fig_202207/m1.png

参考文献



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___Network/20240130_00.html
  10. Computer___NetBSD/20220817_3.html
  11. Computer___Python/20220410_0.html
  12. Computer___Network/20240416_00.html
  13. Computer___NetBSD/20230119_00.html
  14. Computer___Debian/20210223_1.html
  15. Computer___Python/20221013_0.html
  16. Computer___Python/20210124_0.html
  17. Computer___NetBSD/20220428_0.html
  18. Computer___NetBSD/20220818_1.html
  19. Computer___NetBSD/20240101_02.html
  20. Science___Math/20220420_0.html
  21. Computer___Python/20240101_00.html
  22. Computer___NetBSD/20220808_0.html
  23. Computer___TeX/20230503_00.html
  24. Science___Astronomy/20220503_0.html
  25. Computer___NetBSD/20230515_00.html
  26. Computer___Network/20220413_1.html
  27. Computer___NetBSD/20210127_0.html
  28. Computer___TeX/20231107_00.html
  29. Computer___Python/20220816_1.html
  30. Computer___Python/20230717_01.html


HTML file generated by Kinoshita Daisuke.