/[CCFs]/bin/mlovccf
ViewVC logotype

Diff of /bin/mlovccf

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

revision 1.8 by ccflib, Mon Sep 7 13:39:15 2015 UTC revision 1.16 by ccflib, Mon Sep 19 12:36:15 2016 UTC
# Line 7  Line 7 
7  # typically the current date. This list will change with time as far as new  # typically the current date. This list will change with time as far as new
8  # CCFs are issued to deal with new calibration data and/or replace obsolete ones.  # CCFs are issued to deal with new calibration data and/or replace obsolete ones.
9  #  #
10  # To identify the set of CCFs required to process a given ODF is the ijob of task cifbuild.  # To identify the set of CCFs required to process a given ODF is the job of task cifbuild.
11  # To make such identification, cifbuild needs only the start time of the observation.  # To make such identification, cifbuild needs only the start time of the observation.
12  # Therefore, if we provide a list of all observed ODFs at a given date together with their  # 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.  # respective start time, we could compute all the CCFs required to process them.
# Line 16  Line 16 
16  #  #
17  # We need as input the list of all observed ODFs at a given date.  # 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,  # This is obtained from the report of all observations that the XSA makes to CDS,
19  # xsaobslog.txt (ftp://nxsa.esac.esa.int/pub/cfs_obslog/xsaobslog.txt).  # xsaobslog.txt (http://nxsa.esac.esa.int/ftp_public/cfs_obslog/xsaobslog.txt).
20  #  #
21  # $Id: mlovccf,v 1.7 2015/08/27 16:47:16 ccflib Exp $  # $Id: mlovccf,v 1.15 2016/04/13 10:26:13 ccflib Exp $
22    
23  # Next two lines allow to submit this script to the grid  # Next two lines allow to submit this script to the grid
24  # request Bourne shell as shell for job  # request Bourne shell as shell for job
25  #$ -S /bin/bash  #$ -S /bin/bash
26    
27    adminmail="eduardo.ojero@sciops.esa.int"
28    
29    VALID_CCF="$HOME/valid_ccf"
30    
31    mailfile="${VALID_CCF}/mailfile"
32    
33  host=`hostname | cut -d. -f1`  host=`hostname | cut -d. -f1`
34    
35  now=`date +'%Y%m%d_%H%M'`  now=`date +'%Y%m%d_%H%M'`
36  now_table=`date +'%Y-%m-%dT%H:%M:%S'`  now_table=`date +'%Y-%m-%dT%H:%M:%S'`
37    
38  # Function find_latest_mif to get the latest XMM_CALINDEX from given directory  
39    # +++ Function mailnotify
40    #
41    # This function is used to notify adminmail on any issue while runnning this procedure
42    #
43    # Needs a subject as $1 and body as local file to be send.
44    
45    mailnotify ()
46    {
47    
48    [ "$#" -ne "2" ] && return
49    
50    subject=$1
51    
52    bodyfile=$2
53    
54    [ ! -f "${bodyfile}" ] && return
55    
56    echo ; echo "Sending message to ${adminmail} with subject ${subject}" ; echo
57    
58    mailx -v -s "${subject}" "${adminmail}" < ${bodyfile}
59    
60    }
61    
62    
63    
64    # +++ Function getxsaobslog
65    #
66    # We need to get the list of all observed ODFs at the current date.
67    # This is obtained from http://nxsa.esac.esa.int/ftp_public/cds_obslog/xsaobslog.txt.
68    
69    getxsaobslog ()
70    {
71    
72    XSAOBSURL="http://nxsa.esac.esa.int/ftp_public/cds_obslog/xsaobslog.txt"
73    
74    # Remove any xsaobslog.txt previously downloaded.
75    
76    [ -f "${VALID_CCF}/xsaobslog.txt" ] && rm -rf ${VALID_CCF}/xsaobslog.txt
77    
78    # Get the list latest list of ODFs available from nXSA server.
79    
80    wget -q ${XSAOBSURL} -O ${VALID_CCF}/xsaobslog.txt
81    
82    # Rename xsaobslog.txt to xsaobslog_${now}.txt just to have a reference
83    # of which list of ODFs was used to compute the list of valid CCFs.
84    
85    mv ${VALID_CCF}/xsaobslog.txt ${VALID_CCF}/xsaobslog_${now}.txt
86    
87    }
88    
89    
90    
91    # +++ Function find_latest_mif to get the latest XMM_CALINDEX from given directory
92    
93  find_latest_mif()  find_latest_mif()
94  {  {
# Line 51  MIF=${CCFPATH}/XMM_CALINDEX_${maxissue}. Line 109  MIF=${CCFPATH}/XMM_CALINDEX_${maxissue}.
109    
110  }  }
111    
112  # Function get_ccf_list to list on stdout the table of CCFs in a given CIF  
113    
114    # +++Function get_ccf_list to list on stdout the table of CCFs in a given CIF.
115  #  #
116  # Requires that Heasoft is initialised. Otherwise exits with error.  # Requires that Heasoft is initialised. Otherwise exits with error.
117    
# Line 65  noversion=`which fversion | grep -c no` Line 125  noversion=`which fversion | grep -c no`
125    
126  if [ "${noversion}" != "0" ] ; then  if [ "${noversion}" != "0" ] ; then
127          echo "Error: Heasoft not initialised !"          echo "Error: Heasoft not initialised !"
128            [ -f "${mailfile}" ] && rm -rf ${mailfile}
129            echo "Running of fversion produced the following output:" >> $mailfile
130            echo "$noversion" >> $mailfile
131            mailnotify "mvloccf: Error: Heasoft not initialised!" $mailfile
132            rm ${mailfile}
133          exit          exit
134  fi  fi
135    
# Line 74  fdump ${cif_to_process} prhead=no showco Line 139  fdump ${cif_to_process} prhead=no showco
139  }  }
140    
141    
 # We need to get the list of all observed ODFs at the current date.  
 # This is obtained from ftp://nxsa.esac.esa.int/pub/cds_obslog/xsaobslog.txt.  
