Changeset 19037
- Timestamp:
- 06/29/18 11:31:52 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataCheck/Tools/get_data.sh
r19036 r19037 35 35 # ToDo (notes DD): 36 36 # ---------------- 37 # - use get_data.sh for download*.php instead of Send_Data*.sh 38 # -> add policy 37 39 # - update function for correction 38 40 # - update CU for QLA … … 42 44 # - add E2dNdE? 43 45 # - functionality to determine start time for seaon-binning 44 # - can get_data.sh / Send_Data*.sh be combined?45 # get_data.sh should be able to run stand-alone and be kept simple for any user46 46 47 47 # … … 98 98 # conversion to CU (determined by DD for QLA) 99 99 # https://www.fact-project.org/logbook/showthread.php?tid=4927 100 cufactor=" Avg(CUQLA(fNight)) "100 cufactor="CUQLA(fNight)" # missing: ISDC analysis 101 101 # some calculations 102 102 excerr="ExcErr(Sum(fNumSigEvts), SUM(fNumBgEvts))" 103 CU="SUM("$correvts"/ CUQLA(fNight))/SUM("$ontimeif")*3600"104 CUerr=$excerr"/SUM("$ontimeif")*3600*SUM("$correvts"/ CUQLA(fNight))/SUM(fNumExcEvts)"103 CU="SUM("$correvts"/"$cufactor")/SUM("$ontimeif")*3600" 104 CUerr=$excerr"/SUM("$ontimeif")*3600*SUM("$correvts"/"$cufactor")/SUM(fNumExcEvts)" 105 105 excerr2="ExcErr(SUM(o.sigevts),SUM(o.bgevts))" 106 CU2="SUM(o.corevts/o.cu )/SUM(o.ot)*3600"107 CUerr2=$excerr2"/SUM(o.ot)*3600*SUM(o.corevts/o.cu )/(SUM(o.sigevts)-SUM(o.bgevts))"106 CU2="SUM(o.corevts/o.cufactor)/SUM(o.ot)*3600" 107 CUerr2=$excerr2"/SUM(o.ot)*3600*SUM(o.corevts/o.cufactor)/(SUM(o.sigevts)-SUM(o.bgevts))" 108 108 109 109 # columns to be selected … … 138 138 139 139 case $timeunit in 140 mjd) delta="(Mjd(MAX(fRunStop))-Mjd(M in(fRunStart)))/2"141 start=" Mjd(M in(fRunStart)) AS start"140 mjd) delta="(Mjd(MAX(fRunStop))-Mjd(MIN(fRunStart)))/2" 141 start=" Mjd(MIN(fRunStart)) AS start" 142 142 stop=" Mjd(MAX(fRunStop)) AS stop" 143 143 deltat=$delta" AS deltat" 144 time=" Mjd(M in(fRunStart))+"$delta" AS time"144 time=" Mjd(MIN(fRunStart))+"$delta" AS time" 145 145 delta2="(Mjd(MAX(o.stop))-Mjd(MIN(o.start)))/2" 146 146 start2=" Mjd(MIN(o.start)) AS start" … … 149 149 time2=" Mjd(MIN(o.start))+"$delta2" AS time" 150 150 ;; 151 unix) delta="(Unix_timestamp(CONVERT_TZ(M ax(fRunStop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(Min(fRunStart), '+00:00', 'SYSTEM')))/2"152 start="Unix_timestamp(CONVERT_TZ(M in(fRunStart), '+00:00', 'SYSTEM')) AS start"153 stop="Unix_timestamp(CONVERT_TZ(M ax(fRunStop), '+00:00', 'SYSTEM')) AS stop"151 unix) delta="(Unix_timestamp(CONVERT_TZ(MAX(fRunStop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM')))/2" 152 start="Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM')) AS start" 153 stop="Unix_timestamp(CONVERT_TZ(MAX(fRunStop), '+00:00', 'SYSTEM')) AS stop" 154 154 deltat=$delta" AS deltat" 155 time=" Unix_timestamp(CONVERT_TZ(M in(fRunStart), '+00:00', 'SYSTEM'))+"$delta" AS time"156 delta2="(Unix_timestamp(CONVERT_TZ(M ax(o.stop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(Min(o.start), '+00:00', 'SYSTEM')))/2"155 time=" Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM'))+"$delta" AS time" 156 delta2="(Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')))/2" 157 157 startstop2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')) AS start" 158 158 startstop2=$starstop2" Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) AS stop" 159 159 deltat2=$delta2" AS deltat" 160 time2=" Unix_timestamp(CONVERT_TZ(M in(o.start), '+00:00', 'SYSTEM'))+"$delta2" AS time"160 time2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM'))+"$delta2" AS time" 161 161 ;; 162 *) delta="sec_to_time(time_to_sec(timediff(MAX(fRunStop), M in(fRunStart)))/2)"162 *) delta="sec_to_time(time_to_sec(timediff(MAX(fRunStop), MIN(fRunStart)))/2)" 163 163 start=" MIN(fRunStart) AS start" 164 164 stop=" MAX(fRunStop) AS stop" 165 165 deltat=$delta" AS deltat" 166 time=" addtime(M in(fRunStart), "$delta") AS time"167 delta2="sec_to_time(time_to_sec(timediff(MAX(o.stop), M in(o.start)))/2)"166 time=" addtime(MIN(fRunStart), "$delta") AS time" 167 delta2="sec_to_time(time_to_sec(timediff(MAX(o.stop), MIN(o.start)))/2)" 168 168 start2=" MIN(o.start) AS start" 169 169 stop2=" MAX(o.stop) AS stop" 170 170 deltat2=$delta" AS deltat" 171 time2=" addtime(M in(o.start), "$delta2") AS time"171 time2=" addtime(MIN(o.start), "$delta2") AS time" 172 172 ;; 173 173 esac … … 222 222 queryint=$queryint" "$excrateerr", "$correxcrateerr", "$cuerr", "$fluxerr", " 223 223 queryint=$queryint" "$significance", " 224 queryint=$queryint" M in(fNight) AS nightmin, Max(fNight) AS nightmax, "224 queryint=$queryint" MIN(fNight) AS nightmin, MAX(fNight) AS nightmax, " 225 225 queryint=$queryint" "$numexc", "$numsig", "$numbg", " 226 queryint=$queryint" Min("$zenith"Min) AS zdmin, Max("$zenith"Max) AS zdmax, " 227 queryint=$queryint" Min("$thresh") AS thmin, Max("$thresh") AS thmax " 226 queryint=$queryint" MIN("$zenith"Min) AS zdmin, MAX("$zenith"Max) AS zdmax, " 227 queryint=$queryint" MIN("$thresh") AS thmin, MAX("$thresh") AS thmax, " 228 queryint=$queryint" ROUND(AVG("$cufactor"), 1) AS cufactor, ROUND(AVG(fR750Cor), 2) AS R750cor, ROUND(AVG(fR750Ref), 2) AS R750ref " 228 229 queryint=$queryint" "$querybase 229 230 … … 247 248 # final part of the query 248 249 querybase=" FROM (SELECT fNight, fZenithDistanceMin AS zdmin, fZenithDistanceMax AS zdmax, "$thresh" AS th, " 249 querybase=$querybase" @ot:="$ontimeif" AS ot, fRunStart AS start, fRunStop AS stop, fNumSigEvts AS sigevts, fNumBgEvts AS bgevts, " 250 querybase=$querybase" "$correvts" AS corevts, CUQLA(fNight) AS cu, " 250 querybase=$querybase" fR750Cor as R750cor, fR750Ref as R750ref, "$cufactor" AS cufactor, " 251 querybase=$querybase" @ot:="$ontimeif" AS ot, fRunStart AS start, fRunStop AS stop, " 252 querybase=$querybase" fNumSigEvts AS sigevts, fNumBgEvts AS bgevts, "$correvts" AS corevts, " 251 253 querybase=$querybase" IF (@night=fNight AND FLOOR((@os+@ot)/"$bin"./60.)<1, @bl, @bl := @bl + 1) AS block, " 252 254 querybase=$querybase" IF (@night=fNight AND FLOOR((@os+@ot)/"$bin"./60.)<1, @os:=@os + @ot, @os := @ot) AS os, @night :=fNight AS night " 253 # querybase=$querybase" IF (@zdmin<fZenithDistanceMin, @zdmin:=@zdmin, @zdmin:=fZenithDistanceMin) as zdmin, "254 # querybase=$querybase" IF (@zdmin>fZenithDistanceMax, @zdmax:=@zdmax, @zdmax:=fZenithDistanceMax) as zdmax, "255 # querybase=$querybase" IF (@thmin<"$thresh", @thmin:=@thmin, @thmin:="$thresh") as thmin, "256 # querybase=$querybase" IF (@thmax>"$thresh", @thmax:=@thmax, @thmax:="$thresh") as thmax, "257 # querybase=$querybase" fZenithDistanceMin as zdmin, fZenithDistanceMax as zdmax, "$thresh" as thmin, "$thresh" as thmax "258 255 querybase=$querybase$from" CROSS JOIN (SELECT @night :=0, @ot :=0, @os :=0, @bl:=0) PARAMS " 259 256 querybase=$querybase$where" ORDER BY fRunStart) o GROUP BY block HAVING ontime>0.75*"$bin" ORDER BY 'time'" … … 267 264 queryint=$queryint" avg(o.night) AS night, " 268 265 queryint=$queryint" "$numexc2", "$numsig2", "$numbg2", " 269 queryint=$queryint" Min(o.zdmin) AS zdmin, Max(o.zdmax) AS zdmax, Min(o.th) AS thmin, Max(o.th) AS thmax " 266 queryint=$queryint" MIN(o.zdmin) AS zdmin, MAX(o.zdmax) AS zdmax, MIN(o.th) AS thmin, MAX(o.th) AS thmax, " 267 queryint=$queryint" ROUND(AVG(o.cufactor), 1) AS cufactor, ROUND(AVG(o.R750cor), 2) AS R750cor, ROUND(AVG(o.R750ref), 2) AS R750ref " 270 268 queryint=$queryint" "$querybase 271 269 … … 292 290 fi 293 291 headerint="# "$num" time["$timeunit"] start["$timeunit"] stop["$timeunit"] excrate[evts/h] corr.excrate[evts/h] flux[CU] flux[e-11/cm2/s] delta_time["$timeunit"] ontime[min]" 294 headerint=$headerint" excrate_err[evts/h] corr.excrate_err[evts/h] flux_err[CU] flux_err[e-11/cm2/s] significance night num_exc num_sig num_bg zdmin zdmax thmin thmax" 292 headerint=$headerint" excrate_err[evts/h] corr.excrate_err[evts/h] flux_err[CU] flux_err[e-11/cm2/s] significance night num_exc num_sig num_bg " 293 headerint=$headerint" zdmin zdmax thmin thmax avg(cufactor) avg(R750cor) avg(R750ref) " 295 294 echo $headerint >> $fileint 296 295 #echo "$queryint"
Note:
See TracChangeset
for help on using the changeset viewer.