2018-05-01 01:35:34 -06:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from __future__ import print_function
|
|
|
|
import numpy as np
|
|
|
|
from astropy.io import ascii
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import astropy.units as u
|
2018-05-06 08:45:51 -06:00
|
|
|
from astropy.coordinates import SkyCoord, AltAz, EarthLocation
|
2018-05-01 01:35:34 -06:00
|
|
|
from astropy.time import Time
|
2018-05-06 08:45:51 -06:00
|
|
|
import configparser
|
|
|
|
import argparse
|
2018-05-07 14:19:05 -06:00
|
|
|
import os
|
2018-05-01 01:35:34 -06:00
|
|
|
|
2018-05-06 08:45:51 -06:00
|
|
|
# Read commandline options
|
|
|
|
conf_parser = argparse.ArgumentParser(description='Plot image statistics')
|
|
|
|
conf_parser.add_argument("-c", "--conf_file",
|
|
|
|
help="Specify configuration file. If no file" +
|
|
|
|
" is specified 'configuration.ini' is used.",
|
|
|
|
metavar="FILE")
|
|
|
|
conf_parser.add_argument("-i", "--input",
|
|
|
|
help="Specify file to be processed. If no file" +
|
|
|
|
" is specified ./imgstat.csv will be used.",
|
|
|
|
metavar='FILE', default="./imgstat.csv")
|
2018-05-07 14:19:05 -06:00
|
|
|
conf_parser.add_argument("-d", "--directory",
|
|
|
|
help="Specify directory of observations. If no" +
|
|
|
|
" directory is specified parent will be used.",
|
|
|
|
metavar='DIR', dest='file_dir', default=".")
|
2018-05-06 08:45:51 -06:00
|
|
|
conf_parser.add_argument("-o", "--output",
|
|
|
|
help="Specify output file. Default is 'imgstat.png'",
|
|
|
|
metavar='FILE', default="./imgstat.png")
|
2018-05-01 01:35:34 -06:00
|
|
|
|
2018-05-06 08:45:51 -06:00
|
|
|
args = conf_parser.parse_args()
|
2018-05-01 01:35:34 -06:00
|
|
|
|
2018-05-06 08:45:51 -06:00
|
|
|
# Process commandline options and parse configuration
|
|
|
|
cfg = configparser.ConfigParser(inline_comment_prefixes=('#', ';'))
|
|
|
|
if args.conf_file:
|
|
|
|
cfg.read([args.conf_file])
|
|
|
|
else:
|
|
|
|
cfg.read('configuration.ini')
|
2018-05-01 01:35:34 -06:00
|
|
|
|
2018-05-07 14:19:05 -06:00
|
|
|
# Move to processing directory
|
|
|
|
os.chdir(args.file_dir)
|
|
|
|
|
2018-05-06 08:45:51 -06:00
|
|
|
table = ascii.read(args.input, format="csv")
|
2018-05-01 01:35:34 -06:00
|
|
|
|
2018-05-06 08:45:51 -06:00
|
|
|
t = Time(table['mjd'], format="mjd", scale="utc")
|
|
|
|
pos = SkyCoord(ra=table['ra'], dec=table['de'], frame="icrs", unit="deg")
|
2018-05-01 01:35:34 -06:00
|
|
|
|
2018-05-06 08:45:51 -06:00
|
|
|
# Set location
|
|
|
|
loc = EarthLocation(lat=cfg.getfloat('Common', 'observer_lat')*u.deg,
|
|
|
|
lon=cfg.getfloat('Common', 'observer_lon')*u.deg,
|
|
|
|
height=cfg.getfloat('Common', 'observer_el')*u.m)
|
|
|
|
|
|
|
|
pa = pos.transform_to(AltAz(obstime=t, location=loc))
|
|
|
|
|
|
|
|
mjd0 = np.floor(np.min(table['mjd']))
|
|
|
|
|
|
|
|
plt.figure(figsize=(20, 10))
|
2018-05-01 01:35:34 -06:00
|
|
|
plt.subplot(411)
|
|
|
|
|
2018-05-06 08:45:51 -06:00
|
|
|
plt.plot(table['mjd']-mjd0, table['mean'], label='Brightness')
|
|
|
|
plt.plot(table['mjd']-mjd0, table['std'], label='Variation')
|
2018-05-01 01:46:42 -06:00
|
|
|
plt.ylabel("ADU")
|
2018-05-01 01:35:34 -06:00
|
|
|
plt.legend()
|
|
|
|
plt.subplot(412)
|
2018-05-06 08:45:51 -06:00
|
|
|
plt.plot(table['mjd']-mjd0, pa.az.degree)
|
2018-05-01 01:46:42 -06:00
|
|
|
plt.ylabel("Azimuth (deg)")
|
2018-05-01 01:35:34 -06:00
|
|
|
plt.subplot(413)
|
2018-05-06 08:45:51 -06:00
|
|
|
plt.plot(table['mjd']-mjd0, pa.alt.degree)
|
2018-05-01 01:46:42 -06:00
|
|
|
plt.ylabel("Altitude (deg)")
|
2018-05-01 01:35:34 -06:00
|
|
|
plt.subplot(414)
|
2018-05-06 08:45:51 -06:00
|
|
|
plt.plot(table['mjd']-mjd0, table['rmsx'], label='RA')
|
|
|
|
plt.plot(table['mjd']-mjd0, table['rmsy'], label='Dec')
|
|
|
|
plt.ylim(0, 60)
|
2018-05-01 01:46:42 -06:00
|
|
|
plt.ylabel("Residual (arcseconds)")
|
2018-05-06 08:45:51 -06:00
|
|
|
plt.xlabel("MJD - %.0f" % mjd0)
|
2018-05-01 01:35:34 -06:00
|
|
|
plt.legend()
|
2018-05-06 08:45:51 -06:00
|
|
|
plt.savefig(args.output)
|