1 |
#! /bin/csh -f |
2 |
# Script to make HMI V drift coefficient tables from hmi.V_45s_nrt data |
3 |
# |
4 |
# set echo |
5 |
|
6 |
# XXXXXXXXXX test |
7 |
# set echo |
8 |
# XXXXXXXXXX test |
9 |
|
10 |
set HERE = $cwd |
11 |
set LOG = $HERE/runlog |
12 |
|
13 |
if ($?WORKFLOW_ROOT) then |
14 |
set WFDIR = $WORKFLOW_DATA |
15 |
set WFCODE = $WORKFLOW_ROOT |
16 |
else |
17 |
echo Need WORKFLOW_ROOT variable to be set. |
18 |
exit 1 |
19 |
endif |
20 |
|
21 |
foreach ATTR (WANTLOW WANTHIGH GATE) |
22 |
set ATTRTXT = `grep $ATTR ticket` |
23 |
set $ATTRTXT |
24 |
end |
25 |
|
26 |
# set CoefProgram = /home/couvidat/cvs/JSOC/bin/linux_x86_64/correction_velocities |
27 |
# copied 29 Oct 2010 2:00 PM |
28 |
#set CoefProgram = $WFCODE/bin/correction_velocities |
29 |
set CoefProgram = /home/jsoc/cvs/Development/JSOC/bin/linux_x86_64/correction_velocities |
30 |
|
31 |
# verify that there is at least one V_drift record within 24 hours |
32 |
# both before and after both the first and last record to be processed. |
33 |
# step by 24 hour increments through the desired range, including the exact |
34 |
# end time. |
35 |
|
36 |
set wantlow_t = `time_convert time=$WANTLOW` |
37 |
set wanthigh_t = `time_convert time=$WANTHIGH` |
38 |
|
39 |
set need_t = $wantlow_t |
40 |
|
41 |
while ($need_t <= $wanthigh_t) |
42 |
@ needlow_t = $need_t - 86400 |
43 |
@ needhigh_t = $need_t + 86400 |
44 |
set need = `time_convert zone=TAI s=$need_t` |
45 |
set needlow = `time_convert zone=TAI s=$needlow_t` |
46 |
set needhigh = `time_convert zone=TAI s=$needhigh_t` |
47 |
set n = `show_info -cq hmi.coefficients'['$needlow'-'$need']'` |
48 |
if ($n <= 0) then |
49 |
echo >>$LOG Need V_drift record for $needlow - $need |
50 |
# make a new coef record on the nearest 06:45 or 18:45 before the needed time. |
51 |
# do this by rounding the time down to closest target. |
52 |
# do this by subtract 06h45m, divide by 12h, then mult by 12, then add 6h45m |
53 |
@ targ_t = $need_t - 24300 |
54 |
@ targ_t = $targ_t / 43200 |
55 |
@ targ_t = $targ_t * 43200 |
56 |
@ targ_t = $targ_t + 24300 |
57 |
@ targlow_t = $targ_t - 43200 |
58 |
@ targhigh_t = $targ_t + 43200 |
59 |
set targlow = `time_convert s=$targlow_t zone=TAI` |
60 |
set targhigh = `time_convert s=$targhigh_t zone=TAI` |
61 |
$CoefProgram begin=$targlow end=$targhigh levin=hmi.V_45s_nrt levout=hmi.coefficients >>$LOG |
62 |
if ($retstatus) then |
63 |
echo >>$LOG "FAIL $CoefProgram failed for $targ with status=$retstatus" |
64 |
goto FAILURE |
65 |
endif |
66 |
endif |
67 |
set n = `show_info -cq hmi.coefficients'['$need'-'$needhigh']'` |
68 |
if ($n <= 0) then |
69 |
echo >>$LOG Need V_drift record for $need - $needhigh |
70 |
# make a new coef record on the nearest 06:45 or 18:45 after the needed time. |
71 |
# do this by rounding the time up to closest target. |
72 |
# do this by adding 06h45m, divide by 12h, then mult by 12, then add 6h45m |
73 |
@ targ_t = $need_t + 24300 |
74 |
@ targ_t = $targ_t / 43200 |
75 |
@ targ_t = $targ_t * 43200 |
76 |
@ targ_t = $targ_t + 24300 |
77 |
@ targlow_t = $targ_t - 43200 |
78 |
@ targhigh_t = $targ_t + 43200 |
79 |
set targlow = `time_convert s=$targlow_t zone=TAI` |
80 |
set targhigh = `time_convert s=$targhigh_t zone=TAI` |
81 |
$CoefProgram begin=$targlow end=$targhigh levin=hmi.V_45s_nrt levout=hmi.coefficients >>$LOG |
82 |
set retstatus = $status |
83 |
if ($retstatus) then |
84 |
echo >>$LOG "FAIL $CoefProgram failed for $targ with status=$retstatus" |
85 |
goto FAILURE |
86 |
endif |
87 |
endif |
88 |
if ($need_t == $wanthigh_t) goto DONE |
89 |
@ need_t = $need_t + 86400 |
90 |
if ($need_t > $wanthigh_t) set need_t = $wanthigh_t |
91 |
end |
92 |
|
93 |
DONE: |
94 |
exit 0 |
95 |
|
96 |
FAILURE: |
97 |
tail -1 $LOG > FAIL_reason |
98 |
# allow failures to be treated as OK for times before 9 Sept 2010. |
99 |
# these may need to be done by hand in an iterative fashion. |
100 |
|
101 |
set good_processing_t = `time_convert time=2010.09.09_TAI` |
102 |
|
103 |
if ($wantlow_t < $good_processing_t) then |
104 |
echo "Allow drift calc to fail for earliest times. >>$LOG |
105 |
exit 0 |
106 |
endif |
107 |
|
108 |
exit 1 |