Changeset 19057 for trunk/DataCheck/Tools/get_data.sh
- Timestamp:
- 07/18/18 00:02:10 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataCheck/Tools/get_data.sh
r19044 r19057 35 35 # ToDo (notes DD): 36 36 # ---------------- 37 # - fix bug for timeunit=timestamp (min-binning) 38 # - add information on souce, binning, etc to data-file 37 # - finalize policy and references 39 38 # must-have 40 39 # - update function for zd/th-correction … … 47 46 # - functionality to determine start time for seaon-binning 48 47 # - offer several predefined datachecks? 48 # - file as attachment to email ofr download.php 49 49 50 50 # … … 93 93 echo "# href='http://iopscience.iop.org/1748-0221/9/10/P10012" 94 94 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" 96 96 echo "# If you intend to use data or information from this website, please let us know for reference." 97 97 else … … 101 101 echo "#" 102 102 } 103 104 103 104 print_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 } 105 151 106 152 function get_results() … … 183 229 time=" Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM'))+"$delta" AS time" 184 230 delta2="(Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')))/2" 185 start stop2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')) AS start"186 st artstop2=$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" 187 233 deltat2=$delta2" AS deltat" 188 234 time2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM'))+"$delta2" AS time" … … 196 242 start2=" MIN(o.start) AS start" 197 243 stop2=" MAX(o.stop) AS stop" 198 deltat2=$delta " AS deltat"244 deltat2=$delta2" AS deltat" 199 245 time2=" addtime(MIN(o.start), "$delta2") AS time" 200 246 ;; … … 231 277 fi 232 278 # light condition cut 233 if [ "$light" == "no 279 if [ "$light" == "nomoon" ] 234 280 then 235 where=$where" ANDfZenithDistanceMoon>90"281 lightcut=" fZenithDistanceMoon>90" 236 282 fi 237 283 if [ "$light" == "dark" ] 238 284 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 240 290 fi 241 291 querybase=$from$where … … 255 305 if [ $bin -le 0 ] 256 306 then 257 num="#bin"258 307 # first part of the query 259 308 querystart="SELECT " 309 querystart=$querystart" "$time", "$start", "$stop", " 310 # final part of the query 260 311 if [ $bin -eq 0 ] 261 312 then 262 querystart=$querystart" fPeriod AS num, " 313 orderby=" fPeriod " 314 #querystart=$querystart" fPeriod AS num, " 315 queryend=" GROUP BY fPeriod " 263 316 else 264 querystart=$querystart" FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".) AS num,"265 fi266 querystart=$querystart" "$time", "$start", "$stop", "267 268 # final part of the query269 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 " 270 323 if [ "$ontimelimit" = "" ] 271 324 then 272 queryend=$queryend" HAVING SUM("$ontimeif")>1200 ORDER BY num " # 20 min325 queryend=$queryend" HAVING SUM("$ontimeif")>1200 ORDER BY "$orderby 273 326 else 274 queryend=$queryend" HAVING SUM("$ontimeif")>"$ontimelimit" ORDER BY num "327 queryend=$queryend" HAVING SUM("$ontimeif")>"$ontimelimit" ORDER BY "$orderby 275 328 fi 276 329 … … 301 354 302 355 else 303 num=304 356 # first part of the query 305 357 querystart="SELECT " … … 354 406 print_policy >> $fileext 355 407 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] " 357 410 echo $headerext >> $fileext 358 411 #echo "$queryext" … … 374 427 echo "# This file was created at "`date` > $fileint 375 428 print_policy >> $fileint 429 print_selection >> $fileint 376 430 echo "# The following query was used: " >> $fileint 377 431 echo "# "$queryint >> $fileint 378 432 echo "#" >> $fileint 379 433 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]" 381 435 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 " 382 436 headerint=$headerint" zdmin zdmax thmin thmax avg(cufactor) avg(R750cor) avg(R750ref) " … … 396 450 echo "# This file was created at "`date` > $filecol 397 451 print_policy >> $filecol 452 print_selection >> $filecol 398 453 echo "# The following query was used: " >> $filecol 399 454 echo "# "$querycol >> $filecol 400 455 echo "#" >> $filecol 401 456 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]" 403 458 headercol=$headercol" excrate_err[evts/h] corr.excrate_err[evts/h] flux_err[CU] flux_err[e-11/cm2/s] significance " 404 459 echo $headercol >> $filecol … … 417 472 # setup 418 473 datapath="/home/factwww/dch/data" 474 #datapath="./data" 419 475 sqlpw=/home/fact/.mysql.pw 476 #sqlpw=/home/fact/.mysql.pw2 420 477 host=10.0.100.21 421 478 dbname=factdata … … 532 589 # apply additional predefined cuts 533 590 # light conditions 534 #light="no 591 #light="nomoon" # only data with no moon (but twilight allowed) 535 592 #light="dark" # only dark night data 536 593 # TNG dust - cut away data with calima
Note:
See TracChangeset
for help on using the changeset viewer.