source: trunk/Mars/hawc/processing/run-file.sh@ 20084

Last change on this file since 20084 was 20026, checked in by tbretz, 4 years ago
A set of example files for working with the database.
File size: 2.1 KB
Line 
1#!/bin/bash
2
3# The data is expected to be found in /data/raw and data/callisto
4DATA="/data"
5CALLISTO=callisto
6# The .success file in /data/star will be resetted
7STAR=star
8# Directory to Mars environment (usually Mars/build)
9MARS=~/Mars/build
10# Relative path to macros
11MACROS=../hawc/processing
12
13DATNIGHT=$1
14DATRUNID=$2
15
16# Split both into year, month, day
17DATYEAR=`echo ${DATNIGHT} | cut -c1-4`
18DATMONTH=`echo ${DATNIGHT} | cut -c5-6`
19DATDAY=`echo ${DATNIGHT} | cut -c7-8`
20
21DRSYEAR=`echo ${DRSNIGHT} | cut -c1-4`
22DRSMONTH=`echo ${DRSNIGHT} | cut -c5-6`
23DRSDAY=`echo ${DRSNIGHT} | cut -c7-8`
24
25# Formatting of the file paths and names
26DATPATH="${DATYEAR}/${DATMONTH}/${DATDAY}"
27DRSPATH="${DRSYEAR}/${DRSMONTH}/${DRSDAY}"
28
29PREFIX=`printf ${DATNIGHT}_%03d ${DATRUNID}`
30
31DATNAME=`printf ${DATNIGHT}_%03d.fits.fz ${DATRUNID}`
32DRSNAME=`printf ${DRSNIGHT}_%03d.drs.fits ${DRSRUNID}`
33
34COUT=${DATA}/${CALLISTO}/${DATPATH}
35SOUT=${DATA}/${STAR}/${DATPATH}
36
37 echo ""
38 echo DAT=${DATNAME} [${DATPATH}]
39 echo DRS=${DRSNAME} [${DRSPATH}]
40
41 # Check if not yet successfully processed
42 # Removing this file can be used to trigger a re-processing
43 # the next time this script is executed
44 if [ ! -f "${OUT}/.${PREFIX}.success" ]
45 then
46
47 cd ${MARS}
48
49 mkdir -p ${OUT}
50
51 # Trigger reprocessing of the process-fils in the star directory
52 rm -f "${DATA}/${STAR}/${DATPATH}/.${PREFIX}.*"
53
54 # Flag that a process is running
55 rm ${OUT}/.${PREFIX}.done
56 rm ${OUT}/.${PREFIX}.success
57
58 touch ${OUT}/.${PREFIX}.running
59
60 # Execute the calibration and write output to log-file
61 root -b -q -l ${MACROS}/callisto.C'("'${DATA}/raw/${DATPATH}/${DATNAME}'","'${DATA}/raw/${DRSPATH}/${DRSNAME}'","'${OUT}'")' \
62 2>&1 | tee ${OUT}/${PREFIX}.log
63
64 RC=${PIPESTATUS[0]}
65
66 # Remember exit status of callisto
67 echo RC=${RC} | tee -a ${OUT}/${PREFIX}.log
68 echo ${RC} > ${OUT}/.${PREFIX}.done
69
70 # Processing is finished
71 rm -f ${OUT}/.${PREFIX}.running
72
73 # If processing was successfull write corresponding flag
74 if [ "${RC}" == "0" ]
75 then
76 touch ${OUT}/.${PREFIX}.success
77 fi
78
79 cd -
80
81 else
82 echo Skipped.
83 fi
84
85done
Note: See TracBrowser for help on using the repository browser.