1 |
ccflib |
1.1 |
#! /bin/bash |
2 |
|
|
|
3 |
|
|
# mlovccf (make list of valid ccfs) |
4 |
|
|
# |
5 |
ccflib |
1.7 |
# Makes the list of valid CCFs. These are all CCFs, among those published since the |
6 |
ccflib |
1.2 |
# beginning of the project, that are required to process any ODF at a given date, |
7 |
ccflib |
1.7 |
# typically the current date. This list will change with time as far as new |
8 |
ccflib |
1.2 |
# CCFs are issued to deal with new calibration data and/or replace obsolete ones. |
9 |
ccflib |
1.1 |
# |
10 |
ccflib |
1.10 |
# To identify the set of CCFs required to process a given ODF is the job of task cifbuild. |
11 |
ccflib |
1.2 |
# To make such identification, cifbuild needs only the start time of the observation. |
12 |
ccflib |
1.7 |
# Therefore, if we provide a list of all observed ODFs at a given date together with their |
13 |
|
|
# respective start time, we could compute all the CCFs required to process them. |
14 |
|
|
# For such a moment, that list is the list of valid CCFs required to process |
15 |
|
|
# any observed ODF. |
16 |
ccflib |
1.1 |
# |
17 |
ccflib |
1.7 |
# We need as input the list of all observed ODFs at a given date. |
18 |
|
|
# This is obtained from the report of all observations that the XSA makes to CDS, |
19 |
ccflib |
1.10 |
# xsaobslog.txt (http://nxsa.esac.esa.int/ftp_public/cfs_obslog/xsaobslog.txt). |
20 |
ccflib |
1.2 |
# |
21 |
ccflib |
1.25 |
# $Id: mlovccf,v 1.24 2020/11/13 16:09:22 ccflib Exp $ |
22 |
ccflib |
1.4 |
|
23 |
|
|
# Next two lines allow to submit this script to the grid |
24 |
|
|
# request Bourne shell as shell for job |
25 |
ccflib |
1.6 |
#$ -S /bin/bash |
26 |
ccflib |
1.1 |
|
27 |
ccflib |
1.24 |
export DEBUG="T" |
28 |
|
|
|
29 |
ccflib |
1.16 |
adminmail="eduardo.ojero@sciops.esa.int" |
30 |
ccflib |
1.5 |
|
31 |
ccflib |
1.17 |
VALID_CCF="$HOME/processing_valid_ccf" |
32 |
ccflib |
1.10 |
|
33 |
ccflib |
1.13 |
mailfile="${VALID_CCF}/mailfile" |
34 |
|
|
|
35 |
ccflib |
1.1 |
host=`hostname | cut -d. -f1` |
36 |
|
|
|
37 |
ccflib |
1.5 |
now=`date +'%Y%m%d_%H%M'` |
38 |
ccflib |
1.7 |
now_table=`date +'%Y-%m-%dT%H:%M:%S'` |
39 |
ccflib |
1.3 |
|
40 |
ccflib |
1.10 |
|
41 |
ccflib |
1.13 |
# +++ Function mailnotify |
42 |
|
|
# |
43 |
|
|
# This function is used to notify adminmail on any issue while runnning this procedure |
44 |
|
|
# |
45 |
|
|
# Needs a subject as $1 and body as local file to be send. |
46 |
|
|
|
47 |
|
|
mailnotify () |
48 |
|
|
{ |
49 |
|
|
|
50 |
|
|
[ "$#" -ne "2" ] && return |
51 |
|
|
|
52 |
|
|
subject=$1 |
53 |
|
|
|
54 |
|
|
bodyfile=$2 |
55 |
|
|
|
56 |
|
|
[ ! -f "${bodyfile}" ] && return |
57 |
|
|
|
58 |
ccflib |
1.15 |
echo ; echo "Sending message to ${adminmail} with subject ${subject}" ; echo |
59 |
|
|
|
60 |
ccflib |
1.24 |
if [ "$DEBUG" ] ; then |
61 |
|
|
|
62 |
|
|
echo "DEBUG: mlovccf: mailnotify: Going to send mail as " |
63 |
|
|
echo "mailx -v -s ${subject} ${adminmail} < ${bodyfile}" |
64 |
|
|
fi |
65 |
|
|
|
66 |
ccflib |
1.16 |
mailx -v -s "${subject}" "${adminmail}" < ${bodyfile} |
67 |
ccflib |
1.13 |
|
68 |
ccflib |
1.24 |
if [ "$DEBUG" ] ; then |
69 |
|
|
echo "DEBUG: mlovccf: mailnotify: Mail sent!" |
70 |
|
|
fi |
71 |
ccflib |
1.13 |
} |
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
# +++ Function getxsaobslog |
76 |
|
|
# |
77 |
ccflib |
1.10 |
# We need to get the list of all observed ODFs at the current date. |
78 |
|
|
# This is obtained from http://nxsa.esac.esa.int/ftp_public/cds_obslog/xsaobslog.txt. |
79 |
|
|
|
80 |
|
|
getxsaobslog () |
81 |
|
|
{ |
82 |
|
|
|
83 |
|
|
XSAOBSURL="http://nxsa.esac.esa.int/ftp_public/cds_obslog/xsaobslog.txt" |
84 |
|
|
|
85 |
|
|
# Remove any xsaobslog.txt previously downloaded. |
86 |
|
|
|
87 |
|
|
[ -f "${VALID_CCF}/xsaobslog.txt" ] && rm -rf ${VALID_CCF}/xsaobslog.txt |
88 |
|
|
|
89 |
|
|
# Get the list latest list of ODFs available from nXSA server. |
90 |
|
|
|
91 |
ccflib |
1.20 |
wget --quiet ${XSAOBSURL} -O ${VALID_CCF}/xsaobslog.txt |
92 |
ccflib |
1.10 |
|
93 |
|
|
# Rename xsaobslog.txt to xsaobslog_${now}.txt just to have a reference |
94 |
|
|
# of which list of ODFs was used to compute the list of valid CCFs. |
95 |
|
|
|
96 |
|
|
mv ${VALID_CCF}/xsaobslog.txt ${VALID_CCF}/xsaobslog_${now}.txt |
97 |
|
|
|
98 |
ccflib |
1.24 |
if [ "$DEBUG" ] ; then |
99 |
|
|
echo "DEBUG: mlovccf: getxsaobslog: XSA Obs. log file obtained successfully and renamed to ${VALID_CCF}/xsaobslog_${now}.txt" |
100 |
|
|
fi |
101 |
|
|
|
102 |
ccflib |
1.10 |
} |
103 |
|
|
|
104 |
|
|
|
105 |
ccflib |
1.13 |
|
106 |
|
|
# +++Function get_ccf_list to list on stdout the table of CCFs in a given CIF. |
107 |
|
|
# |
108 |
ccflib |
1.2 |
# Requires that Heasoft is initialised. Otherwise exits with error. |
109 |
ccflib |
1.1 |
|
110 |
|
|
get_ccf_list() |
111 |
|
|
{ |
112 |
|
|
[ -z "$1" ] && return |
113 |
|
|
|
114 |
|
|
cif_to_process="$1" |
115 |
|
|
|
116 |
|
|
noversion=`which fversion | grep -c no` |
117 |
|
|
|
118 |
|
|
if [ "${noversion}" != "0" ] ; then |
119 |
|
|
echo "Error: Heasoft not initialised !" |
120 |
ccflib |
1.13 |
[ -f "${mailfile}" ] && rm -rf ${mailfile} |
121 |
|
|
echo "Running of fversion produced the following output:" >> $mailfile |
122 |
|
|
echo "$noversion" >> $mailfile |
123 |
|
|
mailnotify "mvloccf: Error: Heasoft not initialised!" $mailfile |
124 |
|
|
rm ${mailfile} |
125 |
ccflib |
1.1 |
exit |
126 |
|
|
fi |
127 |
|
|
|
128 |
|
|
fdump ${cif_to_process} prhead=no showcol=no showrow=no page=no \ |
129 |
|
|
columns="SCOPE TYPEID ISSUE" \ |
130 |
|
|
rows=- STDOUT |
131 |
ccflib |
1.24 |
|
132 |
ccflib |
1.1 |
} |
133 |
|
|
|
134 |
ccflib |
1.13 |
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
# +++ Fill in the valid_constituents directory with the Valid CCF set |
138 |
|
|
# |
139 |
|
|
# The directory to be filled in is ${VALIDCONSTITUENTSDISR}. |
140 |
|
|
# This directory is synchronized with the similar directory in the |
141 |
|
|
# external ftp server. |
142 |
|
|
# |
143 |
|
|
# In addition to that, we also use this function to fill in the |
144 |
|
|
# /ccf/valid directory available for users in the intranet. |
145 |
ccflib |
1.11 |
|
146 |
|
|
fillvalidccfdir() |
147 |
|
|
{ |
148 |
|
|
|
149 |
|
|
[ -z "$1" ] && return |
150 |
|
|
|
151 |
|
|
validccflist=$1 |
152 |
|
|
|
153 |
ccflib |
1.21 |
if [ ! -f "${VALID_CCF}/${validccflist}" -o ! -s "${VALID_CCF}/${validccflist}" ] ; then |
154 |
|
|
echo "Error: ${VALID_CCF}/${validccflist} not found or empty - Abort!" |
155 |
ccflib |
1.13 |
[ -f "${mailfile}" ] && rm -rf ${mailfile} |
156 |
ccflib |
1.21 |
echo "The list of valid CCF ${VALID_CCF}/${validccflist} is not found or it is empty" >> $mailfile |
157 |
|
|
mailnotify "mvloccf: Error: ${VALID_CCF}/${validccflist} not found or it is empty - Abort!" $mailfile |
158 |
ccflib |
1.13 |
rm ${mailfile} |
159 |
ccflib |
1.11 |
exit |
160 |
|
|
fi |
161 |
|
|
|
162 |
ccflib |
1.13 |
VALIDCONSTITUENTSDIR="/home/ccflib/ftp-area/valid_constituents" |
163 |
ccflib |
1.25 |
# Checks that the VALIDCONSTITUENTSDIR directory is writable by me |
164 |
|
|
touch ${VALIDCONSTITUENTSDIR}/test 2> /dev/null |
165 |
|
|
if [ "$?" != "0" ] ; then |
166 |
|
|
[ -f "${mailfile}" ] && rm -rf ${mailfile} |
167 |
|
|
echo "${VALIDCONSTITUENTSDIR} is not writable. Can not work" >> $mailfile |
168 |
|
|
mailnotify "mvloccf: Error: ${VALIDCONSTITUENTSDIR} is not writable - Abort!" $mailfile |
169 |
|
|
rm ${mailfile} |
170 |
|
|
exit |
171 |
|
|
fi |
172 |
ccflib |
1.11 |
rm -rf ${VALIDCONSTITUENTSDIR}/* |
173 |
|
|
|
174 |
ccflib |
1.19 |
# This operation can only succeed because the subdir valid has enable the write permission |
175 |
|
|
# for the group "sas" (g=rwx), provided that CCFs belong to sasbuild(5153):sas. |
176 |
ccflib |
1.13 |
VALIDCCFDIRINTRANET="/ccf/valid" |
177 |
ccflib |
1.25 |
# Checks that the VALIDCCFDIRINTRANET directory is writable by me |
178 |
|
|
touch ${VALIDCCFDIRINTRANET}/test 2> /dev/null |
179 |
|
|
if [ "$?" != "0" ] ; then |
180 |
|
|
[ -f "${mailfile}" ] && rm -rf ${mailfile} |
181 |
|
|
echo "${VALIDCCFDIRINTRANET} is not writable. Can not work" >> $mailfile |
182 |
|
|
mailnotify "mvloccf: Error: ${VALIDCCFDIRINTRANET} is not writable - Abort!" $mailfile |
183 |
|
|
rm ${mailfile} |
184 |
|
|
exit |
185 |
|
|
fi |
186 |
|
|
|
187 |
ccflib |
1.13 |
rm -rf ${VALIDCCFDIRINTRANET}/* |
188 |
|
|
|
189 |
ccflib |
1.11 |
CONSTITUENTSDIR="/home/ccflib/ftp-area/constituents" |
190 |
ccflib |
1.12 |
n=0 |
191 |
ccflib |
1.11 |
while read ccf |
192 |
|
|
do |
193 |
ccflib |
1.12 |
n=$((n + 1)) |
194 |
|
|
echo "$n cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCONSTITUENTSDIR}/" |
195 |
ccflib |
1.11 |
cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCONSTITUENTSDIR}/ |
196 |
ccflib |
1.13 |
echo "$n cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCCFDIRINTRANET}/" |
197 |
|
|
cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCCFDIRINTRANET}/ |
198 |
ccflib |
1.12 |
done < ${VALID_CCF}/${validccflist} |
199 |
ccflib |
1.11 |
|
200 |
ccflib |
1.24 |
if [ "$DEBUG" ] ; then |
201 |
|
|
echo "DEBUG: mlovccf: fillvalidccfdir: Processed $validccflist" |
202 |
|
|
fi |
203 |
ccflib |
1.11 |
} |
204 |
|
|
|
205 |
|
|
|
206 |
ccflib |
1.13 |
# |
207 |
|
|
# M a i n p r o g r a m |
208 |
|
|
# |
209 |
|
|
# 1. Get the list of all ODFs |
210 |
|
|
|
211 |
ccflib |
1.1 |
|
212 |
ccflib |
1.10 |
xsaobslogsize="0" |
213 |
ccflib |
1.1 |
|
214 |
ccflib |
1.10 |
getxsaobslog |
215 |
ccflib |
1.1 |
|
216 |
ccflib |
1.10 |
xsaobslogsize=`stat --format=%s ${VALID_CCF}/xsaobslog_${now}.txt` |
217 |
ccflib |
1.1 |
|
218 |
ccflib |
1.10 |
if [ "$xsaobslogsize" = "0" ] ; then |
219 |
ccflib |
1.13 |
echo "Error: Failure to download the XSA Obs. Log file - Abort" |
220 |
|
|
[ -f "${mailfile}" ] && rm -rf ${mailfile} |
221 |
|
|
echo "The XSA Obs. Log file has 0 size - Not downloaded?" >> $mailfile |
222 |
|
|
echo "." >> $mailfile |
223 |
ccflib |
1.24 |
if [ "$DEBUG" ] ; then |
224 |
|
|
echo "DEBUG: mlovccf: main: xsaobslogsize has 0 size. Mail notification being sent!" |
225 |
|
|
fi |
226 |
ccflib |
1.13 |
mailnotify "mlovccf: Error: Failure to download the XSA Obs. Log file - Abort" "$mailfile" |
227 |
|
|
rm ${mailfile} |
228 |
ccflib |
1.10 |
exit |
229 |
|
|
fi |
230 |
ccflib |
1.1 |
|
231 |
ccflib |
1.17 |
# |
232 |
ccflib |
1.18 |
# 2. Initialises HEADAS and SAS |
233 |
|
|
# |
234 |
|
|
|
235 |
ccflib |
1.20 |
# Defines SASBUILD_LOCAL depending on host. |
236 |
|
|
# Then uses it to build up HEADAS and setup LD_LIBRARY_PATH accordingly. |
237 |
ccflib |
1.1 |
|
238 |
|
|
case "$host" in |
239 |
ccflib |
1.20 |
sasbld01n|sasbld02n) |
240 |
ccflib |
1.24 |
export SASBUILD_LOCAL="/sasbuild/local/${host}/GNU_CC_CXX_9.2.0" |
241 |
ccflib |
1.1 |
;; |
242 |
ccflib |
1.25 |
sciggw|scigrid-*) |
243 |
ccflib |
1.24 |
export SASBUILD_LOCAL="/sasbuild/local/sasbld04n/GNU_CC_CXX_9.2.0" |
244 |
ccflib |
1.5 |
;; |
245 |
ccflib |
1.17 |
*) echo "Error: Unsupported host $host" ; exit 1 ;; |
246 |
ccflib |
1.1 |
esac |
247 |
|
|
|
248 |
ccflib |
1.20 |
export HEADAS=${SASBUILD_LOCAL}/headas/architecture |
249 |
ccflib |
1.1 |
|
250 |
ccflib |
1.18 |
headas_output="${VALID_CCF}/headas_output" |
251 |
|
|
source $HEADAS/headas-init.sh > ${headas_output} 2>&1 |
252 |
ccflib |
1.20 |
|
253 |
ccflib |
1.24 |
[ "$DEBUG" ] && echo "DEBUG: mlovccf: main: Executed Headas initialisation script for $HEADAS" |
254 |
|
|
|
255 |
ccflib |
1.20 |
# The next statement should not be necessary because the SAS initialisation |
256 |
|
|
# provides under $SAS_DIR/libextra all the necessary libraries from GNU C/C++ |
257 |
|
|
# which were required to build Heasoft. But, in order to make the HEADAS |
258 |
|
|
# initialisation independent of the SAS initialisation, we set the |
259 |
|
|
# LD_LIBRARY_PATH as it has to be to run Headas by itself without SAS been |
260 |
|
|
# ready. |
261 |
|
|
|
262 |
|
|
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${SASBUILD_LOCAL}/gcc/lib64 |
263 |
|
|
|
264 |
|
|
|
265 |
ccflib |
1.18 |
headas_ok=`cat ${headas_output}` |
266 |
|
|
|
267 |
|
|
if [ -n "${headas_ok}" ] ; then |
268 |
|
|
echo "mlovccf: HEADAS initialisation failed with error" >> ${mailfile} |
269 |
|
|
cat ${headas_output} >> ${mailfile} |
270 |
ccflib |
1.17 |
mailnotify "mlovccf: HEADAS initilisation failed" ${mailfile} |
271 |
ccflib |
1.24 |
if [ "$DEBUG" ] ; then |
272 |
|
|
echo "DEBUG: mlovccf: main: Headas initialization failed. Notification mail sent!" |
273 |
|
|
fi |
274 |
|
|
rm -v ${mailfile} |
275 |
|
|
rm -v ${headas_output} |
276 |
ccflib |
1.17 |
exit 1 |
277 |
|
|
fi |
278 |
ccflib |
1.1 |
|
279 |
ccflib |
1.17 |
# To be able to mix several jobs on the same ccflib account |
280 |
|
|
[ ! -d "${HOME}/pfiles/${host}" ] && mkdir ${HOME}/pfiles/${host} |
281 |
|
|
export PFILES="${HOME}/pfiles/${host};${HEADAS}/syspfiles" |
282 |
ccflib |
1.24 |
if [ "$DEBUG" ] ; then |
283 |
|
|
echo -n "DEBUG: mlovccf: main: HEADAS version: "`fversion` |
284 |
|
|
fi |
285 |
ccflib |
1.17 |
|
286 |
ccflib |
1.18 |
# |
287 |
|
|
# W a r n i n g o n S A S i n i t i a l i s a t i o n |
288 |
|
|
# |
289 |
|
|
# The SAS initialisation produced by setsas.sh sets SAS_CCFPATH to /ccf/pub. |
290 |
|
|
# Hence, if we set SAS_CCFPATH before running setsas.sh, we will always |
291 |
|
|
# use /ccf/pub as repository for CCF. This is right as long as /ccf/pub is in |
292 |
|
|
# strict sync with /home/ccflib/ccf_ftp/constituents. But if this is not true, |
293 |
|
|
# the resulting valid CCFs might be wrong. Therefore, we set it here explicitly. |
294 |
|
|
# |
295 |
|
|
|
296 |
|
|
confsas_output="${VALID_CCF}/confsas_output" |
297 |
ccflib |
1.24 |
source /sas/bin/confsas > ${confsas_output} |
298 |
ccflib |
1.18 |
confsas_ok=`cat ${confsas_output}` |
299 |
|
|
|
300 |
ccflib |
1.24 |
if [ "$DEBUG" ] ; then |
301 |
|
|
echo "DEBUG: mlovccf: main: Executed /sas/bin/confsas with output: ${confsas_ok}" |
302 |
|
|
fi |
303 |
|
|
|
304 |
ccflib |
1.18 |
if [ -n "${confsas_ok}" ] ; then |
305 |
|
|
echo "mlovccf: SAS initialization failed with error" >> ${mailfile} |
306 |
|
|
cat ${confsas_output} >> ${mailfile} |
307 |
|
|
mailnotify "mlovccf: SAS initialisation failed" ${mailfile} |
308 |
ccflib |
1.24 |
if [ "$DEBUG" ] ; then |
309 |
|
|
echo "DEBUG: mlovccf: main: SAS initialization failed. Notification mail sent!" |
310 |
|
|
fi |
311 |
|
|
rm -v ${mailfile} |
312 |
|
|
rm -v ${confsas_output} |
313 |
ccflib |
1.18 |
exit 1 |
314 |
ccflib |
1.17 |
fi |
315 |
|
|
|
316 |
|
|
source $HOME/setsas.sh 1> /dev/null |
317 |
ccflib |
1.18 |
|
318 |
ccflib |
1.24 |
if [ "$DEBUG" ] ; then |
319 |
|
|
echo "DEBUG: mlovccf: main: SAS setsas.sh script executed" |
320 |
|
|
echo |
321 |
|
|
echo "DEBUG: mlovccf: main: SAS Version: "`sasversion -V 1` |
322 |
|
|
fi |
323 |
|
|
|
324 |
|
|
|
325 |
|
|
# Set SAS vervbosity to 0 from now onwards |
326 |
|
|
|
327 |
|
|
export SAS_VERBOSITY=0 |
328 |
|
|
|
329 |
|
|
|
330 |
ccflib |
1.18 |
# Re-sets SAS_CCFPATH |
331 |
|
|
|
332 |
ccflib |
1.17 |
export SAS_CCFPATH="/home/ccflib/ftp-area/constituents" |
333 |
ccflib |
1.18 |
|
334 |
ccflib |
1.17 |
|
335 |
ccflib |
1.18 |
|
336 |
ccflib |
1.17 |
# 3. XMM_CALINDEX file from SAS_CCFPATH |
337 |
|
|
|
338 |
|
|
MIF=`ls -1 ${SAS_CCFPATH}/XMM_CALINDEX_*.CCF` |
339 |
|
|
|
340 |
|
|
# 4. For each OBDS ID registered in the XSA observations list, gets the start |
341 |
|
|
# time of the observation. Then runs cifbuild to get the respective CIF. |
342 |
|
|
# all_ccfs_${now}.txt is filled recursively on each iteration. |
343 |
|
|
# Therefore we start with an empty file. The final list will be this one. |
344 |
ccflib |
1.13 |
|
345 |
|
|
# Output file : ${VALID_CCF}/all_ccfs_${now}.txt |
346 |
ccflib |
1.1 |
|
347 |
ccflib |
1.3 |
touch ${VALID_CCF}/all_ccfs_${now}.txt |
348 |
ccflib |
1.2 |
|
349 |
ccflib |
1.1 |
n=0 |
350 |
ccflib |
1.2 |
|
351 |
ccflib |
1.1 |
while read line |
352 |
|
|
do |
353 |
|
|
obsid=`echo $line | awk -F"|" '{print $2}'` |
354 |
|
|
stime=`echo $line | awk -F"|" '{print $9}'` |
355 |
|
|
stime=`echo $stime | tr " " "T"` |
356 |
|
|
n=$((n+1)) |
357 |
|
|
echo "($n) Processing $obsid $stime" ; echo |
358 |
|
|
|
359 |
|
|
# Run cifbuild |
360 |
|
|
|
361 |
|
|
cif_file=${VALID_CCF}/${obsid}.cif |
362 |
|
|
|
363 |
|
|
cifbuild --withmasterindexset='yes' \ |
364 |
|
|
--masterindexset=${MIF} \ |
365 |
|
|
--withobservationdate='yes' \ |
366 |
|
|
--observationdate=${stime} \ |
367 |
|
|
--analysisdate='now' \ |
368 |
|
|
--calindexset=${cif_file} |
369 |
|
|
|
370 |
|
|
|
371 |
|
|
# Gets the list of CCFs included in the CIF |
372 |
|
|
|
373 |
|
|
get_ccf_list "${cif_file}" > ${VALID_CCF}/${obsid}_ccfs.tmp |
374 |
|
|
|
375 |
|
|
while read line |
376 |
|
|
do |
377 |
|
|
[ "$line" = "" ] && continue |
378 |
|
|
class=`echo $line | awk -F" " '{print $1"_"$2}'` |
379 |
|
|
issue=`echo $line | awk -F" " '{print $3}'` |
380 |
|
|
issue=`printf "%04d" ${issue}` |
381 |
|
|
echo ${class}_${issue}.CCF >> ${VALID_CCF}/${obsid}_ccfs.txt |
382 |
ccflib |
1.2 |
|
383 |
ccflib |
1.1 |
done < ${VALID_CCF}/${obsid}_ccfs.tmp |
384 |
|
|
|
385 |
|
|
rm ${VALID_CCF}/${obsid}_ccfs.tmp |
386 |
|
|
|
387 |
ccflib |
1.3 |
mv ${VALID_CCF}/all_ccfs_${now}.txt ${VALID_CCF}/all_ccfs_${now}.tmp |
388 |
ccflib |
1.2 |
|
389 |
ccflib |
1.3 |
cat ${VALID_CCF}/${obsid}_ccfs.txt ${VALID_CCF}/all_ccfs_${now}.tmp | sort -u > ${VALID_CCF}/all_ccfs_${now}.txt |
390 |
ccflib |
1.1 |
|
391 |
ccflib |
1.17 |
comm -1 -3 --nocheck-order ${VALID_CCF}/all_ccfs_${now}.tmp ${VALID_CCF}/all_ccfs_${now}.txt > ${VALID_CCF}/diff_iteration_${n}.txt |
392 |
|
|
|
393 |
|
|
diffsize=`stat --format=%s ${VALID_CCF}/diff_iteration_${n}.txt` |
394 |
|
|
|
395 |
|
|
if [ "$diffsize" != "0" ] ; then |
396 |
|
|
echo "CCF added in this iteration: " |
397 |
|
|
cat ${VALID_CCF}/diff_iteration_${n}.txt |
398 |
|
|
fi |
399 |
|
|
|
400 |
|
|
echo |
401 |
|
|
echo "Number of valid CCFs found so far: "`cat ${VALID_CCF}/all_ccfs_${now}.txt | wc -l` ; echo |
402 |
|
|
|
403 |
|
|
rm ${VALID_CCF}/diff_iteration_${n}.txt |
404 |
ccflib |
1.1 |
rm ${cif_file} |
405 |
|
|
rm ${VALID_CCF}/${obsid}_ccfs.txt |
406 |
ccflib |
1.3 |
rm ${VALID_CCF}/all_ccfs_${now}.tmp |
407 |
ccflib |
1.1 |
|
408 |
ccflib |
1.7 |
done < ${VALID_CCF}/xsaobslog_${now}.txt |
409 |
ccflib |
1.2 |
|
410 |
ccflib |
1.13 |
# 5. Make a table of classes and issues with the style "Pipeline Release Notes" |
411 |
|
|
# To get a classification, we need first to obtain all available classes. |
412 |
|
|
# |
413 |
|
|
|
414 |
ccflib |
1.2 |
|
415 |
|
|
# Lists all CCF classes |
416 |
|
|
|
417 |
|
|
ccf_classes="${VALID_CCF}/ccf_classes.txt" |
418 |
|
|
|
419 |
|
|
while read line |
420 |
|
|
do |
421 |
|
|
class=`echo $line | awk -F"_" '{print $1"_"$2}'` |
422 |
|
|
echo $class >> ${ccf_classes} |
423 |
ccflib |
1.3 |
done < ${VALID_CCF}/all_ccfs_${now}.txt |
424 |
ccflib |
1.2 |
|
425 |
|
|
cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt |
426 |
|
|
mv ${VALID_CCF}/kk.txt ${ccf_classes} |
427 |
|
|
|
428 |
ccflib |
1.13 |
|
429 |
|
|
|
430 |
ccflib |
1.3 |
# Output final file is named all_ccfs_${now}_table.txt |
431 |
|
|
|
432 |
|
|
total_number_of_ccfs=0 |
433 |
ccflib |
1.2 |
|
434 |
ccflib |
1.7 |
all_ccfs_table="${VALID_CCF}/all_ccfs_${now}_table.txt" |
435 |
ccflib |
1.2 |
|
436 |
|
|
[ -f "${all_ccfs_table}" ] && rm ${all_ccfs_table} |
437 |
|
|
|
438 |
ccflib |
1.7 |
echo "Table of valid CCFs at $now_table" >> ${all_ccfs_table} |
439 |
|
|
echo >> ${all_ccfs_table} |
440 |
|
|
echo "|================================|=============|=======|" >> ${all_ccfs_table} |
441 |
|
|
echo "| Calibration File | Issue range | Count |" >> ${all_ccfs_table} |
442 |
|
|
echo "|================================|=============|=======|" >> ${all_ccfs_table} |
443 |
ccflib |
1.2 |
|
444 |
|
|
while read ccf_class |
445 |
ccflib |
1.3 |
do |
446 |
|
|
echo -n "Processing class $ccf_class ..." |
447 |
ccflib |
1.2 |
issues_file="${VALID_CCF}/ccf_issues_for_${ccf_class}.txt" |
448 |
|
|
[ -f "${issues_file}" ] && rm ${issues_file} |
449 |
|
|
while read line |
450 |
|
|
do |
451 |
|
|
class=`echo $line | awk -F"_" '{print $1"_"$2}'` |
452 |
|
|
[ "$class" != "$ccf_class" ] && continue |
453 |
|
|
issue=`echo $line | awk -F"_" '{print $3}' | cut -d. -f1` |
454 |
|
|
echo $issue >> ${issues_file} |
455 |
ccflib |
1.3 |
done < ${VALID_CCF}/all_ccfs_${now}.txt |
456 |
ccflib |
1.2 |
|
457 |
|
|
cat ${issues_file} | sort -u > kk.txt |
458 |
|
|
mv kk.txt ${issues_file} |
459 |
ccflib |
1.3 |
real_number_of_issues_for_this_class=`wc -l ${issues_file} | awk -F" " '{print $1}'` |
460 |
ccflib |
1.2 |
|
461 |
|
|
first_issue=`head -1 ${issues_file}` |
462 |
|
|
last_issue=`tail -1 ${issues_file}` |
463 |
|
|
|
464 |
ccflib |
1.3 |
li=$((10#$last_issue)) |
465 |
|
|
fi=$((10#$first_issue)) |
466 |
|
|
|
467 |
ccflib |
1.7 |
sequential_number_of_issues_for_this_class=$((li - fi + 1)) |
468 |
ccflib |
1.8 |
|
469 |
|
|
asterisk=" " |
470 |
|
|
[ "${real_number_of_issues_for_this_class}" -lt "${sequential_number_of_issues_for_this_class}" ] && asterisk="(*)" |
471 |
|
|
|
472 |
ccflib |
1.7 |
total_number_of_ccfs=$((real_number_of_issues_for_this_class + total_number_of_ccfs)) |
473 |
|
|
|
474 |
|
|
rn=$real_number_of_issues_for_this_class |
475 |
ccflib |
1.3 |
|
476 |
ccflib |
1.8 |
if [ "${first_issue}" != "${last_issue}" ] ; then |
477 |
|
|
if [ "$asterisk" = "(*)" ] ; then |
478 |
|
|
printf "| %-30s | %4s-%4s(*)| %4s |\n" ${ccf_class} ${first_issue} ${last_issue} ${rn} >> ${all_ccfs_table} |
479 |
|
|
else |
480 |
|
|
printf "| %-30s | %4s-%4s | %4s |\n" ${ccf_class} ${first_issue} ${last_issue} ${rn} >> ${all_ccfs_table} |
481 |
|
|
fi |
482 |
|
|
else |
483 |
|
|
printf "| %-30s | %4s | %4s |\n" ${ccf_class} ${first_issue} ${rn} >> ${all_ccfs_table} |
484 |
|
|
fi |
485 |
|
|
|
486 |
ccflib |
1.7 |
|
487 |
|
|
echo "done" |
488 |
ccflib |
1.2 |
done < ${ccf_classes} |
489 |
|
|
|
490 |
ccflib |
1.7 |
echo "|================================|=============|=======|" >> ${all_ccfs_table} |
491 |
|
|
echo >> ${all_ccfs_table} |
492 |
|
|
echo "(*): Incomplete range." >> ${all_ccfs_table} |
493 |
|
|
echo "" >> ${all_ccfs_table} |
494 |
|
|
echo "Total number of valid CCFs required : ${total_number_of_ccfs}" >> ${all_ccfs_table} |
495 |
ccflib |
1.3 |
rm ${VALID_CCF}/ccf_classes.txt |
496 |
|
|
rm ${VALID_CCF}/ccf_issues_for*.txt |
497 |
ccflib |
1.11 |
|
498 |
ccflib |
1.13 |
|
499 |
|
|
|
500 |
|
|
# 6. Fill in the Valid CCF Set dir with the proper CCFs |
501 |
ccflib |
1.11 |
|
502 |
ccflib |
1.25 |
fillvalidccfdir "all_ccfs_${now}.txt" |
503 |
ccflib |
1.13 |
|
504 |
ccflib |
1.22 |
|
505 |
ccflib |
1.25 |
[ -f "${mailfile}" ] && rm -rf ${mailfile} |
506 |
|
|
echo "Valid CCF Set successfully copied to ${VALIDCONSTITUENTSDIR}" >> $mailfile |
507 |
|
|
echo "Valid CCF Set successfully copied to ${VALIDCCFDIRINTRANET}" >> $mailfile |
508 |
|
|
mailnotify "mvloccf: Valid CCF Set created successfully" $mailfile |
509 |
|
|
rm ${mailfile} |