Changeset 19029


Ignore:
Timestamp:
06/26/18 23:50:49 (6 years ago)
Author:
Daniela Dorner
Message:
some cleanup
File:
1 edited

Legend:

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

    r19028 r19029  
    11#!/bin/bash
    22
    3 # add:
    4 # - fkt f dch value?
    5 # - function for correction factor
    6 # - x-day binning
    7 # < 20121212 data
    8 # zd, th for internal
    9 
    10 # todo: check cu-factor for <20121212)
    11 
    12 # comparison:
    13 #  function with select/table: 18.4 sec
    14 #  function with if: 5.7 sec
    15 # function with if:
    16 #  vorteil: schneller
    17 #  nachteil: keine history
    18 #  nachteil: es braucht 2 fkt (qla, isdc)
    19 
    20 # create function CU(night int, ana tinyint) returns double(4,1) deterministic begin declare cu double; set cu=0; select fCU into cu from CU where fValid=1 and fAnalysis=ana and fNight<night order by fNight desc limit 0,1; return cu; end $$
    21 
    22 # floor((mjd(timestamp)-mjd(startnight)+0.5)/numdays)
    23 # floor((mjd(timestamp)-mjd(startnight)-0.5)/numdays)
    24 
     3# todo
     4# - update function for correction
     5# - update CU for QLA
     6# - add CU for ISDC analysis
     7# - add zd, th for internal
     8# - add < 20121212 data for QLA
     9# - check crab flux
     10# - add E2dNdE?
    2511
    2612function get_results()
     
    5137   crabflux="3.37"
    5238   fluxprec=2
    53 #   crabflux="2.8e-11"
    54 #   crabflux="3.9e-11"
    55    # range of crab fluxes:
    56    # Dortmund: 2.8e-11
    57    # HESS: 3.37e-11
    58    # HAWC: 3.01e-11
    59    # Wue: 3.39e-11 - 3.9e-11 (ISDC analysis)
    60    # 15-20% difference
    6139   
    6240   case $timeunit in
     
    128106   flux2="$cu2*"$crabflux
    129107   fluxerr2="$cuerr2*"$crabflux
    130    
    131 # order information such that it is easily readable by tgraph
    132 # tgraph: X, Y
    133 # tgraph errors: X, Y, EX, EY
    134108
    135109# internal
     
    148122#
    149123#
    150 # exter nal
     124# external
    151125# --------
    152126# time, delta time, start, stop
     
    175149      queryint=$queryint" "$numsig" as numsig, "
    176150      queryint=$queryint" "$numbg" as numbg "
    177       #queryint=$queryint" now() as now "
    178151     
    179152      queryext="SELECT "
     
    189162      queryext=$queryext" round("$correxcrateerr", 1) as correxcrateerr, round($fluxerr, "$fluxprec") as fluxerr, "
    190163      queryext=$queryext" round("$significance", 1) as significance "
    191       #queryext=$queryext" now() as now "
    192164     
    193165      querybase=$from$where
    194       #if [ $bin -eq -1 ]
    195       #then
    196       #   querybase=$querybase" GROUP BY fNight "
    197       #fi
    198       #querybase=$querybase" GROUP BY FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".)"
    199166      querybase=$querybase" GROUP BY num "
    200       #echo "-----------------"$querybase
    201167      if [ "$ontimelimit" = "" ]
    202168      then
    203          querybase=$querybase" HAVING SUM("$ontimeif")>1200 AND NOT SUM(fNumBgEvts)=SUM(fNumSigEvts) ORDER BY num " # 20 min
     169         querybase=$querybase" HAVING SUM("$ontimeif")>1200 ORDER BY num " # 20 min
    204170      else
    205          querybase=$querybase" HAVING SUM("$ontimeif")>"$ontimelimit" AND NOT SUM(fNumBgEvts)=SUM(fNumSigEvts) ORDER BY num "
     171         querybase=$querybase" HAVING SUM("$ontimeif")>"$ontimelimit" ORDER BY num "
    206172      fi
    207173     
     
    221187      queryint=$queryint" "$numsig2" as numsig, "
    222188      queryint=$queryint" "$numbg2" as numbg "
    223       #queryint=$queryint" now() as now "
    224189     
    225190      queryext="SELECT "
     
    229194      queryext=$queryext" round("$correxcrateerr2", 1) as correxcrateerr, round("$fluxerr2", "$fluxprec") as fluxerr, "
    230195      queryext=$queryext" round("$significance2", 1) as significance "
    231       #queryext=$queryext" now() as now "
    232196     
    233197      querybase=" FROM (SELECT fNight, @ot:="$ontimeif" AS ot, fRunStart AS start, fRunStop AS stop, fNumSigEvts AS sigevts, fNumBgEvts AS bgevts, "
     
    236200      querybase=$querybase" IF (@night=fNight AND FLOOR((@os+@ot)/"$bin"./60.)<1, @os:=@os + @ot, @os := @ot) AS os, @night :=fNight AS night "
    237201      querybase=$querybase$from" CROSS JOIN (SELECT @night :=0, @ot :=0, @os :=0, @bl:=0) PARAMS "
    238       querybase=$querybase$where" ORDER BY fRunStart) o GROUP BY block HAVING NOT sum(o.bgevts)=sum(o.sigevts) AND ontime>0.75*"$bin
    239       # AND NOT SUM(fNumBgEvts)=SUM(fNumSigEvts)
     202      querybase=$querybase$where" ORDER BY fRunStart) o GROUP BY block HAVING ontime>0.75*"$bin
    240203     
    241204      queryint=$queryint" "$querybase" order by 'time'"
Note: See TracChangeset for help on using the changeset viewer.