Changeset 19057 for trunk


Ignore:
Timestamp:
07/18/18 00:02:10 (6 years ago)
Author:
Daniela Dorner
Message:
fixed some small bugs, added information to header
File:
1 edited

Legend:

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

    r19044 r19057  
    3535# ToDo (notes DD):
    3636# ----------------
    37 # - fix bug for timeunit=timestamp (min-binning)
    38 # - add information on souce, binning, etc to data-file
     37# - finalize policy and references
    3938# must-have
    4039# - update function for zd/th-correction
     
    4746# - functionality to determine start time for seaon-binning
    4847# - offer several predefined datachecks?
     48# - file as attachment to email ofr download.php
    4949
    5050#
     
    9393      echo "#                           href='http://iopscience.iop.org/1748-0221/9/10/P10012"
    9494      echo "#   FACT quick look analysis: https://fact-project.org/monitoring"
    95      echo "#                             http://adsabs.harvard.edu/abs/2015arXiv150202582D"
     95      echo "#                             http://adsabs.harvard.edu/abs/2015arXiv150202582D"
    9696      echo "# If you intend to use data or information from this website, please let us know for reference."
    9797   else
     
    101101   echo "#"
    102102}
    103    
    104 
     103
     104print_selection()
     105{
     106   echo "#"
     107   echo "# Your Selection: "
     108   sourcename=`mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -s -e "SELECT fSourceName FROM Source WHERE fSourceKey="$source`
     109   echo "#   Source: "$sourcename
     110   echo "#   Time range: "$nightmin"-"$nightmax
     111   echo "#   Time format: "$timeunit
     112   if [ $bin -lt 0 ]
     113   then
     114      unit="night(s)"
     115   else
     116      if [ $bin -eq ]
     117      then
     118         unit="periods"
     119      else
     120         unit="minutes"
     121      fi
     122   fi
     123   binning=`echo $bin | sed -e 's/-//'`" "$unit
     124   echo "#   Binning: "$binning
     125   if [ "$expert" = "yes" ]
     126   then
     127      echo "# Additional Internal Selection: "
     128      if [ "$zdmax" != "" ]
     129      then
     130         echo "#   Maximum Zenith Distance: "$zdmax" degree"
     131      fi
     132      if [ "$thmax" != "" ]
     133      then
     134         echo "#   Maximum Trigger Threshold: "$thmax" DAC counts"
     135      fi
     136      if [ "$light" != "" ]
     137      then
     138         echo "#   Light Condition Cut: "$lightcut
     139      fi
     140      if [ "$dust" != "" ]
     141      then
     142         echo "#   Calima Cut: dust < "$dust" ug/cm3"
     143      fi
     144      if [ "$usedch" == "yes" ]
     145      then
     146         echo "#   You are using the a data quality selection based on the cosmic ray rate."
     147      fi
     148   fi
     149   echo "#"
     150}
    105151
    106152function get_results()
     
    183229            time=" Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM'))+"$delta" AS time"
    184230            delta2="(Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')))/2"
    185             startstop2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')) AS start"
    186             startstop2=$starstop2" Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) AS stop"
     231            start2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')) AS start"
     232            stop2=" Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) AS stop"
    187233            deltat2=$delta2" AS deltat"
    188234            time2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM'))+"$delta2" AS time"
     
    196242            start2=" MIN(o.start) AS start"
    197243            stop2=" MAX(o.stop) AS stop"
    198             deltat2=$delta" AS deltat"
     244            deltat2=$delta2" AS deltat"
    199245            time2=" addtime(MIN(o.start), "$delta2") AS time"
    200246            ;;
     
    231277   fi
    232278   # light condition cut
    233    if [ "$light" == "no moon" ]
     279   if [ "$light" == "nomoon" ]
    234280   then
    235       where=$where" AND fZenithDistanceMoon>90"
     281      lightcut=" fZenithDistanceMoon>90"
    236282   fi
    237283   if [ "$light" == "dark" ]
    238284   then
    239       where=$where" AND fMoonZenithDistance>90 AND fSunZenithDistance>108 "
     285      lightcut=" fMoonZenithDistance>90 AND fSunZenithDistance>108 "
     286   fi
     287   if [ "$light" != "" ]
     288   then
     289      where=$where" AND "$lightcut
    240290   fi
    241291   querybase=$from$where
     
    255305   if [ $bin -le 0 ]
    256306   then
    257       num="#bin"
    258307      # first part of the query
    259308      querystart="SELECT "
     309      querystart=$querystart" "$time", "$start", "$stop", "
     310      # final part of the query
    260311      if [ $bin -eq 0 ]
    261312      then
    262          querystart=$querystart" fPeriod AS num, "
     313         orderby=" fPeriod "
     314         #querystart=$querystart" fPeriod AS num, "
     315         queryend=" GROUP BY fPeriod "
    263316      else
    264          querystart=$querystart" FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".) AS num, "
    265       fi
    266       querystart=$querystart" "$time", "$start", "$stop", "
    267      
    268       # final part of the query
    269       queryend=" GROUP BY num "
     317         num=" FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".) "
     318         orderby=$num
     319         #querystart=$querystart" FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".) AS num, "
     320         queryend=" GROUP BY "$num
     321      fi
     322      #queryend=" GROUP BY num "
    270323      if [ "$ontimelimit" = "" ]
    271324      then
    272          queryend=$queryend" HAVING SUM("$ontimeif")>1200 ORDER BY num " # 20 min
     325         queryend=$queryend" HAVING SUM("$ontimeif")>1200 ORDER BY "$orderby
    273326      else
    274          queryend=$queryend" HAVING SUM("$ontimeif")>"$ontimelimit" ORDER BY num "
     327         queryend=$queryend" HAVING SUM("$ontimeif")>"$ontimelimit" ORDER BY "$orderby
    275328      fi
    276329     
     
    301354     
    302355   else
    303       num=
    304356      # first part of the query
    305357      querystart="SELECT "
     
    354406         print_policy >> $fileext
    355407      fi
    356       headerext="# "$num" time["$timeunit"] start["$timeunit"] stop["$timeunit"] excrate[evts/h] delta_time["$timeunit"] excrate_err[evts/h] "
     408      print_selection >> $fileext
     409      headerext="# time["$timeunit"] start["$timeunit"] stop["$timeunit"] excrate[evts/h] (stop-start)/2["$timeunit"] excrate_err[evts/h] "
    357410      echo $headerext >> $fileext
    358411      #echo "$queryext"
     
    374427      echo "# This file was created at "`date` > $fileint
    375428      print_policy >> $fileint
     429      print_selection >> $fileint
    376430      echo "# The following query was used: " >> $fileint
    377431      echo "# "$queryint >> $fileint
    378432      echo "#" >> $fileint
    379433   fi
    380    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]"
     434   headerint="# time["$timeunit"] start["$timeunit"] stop["$timeunit"] excrate[evts/h] corr.excrate[evts/h] flux[CU] flux[e-11/cm2/s] (stop-start)/2["$timeunit"] ontime[min]"
    381435   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 "
    382436   headerint=$headerint" zdmin zdmax thmin thmax avg(cufactor) avg(R750cor) avg(R750ref) "
     
    396450      echo "# This file was created at "`date` > $filecol
    397451      print_policy >> $filecol
     452      print_selection >> $filecol
    398453      echo "# The following query was used: " >> $filecol
    399454      echo "# "$querycol >> $filecol
    400455      echo "#" >> $filecol
    401456   fi
    402    headercol="# "$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]"
     457   headercol="# time["$timeunit"] start["$timeunit"] stop["$timeunit"] excrate[evts/h] corr.excrate[evts/h] flux[CU] flux[e-11/cm2/s] (stop-start)/2["$timeunit"] ontime[min]"
    403458   headercol=$headercol" excrate_err[evts/h] corr.excrate_err[evts/h] flux_err[CU] flux_err[e-11/cm2/s] significance "
    404459   echo $headercol >> $filecol
     
    417472   # setup
    418473   datapath="/home/factwww/dch/data"
     474   #datapath="./data"
    419475   sqlpw=/home/fact/.mysql.pw
     476   #sqlpw=/home/fact/.mysql.pw2
    420477   host=10.0.100.21
    421478   dbname=factdata
     
    532589# apply additional predefined cuts
    533590# light conditions
    534 #light="no moon" # only data with no moon (but twilight allowed)
     591#light="nomoon" # only data with no moon (but twilight allowed)
    535592#light="dark" # only dark night data
    536593# TNG dust - cut away data with calima
Note: See TracChangeset for help on using the changeset viewer.