forked from richardjedgar/observing_stats
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake_stats.csh
More file actions
executable file
·286 lines (228 loc) · 9.09 KB
/
make_stats.csh
File metadata and controls
executable file
·286 lines (228 loc) · 9.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#!/usr/bin/env tcsh
echo -n "Username: "
set username = $<
stty -echo
echo -n "Password: "
set password = $<
stty echo
# get ASCDS tools (sqsh, param_extract)
source /home/ascds/DS.release/config/system/.ascrc
# get rdb tools
source /proj/axaf/simul/etc/mst_envs.tcsh
#edit both these lists to add AO periods
set aolist = "10 11 12 13 14 15 16 17 18 19 20"
set aorev = "20 19 18 17 16 15 14 13 12 11 10"
# set aolist = "15"
# set aorev = "15"
# this script computes observing statistics for the indicated AO periods.
# It expects to find the following files in the directory where it runs:
# cases.rdb
# index.html
# hrc_extract.sqsh
# and a bunch of html files it uses to construct web pages:
# 4blank.html
# all_text.html
# ggto_text.html
# nocal_text.html
# wip_text.html
#
# there is a followup script make_drop_stats.csh that looks at
# chip-drop statistics.
# if new cases are desired, add them to the cases.rdb file
# and write a ${case}_text.html file to describe it.
# COPY THIS STUFF to another directory (label with the date) and run it.
# this next section must be redone if the aolist is expanded.
# if you need to re-run but not re-extract from the obscat, uncomment this
# (and the 'endif' below as marked)
# if ( 0 ) then
which param_extract
rm -f obscat_acis_?? obscat_hrc_?? *remarks *winparams *abstracts
foreach ao ( $aolist )
echo param_extract -a -A $ao -b -o obscat_acis_${ao}
echo "$username\n$password" | param_extract -a -A $ao -b -o obscat_acis_${ao} >! obscat_acis_${ao}.log
echo param_extract -h -A $ao -b -o obscat_hrc_${ao}
echo "$username\n$password" | param_extract -h -A $ao -b -o obscat_hrc_${ao} >! obscat_hrc_${ao}.log
end
rm -f *remarks *winparams *abstracts
date +%D >! date_extracted.txt
# now go use sqsh to get the hrc parameters to file hrc_test
#
/usr/local/bin/sqsh -S ocatsqlsrv -U "$username" -P "$password" -w 400 < hrc_extract.sqsh >! hrc_obscat_test.txt
# endif
# end of obscat extraction; comment out if the 'if (0) then' line is commented out.
echo "************ ckpoint 002 ***************"
# foreach ao ( $aolist )
# cat hrc_test_${ao} \
cat hrc_obscat_test.txt \
| grep -v ' ------' \
| grep -v 'rows affected' \
| grep -v '^$' \
>! hrc_obscat.txt
# >! hrc_obscat_${ao}.txt
repair -blank -w -l -f hrc_obscat.txt
#repair -blank -w -l -f hrc_obscat_${ao}.txt
# end
# rdbcat hrc_obscat_??.rdb >! hrc_obscat.rdb
echo "************ ckpoint 003 ***************"
foreach ao ( $aolist )
# | row obs_ao_str eq $ao \
cat hrc_obscat.rdb \
| sorttbl obsid \
| column -v grating type \
-c approved_exposure_time app_exp -c rem_exp_time rem_exp \
>! tmp.rdb
# apparently a few obsids don't match.
# different opinions as to which AO some things are in.
# so don't cut hrc_obscat.rdb on ao and it works.
#
cat obscat_hrc_${ao} \
| column -v -a ROW N \
| compute ROW eq _NR \
| sorttbl -uniq obsid \
| jointbl obsid tmp.rdb \
| sorttbl -uniq obsid \
>! hrc_obscat_${ao}.rdb
end #ao
# now we have hrc_obscat_*.rdb and obscat_acis* files.
set num_cases = `headchg -del < cases.rdb | wc -l`
set cases = `column case < cases.rdb | headchg -del`
# GTO, GO
echo "************ ckpoint 005 ***************"
foreach case ( $cases )
set ctype=`row < cases.rdb case eq $case | column type | headchg -del`
set cstatus=`row < cases.rdb case eq $case | column status | headchg -del`
echo $case
echo $ctype
echo $cstatus
foreach ao ( $aolist )
foreach inst ( HRC-S HRC-I )
foreach grating ( NONE HETG LETG )
cat hrc_obscat_${ao}.rdb \
| column ao obsid seqnbr grating si status app_exp rem_exp type \
| row $cstatus \
| row grating eq $grating and si eq $inst \
| row $ctype \
| column -v -t app_exp N -t rem_exp N \
| rdbstats app_exp rem_exp \
| column -a ao N -a si S -a grating S app_exp_n app_exp_sum rem_exp_sum \
| compute ao = $ao | compute si = $inst | compute grating = $grating \
| compute app_exp_n = 0 if \( app_exp_sum eq "" \) \
| compute app_exp_sum = 0 if \( app_exp_sum eq "" \) \
| tee ${case}_stats_${inst}_${grating}_${ao}.rdb \
| tbl2lst
end # grating
end # inst
foreach inst ( ACIS-S ACIS-I )
foreach grating ( NONE HETG LETG )
cat obscat_acis_${ao} \
| column ao obsid seqnbr grating si status app_exp rem_exp type \
| row $cstatus \
| row grating eq $grating and si eq $inst \
| row $ctype \
| column -v -t app_exp N -t rem_exp N \
| rdbstats app_exp rem_exp \
| column -a ao N -a si S -a grating S app_exp_n app_exp_sum rem_exp_sum \
| compute ao = $ao | compute si = $inst | compute grating = $grating \
| compute app_exp_n = 0 if \( app_exp_sum eq "" \) \
| compute app_exp_sum = 0 if \( app_exp_sum eq "" \) \
| tee ${case}_stats_${inst}_${grating}_${ao}.rdb \
| tbl2lst
end
end
rdbcat ${case}_stats_*${ao}.rdb \
| rdbstats app_exp_sum app_exp_n \
| column -a ao N -a si S -a grating S \
-c app_exp_n_sum app_exp_n -c app_exp_sum_sum app_exp_sum \
-a rem_exp_sum N \
| compute ao = $ao | compute si = total \
>! ${case}_total_stats_${ao}.rdb
# never created...
set tot_time=`column app_exp_sum < ${case}_total_stats_${ao}.rdb | headchg -del`
set tot_obs=`column app_exp_n < ${case}_total_stats_${ao}.rdb | headchg -del`
echo "${case}" $tot_time $tot_obs
rdbcat ${case}_stats_*${ao}.rdb ${case}_total_stats_${ao}.rdb \
| column -v -a pct_obs N -a pct_time N \
| compute pct_obs = 100.0 \* app_exp_n / $tot_obs \
| compute pct_time = 100.0 \* app_exp_sum / $tot_time \
| rdbfmt pct_obs %.2f pct_time %.2f rem_exp_sum %.1f \
>! ${case}_totals_${ao}.rdb
end
# rdbcat ggto_totals_1[567].rdb \
# | tee ggto_totals_151617.rdb
end #case
echo "************ ckpoint 006 ***************"
# set case = all
# foreach case ( $cases )
# foreach ao ( $aolist )
# cat ${case}_totals_${ao}.rdb \
# | column si grating -c app_exp_n obsids_${ao} -c pct_obs pct_obs_${ao} \
# -c app_exp_sum time_${ao} -c pct_time pct_time_${ao} \
# >! tmp_${ao}.rdb
# end
# # jointbl si grating tmp_17.rdb < tmp_16.rdb \
# # | jointbl si grating tmp_15.rdb \
# # | rdb2html >! $case.html
# end
# new stuff June 20, 2017
#
# possibly make a plot of stuff vs. AO here, to include as an image.
# sorta like this:
# rdbcat all_totals_??.rdb \
# | sorttbl si grating ao \
# | rdbplt xcol=ao ycol=pct_obs break=grating dev=/xs legend+
foreach case ( $cases )
rdbcat ${case}_totals_??.rdb \
| sorttbl si grating ao \
| row si ne "total" \
| tee tmp.rdb \
| rdbplt xcol=ao ycol=pct_obs break=grating dev=/xs legend+ \
legend_opts="x=0.1 y=0.9 ul box" title="red=ACIS-I, green=ACIS-S gray=HRC-I magenta=HRC-S" \
color=red,red,red,green,green,green,lightgray,lightgray,lightgray,magenta,magenta,magenta,white \
marker=1,2,3,1,2,3,1,2,3,1,2,3,4 line_width=3 \
connect=dash,full,dot,dash,full,dot,dash,full,dot,dash,full,dot
cat tmp.rdb \
| rdbplt xcol=ao ycol=pct_obs break=grating dev=${case}_num.ps/cps legend+ \
legend_opts="x=0.1 y=0.9 ul box" title="red=ACIS-I, green=ACIS-S gray=HRC-I magenta=HRC-S" \
color=red,red,red,green,green,green,lightgray,lightgray,lightgray,magenta,magenta,magenta,white \
marker=1,2,3,1,2,3,1,2,3,1,2,3,4 line_width=3 \
connect=dash,full,dot,dash,full,dot,dash,full,dot,dash,full,dot
rm tmp.rdb
rdbcat ${case}_totals_??.rdb \
| sorttbl si grating ao \
| row si ne "total" \
| tee tmp.rdb \
| rdbplt xcol=ao ycol=pct_time break=grating dev=/xs legend+ \
legend_opts="x=0.1 y=0.9 ul box" title="red=ACIS-I, green=ACIS-S gray=HRC-I magenta=HRC-S" \
color=red,red,red,green,green,green,lightgray,lightgray,lightgray,magenta,magenta,magenta,white \
marker=1,2,3,1,2,3,1,2,3,1,2,3,4 line_width=3 \
connect=dash,full,dot,dash,full,dot,dash,full,dot,dash,full,dot
cat tmp.rdb \
| rdbplt xcol=ao ycol=pct_time break=grating dev=${case}_time.ps/cps legend+ \
legend_opts="x=0.1 y=0.9 ul box" title="red=ACIS-I, green=ACIS-S gray=HRC-I magenta=HRC-S" \
color=red,red,red,green,green,green,lightgray,lightgray,lightgray,magenta,magenta,magenta,white \
marker=1,2,3,1,2,3,1,2,3,1,2,3,4 line_width=3 \
connect=dash,full,dot,dash,full,dot,dash,full,dot,dash,full,dot
rm tmp.rdb
ps2any --trim --rotate=90 ${case}_num.ps ${case}_num.png
ps2any --trim --rotate=90 ${case}_time.ps ${case}_time.png
# should use date extracted, not date of script run
echo "OBSCAT data extracted `cat date_extracted.txt`</p><p>" >! tmp.html
# echo "OBSCAT data extracted `date +%D`</p><p>" >! tmp.html
cat ${case}_text.html >> tmp.html
foreach ao ( $aorev )
cat 4blank.html >> tmp.html
cat ${case}_totals_${ao}.rdb \
| column ao si grating -c app_exp_n obsids pct_obs -c app_exp_sum time pct_time \
| rdb2html >> tmp.html
end
mv tmp.html ${case}_allyears.html
end
# end #case
rm -rf observing_stats/*
mkdir observing_stats
cp {all,nocal,ggto,wip}_allyears.html observing_stats
cp {all,nocal,ggto,wip}_{num,time}.png observing_stats
cp index.html observing_stats
tar cfv obscat_stats.tar observing_stats
# this line copies the tarball to the web DMZ.
cp obscat_stats.tar /proj/web-cxc-dmz/htdocs/acis/tmp