142    
 VALID_CCF="$HOME/valid_ccf"  
143    
144  cd ${VALID_CCF}  # +++ Fill in the valid_constituents directory with the Valid CCF set
145    #
146    # The directory to be filled in is ${VALIDCONSTITUENTSDISR}.
147    # This directory is synchronized with the similar directory in the
148    # external ftp server.
149    #
150    # In addition to that, we also use this function to fill in the
151    # /ccf/valid directory available for users in the intranet.
152    
153  # Remove any xsaobslog.txt previously downloaded.  fillvalidccfdir()
154    {
155    
156  [ -f "xsaobslog.txt" ] && rm -rf xsaobslog.txt  [ -z "$1" ] && return
157    
158  # Get the list latest list of ODFs available from nXSA server.  validccflist=$1
   
 wget -q ftp://nxsa.esac.esa.int/pub/cds_obslog/xsaobslog.txt  
159    
160  # Rename xsaobslog.txt to xsaobslog_${now}.txt just to have a reference  if [ ! -f "${VALID_CCF}/${validccflist}"  ] ; then
161  # of which list of ODFs was used to compute the list of valid CCFs.          echo "Error: ${VALID_CCF}/${validccflist} not found - Abort!"
162            [ -f "${mailfile}" ] && rm -rf ${mailfile}
163            echo "The list of valid CCF ${VALID_CCF}/${validccflist} is not found" >> $mailfile
164            mailnotify "mvloccf: Error: ${VALID_CCF}/${validccflist} not found - Abort!" $mailfile
165            rm ${mailfile}
166            exit
167    fi
168    
169    VALIDCONSTITUENTSDIR="/home/ccflib/ftp-area/valid_constituents"
170    rm -rf ${VALIDCONSTITUENTSDIR}/*
171    
172    VALIDCCFDIRINTRANET="/ccf/valid"
173    rm -rf ${VALIDCCFDIRINTRANET}/*
174    
175    CONSTITUENTSDIR="/home/ccflib/ftp-area/constituents"
176    n=0
177    while read ccf
178    do
179            n=$((n + 1))
180            echo "$n cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCONSTITUENTSDIR}/"
181            cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCONSTITUENTSDIR}/
182            echo "$n cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCCFDIRINTRANET}/"
183            cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCCFDIRINTRANET}/
184    done < ${VALID_CCF}/${validccflist}
185    
186    }
187    
188    
189    #
190    #   M a i n    p r o g r a m
191    #
192    # 1. Get the list of all ODFs
193    
 mv xsaobslog.txt xsaobslog_${now}.txt  
194    
195  # Sets SAS_CCFPATH and initialises HEADAS and SAS depending on host  xsaobslogsize="0"
196    
197    getxsaobslog
198    
199    xsaobslogsize=`stat --format=%s ${VALID_CCF}/xsaobslog_${now}.txt`
200    
201    if [ "$xsaobslogsize"  = "0" ] ; then
202            echo "Error: Failure to download the XSA Obs. Log file - Abort"
203            [ -f "${mailfile}" ] && rm -rf ${mailfile}
204            echo "The XSA Obs. Log file has 0 size - Not downloaded?" >> $mailfile
205            echo "." >> $mailfile
206            mailnotify "mlovccf: Error: Failure to download the XSA Obs. Log file - Abort" "$mailfile"
207            rm ${mailfile}
208            exit
209    fi
210    
211    # 2. Sets SAS_CCFPATH and initialises HEADAS and SAS depending on host
212    
213  case "$host" in  case "$host" in
214          xvsoc01|xmm)          xvsoc01|xmm)
# Line 136  case "$host" in Line 250  case "$host" in
250          *) echo "Error: Do not know how to do it in host $host" ; exit ;;          *) echo "Error: Do not know how to do it in host $host" ; exit ;;
251  esac  esac
252    
253  # Finds the latest MIF issue  # 3. Finds the latest MIF issue
254    
255  find_latest_mif "${SAS_CCFPATH}"  find_latest_mif "${SAS_CCFPATH}"
256    
257    
258  # Now scans the list of OBDS ID registered in the previous list to get the start time  # 4. Scans the list of OBDS ID registered in the previous list to get the start time
259  # and then runs cifbuild to get the respective CIF  #    Then runs cifbuild to get the respective CIF.
260    #    all_ccfs_${now}.txt is filled recursively on each iteration. Therefore we start
261    #    with an empty file.
262    
263    #    Output file :          ${VALID_CCF}/all_ccfs_${now}.txt
264    
 # Output file  
265  touch ${VALID_CCF}/all_ccfs_${now}.txt  touch ${VALID_CCF}/all_ccfs_${now}.txt
266    
267  n=0  n=0
# Line 195  do Line 312  do
312    
313  done < ${VALID_CCF}/xsaobslog_${now}.txt  done < ${VALID_CCF}/xsaobslog_${now}.txt
314    
315  # Make a table of classes and issues type "Pipeline Release Notes"  # 5. Make a table of classes and issues with the style "Pipeline Release Notes"
316    #    To get a classification, we need first to obtain all available classes.
317    #
318    
319    
320  # Lists all CCF classes  # Lists all CCF classes
321    
# Line 210  done < ${VALID_CCF}/all_ccfs_${now}.txt Line 330  done < ${VALID_CCF}/all_ccfs_${now}.txt
330  cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt  cat ${ccf_classes} | sort -u > ${VALID_CCF}/kk.txt
331  mv ${VALID_CCF}/kk.txt ${ccf_classes}  mv ${VALID_CCF}/kk.txt ${ccf_classes}
332    
333    
334    
335  # Output final file is named all_ccfs_${now}_table.txt  # Output final file is named all_ccfs_${now}_table.txt
336    
337  total_number_of_ccfs=0  total_number_of_ccfs=0
# Line 277  echo "" Line 399  echo ""
399  echo "Total number of valid CCFs required : ${total_number_of_ccfs}"                                            >> ${all_ccfs_table}  echo "Total number of valid CCFs required : ${total_number_of_ccfs}"                                            >> ${all_ccfs_table}
400  rm ${VALID_CCF}/ccf_classes.txt  rm ${VALID_CCF}/ccf_classes.txt
401  rm ${VALID_CCF}/ccf_issues_for*.txt  rm ${VALID_CCF}/ccf_issues_for*.txt
402    
403    
404    
405    # 6. Fill in the Valid CCF Set dir with the proper CCFs
406    
407    fillvalidccfdir "all_ccfs_${now}.txt"
408    
409    [ -f "${mailfile}" ] && rm -rf ${mailfile}
410    echo "Valid CCF Set successfully copied to ${VALIDCONSTITUENTSDIR}" >> $mailfile
411    echo "Valid CCF Set successfully copied to ${VALIDCCFDIRINTRANET}"  >> $mailfile
412    mailnotify "mvloccf: Valid CCF Set created successfully" $mailfile
413    rm ${mailfile}

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.27