Changeset 19037 for trunk/DataCheck


Ignore:
Timestamp:
06/29/18 11:31:52 (6 years ago)
Author:
Daniela Dorner
Message:
added R750 and CUfactor to internal output
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataCheck/Tools/get_data.sh

    r19036 r19037  
    3535# ToDo (notes DD):
    3636# ----------------
     37# - use get_data.sh for download*.php instead of Send_Data*.sh
     38#   -> add policy
    3739# - update function for correction
    3840# - update CU for QLA
     
    4244# - add E2dNdE?
    4345# - 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 user
    4646
    4747#
     
    9898   # conversion to CU (determined by DD for QLA)
    9999   # https://www.fact-project.org/logbook/showthread.php?tid=4927
    100    cufactor=" Avg(CUQLA(fNight)) "
     100   cufactor="CUQLA(fNight)" # missing: ISDC analysis
    101101   # some calculations
    102102   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)"
    105105   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))"
    108108   
    109109   # columns to be selected
     
    138138
    139139   case $timeunit in
    140       mjd)  delta="(Mjd(MAX(fRunStop))-Mjd(Min(fRunStart)))/2"
    141             start=" Mjd(Min(fRunStart)) AS start"
     140      mjd)  delta="(Mjd(MAX(fRunStop))-Mjd(MIN(fRunStart)))/2"
     141            start=" Mjd(MIN(fRunStart)) AS start"
    142142            stop=" Mjd(MAX(fRunStop)) AS stop"
    143143            deltat=$delta" AS deltat"
    144             time=" Mjd(Min(fRunStart))+"$delta" AS time"
     144            time=" Mjd(MIN(fRunStart))+"$delta" AS time"
    145145            delta2="(Mjd(MAX(o.stop))-Mjd(MIN(o.start)))/2"
    146146            start2=" Mjd(MIN(o.start)) AS start"
     
    149149            time2=" Mjd(MIN(o.start))+"$delta2" AS time"
    150150            ;;
    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"
     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"
    154154            deltat=$delta" AS deltat"
    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"
     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"
    157157            startstop2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')) AS start"
    158158            startstop2=$starstop2" Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) AS stop"
    159159            deltat2=$delta2" AS deltat"
    160             time2=" Unix_timestamp(CONVERT_TZ(Min(o.start), '+00:00', 'SYSTEM'))+"$delta2" AS time"
     160            time2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM'))+"$delta2" AS time"
    161161            ;;
    162       *)    delta="sec_to_time(time_to_sec(timediff(MAX(fRunStop), Min(fRunStart)))/2)"
     162      *)    delta="sec_to_time(time_to_sec(timediff(MAX(fRunStop), MIN(fRunStart)))/2)"
    163163            start=" MIN(fRunStart) AS start"
    164164            stop=" MAX(fRunStop) AS stop"
    165165            deltat=$delta" AS deltat"
    166             time=" addtime(Min(fRunStart), "$delta") AS time"
    167             delta2="sec_to_time(time_to_sec(timediff(MAX(o.stop), Min(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)"
    168168            start2=" MIN(o.start) AS start"
    169169            stop2=" MAX(o.stop) AS stop"
    170170            deltat2=$delta" AS deltat"
    171             time2=" addtime(Min(o.start), "$delta2") AS time"
     171            time2=" addtime(MIN(o.start), "$delta2") AS time"
    172172            ;;
    173173   esac
     
    222222      queryint=$queryint" "$excrateerr", "$correxcrateerr", "$cuerr", "$fluxerr", "
    223223      queryint=$queryint" "$significance", "
    224       queryint=$queryint" Min(fNight) AS nightmin, Max(fNight) AS nightmax, "
     224      queryint=$queryint" MIN(fNight) AS nightmin, MAX(fNight) AS nightmax, "
    225225      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 "
    228229      queryint=$queryint" "$querybase
    229230     
     
    247248      # final part of the query
    248249      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, "
    251253      querybase=$querybase" IF (@night=fNight AND FLOOR((@os+@ot)/"$bin"./60.)<1, @bl, @bl := @bl + 1) AS block, "
    252254      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 "
    258255      querybase=$querybase$from" CROSS JOIN (SELECT @night :=0, @ot :=0, @os :=0, @bl:=0) PARAMS "
    259256      querybase=$querybase$where" ORDER BY fRunStart) o GROUP BY block HAVING ontime>0.75*"$bin" ORDER BY 'time'"
     
    267264      queryint=$queryint" avg(o.night) AS night, "
    268265      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 "
    270268      queryint=$queryint" "$querybase
    271269     
     
    292290   fi
    293291   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) "
    295294   echo $headerint >> $fileint
    296295   #echo "$queryint"
Note: See TracChangeset for help on using the changeset viewer.