source: trunk/DataCheck/QuickLook/Step2a.sh@ 15436

Last change on this file since 15436 was 15400, checked in by Daniela Dorner, 12 years ago
implemented sourcekey to get ra and dec for ganymed.C
  • Property svn:executable set to *
File size: 7.2 KB
Line 
1#!/bin/bash
2#
3source `dirname $0`/../Sourcefile.sh
4printprocesslog "INFO starting $0"
5
6if [ "$1" = "" ]
7then
8 # get date (before 18h there is no new data to be processed)
9 datepath=`date --date="-18HOUR" +%Y/%m/%d`
10else
11 datepath=$1
12fi
13printprocesslog "INFO processing "$datepath
14#echo "INFO processing "$datepath
15night=`echo $datepath | sed -e 's/\///g'`
16
17numganymeds=0
18
19# getting all image files for this night
20printprocesslog "INFO get file list for night "$datepath
21files=( `find /loc_data/analysis/star/$datepath -type f -name '*_I.root' 2>/dev/null | sort` )
22if [ ${#files[@]} -eq 0 ]
23then
24 printprocesslog "INFO no image files available for night "$datepath
25 continue
26fi
27# write data set file
28#dspath=$anapath/$source/datasets`printf %03d $min`min/$datepath
29#dspath=$anapath/$source/datasets_run/$datepath
30dspath=$anapath/datasets_run/$datepath
31makedir $dspath
32
33for (( i=1 ; i<=${#files[@]} ; i++ ))
34do
35 night=`basename ${files[$i-1]} | cut -d_ -f1`
36 echo "night: "$night
37 run=`basename ${files[$i-1]} | cut -d_ -f2`
38 echo "run: "$run
39 dsfile=$dspath"/dataset"$night"_"$run".txt"
40 echo $dsfile
41 printprocesslog "INFO writing dataset file "$dsfile
42 # write dataset only if merpp-log is available to make sure that star-file is complete
43 merpplog=`echo ${files[$i-1]} | sed -e 's/_I.root/-merpp.log/'`
44 stillrunning=`find $merpplog -mmin -1 2>/dev/null`
45 if [ -e $merpplog ] && [ "$stillrunning" == "" ]
46 then
47 echo `dirname ${files[$i-1]}`" "`basename ${files[$i-1]}` > $dsfile
48 else
49 echo "merpp still running - wait with file "${files[$i-1]}
50 continue
51 fi
52 # process only if ganymedlogfiles is not yet there
53 logfile=`echo $dsfile | sed -e 's/datasets/ganymed/' -e 's/dataset//' -e 's/[.]txt/-ganymed[.]log/'`
54 if ! ls $logfile >/dev/null 2>&1
55 then
56 night=`basename ${files[$i-1]} | cut -d_ -f1`
57 runid=`basename ${files[$i-1]} | cut -d_ -f2 | cut -d. -f1`
58 echo "night: "$night
59 echo "runid: "$runid
60 rawfilepath=$rawdata"/"$datepath"/"
61 rawfilename=`basename ${files[$i-1]} | sed -e 's/_I.root/.fits/'`
62 echo $rawfilepath
63 echo $rawfilename
64 rawfile=`find $rawfilepath -name $rawfilename*`
65 ls $rawfile
66 drivefile=$auxdata"/"$datepath"/"`basename ${files[$i-1]} | cut -d_ -f1`".DRIVE_CONTROL_SOURCE_POSITION.fits"
67 ls $drivefile
68 tstopi=`$factpath/fitsdump -h $rawfile 2>/dev/null | grep TSTOPI | grep -E -o '[0-9]+'`
69 tstopf=`$factpath/fitsdump -h $rawfile 2>/dev/null | grep TSTOPF | grep -E -o '[.][0-9]+'`
70 tstop=${tstopi}${tstopf}
71 #echo "tstop: "$tstop
72 if ls $drivefile >/dev/null 2>&1
73 then
74 coordinates=( `${factpath}/fitsdump ${drivefile} -c Ra_src Dec_src -r --filter='Time<'${tstop} 2>/dev/null | tail -1 2>&1` )
75 if [ "${coordinates[0]}" == "" ] || [ "${coordinates[1]}" == "" ]
76 then
77 printprocesslog "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile
78 echo "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile
79 continue
80 fi
81 if [ "${coordinates[0]}" == "0" ] || [ "${coordinates[1]}" == "0" ]
82 then
83 printprocesslog "WARN coordinates "${coordinates[@]}
84 echo "WARN coordinates "${coordinates[@]}
85 continue
86 fi
87 else
88 printprocesslog "DEBUG coordinates "${coordinates[@]}
89 echo "DEBUG coordinates "${coordinates[@]}
90 query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$night" AND fRunID="$runid
91 sourcekey=`sendquery`
92 if [ "$sourcekey" == "" ]
93 then
94 printprocesslog "WARN sourcekey empty - coordinates"${coordinates[@]}
95 echo "WARN sourcekey empty - coordinates"${coordinates[@]}" for "$rawfile
96 continue
97 fi
98 query="SELECT Round(fRightAscension,6), Round(fDeclination,6) from source WHERE fSourceKey="$sourcekey
99 coordinates=( `sendquery` )
100 if [ "${coordinates[0]}" == "" ] || [ "${coordinates[1]}" == "" ]
101 then
102 printprocesslog "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile
103 echo "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile
104 continue
105 fi
106 if [ "${coordinates[0]}" == "0" ] || [ "${coordinates[1]}" == "0" ]
107 then
108 printprocesslog "WARN coordinates "${coordinates[@]}
109 echo "WARN coordinates "${coordinates[@]}
110 continue
111 fi
112 fi
113
114 echo $logfile" "${files[$i-1]}" -"${coordinates[0]}"-"${coordinates[1]}
115 echo "`dirname $0`/RunGanymed.sh $dsfile "${coordinates[0]}" "${coordinates[1]}
116 `dirname $0`/RunGanymed.sh $dsfile ${coordinates[0]} ${coordinates[1]}
117 numganymeds=`echo " $numganymeds + 1 " | bc -l`
118 fi
119done
120echo "found "$numganymeds" ganymeds."
121
122# # get list of 5min-dataset-files as starting point
123# printprocesslog "INFO get list of dataset files for "$min"min"
124# files=( `find $dspath -type f -name 'dataset*.txt' | sort` )
125# minold=5
126# # loop over data set files
127# # copy always 2 in one new file for double observation time
128# while [ ${#files[@]} -gt 1 ]
129# do
130# # get double observation time and path for datasets
131# min=`echo " $minold + $minold " | bc -l `
132# dspathold=$dspath
133# dspath=$anapath"/"$source"/datasets"`printf %03d $min`"min/"$datepath
134# makedir $dspath
135# # loop over already existing data set files
136# for (( i=0 ; i<=${#files[@]} ; i++ ))
137# do
138# # number of 1st and 2nd old dataset file
139# num1=`echo " $i + $i + 1" | bc -l `
140# num2=`echo " $i + $i + 2 " | bc -l `
141# # number of new dataset file
142# dsnum=`echo " $i + 1 " | bc -l `
143# # continue only if 2 dataset files are left
144# if ! [ ${files[$num1]} ]
145# then
146# break
147# fi
148# ds1=$dspathold"/dataset"$num1".txt"
149# ds2=$dspathold"/dataset"$num2".txt"
150# dsfile=$dspath"/dataset"$dsnum".txt"
151# if ! [ -e $ds1 ] || ! [ -e $ds2 ]
152# then
153# echo $ds1" or "$ds2" is still missing -> continue."
154# continue
155# fi
156# # copy two old into one new dataset file
157# printprocesslog "INFO writing dataset "$dsfile
158# cat $ds1 > $dsfile
159# cat $ds2 >> $dsfile
160# # process only if ganymedlogfiles is not yet there
161# logfile=`echo $dsfile | sed -e 's/datasets/ganymed/' -e 's/dataset//' -e 's/[.]txt/-ganymed[.]log/'`
162# if ! ls $logfile >/dev/null 2>&1
163# then
164# echo $logfile
165# `dirname $0`/RunGanymed.sh $source $dsfile
166# numganymeds=`echo " $numganymeds + 1 " | bc -l`
167# fi
168# done
169# # get list of new dataset files
170# printprocesslog "INFO get list of dataset files for "$min"min"
171# files=( `find $dspath -type f -name 'dataset*.txt' | sort` )
172# minold=$min
173# done
174
175# if [ $numganymeds -gt 0 ]
176# then
177# if ! ps aux | grep Step2b | grep -v grep >/dev/null 2>&1
178# then
179# `dirname $0`/Step2b.sh &
180# fi
181# if ! ps aux | grep Step3 | grep -v grep >/dev/null 2>&1
182# then
183# `dirname $0`/Step3.sh min &
184# fi
185# numganymeds=0
186# fi
187#done
188
189finish
Note: See TracBrowser for help on using the repository browser.