Skip to content

Instantly share code, notes, and snippets.

@taldcroft
Created July 23, 2014 13:00
Show Gist options
  • Select an option

  • Save taldcroft/e2155b8ecfaa9ccda6c8 to your computer and use it in GitHub Desktop.

Select an option

Save taldcroft/e2155b8ecfaa9ccda6c8 to your computer and use it in GitHub Desktop.
from Chandra.Time import DateTime
from Ska.DBI import DBI
from astropy.table import Table, join
import numpy as np
from Ska.Matplotlib import plot_cxctime
import matplotlib.pyplot as plt
if 'acqs' not in globals():
start = DateTime() - 365 * .3
db = DBI(server='sybase', user='aca_read', dbi='sybase')
acqs = db.fetchall('SELECT obsid,tstart,obc_id FROM acq_stats_data '
'WHERE tstart>{}'
.format(start.secs))
db.conn.close()
acqs = Table(acqs)
acqs_id = acqs[acqs['obc_id'] == 'ID']
gacqs = acqs_id.group_by('obsid')
n_acqs = gacqs.groups.aggregate(np.size)
del n_acqs['tstart']
t_acqs = gacqs.groups.aggregate(np.mean)
out = join(n_acqs, t_acqs, keys='obsid')
# In [6]: print out
# obsid obc_id tstart
# ----- ------ -------------
# 14204 7 519692466.208
# 14223 8 514467026.682
# 14233 7 519941788.76
# ...
# 14479 8 521789058.212
# 14481 8 516250320.755
# 14487 8 517774710.577
plot_cxctime(out['tstart'], out['obc_id'], '.')
plt.grid()
plt.margins(0.05)
plt.ylabel('Identified acq stars')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment