Changeset 18792


Ignore:
Timestamp:
03/25/17 06:21:01 (8 years ago)
Author:
Daniela Dorner
Message:
added average fluxes, added nightly binning for amon
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataCheck/QuickLook/FlareAlerts.sh

    r18791 r18792  
    7272# missing: time-dependent CU
    7373
     74
     75# missing: excerr is NOT rate
    7476function get_query_nightly_binning()
    7577{
     
    506508}
    507509
     510get_average_flux()
     511{
     512   # query average flux from DB
     513   query="SELECT ROUND(SUM(fNumExcEvts)/SUM("$ontime")*3600,1) as excrate,  "
     514   query=$query"ROUND(ExcErr(SUM(fNumSigEvts), SUM(fNumBgEvts))/SUM("$ontime")*3600, 1) AS excerr, "
     515   query=$query"ROUND(SUM("$ontime")/3600.,1) AS ontime "
     516   query=$query"FROM AnalysisResultsRunLP "
     517   query=$query"LEFT JOIN RunInfo USING (fNight, fRunID) "
     518   if [ "$1" = "" ]
     519   then
     520      query=$query"WHERE fSourceKey="$sourcekey" AND NOT ISNULL(fNumExcEvts) "
     521   else
     522      query=$query"WHERE fSourceKey="$sourcekey" AND fNight BETWEEN "$1" AND "$2" AND NOT ISNULL(fNumExcEvts) "
     523   fi
     524   query=$query"GROUP BY fSourceKey "
     525   sendquery
     526   # missing - get in CU to correct for fluctuations of CU
     527}
     528
     529
    508530
    509531# main part of the script
     
    519541   sourcename=`sendquery` #do not combine this with other source info as sourcename can have spaces
    520542   
     543   # todo: what about data check ?
     544   # should avg include current night?
     545   total=( `get_average_flux` )
     546   month=( `get_average_flux \`date -d $night' - 1 MONTH' +%Y%m%d\` $night` )
     547   year=( `get_average_flux \`date -d $night' - 1 YEAR' +%Y%m%d\` $night` )
     548   avgflux=${total[0]}
     549   avgfluxmonth=${month[0]}
     550   avgfluxyear=${year[0]}
     551   error=${total[1]}
     552   errormonth=${month[1]}
     553   erroryear=${year[1]}
     554   
    521555   # getting some information on the source
    522556   query="SELECT fDeclination, fRightAscension, fRightAscension/24.*15 FROM Source WHERE fSourceKey="$sourcekey
     
    530564   printprocesslog "INFO Evaluation for $sourcename ... "
    531565   echo "Evaluation for $sourcename ... " >> $logfile
     566   echo " average fluxes: "$avgfluxmonth"+-"$errormonth" "$avgfluxyear"+-"$erroryear" "$avgflux"+-"$error
    532567   
    533568   # missing: get limits from DB (structure needs to be defined)
     
    573608      printprocesslog "INFO checking for [Trigger to MAGIC 501 proposal]" >> $logfile
    574609      echo "[Trigger to MAGIC 501 proposal]" >> $logfile
    575       echo " nightly binning..." >> $logfile
    576610      # checking nightly binning
    577611      bin=
     612      echo " nightly binning..." >> $logfile
    578613      get_query_nightly_binning
    579614      results=( `sendquery` )
     
    589624   # sources: Mrk 421, Mrk 501, 2344, 1959
    590625   triggertype=3
    591    #if [ $sourcekey -eq 1 ] || [ $sourcekey -eq 2 ] || [ $sourcekey -eq 3 ] || [ $sourcekey -eq 7 ]
    592    if [ $sourcekey -eq 1 ] || [ $sourcekey -eq 2 ] || [ $sourcekey -eq 3 ] || [ $sourcekey -eq 7 ] || [ $sourcekey -eq 5 ]
     626   #if [ $sourcekey -eq 1 ] || [ $sourcekey -eq 2 ] || [ $sourcekey -eq 3 ] || [ $sourcekey -eq 7 ] || [ $sourcekey -eq 5 ] # for testing
     627   if [ $sourcekey -eq 1 ] || [ $sourcekey -eq 2 ] || [ $sourcekey -eq 3 ] || [ $sourcekey -eq 7 ]
    593628   then
    594629      printprocesslog "INFO checking for [Trigger to MAGIC - fast rise/decay]" >> $logfile
     
    608643   fi
    609644   
    610    # Triggers to AMON
     645   # AMON - automatic triggers using VOEvent files
    611646   triggertype=4
    612647   printprocesslog "INFO checking for [Trigger to AMON]" >> $logfile
    613648   echo "[Trigger to AMON]" >> $logfile
    614    echo " still to be defined" >> $logfile
     649   echo " details still to be defined" >> $logfile
    615650   # missing: trigger limits and binning still to be defined
    616    # also nightly?
    617    # sub-threshold-triggers?
    618    # FP-rate?
    619    siglimit=2.0
     651   #   x times above average + significance limit ?
     652   #   sub-threshold?
     653   # FP-rate to be calculated
     654   # use for the moment 0.5 CU and 3 sigma
     655   siglimit=3.0
    620656   exclimit=0.5
    621657   onlyifhigher="no"
    622658   bin=20
    623    #echo "AMON"
     659   # checking nightly binning
     660   bin=
     661   echo " nightly binning..." >> $logfile
     662   get_query_nightly_binning
     663   results=( `sendquery` )
     664   evaluate_result
    624665   echo " "$bin" min binning..." >> $logfile
    625666   get_query_minute_binning
Note: See TracChangeset for help on using the changeset viewer.