Changeset 18083
- Timestamp:
- 01/04/15 05:41:02 (10 years ago)
- Location:
- trunk/DataCheck/Processing
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataCheck/Processing/CheckRawData.sh
r17907 r18083 1 1 #!/bin/bash 2 2 3 # this script has been written to run on La Palma on the machine data 4 # i.e. paths are only working on this machine 5 # the script starts from the zipped files 6 # this causes a delay until files are in the database 7 # because they have to be rsynced and zipped first (see RsyncRawData.sh, ZipRawData.sh) 8 # 9 # starting from 2012/06/05 the keywords CHECKSUM and DATASUM are 10 # available in the fits header of the rawfile 11 # starting from this time the md5sums are not calculated anymore (not true, only from 2012/12/17) 12 # 3 # completely new version of the script 4 # running on newdaq to fill the information as fast as possible 5 # ftools is not used in this script anymore 13 6 14 7 # todo 15 8 # tempfile for fitsdump -h output 16 17 ## options:18 #skipmd5sum="no" # fill md5 sums in any case19 #skipmd5sum="iffilled" # fill md5 sum only if they are not yet in db # default20 #skipmd5sum="yes" # do not fill md5 sums in any case #new default since 2012/06/05 when the checksum is available in heaser21 9 22 10 # option whether to fill all row or only those where information is missing … … 28 16 fi 29 17 30 31 root=/opt/root_svn/bin/thisroot.sh32 33 18 source `dirname $0`/../Sourcefile.sh 34 19 printprocesslog "INFO starting $0 with options doupdate="$doupdate #" and skipmd5sum="$skipmd5sum 35 36 # setup to use ftools37 source $HEADAS/headas-init.sh38 20 39 21 # check if software is available … … 45 27 46 28 # check if paths are available 47 if ! ls /daq/raw>/dev/null 2>&129 if ! ls $rawdata >/dev/null 2>&1 48 30 then 49 printprocesslog "ERROR /daq/raw is not available." 50 finish 51 fi 52 if ! ls /newdaq/raw >/dev/null 2>&1 53 then 54 printprocesslog "ERROR /newdaq/raw is not available." 55 finish 56 fi 57 if ! ls /loc_data/zipraw >/dev/null 2>&1 58 then 59 printprocesslog "ERROR /loc_data/zipraw is not available." 31 printprocesslog "ERROR "$rawdata" is not available." 60 32 finish 61 33 fi … … 81 53 for date in ${dates[@]} 82 54 do 83 date2=`echo $date | sed -e 's/\///g'`84 night=85 query="SELECT fNight FROM AuxFilesAvailISDCStatus WHERE fNight="$date286 night=`sendquery`87 if [ "$night" == "" ] && ls /loc_data/zipraw/$date >/dev/null 2>&188 then89 printprocesslog "INFO insert "$date2" to AuxFilesAvailISDCStatus"90 query="INSERT AuxFilesAvailISDCStatus SET fNight="$date2", fPriority="$date291 sendquery >/dev/null 2>&192 fi93 night=94 query="SELECT fNight FROM DriveFileAvailISDCStatus WHERE fNight="$date295 night=`sendquery`96 if [ "$night" == "" ] && ls /loc_data/zipraw/$date >/dev/null 2>&197 then98 printprocesslog "INFO insert "$date2" to DriveFileAvailISDCStatus"99 query="INSERT DriveFileAvailISDCStatus SET fNight="$date2", fPriority="$date2100 sendquery >/dev/null 2>&1101 fi102 night=103 query="SELECT fNight FROM RatesFileAvailISDCStatus WHERE fNight="$date2104 night=`sendquery`105 if [ "$night" == "" ] && ls /loc_data/zipraw/$date >/dev/null 2>&1106 then107 printprocesslog "INFO insert "$date2" to RatesFileAvailISDCStatus"108 query="INSERT RatesFileAvailISDCStatus SET fNight="$date2", fPriority="$date2109 sendquery >/dev/null 2>&1110 fi111 night=112 query="SELECT fNight FROM AuxDataInsertStatus WHERE fNight="$date2113 night=`sendquery`114 if [ "$night" == "" ] && ls /loc_data/zipraw/$date >/dev/null 2>&1115 then116 printprocesslog "INFO insert "$date2" to AuxDataInsertStatus"117 query="INSERT AuxDataInsertStatus SET fNight="$date2", fPriority="$date2118 sendquery >/dev/null 2>&1119 fi120 ziprawdir=/loc_data/zipraw/$date121 # check if data are available from that night122 if ! [ -d $ziprawdir ]123 then124 printprocesslog "INFO "$ziprawdir" does not exist."125 continue126 else127 printprocesslog "INFO processing "$ziprawdir"..."128 fi129 130 # find all fits.gz files starting with the oldest file131 printprocesslog "INFO finding files to be checked in $ziprawdir..."132 fitsgzfiles=`find $ziprawdir -type f -name '*.fits.gz'| sort `133 134 55 # get runnumber from date 135 56 runnumber=`echo $date | sed -e 's/\///g'` 136 57 58 night= 59 query="SELECT fNight FROM AuxDataInsertStatus WHERE fNight="$runnumber 60 night=`sendquery` 61 if [ "$night" == "" ] && ls $rawdata/$date >/dev/null 2>&1 62 then 63 printprocesslog "INFO insert "$runnumber" to AuxDataInsertStatus" 64 query="INSERT AuxDataInsertStatus SET fNight="$runnumber", fPriority="$runnumber 65 sendquery >/dev/null 2>&1 66 fi 67 rawdir=$rawdata/$date 68 # check if data are available from that night 69 if ! [ -d $rawdir ] 70 then 71 printprocesslog "INFO "$rawdir" does not exist." 72 continue 73 else 74 printprocesslog "INFO processing "$rawdir"..." 75 fi 76 77 # find all fits.gz files starting with the oldest file 78 printprocesslog "INFO finding files to be checked in $rawdir..." 79 #fitsfiles=`ls $rawdir/*.fits 2>/dev/null | sort ` 80 fitsfiles=`find $rawdir -type f -regex '.*[.]fits[.]?[g]?[f]?[z]?' 2>/dev/null | sort ` 81 137 82 # loop to check files 138 for file in $fits gzfiles83 for file in $fitsfiles 139 84 do 140 filecorrupt="no"141 85 printprocesslog "INFO checking file "$file 142 #echo "INFO checking file "$file" at "`date` 143 144 # raw and original file 145 # file: /loc_data/zipraw 146 # rawfile: /daq/raw 147 # origfile: /newdaq/raw 148 rawfile=`echo $file | sed -e 's/loc_data/daq/' -e 's/zipraw/raw/' -e 's/fits[.]gz/fits/'` 149 rawfile2=`echo $file | sed -e 's/zipraw/raw/' -e 's/fits[.]gz/fits/'` 150 origfile=`echo $rawfile | sed -e 's/daq/newdaq/'` 86 #echo "INFO checking file "$file 87 filenotclosed="no" 151 88 152 89 # check if it is drs file … … 158 95 fi 159 96 160 # not needed anymore as files are only rsynced from newdaq to daq when they are closed161 # # check if file is already finished162 # # original file on daq (if data was taken on daq163 # if [ -e $origfile ]164 # then165 # # check if raw file was changed in the last 30 minutes166 # isnew=`find $origfile -cmin -30`167 # if [ "$isnew" != "" ]168 # then169 # printprocesslog "WARN "$origfile" is not older than 30 min. -> continue"170 # continue171 # fi172 #173 # # get time of last modification as seconds since Epoch for both files174 # timeorig=`stat -c %Y $origfile`175 # timecopy=`stat -c %Y $rawfile`176 # # compare times177 # if ! [ $timeorig -eq $timecopy ]178 # then179 # # if times are not the same, the file is still open => no check180 # printprocesslog "INFO file "$rawfile" not yet closed. -> continue"181 # continue182 # fi183 # else184 # # if the origfile doesn't exist, the data was probably written not on daq but on data185 # printprocesslog "INFO file "$rawfile" was probably taken on data and not daq."186 # fi187 188 97 # get run and file number form filename 189 runnumbererror="no"190 numbererror="no"191 98 numberfromname=`echo $file | grep -E -o '20[1-9][0-9][01][0-9][0-3][0-9]_[0-9]{3}'` 192 99 runnumberfromname=`echo $numberfromname | cut -d_ -f1` … … 194 101 if [ "$runnumber" != "$runnumberfromname" ] 195 102 then 196 runnumbererror="yes"197 103 printprocesslog "ERROR for file "$file": runnumber from date ("$runnumber") and filename ("$runnumberfromname") don't agree." 198 104 fi … … 214 120 215 121 runtype= 216 # check if fits file is corrupted217 numfitserrors=0218 #checkfitsfile=`fverify $rawfile 2>/dev/null | grep '0 error(s)'`219 #numfitserrors=`fverify $rawfile 2>/dev/null | grep -o '[0-9][ ]error(s)' | grep -E -o '[0-9]'`220 # ftools missing on daq221 # numfitserrors=`ssh daq "export HEADAS=/opt/heasoft-6.11/x86_64-unknown-linux-gnu-libc2.13-0/ ; source $HEADAS/headas-init.sh ; fverify $rawfile2 2>/dev/null | grep -o '[0-9][ ]error(s)' | grep -E -o '[0-9]'"`222 # echo $rawfile2" ------ "$numfitserrors223 #if [ "$checkfitsfile" == "" ]224 if [ $numfitserrors -gt 0 ]225 then226 printprocesslog "WARN "$rawfile2" has "$numfitserrors" fitserror(s). "227 #fitsdumperrors=`$factpath/fitsdump -h -t Events $file 2>&1 | grep corrupted`228 fitsdumperrors=`$factpath/fitsdump -h $file 2>&1 | grep corrupted`229 if [ "$fitsdumperrors" != "" ]230 then231 filecorrupt="yes"232 fi233 #numfitserrors=1234 fi235 236 122 # check if file was closed properly 237 123 if [ "`echo $file | grep -o drs`" == "drs" ] 238 124 then 239 nondrsfile=`echo $file | sed -e 's/[.]drs//g'` 240 tstop=`ssh newdaq "source $root ; $factpath/fitsdump -h $nondrsfile 2>/dev/null | grep TSTOPI | grep -E -o '[0-9]+'"` 125 nondrsfile=`echo $file | sed -e 's/[.]drs//g'`".fz" # fixme: maybe more flexible 126 tstop=`$factpath/fitsdump -h $nondrsfile 2>/dev/null | grep TSTOPI | grep -E -o '[0-9]+'` 127 checkstatus=$? 241 128 else 242 tstop=`ssh newdaq "source $root ; $factpath/fitsdump -h $file 2>/dev/null | grep TSTOPI | grep -E -o '[0-9]+'"` 243 fi 244 if [ "$tstop" == "0" ] 245 then 246 echo $file" not yet closed." 247 echo "WARN: $file has empty TSTOP" 248 filecorrupt="yes" 129 tstop=`$factpath/fitsdump -h $file 2>/dev/null | grep TSTOPI | grep -E -o '[0-9]+'` 130 checkstatus=$? 131 fi 132 #if [ $checkstatus -gt 0 ] 133 #then 134 # echo "WARN: getting tstop for file "$file" failed: tstop: -"$tstop"-"`date` 135 #fi 136 if [ "$tstop" == "0" ] || [ "$tstop" == "" ] 137 then 138 fileaccessed=`find $file -amin -30` 139 if ! [ "$fileaccessed" == "" ] 140 then 141 printprocesslog "INFO "$file" was accessed in the last 30 minutes => continue" 142 continue 143 else 144 printprocesslog "WARN "$file" has empty TSTOP but was not touched for 30 minutes" 145 filenotclosed="yes" 146 fi 249 147 fi 250 148 251 149 numdrsfiles= 252 150 step= 253 #if [ $numfitserrors -eq 0 ] 254 if [ "$filecorrupt" == "no" ] 151 if [ "$filenotclosed" == "no" ] 255 152 then 256 153 # get run and file number from file 257 #runnumberfromfile=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep NIGHT | grep -E -o '20[1-9][0-9][01][0-9][0-3][0-9]'`258 154 runnumberfromfile=`$factpath/fitsdump -h $file 2>/dev/null | grep NIGHT | grep -E -o '20[1-9][0-9][01][0-9][0-3][0-9]'` 259 #filenumberfromfileorig=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep RUNID | grep -E -o '[0-9]{1,3}'`260 155 filenumberfromfileorig=`$factpath/fitsdump -h $file 2>/dev/null | grep RUNID | grep -E -o '[0-9]{1,3}'` 261 156 if [ "$runnumberfromfile" = "" ] || [ "$filenumberfromfileorig" = "" ] … … 267 162 if [ "$numberfromfile" != "$numberfromname" ] 268 163 then 269 numbererror="yes"270 164 printprocesslog "ERROR for file "$file": number from filename ("$numberfromname") and file ("$numberfromfile") don't agree." 271 165 fi 272 166 273 167 # get checksums from header 274 #checksum=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep CHECKSUM | grep -E -o '[a-zA-Z0-9]{16}'`275 168 checksum=`$factpath/fitsdump -h $file 2>/dev/null | grep CHECKSUM | grep -E -o '[a-zA-Z0-9]{16}'` 276 169 if [ "$checksum" == "" ] … … 278 171 printprocesslog "WARN checksum for file "$file" is empty." 279 172 fi 280 #datasum=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep DATASUM | grep -E -o '[0-9]{1,10}'`281 173 datasum=`$factpath/fitsdump -h $file 2>/dev/null | grep DATASUM | grep -E -o '[0-9]{1,10}'` 282 174 if [ "$datasum" == "" ] … … 289 181 # in the very beginning only drs-files were existing 290 182 # in the beginning the keywords DRSCALIB and STEP were not existing 291 drsfile=`echo $file | sed -e 's/fits /drs.fits/'`183 drsfile=`echo $file | sed -e 's/fits.fz/drs.fits/'` 292 184 numdrsfiles=`ls $drsfile 2>/dev/null | wc -l` 293 #drscalib=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep DRSCALIB | grep -E -o "['][TF][']" | sed -e "s/'//g"`294 185 drscalib=`$factpath/fitsdump -h $file 2>/dev/null | grep DRSCALIB | grep -E -o "[\ ][TF][\ ]" | sed -e "s/\ //g"` 295 186 if [ "$drscalib" == "T" ] 296 187 then 297 #step=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep DRSSTEP | grep -E -o "['][012][']" | sed -e "s/'//g"`298 188 step=`$factpath/fitsdump -h $file 2>/dev/null | grep DRSSTEP | grep -E -o "[\ ][012][\ ]" | sed -e "s/\ //g"` 299 #stepfromdrs=`$factpath/fitsdump -h -t Events $drsfile 2>/dev/null | grep STEP | grep -E -o "['][012][']" | sed -e "s/'//g"`300 189 stepfromdrs=`$factpath/fitsdump -h $drsfile 2>/dev/null | grep STEP | grep -E -o "[\ ][012][\ ]?" | sed -e "s/\ //g"` 301 190 if [ "$stepfromdrs" != "$step" ] … … 322 211 fi 323 212 fi 324 #echo $numdrsfiles" "$stepfromdrs" "$step" "$drscalib" ("$file")"325 213 326 214 # get other variables from header 327 #runtype=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep RUNTYPE | grep -E -o "['][a-z0-9._-]+[']" | sed -e "s/'//g" -e "s/_/-/g" -e "s/[.]//g"`328 215 runtype=`$factpath/fitsdump -h $file 2>/dev/null | grep RUNTYPE | grep -E -o "['][a-z0-9._-]+[']" | sed -e "s/'//g" -e "s/_/-/g" -e "s/[.]//g"` 329 #echo "runtype for file "$file": "$runtype330 #roi=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep NROI | grep -v NROITM | grep -E -o '[0-9]{1,4}'`331 216 roi=`$factpath/fitsdump -h $file 2>/dev/null | grep NROI | grep -v NROITM | grep -E -o '[0-9]{1,4}'` 332 #roitm=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep NROITM | grep -E -o '[0-9]{1,4}'`333 217 roitm=`$factpath/fitsdump -h $file 2>/dev/null | grep NROITM | grep -E -o '[0-9]{1,4}'` 334 #numevents=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep Events | grep -E -o '[0-9]+'`335 218 numevents=`$factpath/fitsdump -h $file 2>/dev/null | grep Events | grep -E -o '[0-9]+'` 336 #numphys=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep 'NTRG ' | grep -E -o '[0-9]+'`337 219 numphys=`$factpath/fitsdump -h $file 2>/dev/null | grep 'NTRG ' | grep -E -o '[0-9]+'` 338 #numext1=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep 'NTRGEXT1' | grep -E -o '[ ][0-9]+[ ]' | sed -e 's/\ //g'`339 220 numext1=`$factpath/fitsdump -h $file 2>/dev/null | grep 'NTRGEXT1' | grep -E -o '[ ][0-9]+[ ]' | sed -e 's/\ //g'` 340 #numext2=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep 'NTRGEXT2' | grep -E -o '[ ][0-9]+[ ]' | sed -e 's/\ //g'`341 221 numext2=`$factpath/fitsdump -h $file 2>/dev/null | grep 'NTRGEXT2' | grep -E -o '[ ][0-9]+[ ]' | sed -e 's/\ //g'` 342 #numelp=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep 'NTRGLPE' | grep -E -o '[0-9]+'`343 222 numelp=`$factpath/fitsdump -h $file 2>/dev/null | grep 'NTRGLPE' | grep -E -o '[0-9]+'` 344 #numilp=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep 'NTRGLPI' | grep -E -o '[0-9]+'`345 223 numilp=`$factpath/fitsdump -h $file 2>/dev/null | grep 'NTRGLPI' | grep -E -o '[0-9]+'` 346 #numoth=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep 'NTRGMISC' | grep -E -o '[0-9]+'`347 224 numoth=`$factpath/fitsdump -h $file 2>/dev/null | grep 'NTRGMISC' | grep -E -o '[0-9]+'` 348 #numped=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep 'NTRGPED' | grep -E -o '[0-9]+'`349 225 numped=`$factpath/fitsdump -h $file 2>/dev/null | grep 'NTRGPED' | grep -E -o '[0-9]+'` 350 #numtime=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep 'NTRGTIM' | grep -E -o '[0-9]+'`351 226 numtime=`$factpath/fitsdump -h $file 2>/dev/null | grep 'NTRGTIM' | grep -E -o '[0-9]+'` 352 #compiled=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep 'COMPILED' | grep -E -o "['][a-zA-Z]+[ ][ 12][0-9][ ]20[0-9][0-9][ ][0-2][0-9]:[0-5][0-9]:[0-5][0-9][']" | sed -e "s/'//g"`353 227 compiled=`$factpath/fitsdump -h $file 2>/dev/null | grep 'COMPILED' | grep -E -o "['][a-zA-Z]+[ ][ 12][0-9][ ]20[0-9][0-9][ ][0-2][0-9]:[0-5][0-9]:[0-5][0-9][']" | sed -e "s/'//g"` 354 228 if ! [ "$compiled" == "" ] … … 358 232 compiletime= 359 233 fi 360 #revnum=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep 'REVISION' | grep -E -o "['][0-9]+[:]?[0-9]*[MSP]*[']" | sed -e "s/'//g"`361 234 revnum=`$factpath/fitsdump -h $file 2>/dev/null | grep 'REVISION' | grep -E -o "['][0-9]+[:]?[0-9]*[MSP]*[']" | sed -e "s/'//g"` 362 235 # in newest data start time is in DATE-OBS 363 236 # in older data start time is in TSTART 364 237 # in the beginning TSTART was empty 365 #runstart=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep DATE-OBS | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`366 238 runstart=`$factpath/fitsdump -h $file 2>/dev/null | grep DATE-OBS | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'` 367 #runstart2=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep TSTART | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`368 239 runstart2=`$factpath/fitsdump -h $file 2>/dev/null | grep TSTART | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'` 369 240 if [ "$runstart" == "" ] … … 371 242 if [ "$runstart2" == "" ] 372 243 then 373 #runstart=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep DATE | grep -v 'DATE-' | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'` 374 runstart=`$factpath/fitsdump -h $file 2>/dev/null | grep DATE | grep -v 'DATE-' | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'` 244 # for very old data, but gives problems for newer data 245 #runstart=`$factpath/fitsdump -h $file 2>/dev/null | grep DATE | grep -v 'DATE-' | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'` 246 runstart="0000-00-00 00:00:00" 375 247 else 376 248 runstart=$runstart2 … … 380 252 # in older data start time is in TSTOP 381 253 # in the beginning TSTOP was empty 382 #runstop=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep DATE-END | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`383 254 runstop=`$factpath/fitsdump -h $file 2>/dev/null | grep DATE-END | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'` 384 #runstop2=`$factpath/fitsdump -h -t Events $file 2>/dev/null | grep TSTOP | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`385 255 runstop2=`$factpath/fitsdump -h $file 2>/dev/null | grep TSTOP | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'` 386 256 if [ "$runstop" == "" ] … … 388 258 if [ "$runstop2" == "" ] 389 259 then 390 runstop=`stat $file 2>/dev/null | grep Modify | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9][ ][0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{9}'` 260 # for very old data, but gives problems for newer data 261 #runstop=`stat $file 2>/dev/null | grep Modify | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9][ ][0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{9}'` 262 runstop="0000-00-00 00:00:00" 391 263 else 392 264 runstop=$runstop2 … … 427 299 query="SELECT fRunTypeKEY FROM RunType WHERE fRunTypeName='"$runtype"'" 428 300 printprocesslog "DEBUG get run type from DB. QUERY:"$query 429 #result2=( `/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query2"` )430 301 result2=( `sendquery` ) 431 302 if [ ${#result2} -eq 0 ] … … 434 305 continue 435 306 fi 436 437 # # check if entry has already checksums438 # query="SELECT fNight FROM RunInfo WHERE Concat(fNight, '_', LPAD(fRunID, 3, 0))='"$numberfromname"'"439 # query=$query" AND NOT ISNULL(fMd5sumRaw) AND NOT ISNULL(fMd5sumRawZip)"440 # printprocesslog "DEBUG check if md5sums are alreay in DB. QUERY:"$query441 # #result5=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query5"`442 # result5=`sendquery`443 #444 # # get md5sums of raw and zip file445 # # to safe time for tests and update this can be skipped ($skipmd5sum)446 # md5sum=447 # md5sumzip=448 # if [ "$skipmd5sum" == "no" ] || [ "$skipmd5sum" == "iffilled" ]449 # then450 # #echo "skip: "$skipmd5sum >> $logfile 2>&1451 # #echo "res5: -"$result5"-" >> $logfile 2>&1452 # #if [ "$skipmd5sum" == "no" ] || [ "$result5$skipmd5sum" == "iffilled" ]453 # if [ "$skipmd5sum" == "no" ] || [ "$result5" == "" ]454 # then455 # #zipfile=`echo $file | sed -e 's/raw/zipraw/' -e 's/fits/fits.gz/'`456 # # only do the md5sum if the zipfile is already available457 # if ls $file >/dev/null 2>&1458 # then459 # printprocesslog "INFO calculation md5sum for rawfile "$rawfile460 # md5sum=`md5sum $rawfile | cut -d' ' -f1`461 # printprocesslog "INFO calculation md5sum for zipfile "$file462 # md5sumzip=`md5sum $file | cut -d' ' -f1`463 # fi464 # fi465 # fi466 307 467 308 # insert or update depending on whether run exists … … 477 318 fi 478 319 query=$query" RunInfo SET "$querymid" fRunTypeKey="${result2[0]} 479 #if [ $numfitserrors -eq 0 ] 480 if [ "$filecorrupt" == "no" ] 320 if [ "$filenotclosed" == "no" ] 481 321 then 482 322 query=$query", fRunStart='"$runstart"', fRunStop='"$runstop"'" … … 534 374 query=$query", fDataSum='"$datasum"'" 535 375 fi 536 # if [ "$md5sum" != "" ]537 # then538 # query=$query", fMd5sumRaw='"$md5sum"', fMd5sumRawZip='"$md5sumzip"'"539 # fi540 376 if [ "$numdrsfiles" != "" ] 541 377 then … … 554 390 query=$query", fRevisionNumber='"$revnum"'" 555 391 fi 556 query=$query", fFitsFileErrors="$numfitserrors392 #query=$query", fFitsFileErrors="$numfitserrors 557 393 query=$query" "$querystop 558 394 # send query to DB -
trunk/DataCheck/Processing/FillAuxData.sh
r17907 r18083 1 1 #!/bin/bash 2 2 3 # missing: 4 # vferify of files 5 # only treat file if it is there 3 # new version of the script to run on newdaq 4 5 # option whether to fill all row or only those where information is missing 6 # $doupdate might be given as environment variable 7 if [ "$doupdate" = "" ] 8 then 9 doupdate="yes" # update all entries (needed when new fields have been added) 10 doupdate="no" # fill only entries which are not yet existing (default) 11 fi 12 13 source `dirname $0`/../Sourcefile.sh 14 printprocesslog "INFO starting $0 with option doupdate="$doupdate 15 16 logfile=$runlogpath"/FillAuxData-"$datetime".log" 17 date >> $logfile 18 19 # check if software is available 20 if ! ls $factpath/fitsdump >/dev/null 2>&1 21 then 22 printprocesslog "ERROR "$factpath"/fitsdump is not available." 23 finish 24 fi 25 26 # get dates 27 if [ "$certaindate" != "" ] 28 then 29 checkstring=`echo $certaindate | grep -E -o '^20[0-9][0-9]\/[01][0-9]\/[0-3][0-9]$'` 30 if [ "$checkstring" = "" ] 31 then 32 echo "Please give the variable certaindate in the correct format (YYYY/MM/DD)" 33 finish 34 fi 35 getdates $certaindate 36 else 37 # get all night 38 #getdates "all" 39 # get last 3 nights if hour between 7 and 19h, else only current night 40 getdates 3 7 19 41 fi 42 43 44 printprocesslog "INFO processing the following night(s): "${dates[@]} 45 echo `date`": processing the following night(s): "${dates[@]} >> $logfile 2>&1 6 46 7 47 # mjd of 1970-01-01 … … 20 60 # trigger rate has as first value -1, but with using the median it should be fine 21 61 22 # option whether to fill all row or only those where information is missing 23 # $doupdate might be given as environment variable 24 if [ "$doupdate" = "" ] 25 then 26 doupdate="yes" # update all entries (needed when new fields have been added) 27 doupdate="no" # fill only entries which are not yet existing (default) 28 fi 29 30 source `dirname $0`/../Sourcefile.sh 31 printprocesslog "INFO starting $0 with option doupdate="$doupdate 32 33 logfile=$runlogpath"/FillAuxData-"$datetime".log" 34 date >> $logfile 35 36 function getfitsstatistics() 62 63 function evaluatestatistics() 37 64 { 38 # $1 filename 39 # $2 colname 40 # $3 tstart 41 # $4 tstop 42 good= 65 # $1 variable name 66 # $@ statistics 67 if [ "$2" = "" ] 68 then 69 printprocesslog "WARN couldn't get statistics from file $1 for run "$date" "$file 70 continue 71 fi 43 72 min= 44 73 mean= 45 med ian=74 med= 46 75 max= 47 tmpfile=`dirname $0`/`basename $1`.tmp 48 echo "ftcopy $1'[col Time]' - | ftstat - | grep 'mean' | grep -E -o [0-9]+[.] | sed -e 's/[.]//g'" >> $logfile 49 timefromfile=`ftcopy $1'[col Time]' - 2>>$logfile | ftstat - 2>>$logfile | grep 'mean' | grep -E -o [0-9]+[.] | sed -e 's/[.]//g'` 50 echo "here-"$timefromfile"-" >> $logfile 51 if [ "$timefromfile" == "" ] 52 then 53 printprocesslog "WARN couldn't get time from file "$1 54 echo "WARN couldn't get time from file "$1 55 continue 56 fi 57 if [ $timefromfile -gt 30000 ] 58 then 59 echo "ftcopy $1'[Time - 40587> '${3}' && Time - 40587< '${4}' ][col '${2}';Time]' - | ftcopy -'[col '${2}']' - | ftstat -" >> $logfile 60 #ftcopy $1'[Time - 40587> '${3}' && Time - 40587< '${4}' ][col '${2}';Time]' - | ftcopy -'[col '${2}']' - | ftstat - 61 ftcopy $1'[Time - 40587> '${3}' && Time - 40587< '${4}' ][col '${2}';Time]' - 2>>$logfile | ftcopy -'[col '${2}']' - 2>>$logfile | ftstat - 2>>$logfile > $tmpfile 62 else 63 echo "ftcopy $1'[Time> '${3}' && Time< '${4}' ][col '${2}';Time]' - | ftcopy -'[col '${2}']' - | ftstat -" >> $logfile 64 #ftcopy $1'[Time> '${3}' && Time< '${4}' ][col '${2}';Time]' - | ftcopy -'[col '${2}']' - | ftstat - 65 ftcopy $1'[Time> '${3}' && Time< '${4}' ][col '${2}';Time]' - 2>>$logfile | ftcopy -'[col '${2}']' - 2>>$logfile | ftstat - 2>>$logfile > $tmpfile 66 fi 67 good=`cat $tmpfile | grep 'good' | grep -E -o '[-]?[0-9]+[.]?[0-9]*'` 68 min=`cat $tmpfile | grep 'min' | grep -E -o '[-]?[0-9]+[.]?[0-9]*'` 69 mean=`cat $tmpfile | grep 'mean' | grep -E -o '[-]?[0-9]+[.]?[0-9]*'` 70 median=`cat $tmpfile | grep 'median' | grep -E -o '[-]?[0-9]+[.]?[0-9]*'` 71 max=`cat $tmpfile | grep 'max' | grep -E -o '[-]?[0-9]+[.]?[0-9]*'` 72 sigma=`cat $tmpfile | grep 'sigma' | grep -E -o '[-]?[0-9]+[.]?[0-9]*'` 73 if [ "$good" = "" ] 74 then 75 printprocesslog "WARN couldn't get statistics from file $1 for run $date $file" 76 rm $tmpfile 77 continue 78 #finish 79 fi 80 #echo "good: "$good 81 #echo "min: "$min 82 #echo "max: "$max 83 #echo "mean: "$max 84 #echo "median: "$max 85 rm $tmpfile 76 rms= 77 evaluation=`echo $@ | grep -E -o '\['${1}':0[:]?[0-9]*\]\ Min:\ [-]?[0-9]+[.]?[0-9]*\ Max:\ [-]?[0-9]+[.]?[0-9]*\ Med:\ [-]?[0-9]+[.]?[0-9]*\ Avg:\ [-]?[0-9]+[.]?[0-9]*\ Rms:\ [-]?[0-9]+[.]?[0-9]*[e]?[-]?[0-9]*'` 78 if [ "$evaluation" = "" ] 79 then 80 printprocesslog "WARN empty evaluation of statistic ("$@") for run "$date" "$file 81 #echo " ---> "$@ 82 fi 83 #echo "ev: "$evaluation 84 min=`echo $evaluation | grep -E -o 'Min:\ [-]?[0-9]+[.]?[0-9]*' | sed -e 's/Min:\ //'` 85 max=`echo $evaluation | grep -E -o 'Max:\ [-]?[0-9]+[.]?[0-9]*' | sed -e 's/Max:\ //'` 86 med=`echo $evaluation | grep -E -o 'Med:\ [-]?[0-9]+[.]?[0-9]*' | sed -e 's/Med:\ //'` 87 mean=`echo $evaluation | grep -E -o 'Avg:\ [-]?[0-9]+[.]?[0-9]*' | sed -e 's/Avg:\ //'` 88 rms=`echo $evaluation | grep -E -o 'Rms:\ [-]?[0-9]+[.]?[0-9]*[e]?[-]?[0-9]+' | sed -e 's/Rms:\ //'` 89 #echo "eval: "$min" "$max" "$med" "$mean" "$rms 86 90 } 87 88 # setup to use ftools89 source $HEADAS/headas-init.sh90 91 # check if software is available92 if ! ls $factpath/fitsdump >/dev/null 2>&193 then94 printprocesslog "ERROR "$factpath"/fitsdump is not available."95 finish96 fi97 98 # get dates99 if [ "$certaindate" != "" ]100 then101 checkstring=`echo $certaindate | grep -E -o '^20[0-9][0-9]\/[01][0-9]\/[0-3][0-9]$'`102 if [ "$checkstring" = "" ]103 then104 echo "Please give the variable certaindate in the correct format (YYYY/MM/DD)"105 finish106 fi107 getdates $certaindate108 else109 # get all night110 #getdates "all"111 # get last 3 nights if hour between 7 and 19h, else only current night112 getdates 3 7 19113 fi114 115 printprocesslog "INFO processing the following night(s): "${dates[@]}116 echo `date`": processing the following night(s): "${dates[@]} >> $logfile 2>&1117 91 118 92 # do filling of aux data … … 120 94 do 121 95 auxdir=$auxdata/$date 96 rawdir=$rawdata/$date 122 97 runnumber=`echo $date | sed -e 's/\///g'` 123 124 # get file numbers from DB125 # but only for not-corrupted files126 query="SELECT fRunID from RunInfo WHERE fNight="$runnumber" AND fFitsFileErrors=0 "127 # only runs which are not yet filled128 if [ "$doupdate" = "no" ]129 then130 query=$query" AND ISNULL(fRightAscension) "131 fi132 printprocesslog "DEBUG get filenumbers from DB: QUERY: "$query133 filenumbers=( `sendquery $query` )134 # proceed only if there are files available135 if [ ${#filenumbers} -eq 0 ]136 then137 printprocesslog "INFO No files found in the DB for night "$date138 continue139 fi140 98 141 99 # check if aux files are available from that night … … 146 104 else 147 105 printprocesslog "INFO processing files in "$auxdir 106 #echo "INFO processing files in "$auxdir 107 fi 108 109 # check if raw files are available from that night 110 # only needed to get start/stop time 111 # might be removed once the start/stop time comes from the DB 112 if ! [ -d $rawdir ] 113 then 114 printprocesslog "INFO no data available in "$rawdir" -> continue" 115 continue 116 fi 117 118 # get file numbers from DB 119 # but only for not-corrupted files 120 # as aux files are written only once a minute, select only files which are older than 1.5 minutes 121 query="SELECT fRunID from RunInfo WHERE fNight="$runnumber" AND fFitsFileErrors=0 AND NOT ISNULL(fRunStop) AND fRunStop < SUBTIME(UTC_TIMESTAMP(), \"00:01:30\")" 122 # only runs which are not yet filled 123 if [ "$doupdate" = "no" ] 124 then 125 query=$query" AND ISNULL(fRightAscension) " 126 fi 127 printprocesslog "DEBUG get filenumbers from DB: QUERY: "$query 128 filenumbers=( `sendquery $query` ) 129 if [ ${#filenumbers} -eq 0 ] 130 then 131 printprocesslog "INFO No files found in the DB for night "$date 132 continue 148 133 fi 149 134 … … 153 138 then 154 139 printprocesslog "WARN "$trackingfile" not found." 155 else156 tracknumerrors=`fverify $trackingfile 2>/dev/null | grep -o '[0-9][ ]error(s)' | grep -E -o '[0-9]'`157 if [ $tracknumerrors -gt 0 ]158 then159 printprocesslog "WARN for $trackingfile fverify returned "$tracknumerrors" error(s)."160 fi161 140 fi 162 141 … … 166 145 printprocesslog "WARN "$sourceposfile" not found." 167 146 else 168 sourceposnumerrors=`fverify $sourceposfile 2>/dev/null | grep -o '[0-9][ ]error(s)' | grep -E -o '[0-9]'`169 if [ $sourceposnumerrors -gt 0 ]170 then171 printprocesslog "WARN for $sourceposfile fverify returned "$sourceposnumerrors" error(s)."172 fi173 147 sourceposfiletstarti=`$factpath/fitsdump -h $sourceposfile 2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'` 174 148 sourceposfiletstartf=`$factpath/fitsdump -h $sourceposfile 2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'` … … 179 153 sourceposfiletstart=`echo " $sourceposfiletstarti + $sourceposfiletstartf " | bc -l` 180 154 fi 181 #echo "tstart: "$sourceposfiletstart182 155 fi 183 156 … … 186 159 then 187 160 printprocesslog "WARN "$triggerratefile" not found." 188 else189 trignumerrors=`fverify $triggerratefile 2>/dev/null | grep -o '[0-9][ ]error(s)' | grep -E -o '[0-9]'`190 if [ $trignumerrors -gt 0 ]191 then192 printprocesslog "WARN for $triggerratefile fverify returned "$trignumerrors" error(s)."193 fi194 161 fi 195 162 … … 198 165 then 199 166 printprocesslog "WARN "$thresholdfile" not found." 200 else201 treshnumerrors=`fverify $thresholdfile 2>/dev/null | grep -o '[0-9][ ]error(s)' | grep -E -o '[0-9]'`202 if [ $treshnumerrors -gt 0 ]203 then204 printprocesslog "WARN for $thresholdfile fverify returned "$treshnumerrors" error(s)."205 fi206 167 fi 207 168 … … 210 171 then 211 172 printprocesslog "WARN "$biasvoltagefile" not found." 212 else213 biasnumerrors=`fverify $biasvoltagefile 2>/dev/null | grep -o '[0-9][ ]error(s)' | grep -E -o '[0-9]'`214 if [ $biasnumerrors -gt 0 ]215 then216 printprocesslog "WARN for $biasvoltagefile fverify returned "$biasnumerrors" error(s)."217 fi218 173 fi 219 174 … … 223 178 printprocesslog "INFO processing file number "$runnumber"_"`printf %03d $filenum` 224 179 echo `date`": processing file number "$runnumber"_"`printf %03d $filenum` >> $logfile 2>&1 180 #echo `date`": processing file number "$runnumber"_"`printf %03d $filenum` 181 225 182 # get information from rawfile 226 rawfile= $ziprawdata/$date/$runnumber"_"`printf %03d $filenum`.fits.fz183 rawfile=`ls $rawdir/$runnumber"_"\`printf %03d $filenum\`.fits*` 227 184 if ! [ -e $rawfile ] 228 185 then … … 230 187 continue 231 188 fi 232 #checkfitsfile=`fverify $rawfile 2>/dev/null | grep '0 error(s)'` 233 #if [ "$checkfitsfile" == "" ] 234 #then 235 # numfitserrors=1 236 # printprocesslog "WARN: "$rawfile" probably corrupted." 237 # continue 238 #fi 239 runtype=`$factpath/fitsdump -h $rawfile 2>/dev/null | grep RUNTYPE | grep -E -o "['][a-z-]+[']" | sed -e "s/'//g"` 240 mjdrefraw=`$factpath/fitsdump -h $rawfile 2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'` 189 190 #runtype=`$factpath/fitsdump -h $rawfile 2>/dev/null | grep RUNTYPE | grep -E -o "['][a-z-]+[']" | sed -e "s/'//g"` 191 #mjdrefraw=`$factpath/fitsdump -h $rawfile 2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'` 241 192 tstarti=`$factpath/fitsdump -h $rawfile 2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'` 242 193 tstartf=`$factpath/fitsdump -h $rawfile 2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'` … … 277 228 278 229 # get information from source_pos file 279 if [ -e $sourceposfile ] && [ $sourceposnumerrors -eq 0 ]230 if [ -e $sourceposfile ] 280 231 then 281 232 sourcename=`$factpath/fitsdump ${sourceposfile} -c Time -c Name --filter='[1]<'${tstop}' && [1]>'${sourceposfiletstart} 2>/dev/null | tail -1 2>&1 | grep -o -E "['][a-zA-Z0-9\ \.\+\-]+[']" | sed -e "s/'//g"` … … 295 246 # build query to update runinfo in DB 296 247 query="UPDATE RunInfo SET " 248 297 249 # fill source key only if available 298 250 if ! [ "$sourcekey" = "" ] … … 304 256 305 257 # get information from tracking 306 if [ -e $trackingfile ] && [ $tracknumerrors -eq 0 ] 307 then 258 if [ -e $trackingfile ] 259 then 260 # get statistics 261 trackingstats=`$factpath/fitsdump $trackingfile -s -c Time -c Ra -c Dec -c Zd -c Az --filter='[1]<'${tstop}' && [1]>'${tstart} 2>/dev/null` 308 262 # RA 309 getfitsstatistics $trackingfile "Ra" $tstart $tstop 310 if [ "$min" == "$max" ] && [ $good -gt 0 ] 311 then 312 query=$query" fRightAscension="$mean 313 else 314 query=$query" fRightAscension=NULL" 315 if [ $good -gt 0 ] 316 then 263 evaluatestatistics "Ra" $trackingstats 264 #echo $min"_"$max"_"$ 265 if [ "$evaluation" != "" ] 266 then 267 if [ "$min" == "$max" ] 268 then 269 query=$query" fRightAscension="$mean 270 else 271 query=$query" fRightAscension=NULL" 317 272 printprocesslog "WARN for $rawfile RA changes within run (min: "$min", max: "$max")." 318 273 fi 319 fi 320 # Declination 321 getfitsstatistics $trackingfile "Dec" $tstart $tstop 322 if [ "$decmin" == "$decmax" ] && [ $good -gt 0 ] 323 then 324 query=$query", fDeclination="$mean 325 else 326 query=$query", fDeclination=NULL" 327 if [ $good -gt 0 ] 328 then 274 # Declination 275 evaluatestatistics "Dec" $trackingstats 276 if [ "$decmin" == "$decmax" ] 277 then 278 query=$query", fDeclination="$mean 279 else 280 query=$query", fDeclination=NULL" 329 281 printprocesslog "WARN for $rawfile declination changes within run (min: "$min", max: "$max")." 330 282 fi 283 else 284 query=$query" fRightAscension=NULL" 285 query=$query", fDeclination=NULL" 331 286 fi 332 287 # Zd 333 getfitsstatistics $trackingfile "Zd" $tstart $tstop334 if [ $good -gt 0]288 evaluatestatistics "Zd" $trackingstats 289 if [ "$evaluation" != "" ] 335 290 then 336 291 query=$query", fZenithDistanceMin="$min … … 343 298 fi 344 299 # Az 345 getfitsstatistics $trackingfile "Az" $tstart $tstop346 if [ $good -gt 0]300 evaluatestatistics "Az" $trackingstats 301 if [ "$evaluation" != "" ] 347 302 then 348 303 query=$query", fAzimuthMin="$min … … 366 321 367 322 # get information from trigger 368 if [ -e $triggerratefile ] && [ $trignumerrors -eq 0 ] 369 then 370 #echo " $triggerratefile TriggerRate $tstart $tstop" 371 getfitsstatistics $triggerratefile "TriggerRate" $tstart $tstop 372 # if [ "$mjdreftrig" == "" ] 373 # then 374 # ratemin=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]*'` 375 # ratemax=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]*'` 376 # ratemean=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]*'` 377 # ratemedian=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'median' | grep -E -o '[0-9]+[.]?[0-9]*'` 378 # else 379 # ratemin=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'min' | grep -E -o '[0-9]+[.]?[0-9]*'` 380 # ratemax=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'max' | grep -E -o '[0-9]+[.]?[0-9]*'` 381 # ratemean=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'mean' | grep -E -o '[0-9]+[.]?[0-9]*'` 382 # ratemedian=`ftcopy $triggerratefile'[Time> '${tstart}' && Time< '${tstop}' && TriggerRate!=-1][col TriggerRate;Time]' - | ftcopy -'[col TriggerRate]' - | ftstat - | grep 'median' | grep -E -o '[0-9]+[.]?[0-9]*'` 383 # fi 384 if [ $good -gt 0 ] 385 then 386 query=$query", fTriggerRateMedian="$median 323 if [ -e $triggerratefile ] 324 then 325 # get statistics 326 triggerstats=`$factpath/fitsdump $triggerratefile -s -c Time -c TriggerRate --filter='[1]<'${tstop}' && [1]>'${tstart} 2>/dev/null` 327 evaluatestatistics "TriggerRate" $triggerstats 328 if [ "$evaluation" != "" ] 329 then 330 query=$query", fTriggerRateMedian="$med 387 331 else 388 332 query=$query", fTriggerRateMedian=NULL" … … 393 337 394 338 # get information from thresholds 395 if [ -e $thresholdfile ] && [ $treshnumerrors -eq 0 ] 396 then 397 getfitsstatistics $thresholdfile "PatchThresh" $tstart $tstop 398 if [ $good -eq 0 ] 399 then 400 getfitsstatistics $thresholdfile "PatchThresh" $tstart2 $tstop 401 fi 402 if [ $good -gt 0 ] 403 then 404 query=$query", fThresholdMedian="$median 339 if [ -e $thresholdfile ] 340 then 341 # get statistics 342 thresholdstats=`$factpath/fitsdump $thresholdfile -s -c Time -c PatchThresh --filter='[1]<'${tstop}' && [1]>'${tstart} 2>/dev/null` 343 evaluatestatistics "PatchThresh" $thresholdstats 344 if [ "$evaluation" = "" ] 345 then 346 thresholdstats=`$factpath/fitsdump $thresholdfile -s -c Time -c PatchThresh --filter='[1]<'${tstop}' && [1]>'${tstart2} 2>/dev/null` 347 #echo "$factpath/fitsdump $thresholdfile -s -c Time -c PatchThresh --filter='[1]<'${tstop}' && [1]>'${tstart2} 2>/dev/null" 348 evaluatestatistics "PatchThresh" $thresholdstats 349 fi 350 if [ "$evaluation" != "" ] 351 then 352 query=$query", fThresholdMedian="$med 405 353 else 406 354 query=$query", fThresholdMedian=NULL" … … 411 359 412 360 # get information from bias: U 413 if [ -e $biasvoltagefile ] && [ $biasnumerrors -eq 0 ]361 if [ -e $biasvoltagefile ] 414 362 then 415 363 if [ $runnumber -gt 20120324 ] 416 364 then 417 value="Uout" 418 else 419 value="U" 420 fi 421 getfitsstatistics $biasvoltagefile $value $tstart $tstop 422 if [ $good -eq 0 ] 423 then 424 getfitsstatistics $biasvoltagefile $value $tstart2 $tstop 425 fi 426 if [ $good -gt 0 ] 427 then 428 query=$query", fBiasVoltageMedian="$median 365 biasstats=`$factpath/fitsdump $biasvoltagefile -s -c Time -c Uout --filter='[1]<'${tstop}' && [1]>'${tstart} 2>/dev/null` 366 evaluatestatistics "Uout" $biasstats 367 if [ "$evaluation" = "" ] 368 then 369 biasstats=`$factpath/fitsdump $biasvoltagefile -s -c Time -c Uout --filter='[1]<'${tstop}' && [1]>'${tstart2} 2>/dev/null` 370 evaluatestatistics "Uout" $biasstats 371 fi 372 else 373 biasstats=`$factpath/fitsdump $biasvoltagefile -s -c Time -c U --filter='[1]<'${tstop}' && [1]>'${tstart} 2>/dev/null` 374 evaluatestatistics "U" $biasstats 375 if [ "$evaluation" = "" ] 376 then 377 biasstats=`$factpath/fitsdump $biasvoltagefile -s -c Time -c U --filter='[1]<'${tstop}' && [1]>'${tstart2} 2>/dev/null` 378 evaluatestatistics "U" $biasstats 379 fi 380 fi 381 if [ "$evaluation" != "" ] 382 then 383 query=$query", fBiasVoltageMedian="$med 429 384 else 430 385 query=$query", fBiasVoltageMedian=NULL"
Note:
See TracChangeset
for help on using the changeset viewer.