Changeset 19042 for trunk


Ignore:
Timestamp:
06/29/18 18:11:56 (6 years ago)
Author:
Daniela Dorner
Message:
added all options needed for download.php
File:
1 edited

Legend:

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

    r19039 r19042  
    3636# ----------------
    3737# must-have
    38 # - use get_data.sh for download*.php instead of Send_Data*.sh
    39 #   -> add policy
     38# - fix bug for timeunit=timestamp (min-binning)
     39# - add policy
     40# - add email sending and return values
    4041# - update function for zd/th-correction
    4142# - update CU for QLA
     
    191192   where=$where" AND fRunTypeKey=1 "
    192193   # zd cut
    193    where=$where" AND fZenithDistanceMax < "$zdmax
     194   if [ "$zdmax" != "" ]
     195   then
     196      where=$where" AND fZenithDistanceMax < "$zdmax
     197   fi
    194198   # th cut
    195    where=$where" AND fThresholdMedian < "$thmax
     199   if [ "$thmax" != "" ]
     200   then
     201      where=$where" AND "$thresh" < "$thmax
     202   fi
     203   # dust cut
     204   if [ "$dust" != "" ]
     205   then
     206      where=$where" AND fTNGDust<"$dust
     207   fi
     208   # light condition cut
     209   if [ "$light" == "no moon" ]
     210   then
     211      where=$where" AND fZenithDistanceMoon>90"
     212   fi
     213   if [ "$light" == "dark" ]
     214   then
     215      where=$where" AND fMoonZenithDistance>90 AND fSunZenithDistance>108 "
     216   fi
    196217   querybase=$from$where
    197218
     
    296317   fi
    297318   
    298    
    299    fileint=$datapath"/FACT_preliminary_"$name"_internal.dat"
    300    if [ "$overwrite" = "yes" ]
    301    then
    302       echo "creating "$fileint" ..."
    303       echo "# This file was created at "`date` > $fileint
    304       echo "# The following query was used: " >> $fileint
    305       echo "# "$queryint >> $fileint
    306       # add policy here
    307    fi
    308    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]"
    309    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 "
    310    headerint=$headerint" zdmin zdmax thmin thmax avg(cufactor) avg(R750cor) avg(R750ref) "
    311    echo $headerint >> $fileint
    312    #echo "$queryint"
    313    mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -s -e "$queryint" >> $fileint
    314    #mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -e "$queryint"
    315    
    316    filecol=$datapath"/FACT_preliminary_"$name"_collaborators.dat"
    317    if [ "$overwrite" = "yes" ]
    318    then
    319       echo "creating "$filecol" ..."
    320       echo "# This file was created at "`date` > $filecol
    321       echo "# The following query was used: " >> $filecol
    322       echo "# "$querycol >> $filecol
    323       # add policy here
    324    fi
    325    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]"
    326    headercol=$headercol" excrate_err[evts/h] corr.excrate_err[evts/h] flux_err[CU] flux_err[e-11/cm2/s] significance "
    327    echo $headercol >> $filecol
    328    #echo "$querycol"
    329    mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -s -e "$querycol" >> $filecol
    330    #mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -e "$querycol
    331    
    332319   # write file for externals only for allowed binnings
    333320   if [ $bin -eq 20 ] || [ $bin -eq -1 ]
     
    346333      #mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -e "$queryext"
    347334   fi
     335   if [ "$mode" == "auto" ] && [ "$expert" == "no" ]
     336   then
     337      return
     338   fi
     339   
     340   fileint=$datapath"/FACT_preliminary_"$name"_internal.dat"
     341   if [ "$overwrite" = "yes" ]
     342   then
     343      echo "creating "$fileint" ..."
     344      echo "# This file was created at "`date` > $fileint
     345      echo "# The following query was used: " >> $fileint
     346      echo "# "$queryint >> $fileint
     347      # add policy here
     348   fi
     349   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]"
     350   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 "
     351   headerint=$headerint" zdmin zdmax thmin thmax avg(cufactor) avg(R750cor) avg(R750ref) "
     352   echo $headerint >> $fileint
     353   #echo "$queryint"
     354   mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -s -e "$queryint" >> $fileint
     355   #mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -e "$queryint"
     356   if [ "$mode"="auto" ]
     357   then
     358      return
     359   fi
     360   
     361   filecol=$datapath"/FACT_preliminary_"$name"_collaborators.dat"
     362   if [ "$overwrite" = "yes" ]
     363   then
     364      echo "creating "$filecol" ..."
     365      echo "# This file was created at "`date` > $filecol
     366      echo "# The following query was used: " >> $filecol
     367      echo "# "$querycol >> $filecol
     368      # add policy here
     369   fi
     370   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]"
     371   headercol=$headercol" excrate_err[evts/h] corr.excrate_err[evts/h] flux_err[CU] flux_err[e-11/cm2/s] significance "
     372   echo $headercol >> $filecol
     373   #echo "$querycol"
     374   mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -s -e "$querycol" >> $filecol
     375   #mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -e "$querycol
     376   
    348377}
     378
     379# evaluation of command line options (for usage with download.php)
     380
     381if [ ${#@} -eq 13 ]
     382then
     383   #get_data.sh $start $stop $source $timebin $email $table $time $expert $dch $zd $th $light $dust
     384   mode="auto"
     385   # setup
     386   path=`dirname $0`
     387   datapath=$path"/data"
     388   sqlpw=/home/$USER/.mysql.pw2
     389   host=10.0.100.21
     390   dbname=factdata
     391   nightmin=$1
     392   nightmax=$2
     393   source=$3
     394   bin=$4
     395   email=$5
     396   table=$6
     397   timeunit=$7
     398   expert=$8
     399   usedch=$9 # novalue gives same result as no
     400   if [ "${10}" != "novalue" ] && [ "${10}" != "all" ]
     401   then
     402      zdmax=${10}
     403   fi
     404   if [ "${11}" != "novalue" ] && [ "${11}" != "all" ]
     405   then
     406      thmax=${11}
     407   fi
     408   if [ "${12}" != "novalue" ] && [ "${12}" != "all" ]
     409   then
     410      light=${12}
     411   fi
     412   if [ "${13}" != "novalue" ] && [ "${13}" != "all" ]
     413   then
     414      dust=${13}
     415   fi
     416   name=`echo $email | sed -e 's/@/-at-/'`
     417   get_results
     418   
     419   if [ "$expert" == "yes" ]
     420   then
     421      echo $fileint
     422   else
     423      echo $fileext
     424   fi
     425     
     426   # next: light, dust
     427   # implement all options
     428   # make dch swi
     429   
     430   exit
     431fi
     432
     433
    349434
    350435# -------------------------------------------------------------------------------------- #
     
    401486nightmin=20111115
    402487nightmax=20201231
    403 # defaults for zd and threshold
    404 zdmax=90 # all data
    405 thmax=1500 # all data
    406488# overwrite dataset file?
    407489# (useful to combine different binnings in one file -> set to "no")
     
    416498#   use a line like the following defining your own data quality selection cut
    417499#dch=" AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "
     500# apply additional predefined cuts
     501# light conditions
     502#light="no moon" # only data with no moon (but twilight allowed)
     503#light="dark" # only dark night data
     504# TNG dust - cut away data with calima
     505#dust=1
     506#dust=10
     507
    418508
    419509# -------------------------------------------------------------------------------------- #
Note: See TracChangeset for help on using the changeset viewer.