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