/[CCFs]/bin/mlovccf
ViewVC logotype

Diff of /bin/mlovccf

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by ccflib, Tue Mar 10 13:27:33 2015 UTC revision 1.6 by ccflib, Thu Mar 12 16:02:52 2015 UTC
# Line 16  Line 16 
16  # date. This is obtained from the report of all observations that the XSA makes to CDS,  # date. This is obtained from the report of all observations that the XSA makes to CDS,
17  # xsaobslog.txt (ftp://nxsa.esac.esa.int/pub/cfs_obslog/xsaobslog.txt).  # xsaobslog.txt (ftp://nxsa.esac.esa.int/pub/cfs_obslog/xsaobslog.txt).
18  #  #
19  # $Id: mlovccf,v 1.1 2015/03/09 17:06:20 ccflib Exp $  # $Id: mlovccf,v 1.5 2015/03/11 16:12:16 ccflib Exp $
20    
21    # Next two lines allow to submit this script to the grid
22    # request Bourne shell as shell for job
23    #$ -S /bin/bash
24    
25    
26  host=`hostname | cut -d. -f1`  host=`hostname | cut -d. -f1`
27    
28    now=`date +'%Y%m%d_%H%M'`
29    
30  # Function find_latest_mif to get the latest XMM_CALINDEX from given directory  # Function find_latest_mif to get the latest XMM_CALINDEX from given directory
31    
32  find_latest_mif()  find_latest_mif()
# Line 77  wget -nc -q ftp://nxsa.esac.esa.int/pub/ Line 84  wget -nc -q ftp://nxsa.esac.esa.int/pub/
84    
85  case "$host" in  case "$host" in
86          xvsoc01|xmm)          xvsoc01|xmm)
87                  SAS_CCFPATH="/data/xmm/ccflib/ftp-area/constituents"                  export SAS_CCFPATH="/data/xmm/ccflib/ftp-area/constituents"
88                  SAS_DIR=/data/xmm/ccflib/sas                  export SAS_DIR=/data/xmm/ccflib/sas
89                  SAS_PATH=$SAS_DIR                  export SAS_PATH=$SAS_DIR
90                  source $SAS_DIR/sas-setup.sh                  source $SAS_DIR/sas-setup.sh
91                  ;;                  ;;
92          sasbld01|sasbld02)          sasbld01|sasbld02)
93                  SAS_CCFPATH="/home/ccflib/ftp-area/constituents"                  export SAS_CCFPATH="/home/ccflib/ftp-area/constituents"
94                  /sas/bin/confsas                  /sas/bin/confsas
95                  export HEADAS=/sasbuild/local/${host}/headas/architecture                  export HEADAS=/sasbuild/local/${host}/headas/architecture
96                  . $HEADAS/headas-init.sh                  . $HEADAS/headas-init.sh
97                  source $HOME/setsas.sh 1> /dev/null                  source $HOME/setsas.sh 1> /dev/null
98                  export SAS_VERBOSITY=0                  export SAS_VERBOSITY=0
99                  ;;                  ;;
100            scigrid6|cn-*)
101                    export SAS_CCFPATH="/home/ccflib/ftp-area/constituents"
102                    /sas/bin/confsas
103                    export HEADAS=/sasbuild/local/sasbld02/headas/architecture
104                    . $HEADAS/headas-init.sh
105                    fversion
106                    source $HOME/setsas.sh 1> /dev/null
107                    export SAS_VERBOSITY=0
108                    ;;
109            *) echo "Error: Do not know how to do it in host $host" ; exit ;;
110  esac  esac
111    
112  # Finds the latest MIF issue  # Finds the latest MIF issue
# Line 101  find_latest_mif "${SAS_CCFPATH}" Line 118  find_latest_mif "${SAS_CCFPATH}"
118  # and then runs cifbuild to get the respective CIF  # and then runs cifbuild to get the respective CIF
119    
120  # Output file  # Output file
121  touch ${VALID_CCF}/all_ccfs.txt  touch ${VALID_CCF}/all_ccfs_${now}.txt
122    
123  n=0  n=0
124    
# Line 141  do Line 158  do
158    
159          rm ${VALID_CCF}/${obsid}_ccfs.tmp          rm ${VALID_CCF}/${obsid}_ccfs.tmp
160    
161          mv ${VALID_CCF}/all_ccfs.txt ${VALID_CCF}/all_ccfs.tmp          mv ${VALID_CCF}/all_ccfs_${now}.txt ${VALID_CCF}/all_ccfs_${now}.tmp
162    
163          cat ${VALID_CCF}/${obsid}_ccfs.txt ${VALID_CCF}/all_ccfs.tmp | sort -u  >  ${VALID_CCF}/all_ccfs.txt          cat ${VALID_CCF}/${obsid}_ccfs.txt ${VALID_CCF}/all_ccfs_${now}.tmp | sort -u  >  ${VALID_CCF}/all_ccfs_${now}.txt
164    
165          rm ${cif_file}          rm ${cif_file}
166          rm ${VALID_CCF}/${obsid}_ccfs.txt          rm ${VALID_CCF}/${obsid}_ccfs.txt
167          rm ${VALID_CCF}/all_ccfs.tmp          rm ${VALID_CCF}/all_ccfs_${now}.tmp
168    
169  done < ${VALID_CCF}/xsaobslog.txt  done < ${VALID_CCF}/xsaobslog.txt
170    
# Line 161  while read line Line 178  while read line
178  do  do
179          class=`echo $line | awk -F"_" '{print $1"_"$2}'`          class=`echo $line | awk -F"_" '{print $1"_"$2}'`
180          echo $class >> ${ccf_classes}          echo $class >> ${ccf_classes}
181  done < ${VALID_CCF}/all_ccfs.txt  done < ${VALID_CCF}/all_ccfs_${now}.txt
182    
183  cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt  cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt
184  mv ${VALID_CCF}/kk.txt ${ccf_classes}  mv ${VALID_CCF}/kk.txt ${ccf_classes}
185    
186  # Output final file is named all_ccfs_table.txt  # Output final file is named all_ccfs_${now}_table.txt
187    
188  all_ccfs_table="{VALID_CCF}/all_ccfs_table.txt  total_number_of_ccfs=0
189    
190    all_ccfs_table="{VALID_CCF}/all_ccfs_${now}_table.txt
191    
192  [ -f "${all_ccfs_table}" ] && rm ${all_ccfs_table}  [ -f "${all_ccfs_table}" ] && rm ${all_ccfs_table}
193    
194    echo "Table of valid CCFs at $now"                      >> ${all_ccfs_table}
195    echo                                                    >> ${all_ccfs_table}
196  echo "|================================|=============|" >> ${all_ccfs_table}  echo "|================================|=============|" >> ${all_ccfs_table}
197  echo "| Calibration File               | Issue range |" >> ${all_ccfs_table}  echo "| Calibration File               | Issue range |" >> ${all_ccfs_table}
198  echo "|================================|=============|" >> ${all_ccfs_table}  echo "|================================|=============|" >> ${all_ccfs_table}
199    
200  while read ccf_class  while read ccf_class
201  do  do
202            echo -n "Processing class $ccf_class ..."
203          issues_file="${VALID_CCF}/ccf_issues_for_${ccf_class}.txt"          issues_file="${VALID_CCF}/ccf_issues_for_${ccf_class}.txt"
204          [ -f "${issues_file}" ] && rm ${issues_file}          [ -f "${issues_file}" ] && rm ${issues_file}
205          while read line          while read line
# Line 186  do Line 208  do
208                  [ "$class" != "$ccf_class" ] && continue                  [ "$class" != "$ccf_class" ] && continue
209                  issue=`echo $line | awk -F"_" '{print $3}' | cut -d. -f1`                  issue=`echo $line | awk -F"_" '{print $3}' | cut -d. -f1`
210                  echo $issue >> ${issues_file}                  echo $issue >> ${issues_file}
211          done < ${VALID_CCF}/all_ccfs.txt          done < ${VALID_CCF}/all_ccfs_${now}.txt
212    
213          cat ${issues_file} | sort -u > kk.txt          cat ${issues_file} | sort -u > kk.txt
214          mv kk.txt ${issues_file}          mv kk.txt ${issues_file}
215            real_number_of_issues_for_this_class=`wc -l ${issues_file} | awk -F" " '{print $1}'`
216    
217          first_issue=`head -1 ${issues_file}`          first_issue=`head -1 ${issues_file}`
218          last_issue=`tail -1 ${issues_file}`          last_issue=`tail -1 ${issues_file}`
219    
220            li=$((10#$last_issue))
221            fi=$((10#$first_issue))
222    
223            sequential_number_of_issues_for_this_class=$(($li - $fi + 1))
224            if [ "${real_number_of_issues_for_this_class}"  -lt "${sequential_number_of_issues_for_this_class}" ] ; then
225                    asterisk="(*)"
226            else
227                    asterisk="   "
228            fi
229            total_number_of_ccfs=$(($real_number_of_issues_for_this_class + $total_number_of_ccfs))
230    
231          if [ "${first_issue}" != "${last_issue}" ] ; then          if [ "${first_issue}" != "${last_issue}" ] ; then
232                  printf "| %-30s | %4s-%4s   |\n" ${ccf_class} ${first_issue} ${last_issue} >> ${all_ccfs_table}                  printf "| %-30s | %4s-%4s%3s|\n" ${ccf_class} ${first_issue} ${last_issue} ${asterisk} >> ${all_ccfs_table}
233          else          else
234                  printf "| %-30s | %4s        |\n" ${ccf_class} ${first_issue}              >> ${all_ccfs_table}                  printf "| %-30s | %4s        |\n" ${ccf_class} ${first_issue}                          >> ${all_ccfs_table}
235          fi          fi
236        
237  done < ${ccf_classes}    done < ${ccf_classes}  
238    
239  echo "|================================|=============|"                                    >> ${all_ccfs_table}  echo "|================================|=============|"                                                >> ${all_ccfs_table}
240    echo                                                                                                   >> ${all_ccfs_table}
241    echo "(*): Some issues in the range are not required."                                                 >> ${all_ccfs_table}
242    rm ${VALID_CCF}/ccf_classes.txt
243    rm ${VALID_CCF}/ccf_issues_for*.txt
244    
245    
246    
247    echo ; echo "Number of valid CCFs required as of $now : ${total_number_of_ccfs}"

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.27