This is a very simple process notebook to take the full set of possible stars for plate scale calibration and extract pairs within an obsid that can be used in the plate scale fitting process.
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.style
matplotlib.style.use('bmh')
import itertools
import chandra_aca.transform
from Ska.Matplotlib import plot_cxctime
from astropy.table import Table
stars_all = Table.read('stars_all.fits')
stars_all = stars_all[stars_all['t_aca'] != -99]
stars_all = stars_all.group_by('obsid')
In the code below, star_yag,zag
are derived using the OBC quaternion at mid_time
and the
star RA, Dec (PM-corrected) from the AGASC.
mean_dys = []
mean_dzs = []
ddys = []
ddzs = []
for stars in stars_all.groups:
dy = stars['aoacyan_mean'] - stars['star_yag']
dz = stars['aoaczan_mean'] - stars['star_zag']
mean_dys.append(np.mean(dy))
mean_dzs.append(np.mean(dz))
ddys.append(dy - mean_dys[-1])
ddzs.append(dz - mean_dzs[-1])
ddys = np.concatenate(ddys)
ddzs = np.concatenate(ddzs)
plt.plot(ddys, '.')
plt.plot(ddzs, '.');
# This is offset of predicted yag/zag at a single time (mid_time) from
# the mean centroids over the whole observation. The different reflects
# the dither amplitude.
plt.plot(mean_dys, '.')
plt.plot(mean_dzs, '.');
def dist(x1, y1, x2, y2):
return np.sqrt((x1 - x2)**2 + (y1 - y2)**2)
rows = []
for stars in stars_all.groups:
for star1, star2 in itertools.combinations(stars, 2):
yz_dist = dist(star1['star_yag'], star1['star_zag'],
star2['star_yag'], star2['star_zag'])
rc_dist = dist(star1['cent_i'], star1['cent_j'],
star2['cent_i'], star2['cent_j'])
row = [star1['obsid'], star1['t_aca'], star1['kalman_tstart'], star1['kalman_datestart']]
row.extend([yz_dist, rc_dist,
star1['star_yag'], star1['star_zag'],
star2['star_yag'], star2['star_zag'],
star1['cent_i'], star1['cent_j'],
star2['cent_i'], star2['cent_j']])
rows.append(row)
names=['obsid', 't_aca', 'tstart', 'datestart',
'yz_dist', 'rc_dist',
'yag1', 'zag1', 'yag2', 'zag2',
'row1', 'col1', 'row2', 'col2']
pairs = Table(rows=rows, names=names)
pairs[:4]
obsid | t_aca | tstart | datestart | yz_dist | rc_dist | yag1 | zag1 | yag2 | zag2 | row1 | col1 | row2 | col2 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
int64 | float64 | float64 | str21 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 | float64 |
2519 | 14.2348555073 | 162519980.317 | 2003:056:00:25:16.133 | 1655.98422399 | 335.30992922 | -732.717137686 | -878.756044107 | -2129.02009109 | -1769.0491489 | 152.14466568 | -171.979576091 | 434.308332221 | -353.132588534 |
2519 | 14.2348555073 | 162519980.317 | 2003:056:00:25:16.133 | 3446.50330022 | 693.462594358 | -732.717137686 | -878.756044107 | 2384.38922672 | 591.629249413 | 152.14466568 | -171.979576091 | -474.75678961 | 124.474358154 |
2519 | 14.2348555073 | 162519980.317 | 2003:056:00:25:16.133 | 5093.49253169 | 1026.89229779 | -2129.02009109 | -1769.0491489 | 2384.38922672 | 591.629249413 | 434.308332221 | -353.132588534 | -474.75678961 | 124.474358154 |
2528 | 14.4979238094 | 142482635.784 | 2002:189:02:29:31.600 | 2148.47314153 | 432.242221409 | -2383.24937216 | 43.2632252573 | -1058.29042713 | 1734.54103623 | 485.310911849 | 12.3744780293 | 219.000468423 | 352.833118235 |
pairs.write('star_pairs.fits', overwrite=True)
len(pairs)
8945