/[CCFs]/bin/mlovccf
ViewVC logotype

Contents of /bin/mlovccf

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Mon Mar 9 17:06:20 2015 UTC (9 years, 8 months ago) by ccflib
Branch: MAIN
Creates the list of valid CCFs for current date

1 #! /bin/bash
2
3 # mlovccf (make list of valid ccfs)
4 #
5 # Makes the list of valid CCF. This is the list of the CCFs required to process any ODF
6 # at the current date.
7 #
8 # To get the set of CCFs required to process a given ODF is the task of cifbuild.
9 # To get such list, cifbuild needs only the ODF observation time, typically the start
10 # of it. If we do this exercise for all observed ODFs at a given date, we will obtain
11 # for such a moment, the list of valid CCFs required to process any observed ODF.
12 #
13 # $Id$
14
15 host=`hostname | cut -d. -f1`
16
17 # Function find_latest_mif to get the latest XMM_CALINDEX from given directory
18
19 find_latest_mif()
20 {
21
22 [ -z "$1" ] && return
23
24 CCFPATH="$1"
25
26 maxissue="0"
27 for mif in `ls -1 ${CCFPATH}/XMM_CALINDEX_*.CCF`
28 do
29 mifbase=`basename $mif`
30 issue=`echo $mifbase | awk -F"." '{print $1}' | awk -F"_" '{print $3}'`
31 [ "$issue" -ge "$maxissue" ] && maxissue="$issue"
32 done
33
34 MIF=${CCFPATH}/XMM_CALINDEX_${maxissue}.CCF
35
36 }
37
38 # Function get_ccf_list to list on stdout the table of CCFS in a given CIF
39 #
40 # requires Heasoft be initialized. Otherwise exits with error.
41
42 get_ccf_list()
43 {
44 [ -z "$1" ] && return
45
46 cif_to_process="$1"
47
48 noversion=`which fversion | grep -c no`
49
50 if [ "${noversion}" != "0" ] ; then
51 echo "Error: Heasoft not initialised !"
52 exit
53 fi
54
55 fdump ${cif_to_process} prhead=no showcol=no showrow=no page=no \
56 columns="SCOPE TYPEID ISSUE" \
57 rows=- STDOUT
58 }
59
60
61 # We need to get the list of all observed ODFs at the current date. This is obtained from
62 # ftp://nxsa.esac.esa.int/pub/cds_obslog/xsaobslog.txt.
63
64 VALID_CCF="$HOME/valid_ccf"
65
66 cd ${VALID_CCF}
67 wget -nc -q ftp://nxsa.esac.esa.int/pub/cds_obslog/xsaobslog.txt
68
69
70 # Sets SAS_CCFPATH and initialises HEADAS and SAS depending on host
71
72 case "$host" in
73 xvsoc01|xmm)
74 SAS_CCFPATH="/data/xmm/ccflib/ftp-area/constituents"
75 SAS_DIR=/data/xmm/ccflib/sas
76 SAS_PATH=$SAS_DIR
77 source $SAS_DIR/sas-setup.sh
78 ;;
79 sasbld01|sasbld02)
80 SAS_CCFPATH="/home/ccflib/ftp-area/constituents"
81 /sas/bin/confsas
82 export HEADAS=/sasbuild/local/${host}/headas/architecture
83 . $HEADAS/headas-init.sh
84 source $HOME/setsas.sh 1> /dev/null
85 export SAS_VERBOSITY=0
86 ;;
87 esac
88
89 # Finds the latest MIF issue
90
91 find_latest_mif "${SAS_CCFPATH}"
92
93
94 # Now scans the list of OBDS ID registered in the previous list to get the start time
95 # and then runs cifbuild to get the respective CIF
96
97 touch ${VALID_CCF}/all_ccfs.txt
98 n=0
99 while read line
100 do
101 obsid=`echo $line | awk -F"|" '{print $2}'`
102 stime=`echo $line | awk -F"|" '{print $9}'`
103 stime=`echo $stime | tr " " "T"`
104 n=$((n+1))
105 echo "($n) Processing $obsid $stime" ; echo
106
107 # Run cifbuild
108
109 cif_file=${VALID_CCF}/${obsid}.cif
110
111 cifbuild --withmasterindexset='yes' \
112 --masterindexset=${MIF} \
113 --withobservationdate='yes' \
114 --observationdate=${stime} \
115 --analysisdate='now' \
116 --calindexset=${cif_file}
117
118
119 # Gets the list of CCFs included in the CIF
120
121 get_ccf_list "${cif_file}" > ${VALID_CCF}/${obsid}_ccfs.tmp
122
123 while read line
124 do
125 [ "$line" = "" ] && continue
126 class=`echo $line | awk -F" " '{print $1"_"$2}'`
127 issue=`echo $line | awk -F" " '{print $3}'`
128 issue=`printf "%04d" ${issue}`
129 echo ${class}_${issue}.CCF >> ${VALID_CCF}/${obsid}_ccfs.txt
130 done < ${VALID_CCF}/${obsid}_ccfs.tmp
131
132 rm ${VALID_CCF}/${obsid}_ccfs.tmp
133
134 mv ${VALID_CCF}/all_ccfs.txt ${VALID_CCF}/all_ccfs.tmp
135 cat ${VALID_CCF}/${obsid}_ccfs.txt ${VALID_CCF}/all_ccfs.tmp \
136 | sort -u > ${VALID_CCF}/all_ccfs.txt
137
138 rm ${cif_file}
139 rm ${VALID_CCF}/${obsid}_ccfs.txt
140
141 done < ${VALID_CCF}/xsaobslog.txt

  ViewVC Help
Powered by ViewVC 1.1.27