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 | # must-have
|
---|
38 | # - use get_data.sh for download*.php instead of Send_Data*.sh
|
---|
39 | # -> add policy
|
---|
40 | # - update function for zd/th-correction
|
---|
41 | # - update CU for QLA
|
---|
42 | # - add CU for ISDC analysis
|
---|
43 | # - add < 20121212 data for QLA
|
---|
44 | # - check crab flux
|
---|
45 | # nice-to-have
|
---|
46 | # - add E2dNdE
|
---|
47 | # - functionality to determine start time for seaon-binning
|
---|
48 | # - offer several predefined datachecks?
|
---|
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 |
|
---|
80 |
|
---|
81 | function get_results()
|
---|
82 | {
|
---|
83 | # some query parts
|
---|
84 |
|
---|
85 | # some numbers for flux calculation
|
---|
86 | crabflux="3.37e-11"
|
---|
87 | fluxprec=13
|
---|
88 | crabflux="3.37"
|
---|
89 | fluxprec=2
|
---|
90 |
|
---|
91 | # some names and definitions needed several times below
|
---|
92 | # ontime
|
---|
93 | ontime1=" TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn "
|
---|
94 | ontime2=" fOnTimeAfterCuts "
|
---|
95 | ontimeif=" IF(ISNULL(fEffectiveOn), "$ontime2", "$ontime1") "
|
---|
96 | # zd and threshold
|
---|
97 | zenith="fZenithDistance"
|
---|
98 | thresh="IF(ISNULL(fThresholdMinSet),fThresholdMedian,fThresholdMinSet)"
|
---|
99 | # correction factor for excess rate (formula by TB)
|
---|
100 | 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))) "
|
---|
101 | # conversion to CU (determined by DD for QLA)
|
---|
102 | # https://www.fact-project.org/logbook/showthread.php?tid=4927
|
---|
103 | cufactor="CUQLA(fNight)" # missing: ISDC analysis
|
---|
104 | # some calculations
|
---|
105 | excerr="ExcErr(Sum(fNumSigEvts), SUM(fNumBgEvts))"
|
---|
106 | CU="SUM("$correvts"/"$cufactor")/SUM("$ontimeif")*3600"
|
---|
107 | CUerr=$excerr"/SUM("$ontimeif")*3600*SUM("$correvts"/"$cufactor")/SUM(fNumExcEvts)"
|
---|
108 | excerr2="ExcErr(SUM(o.sigevts),SUM(o.bgevts))"
|
---|
109 | CU2="SUM(o.corevts/o.cufactor)/SUM(o.ot)*3600"
|
---|
110 | CUerr2=$excerr2"/SUM(o.ot)*3600*SUM(o.corevts/o.cufactor)/(SUM(o.sigevts)-SUM(o.bgevts))"
|
---|
111 |
|
---|
112 | # columns to be selected
|
---|
113 | # for night-binning
|
---|
114 | ontime=" ROUND(SUM("$ontimeif")/60., 1) AS ontime"
|
---|
115 | excrate=" ROUND(SUM(fNumExcEvts)/SUM("$ontimeif")*3600, 1) AS excrate"
|
---|
116 | significance="ROUND(LiMa(Sum(fNumSigEvts), SUM(fNumBgEvts)), 1) AS significance"
|
---|
117 | numexc="Sum(fNumExcEvts) AS numexc"
|
---|
118 | numsig="Sum(fNumSigEvts) AS numsig"
|
---|
119 | numbg="Sum(fNumBgEvts) AS numbg"
|
---|
120 | excrateerr=" ROUND("$excerr"/SUM("$ontimeif")*3600, 1) AS excrateerr"
|
---|
121 | correxcrate=" ROUND(SUM("$correvts")/SUM("$ontimeif")*3600, 1) AS correxcrate"
|
---|
122 | correxcrateerr=" ROUND("$excerr"/SUM("$ontimeif")*3600*SUM("$correvts")/SUM(fNumExcEvts), 1) AS correxcrateerr"
|
---|
123 | cu=" ROUND("$CU", 2) AS cu"
|
---|
124 | cuerr=" ROUND("$CUerr", 2) AS cuerr"
|
---|
125 | flux="ROUND("$CU" * "$crabflux", 2) AS flux"
|
---|
126 | fluxerr="ROUND("$CUerr" * "$crabflux", 2) AS fluxerr"
|
---|
127 | # for minute binning
|
---|
128 | ontime2=" ROUND(SUM(o.ot)/60., 1) AS ontime"
|
---|
129 | excrate2=" ROUND((SUM(o.sigevts)-SUM(o.bgevts))/SUM(o.ot)*3600, 1) AS excrate"
|
---|
130 | significance2=" ROUND(LiMa(SUM(o.sigevts),SUM(o.bgevts)), 1) AS significance"
|
---|
131 | numexc2="Sum(o.sigevts-o.bgevts) AS numexc"
|
---|
132 | numsig2="Sum(o.sigevts) AS numsig"
|
---|
133 | numbg2="Sum(o.bgevts) AS numbg"
|
---|
134 | excrateerr2=" ROUND("$excerr2"/SUM(o.ot)*3600, 1) AS excrateerr"
|
---|
135 | correxcrate2=" ROUND(SUM(o.corevts)/SUM(o.ot)*3600, 1) AS correxcrate"
|
---|
136 | correxcrateerr2=" ROUND("$excerr2"/SUM(o.ot)*3600*SUM(o.corevts)/(SUM(o.sigevts)-SUM(o.bgevts)), 1) AS correxcrateerr"
|
---|
137 | cu2=" ROUND("$CU2", 2) AS cu"
|
---|
138 | cuerr2=" ROUND("$CUerr2", 2) AS cuerr"
|
---|
139 | flux2="ROUND("$CU2" * "$crabflux", "$fluxprec") AS flux"
|
---|
140 | fluxerr2="ROUND("$CUerr2" *"$crabflux", "$fluxprec") AS fluxerr"
|
---|
141 |
|
---|
142 | case $timeunit in
|
---|
143 | mjd) delta="(Mjd(MAX(fRunStop))-Mjd(MIN(fRunStart)))/2"
|
---|
144 | start=" Mjd(MIN(fRunStart)) AS start"
|
---|
145 | stop=" Mjd(MAX(fRunStop)) AS stop"
|
---|
146 | deltat=$delta" AS deltat"
|
---|
147 | time=" Mjd(MIN(fRunStart))+"$delta" AS time"
|
---|
148 | delta2="(Mjd(MAX(o.stop))-Mjd(MIN(o.start)))/2"
|
---|
149 | start2=" Mjd(MIN(o.start)) AS start"
|
---|
150 | stop2=" Mjd(MAX(o.stop)) AS stop"
|
---|
151 | deltat2=$delta2" AS deltat"
|
---|
152 | time2=" Mjd(MIN(o.start))+"$delta2" AS time"
|
---|
153 | ;;
|
---|
154 | unix) delta="(Unix_timestamp(CONVERT_TZ(MAX(fRunStop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM')))/2"
|
---|
155 | start="Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM')) AS start"
|
---|
156 | stop="Unix_timestamp(CONVERT_TZ(MAX(fRunStop), '+00:00', 'SYSTEM')) AS stop"
|
---|
157 | deltat=$delta" AS deltat"
|
---|
158 | time=" Unix_timestamp(CONVERT_TZ(MIN(fRunStart), '+00:00', 'SYSTEM'))+"$delta" AS time"
|
---|
159 | delta2="(Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')))/2"
|
---|
160 | startstop2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')) AS start"
|
---|
161 | startstop2=$starstop2" Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) AS stop"
|
---|
162 | deltat2=$delta2" AS deltat"
|
---|
163 | time2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM'))+"$delta2" AS time"
|
---|
164 | ;;
|
---|
165 | *) delta="sec_to_time(time_to_sec(timediff(MAX(fRunStop), MIN(fRunStart)))/2)"
|
---|
166 | start=" MIN(fRunStart) AS start"
|
---|
167 | stop=" MAX(fRunStop) AS stop"
|
---|
168 | deltat=$delta" AS deltat"
|
---|
169 | time=" addtime(MIN(fRunStart), "$delta") AS time"
|
---|
170 | delta2="sec_to_time(time_to_sec(timediff(MAX(o.stop), MIN(o.start)))/2)"
|
---|
171 | start2=" MIN(o.start) AS start"
|
---|
172 | stop2=" MAX(o.stop) AS stop"
|
---|
173 | deltat2=$delta" AS deltat"
|
---|
174 | time2=" addtime(MIN(o.start), "$delta2") AS time"
|
---|
175 | ;;
|
---|
176 | esac
|
---|
177 |
|
---|
178 | # from and join of query
|
---|
179 | from=" FROM RunInfo LEFT JOIN "$table" USING (fNight, fRunID) "
|
---|
180 |
|
---|
181 | # data check based on artificial trigger rate
|
---|
182 | # details see https://www.fact-project.org/logbook/showthread.php?tid=5790
|
---|
183 | #dch=" AND fR750Cor/fR750Ref >0.93 "
|
---|
184 | dchstd=" AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "
|
---|
185 |
|
---|
186 | # put together where-clause of query
|
---|
187 | # time range and source
|
---|
188 | where=" WHERE fSourceKey="$source" AND fNight BETWEEN "$nightmin" AND "$nightmax
|
---|
189 | where=$where" AND NOT ISNULL(fNumExcEvts) "
|
---|
190 | # some sanity checks
|
---|
191 | where=$where" AND fRunTypeKey=1 "
|
---|
192 | # zd cut
|
---|
193 | where=$where" AND fZenithDistanceMax < "$zdmax
|
---|
194 | # th cut
|
---|
195 | where=$where" AND fThresholdMedian < "$thmax
|
---|
196 | querybase=$from$where
|
---|
197 |
|
---|
198 | if [ "$usedch" == "yes" ]
|
---|
199 | then
|
---|
200 | if [ "$dch" == "" ]
|
---|
201 | then
|
---|
202 | querydch=$dchstd
|
---|
203 | else
|
---|
204 | echo "you are using for datacheck: "$dch
|
---|
205 | querydch=$dch
|
---|
206 | fi
|
---|
207 | fi
|
---|
208 |
|
---|
209 |
|
---|
210 | if [ $bin -le 0 ]
|
---|
211 | then
|
---|
212 | num="#bin"
|
---|
213 | # first part of the query
|
---|
214 | querystart="SELECT "
|
---|
215 | if [ $bin -eq 0 ]
|
---|
216 | then
|
---|
217 | querystart=$querystart" fPeriod AS num, "
|
---|
218 | else
|
---|
219 | querystart=$querystart" FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".) AS num, "
|
---|
220 | fi
|
---|
221 | querystart=$querystart" "$time", "$start", "$stop", "
|
---|
222 |
|
---|
223 | # final part of the query
|
---|
224 | queryend=" GROUP BY num "
|
---|
225 | if [ "$ontimelimit" = "" ]
|
---|
226 | then
|
---|
227 | queryend=$queryend" HAVING SUM("$ontimeif")>1200 ORDER BY num " # 20 min
|
---|
228 | else
|
---|
229 | queryend=$queryend" HAVING SUM("$ontimeif")>"$ontimelimit" ORDER BY num "
|
---|
230 | fi
|
---|
231 |
|
---|
232 | # internal
|
---|
233 | queryint=$querystart
|
---|
234 | queryint=$queryint" "$excrate", "$correxcrate", "$cu", "$flux", "
|
---|
235 | queryint=$queryint" "$deltat", "$ontime", "
|
---|
236 | queryint=$queryint" "$excrateerr", "$correxcrateerr", "$cuerr", "$fluxerr", "
|
---|
237 | queryint=$queryint" "$significance", "
|
---|
238 | queryint=$queryint" MIN(fNight) AS nightmin, MAX(fNight) AS nightmax, "
|
---|
239 | queryint=$queryint" "$numexc", "$numsig", "$numbg", "
|
---|
240 | queryint=$queryint" MIN("$zenith"Min) AS zdmin, MAX("$zenith"Max) AS zdmax, "
|
---|
241 | queryint=$queryint" MIN("$thresh") AS thmin, MAX("$thresh") AS thmax, "
|
---|
242 | queryint=$queryint" ROUND(AVG("$cufactor"), 1) AS cufactor, ROUND(AVG(fR750Cor), 2) AS R750cor, ROUND(AVG(fR750Ref), 2) AS R750ref "
|
---|
243 | queryint=$queryint" "$querybase" "$querydch" "$queryend
|
---|
244 |
|
---|
245 | # for collaborators
|
---|
246 | querycol=$querystart
|
---|
247 | querycol=$querycol" "$excrate", "$correxcrate", "$cu", "$flux", "
|
---|
248 | querycol=$querycol" "$deltat", "$ontime", "
|
---|
249 | querycol=$querycol" "$excrateerr", "$correxcrateerr", "$cuerr", "$fluxerr", "
|
---|
250 | querycol=$querycol" "$significance
|
---|
251 | querycol=$querycol" "$querybase" "$querydch" "$queryend
|
---|
252 |
|
---|
253 | # external
|
---|
254 | # no datacheck applied for external files
|
---|
255 | queryext=$querystart" "$excrate", "$deltat", "$excrateerr" "$querybase" "$queryend
|
---|
256 |
|
---|
257 | else
|
---|
258 | num=
|
---|
259 | # first part of the query
|
---|
260 | querystart="SELECT "
|
---|
261 | querystart=$querystart" "$time2", "$start2", "$stop2", "
|
---|
262 |
|
---|
263 | # final part of the query
|
---|
264 | querybase=" FROM (SELECT fNight, fZenithDistanceMin AS zdmin, fZenithDistanceMax AS zdmax, "$thresh" AS th, "
|
---|
265 | querybase=$querybase" fR750Cor AS R750cor, fR750Ref AS R750ref, "$cufactor" AS cufactor, "
|
---|
266 | querybase=$querybase" @ot:="$ontimeif" AS ot, fRunStart AS start, fRunStop AS stop, "
|
---|
267 | querybase=$querybase" fNumSigEvts AS sigevts, fNumBgEvts AS bgevts, "$correvts" AS corevts, "
|
---|
268 | querybase=$querybase" IF (@night=fNight AND FLOOR((@os+@ot)/"$bin"./60.)<1, @bl, @bl := @bl + 1) AS block, "
|
---|
269 | querybase=$querybase" IF (@night=fNight AND FLOOR((@os+@ot)/"$bin"./60.)<1, @os:=@os + @ot, @os := @ot) AS os, @night :=fNight AS night "
|
---|
270 | querybase=$querybase$from" CROSS JOIN (SELECT @night :=0, @ot :=0, @os :=0, @bl:=0) PARAMS "
|
---|
271 | querybase=$querybase$where" ORDER BY fRunStart) o GROUP BY block HAVING ontime>0.75*"$bin" ORDER BY 'time'"
|
---|
272 |
|
---|
273 | # internal
|
---|
274 | queryint=$querystart
|
---|
275 | queryint=$queryint" "$excrate2", "$correxcrate2", "$cu2", "$flux2", "
|
---|
276 | queryint=$queryint" "$deltat2", "$ontime2", "
|
---|
277 | queryint=$queryint" "$excrateerr2", "$correxcrateerr2", "$cuerr2", "$fluxerr2", "
|
---|
278 | queryint=$queryint" "$significance2", "
|
---|
279 | queryint=$queryint" avg(o.night) AS night, "
|
---|
280 | queryint=$queryint" "$numexc2", "$numsig2", "$numbg2", "
|
---|
281 | queryint=$queryint" MIN(o.zdmin) AS zdmin, MAX(o.zdmax) AS zdmax, MIN(o.th) AS thmin, MAX(o.th) AS thmax, "
|
---|
282 | queryint=$queryint" ROUND(AVG(o.cufactor), 1) AS cufactor, ROUND(AVG(o.R750cor), 2) AS R750cor, ROUND(AVG(o.R750ref), 2) AS R750ref "
|
---|
283 | queryint=$queryint" "$querybase
|
---|
284 |
|
---|
285 | # for collaborators
|
---|
286 | querycol=$querystart
|
---|
287 | querycol=$querycol" "$excrate2", "$correxcrate2", "$cu2", "$flux2", "
|
---|
288 | querycol=$querycol" "$deltat2", "$ontime2", "
|
---|
289 | querycol=$querycol" "$excrateerr2", "$correxcrateerr2", "$cuerr2", "$fluxerr2", "
|
---|
290 | querycol=$querycol" "$significance2
|
---|
291 | querycol=$querycol" "$querybase
|
---|
292 |
|
---|
293 | # external
|
---|
294 | queryext=$querystart" "$excrate2", "$deltat2", "$ontime2", "$excrateerr2" "$querybase
|
---|
295 |
|
---|
296 | fi
|
---|
297 |
|
---|
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 |
|
---|
332 | # write file for externals only for allowed binnings
|
---|
333 | if [ $bin -eq 20 ] || [ $bin -eq -1 ]
|
---|
334 | then
|
---|
335 | fileext=$datapath"/FACT_preliminary_"$name"_external.dat"
|
---|
336 | if [ "$overwrite" = "yes" ]
|
---|
337 | then
|
---|
338 | echo "creating "$fileext" ..."
|
---|
339 | echo "# This file was created at "`date` > $fileext
|
---|
340 | # add policy here
|
---|
341 | fi
|
---|
342 | headerext="# "$num" time["$timeunit"] start["$timeunit"] stop["$timeunit"] excrate[evts/h] delta_time["$timeunit"] excrate_err[evts/h] "
|
---|
343 | echo $headerext >> $fileext
|
---|
344 | #echo "$queryext"
|
---|
345 | mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -s -e "$queryext" >> $fileext
|
---|
346 | #mysql --defaults-file=$sqlpw -u factread --host=$host $dbname -e "$queryext"
|
---|
347 | fi
|
---|
348 | }
|
---|
349 |
|
---|
350 | # -------------------------------------------------------------------------------------- #
|
---|
351 | # SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP #
|
---|
352 | # -------------------------------------------------------------------------------------- #
|
---|
353 | # #
|
---|
354 | # The lines below define the basic setup for the database and give examples and #
|
---|
355 | # explanations for the various options available. #
|
---|
356 | # The request of the data itself is done with a smaller setup further down. #
|
---|
357 | # #
|
---|
358 | # -------------------------------------------------------------------------------------- #
|
---|
359 | #
|
---|
360 | # ----------
|
---|
361 | # DB SETUP
|
---|
362 | # ----------
|
---|
363 | # path to file with mysql password
|
---|
364 | sqlpw=/home/$USER/.mysql.pw
|
---|
365 | # host of mysql server with FACT DB
|
---|
366 | #host=lp-fact # ISDC
|
---|
367 | host=10.0.100.21 # LP or LP via vpn
|
---|
368 | #host=localhost # your local machine in case you have a copy of DB
|
---|
369 | # name of database
|
---|
370 | dbname=factdata
|
---|
371 | #
|
---|
372 | # -------------
|
---|
373 | # BASIC SETUP
|
---|
374 | # -------------
|
---|
375 | # output path
|
---|
376 | path=`dirname $0`
|
---|
377 | datapath=$path"/data"
|
---|
378 | # create directory for data files
|
---|
379 | if ! [ -e $datapath ]
|
---|
380 | then
|
---|
381 | mkdir $datapath
|
---|
382 | fi
|
---|
383 | # time unit
|
---|
384 | #timeunit=timestamp # default
|
---|
385 | #timeunit=unix
|
---|
386 | timeunit=mjd
|
---|
387 | # time binning
|
---|
388 | # positive values: minutes
|
---|
389 | # negative values: days
|
---|
390 | # special case 0: period
|
---|
391 | # for season binning choose -365 and according start date
|
---|
392 | #bin=20 # minutes
|
---|
393 | #bin=0 # period
|
---|
394 | bin=-1 # nightly
|
---|
395 | #bin=-365 # yearly
|
---|
396 | # choose analysis
|
---|
397 | #table="AnalysisResultsAllQLA" # N/A
|
---|
398 | table="AnalysisResultsRunLP" # QLA
|
---|
399 | #table="AnalysisResultsRunISDC" # ISDC
|
---|
400 | # time range
|
---|
401 | nightmin=20111115
|
---|
402 | nightmax=20201231
|
---|
403 | # defaults for zd and threshold
|
---|
404 | zdmax=90 # all data
|
---|
405 | thmax=1500 # all data
|
---|
406 | # overwrite dataset file?
|
---|
407 | # (useful to combine different binnings in one file -> set to "no")
|
---|
408 | overwrite="yes"
|
---|
409 | # optional: require minimal ontime per bin (default 20 min)
|
---|
410 | #ontimelimit=30 # 30 min
|
---|
411 | ontimelimit= # default 20 min
|
---|
412 | # data quality selection
|
---|
413 | # if you explicitely don't want a datacheck, you can comment the following line
|
---|
414 | usedch="yes"
|
---|
415 | # use your own datacheck instead
|
---|
416 | # use a line like the following defining your own data quality selection cut
|
---|
417 | #dch=" AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "
|
---|
418 |
|
---|
419 | # -------------------------------------------------------------------------------------- #
|
---|
420 | # SETUP - GET YOUR DATA HERE - SETUP - GET YOUR DATA HERE - SETUP - GET YOUR DATA HERE #
|
---|
421 | # -------------------------------------------------------------------------------------- #
|
---|
422 | # #
|
---|
423 | # Adapt the lines below to your needs. #
|
---|
424 | # Overwrite default settings above. #
|
---|
425 | # The data-request is sent with the line 'get_results.' #
|
---|
426 | # Minumum setup: Define source key and name for file. #
|
---|
427 | # The list of source keys can be found at #
|
---|
428 | # https://fact-project.org/run_db/db/printtable.php?fTable=Source&fSortBy=fSourceKEY+ #
|
---|
429 | # More examples can be found further down. #
|
---|
430 | # #
|
---|
431 | # REMARKS: #
|
---|
432 | # - correction of effect of zd and threshold not yet finalized and only valid for QLA #
|
---|
433 | # - no CU-conversion available for ISDC-analysis so far (that for QLA is used instead) #
|
---|
434 | # #
|
---|
435 | # -------------------------------------------------------------------------------------- #
|
---|
436 |
|
---|
437 | # 501 MAGIC
|
---|
438 | source=2
|
---|
439 | name="Mrk501_2014_forMAGIC"
|
---|
440 | bin=-1
|
---|
441 | nightmin=20140714
|
---|
442 | nightmax=20140805
|
---|
443 | get_results
|
---|
444 |
|
---|
445 | bin=30
|
---|
446 | name="Mrk501_2014_forMAGIC30"
|
---|
447 | get_results
|
---|
448 |
|
---|
449 | bin=0
|
---|
450 | name="P"
|
---|
451 | nightmin=20140501
|
---|
452 | nightmax=20140930
|
---|
453 | get_results
|
---|
454 |
|
---|
455 | bin=20
|
---|
456 | nightmin=20140623
|
---|
457 | nightmax=20140623
|
---|
458 | name="Mrk501_test"
|
---|
459 | get_results
|
---|
460 |
|
---|
461 |
|
---|
462 | # end script here
|
---|
463 | exit
|
---|
464 |
|
---|
465 |
|
---|
466 |
|
---|
467 | #
|
---|
468 | # more examples
|
---|
469 | #
|
---|
470 |
|
---|
471 | # Mrk 421
|
---|
472 | source=1
|
---|
473 | name="Mrk421_nightly"
|
---|
474 | bin=-1
|
---|
475 | get_results
|
---|
476 | name="Mrk421_20min"
|
---|
477 | bin=20
|
---|
478 | get_results
|
---|
479 | name="Mrk421_3d"
|
---|
480 | bin=-3
|
---|
481 | get_results
|
---|
482 | name="Mrk421_10d"
|
---|
483 | bin=-10
|
---|
484 | get_results
|
---|
485 | name="Mrk421_period"
|
---|
486 | bin=0
|
---|
487 | get_results
|
---|
488 |
|
---|
489 |
|
---|
490 |
|
---|
491 | # Mrk 501
|
---|
492 | source=2
|
---|
493 | name="Mrk501_nightly"
|
---|
494 | bin=-1
|
---|
495 | get_results
|
---|
496 | name="Mrk501_20min"
|
---|
497 | bin=20
|
---|
498 | get_results
|
---|
499 | name="Mrk501_3d"
|
---|
500 | bin=-3
|
---|
501 | get_results
|
---|
502 | name="Mrk501_10d"
|
---|
503 | bin=-10
|
---|
504 | get_results
|
---|
505 | name="Mrk501_period"
|
---|
506 | bin=0
|
---|
507 | get_results
|
---|
508 |
|
---|
509 |
|
---|
510 |
|
---|
511 | # 2344
|
---|
512 | source=3
|
---|
513 | name="2344_nightly"
|
---|
514 | bin=-1
|
---|
515 | get_results
|
---|
516 | name="2344_20min"
|
---|
517 | bin=20
|
---|
518 | get_results
|
---|
519 | name="2344_period"
|
---|
520 | bin=0
|
---|
521 | get_results
|
---|
522 |
|
---|
523 |
|
---|
524 |
|
---|
525 | # 1959
|
---|
526 | source=7
|
---|
527 | name="1959_nightly"
|
---|
528 | bin=-1
|
---|
529 | get_results
|
---|
530 | name="1959_20min"
|
---|
531 | bin=20
|
---|
532 | get_results
|
---|
533 | name="1959_period"
|
---|
534 | bin=0
|
---|
535 | get_results
|
---|
536 |
|
---|
537 |
|
---|
538 |
|
---|
539 | # 0323
|
---|
540 | source=12
|
---|
541 | name="0323_nightly"
|
---|
542 | bin=-1
|
---|
543 | get_results
|
---|
544 | name="0323_20min"
|
---|
545 | bin=20
|
---|
546 | get_results
|
---|
547 | name="0323_period"
|
---|
548 | bin=0
|
---|
549 | get_results
|
---|
550 |
|
---|
551 |
|
---|
552 |
|
---|
553 | # crab
|
---|
554 | source=5
|
---|
555 | name="Crab_nightly"
|
---|
556 | bin=-1
|
---|
557 | get_results
|
---|
558 | name="Crab_20min"
|
---|
559 | bin=20
|
---|
560 | get_results
|
---|
561 | name="Crab_period"
|
---|
562 | bin=0
|
---|
563 | get_results
|
---|
564 | name="Crab_season"
|
---|
565 | bin=-365
|
---|
566 | nightmin=20110716
|
---|
567 | nightmax=20180716
|
---|
568 | get_results
|
---|
569 |
|
---|
570 |
|
---|
571 |
|
---|
572 | name="1959_2016"
|
---|
573 | source=7
|
---|
574 | bin=-1
|
---|
575 | nightmin=20160201
|
---|
576 | nightmax=20161105
|
---|
577 | get_results
|
---|
578 |
|
---|
579 | name="1959_all_variable"
|
---|
580 | overwrite="no"
|
---|
581 | source=7
|
---|
582 | bin=-365
|
---|
583 | nightmin=20120201
|
---|
584 | nightmax=20130131
|
---|
585 | get_results
|
---|
586 | nightmin=20130201
|
---|
587 | nightmax=20140131
|
---|
588 | get_results
|
---|
589 | nightmin=20140201
|
---|
590 | nightmax=20150131
|
---|
591 | get_results
|
---|
592 | bin=0
|
---|
593 | nightmin=20150201
|
---|
594 | nightmax=20160131
|
---|
595 | get_results
|
---|
596 | bin=-1
|
---|
597 | nightmin=20160201
|
---|
598 | nightmax=20170131
|
---|
599 | get_results
|
---|
600 | bin=0
|
---|
601 | nightmin=20170201
|
---|
602 | nightmax=20180131
|
---|
603 | get_results
|
---|
604 |
|
---|
605 |
|
---|
606 |
|
---|
607 | overwrite="yes"
|
---|
608 | name="1959_all_variable2"
|
---|
609 | overwrite="no"
|
---|
610 | source=7
|
---|
611 | bin=-365
|
---|
612 | nightmin=20120201
|
---|
613 | nightmax=20130131
|
---|
614 | get_results
|
---|
615 | nightmin=20130201
|
---|
616 | nightmax=20140131
|
---|
617 | get_results
|
---|
618 | nightmin=20140201
|
---|
619 | nightmax=20150131
|
---|
620 | get_results
|
---|
621 | bin=0
|
---|
622 | nightmin=20150201
|
---|
623 | nightmax=20160131
|
---|
624 | get_results
|
---|
625 | bin=-1
|
---|
626 | nightmin=20160201
|
---|
627 | nightmax=20160817
|
---|
628 | get_results
|
---|
629 | bin=0
|
---|
630 | nightmin=20160818
|
---|
631 | nightmax=20180131
|
---|
632 | get_results
|
---|
633 |
|
---|
634 |
|
---|
635 |
|
---|
636 | overwrite="yes"
|
---|
637 | bin=0
|
---|
638 | source=3
|
---|
639 | name="2344period"
|
---|
640 | get_results
|
---|
641 |
|
---|
642 |
|
---|
643 |
|
---|
644 | # flare night (HESS)
|
---|
645 | name="Mrk501_10min_flarenight"
|
---|
646 | source=2
|
---|
647 | bin=10
|
---|
648 | nightmin=20140623
|
---|
649 | nightmax=20140623
|
---|
650 | get_results
|
---|
651 |
|
---|
652 |
|
---|
653 |
|
---|
654 | # flare night (HESS)
|
---|
655 | name="Mrk501_5min_flarenight"
|
---|
656 | source=2
|
---|
657 | bin=5
|
---|
658 | nightmin=20140623
|
---|
659 | nightmax=20140623
|
---|
660 | get_results
|
---|
661 |
|
---|
662 |
|
---|
663 |
|
---|
664 |
|
---|
665 | # full sample
|
---|
666 | name="Mrk421_all_nightly"
|
---|
667 | source=1
|
---|
668 | get_results
|
---|
669 |
|
---|
670 | name="Mrk501_all_nightly"
|
---|
671 | source=2
|
---|
672 | get_results
|
---|
673 |
|
---|
674 | name="1959_all_nightly"
|
---|
675 | source=7
|
---|
676 | get_results
|
---|
677 |
|
---|
678 | name="2344_all_nightly"
|
---|
679 | source=3
|
---|
680 | get_results
|
---|
681 |
|
---|
682 |
|
---|
683 |
|
---|
684 | name="HESE20160427"
|
---|
685 | source=19
|
---|
686 | nightmin=20160425
|
---|
687 | bin=-10
|
---|
688 | get_results
|
---|
689 |
|
---|
690 | name="AMON20160731"
|
---|
691 | source=21
|
---|
692 | nightmin=20160730
|
---|
693 | bin=-10
|
---|
694 | get_results
|
---|
695 |
|
---|
696 |
|
---|
697 |
|
---|