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. |
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.11 2016/03/23 09:31:49 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 |
|
|
28 |
|
VALID_CCF="$HOME/valid_ccf" |
29 |
|
|
30 |
host=`hostname | cut -d. -f1` |
host=`hostname | cut -d. -f1` |
31 |
|
|
32 |
now=`date +'%Y%m%d_%H%M'` |
now=`date +'%Y%m%d_%H%M'` |
33 |
now_table=`date +'%Y-%m-%dT%H:%M:%S'` |
now_table=`date +'%Y-%m-%dT%H:%M:%S'` |
34 |
|
|
35 |
|
|
36 |
|
# Function getxsaobslog |
37 |
|
# We need to get the list of all observed ODFs at the current date. |
38 |
|
# This is obtained from http://nxsa.esac.esa.int/ftp_public/cds_obslog/xsaobslog.txt. |
39 |
|
|
40 |
|
getxsaobslog () |
41 |
|
{ |
42 |
|
|
43 |
|
XSAOBSURL="http://nxsa.esac.esa.int/ftp_public/cds_obslog/xsaobslog.txt" |
44 |
|
|
45 |
|
# Remove any xsaobslog.txt previously downloaded. |
46 |
|
|
47 |
|
[ -f "${VALID_CCF}/xsaobslog.txt" ] && rm -rf ${VALID_CCF}/xsaobslog.txt |
48 |
|
|
49 |
|
# Get the list latest list of ODFs available from nXSA server. |
50 |
|
|
51 |
|
wget -q ${XSAOBSURL} -O ${VALID_CCF}/xsaobslog.txt |
52 |
|
|
53 |
|
# Rename xsaobslog.txt to xsaobslog_${now}.txt just to have a reference |
54 |
|
# of which list of ODFs was used to compute the list of valid CCFs. |
55 |
|
|
56 |
|
mv ${VALID_CCF}/xsaobslog.txt ${VALID_CCF}/xsaobslog_${now}.txt |
57 |
|
|
58 |
|
} |
59 |
|
|
60 |
|
|
61 |
# 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 |
62 |
|
|
63 |
find_latest_mif() |
find_latest_mif() |
79 |
|
|
80 |
} |
} |
81 |
|
|
82 |
# Function get_ccf_list to list on stdout the table of CCFs in a given CIF |
# Function get_ccf_list to list on stdout the table of CCFs in a given CIF. |
|
# |
|
83 |
# Requires that Heasoft is initialised. Otherwise exits with error. |
# Requires that Heasoft is initialised. Otherwise exits with error. |
84 |
|
|
85 |
get_ccf_list() |
get_ccf_list() |
100 |
rows=- STDOUT |
rows=- STDOUT |
101 |
} |
} |
102 |
|
|
103 |
|
# Fill in the valid_constituents directory with the Valid CCF set |
104 |
|
|
105 |
# We need to get the list of all observed ODFs at the current date. |
fillvalidccfdir() |
106 |
# This is obtained from ftp://nxsa.esac.esa.int/pub/cds_obslog/xsaobslog.txt. |
{ |
107 |
|
|
108 |
VALID_CCF="$HOME/valid_ccf" |
[ -z "$1" ] && return |
109 |
|
|
110 |
cd ${VALID_CCF} |
validccflist=$1 |
111 |
|
|
112 |
# Remove any xsaobslog.txt previously downloaded. |
if [ ! -f "${VALID_CCF}/${validccflist}" ] ; then |
113 |
|
echo "Error: ${VALID_CCF}/${validccflist} not found - Abort!" |
114 |
|
exit |
115 |
|
fi |
116 |
|
|
117 |
[ -f "xsaobslog.txt" ] && rm -rf xsaobslog.txt |
VALIDCONSTITUENTSDIR="/home/ccflib/ftp-area/valid_constituents/" |
118 |
|
rm -rf ${VALIDCONSTITUENTSDIR}/* |
119 |
|
|
120 |
# Get the list latest list of ODFs available from nXSA server. |
CONSTITUENTSDIR="/home/ccflib/ftp-area/constituents" |
121 |
|
n=0 |
122 |
wget -q ftp://nxsa.esac.esa.int/pub/cds_obslog/xsaobslog.txt |
while read ccf |
123 |
|
do |
124 |
|
n=$((n + 1)) |
125 |
|
echo "$n cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCONSTITUENTSDIR}/" |
126 |
|
cp -a ${CONSTITUENTSDIR}/${ccf} ${VALIDCONSTITUENTSDIR}/ |
127 |
|
done < ${VALID_CCF}/${validccflist} |
128 |
|
|
129 |
# Rename xsaobslog.txt to xsaobslog_${now}.txt just to have a reference |
} |
130 |
# of which list of ODFs was used to compute the list of valid CCFs. |
|
131 |
|
|
132 |
|
# Get the list of all ODFs |
133 |
|
|
134 |
|
xsaobslogsize="0" |
135 |
|
|
136 |
mv xsaobslog.txt xsaobslog_${now}.txt |
getxsaobslog |
137 |
|
|
138 |
|
xsaobslogsize=`stat --format=%s ${VALID_CCF}/xsaobslog_${now}.txt` |
139 |
|
|
140 |
|
if [ "$xsaobslogsize" = "0" ] ; then |
141 |
|
echo "Error: Failure to download the XSA Obs. Log file - Abort" |
142 |
|
exit |
143 |
|
fi |
144 |
|
|
145 |
# Sets SAS_CCFPATH and initialises HEADAS and SAS depending on host |
# Sets SAS_CCFPATH and initialises HEADAS and SAS depending on host |
146 |
|
|
325 |
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} |
326 |
rm ${VALID_CCF}/ccf_classes.txt |
rm ${VALID_CCF}/ccf_classes.txt |
327 |
rm ${VALID_CCF}/ccf_issues_for*.txt |
rm ${VALID_CCF}/ccf_issues_for*.txt |
328 |
|
|
329 |
|
# Fill in the Valid CCF Set dir with the proper CCFs |
330 |
|
|
331 |
|
fillvalidccfdir "all_ccfs_${now}.txt" |