Created
December 15, 2011 02:36
-
-
Save taldcroft/1479577 to your computer and use it in GitHub Desktop.
Calculate DPA max temperatures for different pitch and CCD configurations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import xija | |
from Chandra.Time import DateTime | |
from Ska.Matplotlib import plot_cxctime | |
import Ska.DBI | |
import Ska.engarchive.fetch_sci as fetch | |
import matplotlib.pyplot as plt | |
db = Ska.DBI.DBI(server='sybase', dbi='sybase', user='aca_read') | |
if 'obs' not in globals(): | |
obs = db.fetchall('select * from observations ' | |
'where kalman_datestart > "2006:001" ' | |
'and instrume = "ACIS" ' | |
'and kalman_tstop - kalman_tstart > 50000') | |
if 'states' not in globals(): | |
states = db.fetchall('select * from cmd_states ' | |
'where datestart > "2005:365" ' | |
'and pcad_mode = "NPNT"') | |
if 'dpamzt' not in globals(): | |
dpamzt = fetch.Msid('1dpamzt', '2005:365', stat='5min') | |
del db | |
def plot_tlm_maxes(pitch, n_ccd, color): | |
for ob in obs: | |
tstop = ob['kalman_tstop'] - 1000 | |
ok = (states['tstart'] < tstop) & (states['tstop'] > tstop) | |
state = states[ok][0] | |
if state['ccd_count'] != n_ccd or abs(state['pitch'] - pitch) > 5: | |
continue | |
idx = np.searchsorted(dpamzt.times, tstop) | |
plot_cxctime([tstop], [dpamzt.vals[idx]], 'o', mfc=color) | |
if dpamzt.vals[idx] > 30.0 or (dpamzt.vals[idx] > 28.0 | |
and n_ccd <= 5): | |
print state['obsid'], state['ccd_count'], dpamzt.vals[idx], \ | |
DateTime(tstop).date | |
# DPA power (W) corresponding to number of FEP / CCD with | |
# vid_board=1 and clocking=1 | |
def calc_settle_temp(date, n_fep, pitch): | |
dpa_power = [21.5, 29.2, 39.1, 47.9, 57.0, 66.5, 76.5] | |
date = DateTime(date) | |
model = xija.ThermalModel('dpa', start=date, stop=date + 5, | |
model_spec='dpa/dpa_mask_2006-2011_lin.json') | |
model.comp['1dpamzt'].set_data(20.0) | |
model.comp['sim_z'].set_data(75000.0) | |
model.comp['dpa__1dpamzt'].set_data(dpa_power[n_fep]) | |
model.comp['pitch'].set_data(pitch) | |
model.comp['eclipse'].set_data(False) | |
model.make() | |
model.calc() | |
return model.comp['1dpamzt'].mvals[-2] | |
linestyles = ['-', '-'] | |
colors = ['r', 'g', 'b', 'k'] | |
dates = DateTime('2006:001') + np.arange(0, 365*7.2, 30) | |
times = dates.secs | |
for n_fep, linestyle in zip((5, 6), linestyles): | |
plt.figure(n_fep) | |
plt.clf() | |
for pitch, color in zip((130, 140, 150), colors): | |
temps = [] | |
for time in times: | |
t_settle = calc_settle_temp(time, n_fep, pitch) | |
temps.append(t_settle) | |
plot_cxctime(times, temps, color=color, linestyle=linestyle, | |
label='DPA model, pitch {} - {}'.format(pitch - 5, pitch + 5)) | |
plot_tlm_maxes(pitch, n_fep, color) | |
plt.ylim(16, 36) | |
xlims = plt.xlim() | |
plt.plot(xlims, [35, 35], '--m', linewidth=2) | |
plt.plot(xlims, [32.5, 32.5], '--y', linewidth=2) | |
plt.grid() | |
plt.title('Max 1DPAMZT versus time: {} CCDs'.format(n_fep)) | |
plt.ylabel('Max 1DPAMZT (degC)') | |
plt.legend(loc='upper left') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment