source: trunk/DataCheck/Tools/get_data.sh@ 19064

Last change on this file since 19064 was 19059, checked in by Daniela Dorner, 7 years ago
fixed small bug, updated header
  • Property svn:executable set to *
File size: 27.3 KB
Line 
1#!/bin/bash
2
3# ---------------------------------------------------------------- #
4# README README README README README README README README README #
5# ---------------------------------------------------------------- #
6# #
7# To use this script, you need #
8# - a computer with access to the FACT database in La Palma #
9# - a file with the password of a valid mysql-user #
10# - to define the setup below for #
11# a) the DB access #
12# b) the data you want to have #
13# #
14# To define the setup, search for SETUP in this script and #
15# read the details there #
16# #
17# Per data request, you get up to 3 files: #
18# *_internal.dat #
19# *_collaborators.dat #
20# *_external.dat (only if binning is 20min or nightly) #
21# #
22# Please have in mind that this started as a tool for myself, then #
23# others started using it. Also the script is not yet finalized. #
24# In case you find problems and/or have a feature request, please #
25# send and email to dorner@astro.uni-wuerzburg.de #
26# #
27# ---------------------------------------------------------------- #
28# README README README README README README README README README #
29# ---------------------------------------------------------------- #
30
31
32
33
34
35# ToDo (notes DD):
36# ----------------
37# - finalize policy and references
38# must-have
39# - update function for zd/th-correction
40# - update CU for QLA
41# - add CU for ISDC analysis
42# - add < 20121212 data for QLA
43# - check crab flux
44# nice-to-have
45# - add E2dNdE
46# - functionality to determine start time for seaon-binning
47# - offer several predefined datachecks?
48# - file as attachment to email ofr download.php
49
50#
51# content of files (wish list):
52# -----------------------------
53# REMARK: keep order of columns to allow for reading with TGraph directly from file: X Y EX EY
54#
55# internal
56# --------
57# time: time, delta time, start, stop, ontime
58# flux: excrate, excerr, corrate, corerr, CU CUerr, flux, fluxerr,
59# other info on flux: signif, cu-factor, num exc, num sig, num bg
60# other info: zd th R750cor R750ref
61#
62# external (allow only 20min and nightly binning)
63# --------
64# time: time, delta time, start, stop
65# flux: excrate, excerr
66#
67# collaborators
68# -------------
69# time: time, delta time, start, stop, ontime
70# flux: excrate, excerr, corrate, corerr, flux, flux-err, significance
71#
72# additional information to put:
73# ------------------------------
74# timestamp of creation
75# query (for debugging / answering questions)
76# policy (adapted for internal/collaborators/external) [define in files to be used also by Send_Data*.sh
77#
78
79
80function print_policy()
81{
82 echo "#"
83 echo "# Data Usage Policy: "
84 if [ "$expert" == "no" ]
85 then
86 echo "# Using data from the FACT Quick Look Analysis, you agree to cite the FACT design"
87 echo "# paper and the quick look analysis website. "
88 echo "#"
89 echo "# References: "
90 echo "# FACT design paper: http://adsabs.harvard.edu/abs/2013JInst...8P6008A"
91 echo "# http://iopscience.iop.org/1748-0221/8/06/P06008 "
92 echo "# FACT Performance Paper: href='http://adsabs.harvard.edu/abs/2014JInst...9P0012B"
93 echo "# href='http://iopscience.iop.org/1748-0221/9/10/P10012"
94 echo "# FACT quick look analysis: https://fact-project.org/monitoring"
95 echo "# http://adsabs.harvard.edu/abs/2015arXiv150202582D"
96 echo "# If you intend to use data or information from this website, please let us know for reference."
97 else
98 echo "# As a member or associated member of the FACT Collaboration, you have access to internal information."
99 echo "# Any publication using FACT internal information has to have the full FACT author list."
100 fi
101 echo "#"
102}
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 0 ]
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 echo "# "`echo $table | sed -e 's/AnalysisResultsRun//'`"-Analysis was used."
129 if [ "$zdmax" != "" ]
130 then
131 echo "# Maximum Zenith Distance: "$zdmax" degree"
132 fi
133 if [ "$thmax" != "" ]
134 then
135 echo "# Maximum Trigger Threshold: "$thmax" DAC counts"
136 fi
137 if [ "$light" != "" ]
138 then
139 echo "# Light Condition Cut: "$lightcut
140 fi
141 if [ "$dust" != "" ]
142 then
143 echo "# Calima Cut: dust < "$dust" ug/cm3"
144 fi
145 if [ "$usedch" == "yes" ]
146 then
147 echo "# Data quality selection based on the cosmic ray rate was applied."
148 fi
149 fi
150 echo "#"
151}
152
153function get_results()
154{
155 # some query parts
156
157 # some numbers for flux calculation
158 crabflux="3.37e-11"
159 fluxprec=13
160 crabflux="3.37"
161 fluxprec=2
162
163 # some names and definitions needed several times below
164 # ontime
165 ontime1=" TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn "
166 ontime2=" fOnTimeAfterCuts "
167 ontimeif=" IF(ISNULL(fEffectiveOn), "$ontime2", "$ontime1") "
168 # zd and threshold
169 zenith="fZenithDistance"
170 thresh="IF(ISNULL(fThresholdMinSet),fThresholdMedian,fThresholdMinSet)"
171 # correction factor for excess rate (formula by TB)
172 correvts=" fNumExcEvts*(pow(cos("$zenith"Mean*PI()/180),3)+14.8/21.9*pow(sin(2*"$zenith"Mean*PI()/180),5))/((1-0.00124/1.21*("$thresh"-500)*("$thresh">=500))) "
173 # conversion to CU (determined by DD for QLA)
174 # https://www.fact-project.org/logbook/showthread.php?tid=4927
175 cufactor="CUQLA(fNight)" # missing: ISDC analysis
176 # some calculations
177 excerr="ExcErr(Sum(fNumSigEvts), SUM(fNumBgEvts))"
178 CU="SUM("$correvts"/"$cufactor")/SUM("$ontimeif")*3600"
179 CUerr=$excerr"/SUM("$ontimeif")*3600*SUM("$correvts"/"$cufactor")/SUM(fNumExcEvts)"
180 excerr2="ExcErr(SUM(o.sigevts),SUM(o.bgevts))"
181 CU2="SUM(o.corevts/o.cufactor)/SUM(o.ot)*3600"
182 CUerr2=$excerr2"/SUM(o.ot)*3600*SUM(o.corevts/o.cufactor)/(SUM(o.sigevts)-SUM(o.bgevts))"
183
184 # columns to be selected
185 # for night-binning
186 ontime=" ROUND(SUM("$ontimeif")/60., 1) AS ontime"
187 excrate=" ROUND(SUM(fNumExcEvts)/SUM("$ontimeif")*3600, 1) AS excrate"
188 significance="ROUND(LiMa(Sum(fNumSigEvts), SUM(fNumBgEvts)), 1) AS significance"
189 numexc="Sum(fNumExcEvts) AS numexc"
190 numsig="Sum(fNumSigEvts) AS numsig"
191 numbg="Sum(fNumBgEvts) AS numbg"
192 excrateerr=" ROUND("$excerr"/SUM("$ontimeif")*3600, 1) AS excrateerr"
193 correxcrate=" ROUND(SUM("$correvts")/SUM("$ontimeif")*3600, 1) AS correxcrate"
194 correxcrateerr=" ROUND("$excerr"/SUM("$ontimeif")*3600*SUM("$correvts")/SUM(fNumExcEvts), 1) AS correxcrateerr"
195 cu=" ROUND("$CU", 2) AS cu"
196 cuerr=" ROUND("$CUerr", 2) AS cuerr"
197 flux="ROUND("$CU" * "$crabflux", 2) AS flux"
198 fluxerr="ROUND("$CUerr" * "$crabflux", 2) AS fluxerr"
199 # for minute binning
200 ontime2=" ROUND(SUM(o.ot)/60., 1) AS ontime"
201 excrate2=" ROUND((SUM(o.sigevts)-SUM(o.bgevts))/SUM(o.ot)*3600, 1) AS excrate"
202 significance2=" ROUND(LiMa(SUM(o.sigevts),SUM(o.bgevts)), 1) AS significance"
203 numexc2="Sum(o.sigevts-o.bgevts) AS numexc"
204 numsig2="Sum(o.sigevts) AS numsig"
205 numbg2="Sum(o.bgevts) AS numbg"
206 excrateerr2=" ROUND("$excerr2"/SUM(o.ot)*3600, 1) AS excrateerr"
207 correxcrate2=" ROUND(SUM(o.corevts)/SUM(o.ot)*3600, 1) AS correxcrate"
208 correxcrateerr2=" ROUND("$excerr2"/SUM(o.ot)*3600*SUM(o.corevts)/(SUM(o.sigevts)-SUM(o.bgevts)), 1) AS correxcrateerr"
209 cu2=" ROUND("$CU2", 2) AS cu"
210 cuerr2=" ROUND("$CUerr2", 2) AS cuerr"
211 flux2="ROUND("$CU2" * "$crabflux", "$fluxprec") AS flux"
212 fluxerr2="ROUND("$CUerr2" *"$crabflux", "$fluxprec") AS fluxerr"
213
214 case $timeunit in
215 mjd) delta="(Mjd(MAX(fRunStop))-Mjd(MIN(fRunStart)))/2"
216 start=" Mjd(MIN(fRunStart)) AS start"
217 stop=" Mjd(MAX(fRunStop)) AS stop"
218 deltat=$delta" AS deltat"
219 time=" Mjd(MIN(fRunStart))+"$delta" AS time"
220 delta2="(Mjd(MAX(o.stop))-Mjd(MIN(o.start)))/2"
221 start2=" Mjd(MIN(o.start)) AS start"
222 stop2=" Mjd(MAX(o.stop)) AS stop"
223 deltat2=$delta2" AS deltat"
224 time2=" Mjd(MIN(o.start))+"$delta2" AS time"
225 ;;
226 unix) delta="(Unix_timestamp(CONVERT_TZ(MAX(fRunStop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM')))/2"
227 start="Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM')) AS start"
228 stop="Unix_timestamp(CONVERT_TZ(MAX(fRunStop), '+00:00', 'SYSTEM')) AS stop"
229 deltat=$delta" AS deltat"
230 time=" Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM'))+"$delta" AS time"
231 delta2="(Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')))/2"
232 start2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')) AS start"
233 stop2=" Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) AS stop"
234 deltat2=$delta2" AS deltat"
235 time2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM'))+"$delta2" AS time"
236 ;;
237 *) delta="sec_to_time(time_to_sec(timediff(MAX(fRunStop), MIN(fRunStart)))/2)"
238 start=" MIN(fRunStart) AS start"
239 stop=" MAX(fRunStop) AS stop"
240 deltat=$delta" AS deltat"
241 time=" addtime(MIN(fRunStart), "$delta") AS time"
242 delta2="sec_to_time(time_to_sec(timediff(MAX(o.stop), MIN(o.start)))/2)"
243 start2=" MIN(o.start) AS start"
244 stop2=" MAX(o.stop) AS stop"
245 deltat2=$delta2" AS deltat"
246 time2=" addtime(MIN(o.start), "$delta2") AS time"
247 ;;
248 esac
249
250 # from and join of query
251 from=" FROM RunInfo LEFT JOIN "$table" USING (fNight, fRunID) "
252
253 # data check based on artificial trigger rate
254 # details see https://www.fact-project.org/logbook/showthread.php?tid=5790
255 #dch=" AND fR750Cor/fR750Ref >0.93 "
256 dchstd=" AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "
257
258 # put together where-clause of query
259 # time range and source
260 where=" WHERE fSourceKey="$source" AND fNight BETWEEN "$nightmin" AND "$nightmax
261 where=$where" AND NOT ISNULL(fNumExcEvts) "
262 # some sanity checks
263 where=$where" AND fRunTypeKey=1 "
264 # zd cut
265 if [ "$zdmax" != "" ]
266 then
267 where=$where" AND fZenithDistanceMax < "$zdmax
268 fi
269 # th cut
270 if [ "$thmax" != "" ]
271 then
272 where=$where" AND "$thresh" < "$thmax
273 fi
274 # dust cut
275 if [ "$dust" != "" ]
276 then
277 where=$where" AND fTNGDust<"$dust
278 fi
279 # light condition cut
280 if [ "$light" == "nomoon" ]
281 then
282 lightcut=" fZenithDistanceMoon>90"
283 fi
284 if [ "$light" == "dark" ]
285 then
286 lightcut=" fMoonZenithDistance>90 AND fSunZenithDistance>108 "
287 fi
288 if [ "$light" != "" ]
289 then
290 where=$where" AND "$lightcut
291 fi
292 querybase=$from$where
293
294 if [ "$usedch" == "yes" ]
295 then
296 if [ "$dch" == "" ]
297 then
298 querydch=$dchstd
299 else
300 echo "you are using for datacheck: "$dch
301 querydch=$dch
302 fi
303 fi
304
305
306 if [ $bin -le 0 ]
307 then
308 # first part of the query
309 querystart="SELECT "
310 querystart=$querystart" "$time", "$start", "$stop", "
311 # final part of the query
312 if [ $bin -eq 0 ]
313 then
314 orderby=" fPeriod "
315 #querystart=$querystart" fPeriod AS num, "
316 queryend=" GROUP BY fPeriod "
317 else
318 num=" FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".) "
319 orderby=$num
320 #querystart=$querystart" FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".) AS num, "
321 queryend=" GROUP BY "$num
322 fi
323 #queryend=" GROUP BY num "
324 if [ "$ontimelimit" = "" ]
325 then
326 queryend=$queryend" HAVING SUM("$ontimeif")>1200 ORDER BY "$orderby
327 else
328 queryend=$queryend" HAVING SUM("$ontimeif")>"$ontimelimit" ORDER BY "$orderby
329 fi
330
331 # internal
332 queryint=$querystart
333 queryint=$queryint" "$excrate", "$correxcrate", "$cu", "$flux", "
334 queryint=$queryint" "$deltat", "$ontime", "
335 queryint=$queryint" "$excrateerr", "$correxcrateerr", "$cuerr", "$fluxerr", "
336 queryint=$queryint" "$significance", "
337 queryint=$queryint" MIN(fNight) AS nightmin, MAX(fNight) AS nightmax, "
338 queryint=$queryint" "$numexc", "$numsig", "$numbg", "
339 queryint=$queryint" MIN("$zenith"Min) AS zdmin, MAX("$zenith"Max) AS zdmax, "
340 queryint=$queryint" MIN("$thresh") AS thmin, MAX("$thresh") AS thmax, "
341 queryint=$queryint" ROUND(AVG("$cufactor"), 1) AS cufactor, ROUND(AVG(fR750Cor), 2) AS R750cor, ROUND(AVG(fR750Ref), 2) AS R750ref "
342 queryint=$queryint" "$querybase" "$querydch" "$queryend
343
344 # for collaborators
345 querycol=$querystart
346 querycol=$querycol" "$excrate", "$correxcrate", "$cu", "$flux", "
347 querycol=$querycol" "$deltat", "$ontime", "
348 querycol=$querycol" "$excrateerr", "$correxcrateerr", "$cuerr", "$fluxerr", "
349 querycol=$querycol" "$significance
350 querycol=$querycol" "$querybase" "$querydch" "$queryend
351
352 # external
353 # no datacheck applied for external files
354 queryext=$querystart" "$excrate", "$deltat", "$excrateerr" "$querybase" "$queryend
355
356 else
357 # first part of the query
358 querystart="SELECT "
359 querystart=$querystart" "$time2", "$start2", "$stop2", "
360
361 # final part of the query
362 querybase=" FROM (SELECT fNight, fZenithDistanceMin AS zdmin, fZenithDistanceMax AS zdmax, "$thresh" AS th, "
363 querybase=$querybase" fR750Cor AS R750cor, fR750Ref AS R750ref, "$cufactor" AS cufactor, "
364 querybase=$querybase" @ot:="$ontimeif" AS ot, fRunStart AS start, fRunStop AS stop, "
365 querybase=$querybase" fNumSigEvts AS sigevts, fNumBgEvts AS bgevts, "$correvts" AS corevts, "
366 querybase=$querybase" IF (@night=fNight AND FLOOR((@os+@ot)/"$bin"./60.)<1, @bl, @bl := @bl + 1) AS block, "
367 querybase=$querybase" IF (@night=fNight AND FLOOR((@os+@ot)/"$bin"./60.)<1, @os:=@os + @ot, @os := @ot) AS os, @night :=fNight AS night "
368 querybase=$querybase$from" CROSS JOIN (SELECT @night :=0, @ot :=0, @os :=0, @bl:=0) PARAMS "
369 querybase=$querybase$where" ORDER BY fRunStart) o GROUP BY block HAVING ontime>0.75*"$bin" ORDER BY 'time'"
370
371 # internal
372 queryint=$querystart
373 queryint=$queryint" "$excrate2", "$correxcrate2", "$cu2", "$flux2", "
374 queryint=$queryint" "$deltat2", "$ontime2", "
375 queryint=$queryint" "$excrateerr2", "$correxcrateerr2", "$cuerr2", "$fluxerr2", "
376 queryint=$queryint" "$significance2", "
377 queryint=$queryint" avg(o.night) AS night, "
378 queryint=$queryint" "$numexc2", "$numsig2", "$numbg2", "
379 queryint=$queryint" MIN(o.zdmin) AS zdmin, MAX(o.zdmax) AS zdmax, MIN(o.th) AS thmin, MAX(o.th) AS thmax, "
380 queryint=$queryint" ROUND(AVG(o.cufactor), 1) AS cufactor, ROUND(AVG(o.R750cor), 2) AS R750cor, ROUND(AVG(o.R750ref), 2) AS R750ref "
381 queryint=$queryint" "$querybase
382
383 # for collaborators
384 querycol=$querystart
385 querycol=$querycol" "$excrate2", "$correxcrate2", "$cu2", "$flux2", "
386 querycol=$querycol" "$deltat2", "$ontime2", "
387 querycol=$querycol" "$excrateerr2", "$correxcrateerr2", "$cuerr2", "$fluxerr2", "
388 querycol=$querycol" "$significance2
389 querycol=$querycol" "$querybase
390
391 # external
392 queryext=$querystart" "$excrate2", "$deltat2", "$ontime2", "$excrateerr2" "$querybase
393
394 fi
395
396 # write file for externals only for allowed binnings
397 if [ $bin -eq 20 ] || [ $bin -eq -1 ]
398 then
399 fileext=$datapath"/FACT_preliminary_"$name"_external.dat"
400 if [ "$overwrite" = "yes" ]
401 then
402 if [ "$mode" != "auto" ]
403 then
404 echo "creating "$fileext" ..."
405 fi
406 echo "# This file was created at "`date` > $fileext
407 print_policy >> $fileext
408 fi
409 print_selection >> $fileext
410 headerext="# time["$timeunit"] start["$timeunit"] stop["$timeunit"] excrate[evts/h] (stop-start)/2["$timeunit"] excrate_err[evts/h] "
411 echo $headerext >> $fileext
412 #echo "$queryext"
413 mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -s -e "$queryext" >> $fileext
414 #mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -e "$queryext"
415 fi
416 if [ "$mode" == "auto" ] && [ "$expert" == "no" ]
417 then
418 return
419 fi
420
421 fileint=$datapath"/FACT_preliminary_"$name"_internal.dat"
422 if [ "$overwrite" = "yes" ]
423 then
424 if [ "$mode" != "auto" ]
425 then
426 echo "creating "$fileint" ..."
427 fi
428 echo "# This file was created at "`date` > $fileint
429 print_policy >> $fileint
430 print_selection >> $fileint
431 echo "# The following query was used: " >> $fileint
432 echo "# "$queryint >> $fileint
433 echo "#" >> $fileint
434 fi
435 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]"
436 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 "
437 headerint=$headerint" zdmin zdmax thmin thmax avg(cufactor) avg(R750cor) avg(R750ref) "
438 echo $headerint >> $fileint
439 #echo "$queryint"
440 mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -s -e "$queryint" >> $fileint
441 #mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -e "$queryint"
442 if [ "$mode"="auto" ]
443 then
444 return
445 fi
446
447 filecol=$datapath"/FACT_preliminary_"$name"_collaborators.dat"
448 if [ "$overwrite" = "yes" ]
449 then
450 echo "creating "$filecol" ..."
451 echo "# This file was created at "`date` > $filecol
452 print_policy >> $filecol
453 print_selection >> $filecol
454 echo "# The following query was used: " >> $filecol
455 echo "# "$querycol >> $filecol
456 echo "#" >> $filecol
457 fi
458 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]"
459 headercol=$headercol" excrate_err[evts/h] corr.excrate_err[evts/h] flux_err[CU] flux_err[e-11/cm2/s] significance "
460 echo $headercol >> $filecol
461 #echo "$querycol"
462 mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -s -e "$querycol" >> $filecol
463 #mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -e "$querycol
464}
465
466# evaluation of command line options (for usage with download.php)
467
468if [ ${#@} -eq 13 ]
469then
470 #get_data.sh $start $stop $source $timebin $email $table $time $expert $dch $zd $th $light $dust
471 mode="auto"
472 overwrite="yes"
473 # setup
474 datapath="/home/factwww/dch/data"
475 #datapath="./data"
476 sqlpw=/home/fact/.mysql.pw
477 #sqlpw=/home/fact/.mysql.pw2
478 host=10.0.100.21
479 dbname=factdata
480 nightmin=$1
481 nightmax=$2
482 source=$3
483 bin=$4
484 if [ "$bin" == "00" ]
485 then
486 bin=0
487 fi
488 email=$5
489 table=$6
490 timeunit=$7
491 expert=$8
492 usedch=$9 # novalue gives same result as no
493 if [ "${10}" != "novalue" ] && [ "${10}" != "all" ]
494 then
495 zdmax=${10}
496 fi
497 if [ "${11}" != "novalue" ] && [ "${11}" != "all" ]
498 then
499 thmax=${11}
500 fi
501 if [ "${12}" != "novalue" ] && [ "${12}" != "all" ]
502 then
503 light=${12}
504 fi
505 if [ "${13}" != "novalue" ] && [ "${13}" != "all" ]
506 then
507 dust=${13}
508 fi
509 name=`echo $email | sed -e 's/@/-at-/'`
510 get_results
511
512 # sending email
513 if [ "$expert" == "yes" ]
514 then
515 cat $fileint | mail -s 'FACT internal data download' -b dorner@astro.uni-wuerzburg.de -r dorner@astro.uni-wuerzburg.de $email
516 else
517 cat $fileext | mail -s 'FACT data download' -b dorner@astro.uni-wuerzburg.de -r dorner@astro.uni-wuerzburg.de $email
518 fi
519
520 exit
521fi
522
523
524
525# -------------------------------------------------------------------------------------- #
526# SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP #
527# -------------------------------------------------------------------------------------- #
528# #
529# The lines below define the basic setup for the database and give examples and #
530# explanations for the various options available. #
531# The request of the data itself is done with a smaller setup further down. #
532# #
533# -------------------------------------------------------------------------------------- #
534#
535# ----------
536# DB SETUP
537# ----------
538# path to file with mysql password
539sqlpw=/home/$USER/.mysql.pw
540# host of mysql server with FACT DB
541#host=lp-fact # ISDC
542host=10.0.100.21 # LP or LP via vpn
543#host=localhost # your local machine in case you have a copy of DB
544# name of database
545dbname=factdata
546#
547# -------------
548# BASIC SETUP
549# -------------
550# output path
551path=`dirname $0`
552datapath=$path"/data"
553# create directory for data files
554if ! [ -e $datapath ]
555then
556 mkdir $datapath
557fi
558# time unit
559#timeunit=timestamp # default
560#timeunit=unix
561timeunit=mjd
562# time binning
563# positive values: minutes
564# negative values: days
565# special case 0: period
566# for season binning choose -365 and according start date
567#bin=20 # minutes
568#bin=0 # period
569bin=-1 # nightly
570#bin=-365 # yearly
571# choose analysis
572#table="AnalysisResultsAllQLA" # N/A
573table="AnalysisResultsRunLP" # QLA
574#table="AnalysisResultsRunISDC" # ISDC
575# time range
576nightmin=20111115
577nightmax=20201231
578# overwrite dataset file?
579# (useful to combine different binnings in one file -> set to "no")
580overwrite="yes"
581# optional: require minimal ontime per bin (default 20 min)
582#ontimelimit=30 # 30 min
583ontimelimit= # default 20 min
584# data quality selection
585# if you explicitely don't want a datacheck, you can comment the following line
586usedch="yes"
587# use your own datacheck instead
588# use a line like the following defining your own data quality selection cut
589#dch=" AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "
590# apply additional predefined cuts
591# light conditions
592#light="nomoon" # only data with no moon (but twilight allowed)
593#light="dark" # only dark night data
594# TNG dust - cut away data with calima
595#dust=1
596#dust=10
597
598
599# -------------------------------------------------------------------------------------- #
600# SETUP - GET YOUR DATA HERE - SETUP - GET YOUR DATA HERE - SETUP - GET YOUR DATA HERE #
601# -------------------------------------------------------------------------------------- #
602# #
603# Adapt the lines below to your needs. #
604# Overwrite default settings above. #
605# The data-request is sent with the line 'get_results.' #
606# Minumum setup: Define source key and name for file. #
607# The list of source keys can be found at #
608# https://fact-project.org/run_db/db/printtable.php?fTable=Source&fSortBy=fSourceKEY+ #
609# More examples can be found further down. #
610# #
611# REMARKS: #
612# - correction of effect of zd and threshold not yet finalized and only valid for QLA #
613# - no CU-conversion available for ISDC-analysis so far (that for QLA is used instead) #
614# #
615# -------------------------------------------------------------------------------------- #
616
617# 501 MAGIC
618source=2
619name="Mrk501_2014_forMAGIC"
620bin=-1
621nightmin=20140714
622nightmax=20140805
623get_results
624
625bin=30
626name="Mrk501_2014_forMAGIC30"
627get_results
628
629bin=0
630name="P"
631nightmin=20140501
632nightmax=20140930
633get_results
634
635bin=20
636nightmin=20140623
637nightmax=20140623
638name="Mrk501_test"
639get_results
640
641
642# end script here
643exit
644
645
646
647#
648# more examples
649#
650
651# Mrk 421
652source=1
653name="Mrk421_nightly"
654bin=-1
655get_results
656name="Mrk421_20min"
657bin=20
658get_results
659name="Mrk421_3d"
660bin=-3
661get_results
662name="Mrk421_10d"
663bin=-10
664get_results
665name="Mrk421_period"
666bin=0
667get_results
668
669
670
671# Mrk 501
672source=2
673name="Mrk501_nightly"
674bin=-1
675get_results
676name="Mrk501_20min"
677bin=20
678get_results
679name="Mrk501_3d"
680bin=-3
681get_results
682name="Mrk501_10d"
683bin=-10
684get_results
685name="Mrk501_period"
686bin=0
687get_results
688
689
690
691# 2344
692source=3
693name="2344_nightly"
694bin=-1
695get_results
696name="2344_20min"
697bin=20
698get_results
699name="2344_period"
700bin=0
701get_results
702
703
704
705# 1959
706source=7
707name="1959_nightly"
708bin=-1
709get_results
710name="1959_20min"
711bin=20
712get_results
713name="1959_period"
714bin=0
715get_results
716
717
718
719# 0323
720source=12
721name="0323_nightly"
722bin=-1
723get_results
724name="0323_20min"
725bin=20
726get_results
727name="0323_period"
728bin=0
729get_results
730
731
732
733# crab
734source=5
735name="Crab_nightly"
736bin=-1
737get_results
738name="Crab_20min"
739bin=20
740get_results
741name="Crab_period"
742bin=0
743get_results
744name="Crab_season"
745bin=-365
746nightmin=20110716
747nightmax=20180716
748get_results
749
750
751
752name="1959_2016"
753source=7
754bin=-1
755nightmin=20160201
756nightmax=20161105
757get_results
758
759name="1959_all_variable"
760overwrite="no"
761source=7
762bin=-365
763nightmin=20120201
764nightmax=20130131
765get_results
766nightmin=20130201
767nightmax=20140131
768get_results
769nightmin=20140201
770nightmax=20150131
771get_results
772bin=0
773nightmin=20150201
774nightmax=20160131
775get_results
776bin=-1
777nightmin=20160201
778nightmax=20170131
779get_results
780bin=0
781nightmin=20170201
782nightmax=20180131
783get_results
784
785
786
787overwrite="yes"
788name="1959_all_variable2"
789overwrite="no"
790source=7
791bin=-365
792nightmin=20120201
793nightmax=20130131
794get_results
795nightmin=20130201
796nightmax=20140131
797get_results
798nightmin=20140201
799nightmax=20150131
800get_results
801bin=0
802nightmin=20150201
803nightmax=20160131
804get_results
805bin=-1
806nightmin=20160201
807nightmax=20160817
808get_results
809bin=0
810nightmin=20160818
811nightmax=20180131
812get_results
813
814
815
816overwrite="yes"
817bin=0
818source=3
819name="2344period"
820get_results
821
822
823
824# flare night (HESS)
825name="Mrk501_10min_flarenight"
826source=2
827bin=10
828nightmin=20140623
829nightmax=20140623
830get_results
831
832
833
834# flare night (HESS)
835name="Mrk501_5min_flarenight"
836source=2
837bin=5
838nightmin=20140623
839nightmax=20140623
840get_results
841
842
843
844
845# full sample
846name="Mrk421_all_nightly"
847source=1
848get_results
849
850name="Mrk501_all_nightly"
851source=2
852get_results
853
854name="1959_all_nightly"
855source=7
856get_results
857
858name="2344_all_nightly"
859source=3
860get_results
861
862
863
864name="HESE20160427"
865source=19
866nightmin=20160425
867bin=-10
868get_results
869
870name="AMON20160731"
871source=21
872nightmin=20160730
873bin=-10
874get_results
875
876
877
Note: See TracBrowser for help on using the repository browser.