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

Last change on this file since 20030 was 20026, checked in by tbretz, 4 years ago
A set of example files for working with the database.
File size: 1.6 KB
Line 
1#/bin/bash
2
3# Path where the data is stored... can be callisto or star
4BASEIN=/data/callisto
5# This is Y for calibrated data and I for image parameters
6SUFFIX=Y
7# The table to insert the data into (and create if not exists)
8TABLE=Callisto
9# Path to the executable
10ROOT2SQL=~/FACT++/build/root2sql
11# Resource file to use (should match the input files)
12RESOURCE=root2sql-callisto.rc
13
14# Get all runs that can (and should) be calibrated
15# Pipe the output to mysql and read the
16# mysql output line-by-libe
17echo \
18"\
19SELECT
20 NIGHT, RUNID
21FROM
22 Calibration_new
23ORDER BY
24 NIGHT, RUNID\
25
26"\
27 | mysql \
28 --defaults-file=~/.password.cnf \
29 --user=hawcwrite \
30 --host=ihp-pc45.ethz.ch \
31 --database=hawcdata \
32 --skip-column-names \
33 --batch --raw \
34 --compress \
35 | \
36while IFS= read -r LINE
37do
38
39 # Get NIGHT and RUNID of all files
40 NIGHT=`echo "$LINE" | awk -F"\t" '{print $1}'`
41 RUNID=`echo "$LINE" | awk -F"\t" '{print $2}'`
42
43 # Split into year, month, day
44 YEAR=`echo ${NIGHT} | cut -c1-4`
45 MONTH=`echo ${NIGHT} | cut -c5-6`
46 DAY=`echo ${NIGHT} | cut -c7-8`
47
48 # Format file and path names
49 DIR="${BASEIN}/${YEAR}/${MONTH}/${DAY}"
50
51 PREFIX=`printf ${NIGHT}_%03d ${RUNID}`
52
53 echo ""
54 echo ${DIR}/${PREFIX}
55
56 # Check if processing was successfull
57 if [ -f ${DIR}/.${PREFIX}.success ]
58 then
59
60 ${ROOT2SQL} ${DIR}/${PREFIX}_${SUFFIX}Y.root \
61 -C ${RESOURCE} \
62 --table=${TABLE} \
63 --const.NIGHT=${NIGHT} \
64 --const.RUNID=${RUNID} \
65 2>&1 | tee ${DIR}/${PREFIX}-root2sql.log
66
67 echo RC=${PIPESTATUS[0]} >> ${DIR}/${PREFIX}-root2sql.log
68 else
69 echo Skipped.
70 fi
71
72done
Note: See TracBrowser for help on using the repository browser.