Index: trunk/DataCheck/QuickLook/Step2a.sh
===================================================================
--- trunk/DataCheck/QuickLook/Step2a.sh	(revision 16677)
+++ trunk/DataCheck/QuickLook/Step2a.sh	(revision 16987)
@@ -6,17 +6,24 @@
 if [ "$1" = "" ]
 then 
+   hour=`date +%k`
    # get date (before 18h there is no new data to be processed)
-   datepaths=( `date --date="-18HOUR" +%Y/%m/%d` )
-   datepaths=( `find -L $datapath/star -mindepth 3 -type d | sort -r | sed "s/\${datapath_for_sed}\/star//g" | sed -e 's/^\///'` ) #all available dates in star-directory
+   if [ $hour -le 7 ] || [ $hour -ge 19 ]
+   then
+      datepaths=( `date --date="-19HOUR" +%Y/%m/%d` )
+   else
+      datepaths=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-60hour"` \
+              `date +%Y/%m/%d --date="-84hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-132hour"` \
+#              `date +%Y/%m/%d --date="-156hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-204hour"` \
+              )
+   fi
+   #datepaths=( `find -L $datapath/star -mindepth 3 -type d | sort -r | sed "s/\${datapath_for_sed}\/star//g" | sed -e 's/^\///'` ) #all available dates in star-directory
 else
    datepaths=( $1 )
 fi
 
-echo ${datepaths[@]}
-
 for datepath in ${datepaths[@]}
 do 
    printprocesslog "INFO processing "$datepath
-   echo "INFO processing "$datepath
+   #echo "INFO processing "$datepath
    night=`echo $datepath | sed -e 's/\///g'`
    
@@ -69,20 +76,19 @@
          night=`basename ${files[$i-1]} | cut -d_ -f1`
          runid=`basename ${files[$i-1]} | cut -d_ -f2 | cut -d. -f1`
-         #echo "night: "$night
-         #echo "runid: "$runid
+         drivefile=$auxdata"/"$datepath"/"`basename ${files[$i-1]} | cut -d_ -f1`".DRIVE_CONTROL_SOURCE_POSITION.fits"
          rawfilepath=$rawdata"/"$datepath"/"
          rawfilename=`basename ${files[$i-1]} | sed -e 's/_I.root/.fits/'`
-         #echo $rawfilepath
-         #echo $rawfilename
-         rawfile=`find $rawfilepath -name $rawfilename*`
-         printprocesslog "INFO processing "$rawfile
-         drivefile=$auxdata"/"$datepath"/"`basename ${files[$i-1]} | cut -d_ -f1`".DRIVE_CONTROL_SOURCE_POSITION.fits"
-         printprocesslog "INFO getting coordinates from "$drivefile
-         tstopi=`$factpath/fitsdump -h $rawfile  2>/dev/null | grep TSTOPI | grep -E -o '[0-9]+'`
-         tstopf=`$factpath/fitsdump -h $rawfile  2>/dev/null | grep TSTOPF | grep -E -o '[.][0-9]+'`
-         tstop=${tstopi}${tstopf}
+         rawfile=`find $rawfilepath -name $rawfilename* 2>/dev/null`
+         if ! [ "$rawfile" == "" ]
+         then 
+            printprocesslog "INFO processing "$rawfile
+            tstopi=`$factpath/fitsdump -h $rawfile  2>/dev/null | grep TSTOPI | grep -E -o '[0-9]+'`
+            tstopf=`$factpath/fitsdump -h $rawfile  2>/dev/null | grep TSTOPF | grep -E -o '[.][0-9]+'`
+            tstop=${tstopi}${tstopf}
+         fi
          #echo "tstop: "$tstop
-         if ls $drivefile >/dev/null 2>&1
-            then
+         if [ ls $drivefile >/dev/null 2>&1 ] && ! [ "$tstop" == "" ]
+         then
+            printprocesslog "INFO getting coordinates from "$drivefile
             coordinates=( `${factpath}/fitsdump ${drivefile} -c Ra_src Dec_src -r --filter='Time<'${tstop}  2>/dev/null | tail -1 2>&1` )
             if [ "${coordinates[0]}" == "" ] || [ "${coordinates[1]}" == "" ]
@@ -99,6 +105,5 @@
             fi
          else
-            printprocesslog "DEBUG coordinates "${coordinates[@]}
-            #echo "DEBUG coordinates "${coordinates[@]}
+            printprocesslog "INFO getting coordinates from DB."
             query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$night" AND fRunID="$runid
             sourcekey=`sendquery`
@@ -113,5 +118,5 @@
             if [ "${coordinates[0]}" == "" ] || [ "${coordinates[1]}" == "" ]
             then
-               printprocesslog "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile
+               printprocesslog "WARN couldn't get coordinates ("${coordinates[@]}") from DB."
                #echo "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile
                continue
@@ -133,4 +138,5 @@
          else
             `dirname $0`/RunGanymed.sh $dsfile ${coordinates[0]} ${coordinates[1]}
+            #echo "ganymed for "$dsfile" "${coordinates[0]}" "${coordinates[1]}
          fi
          numganymeds=`echo " $numganymeds + 1 " | bc -l`
