source: trunk/Mars/hawc/processing/run-root2sql.sh@ 20103

Last change on this file since 20103 was 20039, checked in by tbretz, 4 years ago
Fixed some typos.
File size: 1.6 KB
Line 
1#/bin/bash
2
3# File containing the access credentials for the database
4CREDENTIALS=credentials-read-only.cnf
5
6# Specify the telescope for which to run the script. Replace '1'
7# by $1 if the telesocpe number is supplied as an option to the script
8TELESCOPE=1
9
10# Path where the data is stored... can be callisto or star
11BASEIN=/data/callisto
12# This is Y for calibrated data and I for image parameters
13SUFFIX=Y
14# The table to insert the data into (and create if not exists)
15TABLE=Callisto
16# Path to the executable
17ROOT2SQL=~/FACT++/build/root2sql
18# Resource file to use (should match the input files)
19RESOURCE=root2sql-callisto.rc
20
21# Get all runs that can (and should) be calibrated
22# Pipe the output to mysql and read the
23# mysql output line-by-libe
24echo \
25"\
26SELECT
27 NIGHT, RUNID
28FROM
29 Calibration
30ORDER BY
31 NIGHT, RUNID\
32
33"\
34 | mysql \
35 --defaults-file=${CREDENTIALS} \
36 --skip-column-names \
37 --batch --raw \
38 --compress \
39 | \
40while read -r -a LINE
41do
42 # Get NIGHT and RUNID of all files
43 NIGHT=${LINE[0]}
44 RUNID=${LINE[1]}
45
46 # Format file and path names
47 DIR="${BASEIN}"/${NIGHT:0:4}/${NIGHT:4:2}/${NIGHT:6:2}
48
49 PREFIX=`printf ${NIGHT}_%03d ${RUNID}`
50
51 echo ""
52 echo ${DIR}/${PREFIX}
53
54 # Check if processing was successfull
55 if [ -f ${DIR}/.${PREFIX}.success ]
56 then
57
58 ${ROOT2SQL} ${DIR}/${PREFIX}_${SUFFIX}.root \
59 -C ${RESOURCE} \
60 --table=${TABLE} \
61 --const.Telescope=${TELESCOPE} \
62 --const.NIGHT=${NIGHT} \
63 --const.RUNID=${RUNID} \
64 2>&1 | tee ${DIR}/${PREFIX}-root2sql.log
65
66 echo RC=${PIPESTATUS[0]} >> ${DIR}/${PREFIX}-root2sql.log
67 else
68 echo Skipped.
69 fi
70
71done
Note: See TracBrowser for help on using the repository browser.