source: trunk/DataCheck/QuickLook/Step2b.sh@ 17120

Last change on this file since 17120 was 16988, checked in by Daniela Dorner, 11 years ago
completely rewritten to run only nightly ganymeds (summing more nights will be done with lightcurve macro)
  • Property svn:executable set to *
File size: 4.7 KB
Line 
1#!/bin/bash
2#
3source `dirname $0`/../Sourcefile.sh
4printprocesslog "INFO starting $0"
5
6# fixme: get sources from DB
7sources=( 1 2 5 7 )
8#sources=( 1 2 5 )
9numganymeds=0
10
11printprocesslog "INFO get all nights."
12query="SELECT fNight FROM RunInfo WHERE not isnull(fSourceKey) and fNight > 20130301 GROUP BY fNight ORDER BY fNight DESC"
13nights=( `sendquery` )
14
15for source in ${sources[@]}
16do
17 dspath=$anapath/datasets_night/$source
18 makedir $dspath
19done
20
21for night in ${nights[@]}
22do
23 echo $night
24 for source in ${sources[@]}
25 do
26 dspath=$anapath/datasets_night/$source
27 dsfile=$dspath"/dataset"$night".txt"
28 if ! ls $dsfile >/dev/null 2>&1
29 then
30 echo "# source "$source" for night "$night > $dsfile
31 linesold=0
32 else
33 lines=( `wc -l $dsfile` )
34 linesold[$source]=${lines[0]}
35 fi
36 done
37
38 inpath=$anapath/star/`echo $night | cut -c 1-4`/`echo $night | cut -c 5-6`/`echo $night | cut -c 7-8`
39 #files=`find $inpath -name '*_I.root'`
40 files=( `ls $inpath/*_I.root 2>/dev/null` )
41 if [ ${#files[@]} -eq 0 ]
42 then
43 continue
44 fi
45 echo "files: "${#files[@]}
46 for file in ${files[@]}
47 do
48 run=`basename $file | cut -d_ -f2`
49 query="SELECT fSourceKey FROM RunInfo WHERE fNight="$night" AND fRunId="$run" GROUP BY fSourceKey"
50 source=`sendquery`
51 if [ $source -eq 0 ]
52 then
53 continue
54 fi
55 dspath=$anapath/datasets_night/$source
56 dsfile=$dspath"/dataset"$night".txt"
57 if ! grep `basename $file` $dsfile >/dev/null 2>&1
58 then
59 if echo $resulttable1 | grep ISDC >/dev/null 2>&1
60 then
61 query="SELECT LPAD(fSequenceID, 3, 0) FROM RunInfo WHERE fNight="$night" AND fRunID="$run
62 seq=`sendquery`
63 merpplog=`dirname $file`"/"$night"_"$seq"-merpp.log"
64 else
65 merpplog=`echo $file | sed -e 's/_I.root/-merpp.log/'`
66 fi
67 echo $merpplog
68 stillrunning=`find $merpplog -mmin -1 2>/dev/null`
69 if [ -e $merpplog ] && [ "$stillrunning" == "" ]
70 then
71 echo `dirname $file`" "`basename $file` >> $dsfile
72 echo `dirname $file`" "`basename $file`
73 else
74 printprocesslog "INFO merpp still running - wait with file "$file
75 continue
76 fi
77 fi
78 done
79
80 for source in ${sources[@]}
81 do
82 dspath=$anapath/datasets_night/$source
83 dsfile=$dspath"/dataset"$night".txt"
84 if ls $dsfile >/dev/null 2>&1
85 then
86 lines=( `wc -l $dsfile` )
87 linesnew[$source]=${lines[0]}
88 if [ ${lines[0]} -le 1 ]
89 then
90 # not ideal - what if number of files stays the same, but files change?
91 rm -v $dsfile
92 continue
93 fi
94 echo "new: "${linesnew[$source]}
95 echo "old: "${linesold[$source]}
96 if [ ${linesnew[$source]} -le ${linesold[$source]} ]
97 then
98 echo "nothing new"
99 continue
100 else
101 ls $dsfile
102 fi
103 fi
104 query="SELECT Round(fRightAscension,6), Round(fDeclination,6) from source WHERE fSourceKey="$source
105 coordinates=( `sendquery` )
106 if [ "${coordinates[0]}" == "" ] || [ "${coordinates[1]}" == "" ]
107 then
108 printprocesslog "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile
109 #echo "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile
110 continue
111 fi
112 if [ "${coordinates[0]}" == "0" ] || [ "${coordinates[1]}" == "0" ]
113 then
114 printprocesslog "WARN coordinates "${coordinates[@]}
115 #echo "WARN coordinates "${coordinates[@]}
116 continue
117 fi
118 if ls $dsfile >/dev/null 2>&1
119 then
120 outpath=$anapath/ganymeds_night/$source
121 logfile=$outpath"/ganymed"$night".log"
122 echo $logfile
123 #ls $logfile
124 if ! ls $logfile >/dev/null 2>&1
125 then
126 ls $dsfile
127 if [ "$qlasge" = "yes" ]
128 then
129 printprocesslog "$sgepath/qsub -b y -q fact_short -v AUTOMATIONSETUP=$AUTOMATIONSETUP -v dsfile=$dsfile -v ra=${coordinates[0]} -v dec=${coordinates[1]} -e bla.txt -o bla.txt `dirname $0`/RunGanymed.sh"
130 $sgepath/qsub -b y -q fact_short -v AUTOMATIONSETUP=$AUTOMATIONSETUP -v dsfile=$dsfile -v ra=${coordinates[0]} -v dec=${coordinates[1]} -e bla.txt -o bla.txt `dirname $0`/RunGanymed.sh
131 else
132 `dirname $0`/RunGanymed.sh $dsfile ${coordinates[0]} ${coordinates[1]}
133 fi
134 #echo "`dirname $0`/RunGanymed.sh $source $dsfile"
135 #`dirname $0`/RunGanymed.sh $source $dsfile
136 numganymeds=`echo " $numganymeds + 1 " | bc -l`
137 fi
138 fi
139 done
140
141 echo "found "$numganymeds" ganymeds."
142done
143
144finish
Note: See TracBrowser for help on using the repository browser.