| 1 | #!/bin/bash
|
|---|
| 2 |
|
|---|
| 3 | # add:
|
|---|
| 4 | # - fkt f dch value?
|
|---|
| 5 | # - function for correction factor
|
|---|
| 6 | # - x-day binning
|
|---|
| 7 | # < 20121212 data
|
|---|
| 8 | # zd, th for internal
|
|---|
| 9 |
|
|---|
| 10 | # todo: check cu-factor for <20121212)
|
|---|
| 11 |
|
|---|
| 12 | # comparison:
|
|---|
| 13 | # function with select/table: 18.4 sec
|
|---|
| 14 | # function with if: 5.7 sec
|
|---|
| 15 | # function with if:
|
|---|
| 16 | # vorteil: schneller
|
|---|
| 17 | # nachteil: keine history
|
|---|
| 18 | # nachteil: es braucht 2 fkt (qla, isdc)
|
|---|
| 19 |
|
|---|
| 20 | # create function CU(night int, ana tinyint) returns double(4,1) deterministic begin declare cu double; set cu=0; select fCU into cu from CU where fValid=1 and fAnalysis=ana and fNight<night order by fNight desc limit 0,1; return cu; end $$
|
|---|
| 21 |
|
|---|
| 22 | # floor((mjd(timestamp)-mjd(startnight)+0.5)/numdays)
|
|---|
| 23 | # floor((mjd(timestamp)-mjd(startnight)-0.5)/numdays)
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | function get_results()
|
|---|
| 27 | {
|
|---|
| 28 | # some basic query parts
|
|---|
| 29 |
|
|---|
| 30 | # DataCheck (old)
|
|---|
| 31 | ##data with old feedback and/or different bias voltage
|
|---|
| 32 | #query=$query" AND fNight>20120420 AND NOT fNight IN (20120406,20120410,20120503) AND"
|
|---|
| 33 | ## broken bias channel
|
|---|
| 34 | #query=$query" NOT fNight BETWEEN 20121206 AND 20130110"
|
|---|
| 35 | # bg-rate cut
|
|---|
| 36 | zdparam=" pow(0.753833*cos(Radians(fZenithDistanceMean)), 7.647435)*exp(-5.753686*pow(Radians(fZenithDistanceMean),2.089609))"
|
|---|
| 37 | thparam=" pow((if(isnull(fThresholdMinSet),fThresholdMedian,fThresholdMinSet)-329.4203),2)*(-0.0000002044803) "
|
|---|
| 38 | param=" (fNumEvtsAfterBgCuts/5-fNumSigEvts)/fOnTimeAfterCuts - "$zdparam" - "$thparam" "
|
|---|
| 39 | dchold=" -0.085 < ("$param") "
|
|---|
| 40 | dchold=$dchold" AND 0.25 > ("$param") "
|
|---|
| 41 | # Datacheck (new) -> combine
|
|---|
| 42 | dchval=" fNumEvtsAfterBgCuts/(1.41*POW(fZenithDistanceMean*PI()/180,2)+0.975)/(-7.53e-12*POW(10, LOG10(fThresholdMinSet)*3.69)+1.035)/TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))/fEffectiveOn "
|
|---|
| 43 | # some semi-automatic datacheck
|
|---|
| 44 | dch=" AND (("$dchval" BETWEEN 0.8 AND 1.7 AND fNight BETWEEN 20140520 AND 20150131) " #A
|
|---|
| 45 | dch=$dch" OR ("$dchval" BETWEEN 0.4 AND 1.6 AND fNight BETWEEN 20150201 AND 20150715) " #B
|
|---|
| 46 | dch=$dch" OR ("$dchval" BETWEEN 0.7 AND 1.4 AND fNight BETWEEN 20150716 AND 20160218) " #C
|
|---|
| 47 | dch=$dch" OR ("$dchval" BETWEEN 0.5 AND 1.0 AND fNight > 20160220) " #D
|
|---|
| 48 | dch=$dch" OR ("$dchold" AND fNight<20140520)) " #old
|
|---|
| 49 |
|
|---|
| 50 | ontime1=" TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn "
|
|---|
| 51 | ontime2=" fOnTimeAfterCuts "
|
|---|
| 52 | ontimeif=" IF(ISNULL(fEffectiveOn), "$ontime2", "$ontime1") "
|
|---|
| 53 | from=" FROM RunInfo LEFT JOIN "$table" USING (fNight, fRunID) "
|
|---|
| 54 | # time range and source
|
|---|
| 55 | where=" WHERE fSourceKey="$source" AND fNight BETWEEN "$nightmin" AND "$nightmax
|
|---|
| 56 | # some sanity checks
|
|---|
| 57 | where=$where" AND fRunTypeKey=1 "
|
|---|
| 58 | # where=$where" AND NOT ISNULL(fNumSigEvts) AND NOT ISNULL(fNumBgEvts) "
|
|---|
| 59 | # where=$where" AND NOT fRunStart='0000-00-00 00:00:00' AND NOT fRunStop='0000-00-00 00:00:00' "
|
|---|
| 60 | # zd cut
|
|---|
| 61 | where=$where" AND fZenithDistanceMax < "$zdmax
|
|---|
| 62 | # th cut
|
|---|
| 63 | where=$where" AND fThresholdMedian < "$thmax
|
|---|
| 64 | where=$where" "$dch
|
|---|
| 65 |
|
|---|
| 66 | cufactor=" Avg(25.2) "
|
|---|
| 67 | crabflux="3.37e-11"
|
|---|
| 68 | fluxprec=13
|
|---|
| 69 | crabflux="3.37"
|
|---|
| 70 | fluxprec=2
|
|---|
| 71 | # crabflux="2.8e-11"
|
|---|
| 72 | # crabflux="3.9e-11"
|
|---|
| 73 | # range of crab fluxes:
|
|---|
| 74 | # Dortmund: 2.8e-11
|
|---|
| 75 | # HESS: 3.37e-11
|
|---|
| 76 | # HAWC: 3.01e-11
|
|---|
| 77 | # Wue: 3.39e-11 - 3.9e-11 (ISDC analysis)
|
|---|
| 78 | # 15-20% difference
|
|---|
| 79 |
|
|---|
| 80 | case $timeunit in
|
|---|
| 81 | mjd) start=" Mjd(Min(fRunStart)) "
|
|---|
| 82 | stop=" Mjd(MAX(fRunStop)) "
|
|---|
| 83 | deltat=" (Mjd(MAX(fRunStop))-Mjd(Min(fRunStart)))/2 "
|
|---|
| 84 | time=" Mjd(Min(fRunStart))+"$deltat
|
|---|
| 85 | start2=" Mjd(MIN(o.start)) "
|
|---|
| 86 | stop2=" Mjd(MAX(o.stop)) "
|
|---|
| 87 | deltat2=" (Mjd(MAX(o.stop))-Mjd(MIN(o.start)))/2 "
|
|---|
| 88 | time2=" Mjd(MIN(o.start))+"$deltat2
|
|---|
| 89 | ;;
|
|---|
| 90 | unix) start="Unix_timestamp(CONVERT_TZ(Min(fRunStart), '+00:00', 'SYSTEM')) "
|
|---|
| 91 | stop="Unix_timestamp(CONVERT_TZ(Max(fRunStop), '+00:00', 'SYSTEM')) "
|
|---|
| 92 | deltat=" (Unix_timestamp(CONVERT_TZ(Max(fRunStop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(Min(fRunStart), '+00:00', 'SYSTEM')))/2 "
|
|---|
| 93 | time=" Unix_timestamp(CONVERT_TZ(Min(fRunStart), '+00:00', 'SYSTEM'))+"$deltat
|
|---|
| 94 | startstop2=" Unix_timestamp(CONVERT_TZ(MIN(o.start), '+00:00', 'SYSTEM')) AS start, "
|
|---|
| 95 | startstop2=$starstop2" Unix_timestamp(CONVERT_TZ(MAX(o.stop), '+00:00', 'SYSTEM')) AS stop, "
|
|---|
| 96 | time2=" (Unix_timestamp(CONVERT_TZ(Max(o.stop), '+00:00', 'SYSTEM')) - Unix_timestamp(CONVERT_TZ(Min(o.start), '+00:00', 'SYSTEM')))/2 "
|
|---|
| 97 | time2=" Unix_timestamp(CONVERT_TZ(Min(o.start), '+00:00', 'SYSTEM'))+"$deltat2
|
|---|
| 98 | ;;
|
|---|
| 99 | *) start=" MIN(fRunStart) "
|
|---|
| 100 | stop=" MAX(fRunStop) "
|
|---|
| 101 | deltat=" sec_to_time(time_to_sec(timediff(MAX(fRunStop), Min(fRunStart)))/2) "
|
|---|
| 102 | time=" addtime(Min(fRunStart), "$deltat") "
|
|---|
| 103 | start2=" MIN(o.start) "
|
|---|
| 104 | stop2=" MAX(o.stop) "
|
|---|
| 105 | deltat2=" sec_to_time(time_to_sec(timediff(MAX(o.stop), Min(o.start)))/2) "
|
|---|
| 106 | time2=" addtime(Min(o.start), "$deltat2") "
|
|---|
| 107 | ;;
|
|---|
| 108 | esac
|
|---|
| 109 | ontime=" SUM("$ontimeif")/60."
|
|---|
| 110 | ontime2=" SUM(o.ot)/60. "
|
|---|
| 111 |
|
|---|
| 112 | excrate=" SUM(fNumExcEvts)/SUM("$ontimeif")*3600 "
|
|---|
| 113 | excerr="ExcErr(Sum(fNumSigEvts), SUM(fNumBgEvts))"
|
|---|
| 114 | significance="LiMa(Sum(fNumSigEvts), SUM(fNumBgEvts))"
|
|---|
| 115 | numexc="Sum(fNumExcEvts)"
|
|---|
| 116 | numsig="Sum(fNumSigEvts)"
|
|---|
| 117 | numbg="Sum(fNumBgEvts)"
|
|---|
| 118 | excrateerr=" "$excerr"/SUM("$ontimeif")*3600 "
|
|---|
| 119 | # thomas correction factor
|
|---|
| 120 | correvts=" fNumExcEvts*(pow(cos(fZenithDistanceMean*PI()/180),3)+14.8/21.9*pow(sin(2*fZenithDistanceMean*PI()/180),5))/((1-0.00124/1.21*(if(isnull(fThresholdMinSet),fThresholdMedian,fThresholdMinSet)-500)*(if(isnull(fThresholdMinSet),fThresholdMedian,fThresholdMinSet)>=500))) "
|
|---|
| 121 | correxcrate=" SUM("$correvts")/SUM("$ontimeif")*3600 "
|
|---|
| 122 | # corerr = MMath::ErrorExc(excevtssum+bgevtssum, bgevtssum*5, 0.2)/ontimesum*3600.*corrate/excrate;
|
|---|
| 123 | correxcrateerr=" "$excerr"/SUM("$ontimeif")*3600*SUM("$correvts")/SUM(fNumExcEvts) "
|
|---|
| 124 | # correction on run basis (not relevant for hess)
|
|---|
| 125 | #cu=$correxcrate"/"$cufactor
|
|---|
| 126 | cu=" SUM("$correvts"/CUQLA(fNight))/SUM("$ontimeif")*3600 "
|
|---|
| 127 | #cuerr=$correxcrateerr"/"$cufactor
|
|---|
| 128 | cuerr=" "$excerr"/SUM("$ontimeif")*3600*SUM("$correvts"/CUQLA(fNight))/SUM(fNumExcEvts) "
|
|---|
| 129 | flux=$cu" * "$crabflux
|
|---|
| 130 | fluxerr=$cuerr" * "$crabflux
|
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 | excrate2=" (SUM(o.sigevts)-SUM(o.bgevts))/SUM(o.ot)*3600 "
|
|---|
| 134 | excerr2="ExcErr(SUM(o.sigevts),SUM(o.bgevts))"
|
|---|
| 135 | significance2="LiMa(SUM(o.sigevts),SUM(o.bgevts))"
|
|---|
| 136 | numexc2="Sum(o.sigevts-o.bgevts)"
|
|---|
| 137 | numsig2="Sum(o.sigevts)"
|
|---|
| 138 | numbg2="Sum(o.bgevts)"
|
|---|
| 139 | excrateerr2=" "$excerr2"/SUM(o.ot)*3600 "
|
|---|
| 140 | correxcrate2=" SUM(o.corevts)/SUM(o.ot)*3600 "
|
|---|
| 141 | correxcrateerr2=" "$excerr2"/SUM(o.ot)*3600*SUM(o.corevts)/(SUM(o.sigevts)-SUM(o.bgevts)) "
|
|---|
| 142 | #cu2=$correxcrate2"/"$cufactor
|
|---|
| 143 | cu2=" SUM(o.corevts/o.cu)/SUM(o.ot)*3600 "
|
|---|
| 144 | #cuerr2=$correxcrateerr2"/"$cufactor
|
|---|
| 145 | cuerr2=" "$excerr2"/SUM(o.ot)*3600*SUM(o.corevts/o.cu)/(SUM(o.sigevts)-SUM(o.bgevts)) "
|
|---|
| 146 | flux2="$cu2*"$crabflux
|
|---|
| 147 | fluxerr2="$cuerr2*"$crabflux
|
|---|
| 148 |
|
|---|
| 149 | # order information such that it is easily readable by tgraph
|
|---|
| 150 | # tgraph: X, Y
|
|---|
| 151 | # tgraph errors: X, Y, EX, EY
|
|---|
| 152 |
|
|---|
| 153 | # internal
|
|---|
| 154 | # --------
|
|---|
| 155 | # timeselect:
|
|---|
| 156 | # mjdstar, mjdstop, mjdmean, ontime
|
|---|
| 157 | # excselect:
|
|---|
| 158 | # excrate, excerr
|
|---|
| 159 | # corrected: excrate, excerr
|
|---|
| 160 | # CU CUerr
|
|---|
| 161 | # flux, fluxerr
|
|---|
| 162 | # addselect:
|
|---|
| 163 | # signif
|
|---|
| 164 | # num exc, num sig, num bg
|
|---|
| 165 | # other info: zd? th?
|
|---|
| 166 | #
|
|---|
| 167 | #
|
|---|
| 168 | # exter nal
|
|---|
| 169 | # --------
|
|---|
| 170 | # time, delta time, start, stop
|
|---|
| 171 | # corr-excrate, corr-excerr
|
|---|
| 172 | # flux, flux-err
|
|---|
| 173 |
|
|---|
| 174 | if [ $bin -le 0 ]
|
|---|
| 175 | then
|
|---|
| 176 | queryint="SELECT "
|
|---|
| 177 | if [ $bin -eq 0 ]
|
|---|
| 178 | then
|
|---|
| 179 | queryint=$queryint" fPeriod as num, "
|
|---|
| 180 | else
|
|---|
| 181 | queryint=$queryint" FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".) as num, "
|
|---|
| 182 | fi
|
|---|
| 183 | queryint=$queryint" "$time" as time, "$start" as start, "$stop" as stop, "
|
|---|
| 184 | queryint=$queryint" round("$excrate", 1) as excrate, round("$correxcrate", 1) as correxcrate, "
|
|---|
| 185 | queryint=$queryint" round($cu, 1) as cu, $flux as flux, "
|
|---|
| 186 | queryint=$queryint" "$deltat" as deltat, round("$ontime", 1) as ontime, "
|
|---|
| 187 | queryint=$queryint" round("$excrateerr", 1) as excrateerr, round("$correxcrateerr", 1) as correxcrateerr, "
|
|---|
| 188 | queryint=$queryint" round($cuerr, 1) as cuerr, $fluxerr as fluxerr, "
|
|---|
| 189 | queryint=$queryint" round("$significance", 1) as significance, "
|
|---|
| 190 | queryint=$queryint" Min(fNight) as nightmin, "
|
|---|
| 191 | queryint=$queryint" Max(fNight) as nightmax, "
|
|---|
| 192 | queryint=$queryint" "$numexc" as numexc, "
|
|---|
| 193 | queryint=$queryint" "$numsig" as numsig, "
|
|---|
| 194 | queryint=$queryint" "$numbg" as numbg "
|
|---|
| 195 | #queryint=$queryint" now() as now "
|
|---|
| 196 |
|
|---|
| 197 | queryext="SELECT "
|
|---|
| 198 | if [ $bin -eq 0 ]
|
|---|
| 199 | then
|
|---|
| 200 | queryext=$queryext" fPeriod as num, "
|
|---|
| 201 | else
|
|---|
| 202 | queryext=$queryext" FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".) as num, "
|
|---|
| 203 | fi
|
|---|
| 204 | queryext=$queryext" "$time" as time, "$start" as start, "$stop" as stop, "
|
|---|
| 205 | queryext=$queryext" round("$correxcrate", 1) as correxcrate, round($flux, "$fluxprec") as flux, "
|
|---|
| 206 | queryext=$queryext" "$deltat" as deltat, round("$ontime", 1) as ontime, "
|
|---|
| 207 | queryext=$queryext" round("$correxcrateerr", 1) as correxcrateerr, round($fluxerr, "$fluxprec") as fluxerr, "
|
|---|
| 208 | queryext=$queryext" round("$significance", 1) as significance "
|
|---|
| 209 | #queryext=$queryext" now() as now "
|
|---|
| 210 |
|
|---|
| 211 | querybase=$from$where
|
|---|
| 212 | #if [ $bin -eq -1 ]
|
|---|
| 213 | #then
|
|---|
| 214 | # querybase=$querybase" GROUP BY fNight "
|
|---|
| 215 | #fi
|
|---|
| 216 | #querybase=$querybase" GROUP BY FLOOR((Mjd(fRunStart)-Mjd("$nightmin")-0.5)/"`echo $bin | sed -e 's/-//'`".)"
|
|---|
| 217 | querybase=$querybase" GROUP BY num "
|
|---|
| 218 | #echo "-----------------"$querybase
|
|---|
| 219 | if [ "$ontimelimit" = "" ]
|
|---|
| 220 | then
|
|---|
| 221 | querybase=$querybase" HAVING SUM("$ontimeif")>1200 AND NOT SUM(fNumBgEvts)=SUM(fNumSigEvts) ORDER BY num " # 20 min
|
|---|
| 222 | else
|
|---|
| 223 | querybase=$querybase" HAVING SUM("$ontimeif")>"$ontimelimit" AND NOT SUM(fNumBgEvts)=SUM(fNumSigEvts) ORDER BY num "
|
|---|
| 224 | fi
|
|---|
| 225 |
|
|---|
| 226 | queryint=$queryint" "$querybase
|
|---|
| 227 | queryext=$queryext" "$querybase
|
|---|
| 228 | else
|
|---|
| 229 | queryint="SELECT "
|
|---|
| 230 | queryint=$queryint" "$time2" as time, "$start2" as start, "$stop2" as stop, "
|
|---|
| 231 | queryint=$queryint" round("$excrate2", 1) as excrate, round("$correxcrate2", 1) as correxcrate, "
|
|---|
| 232 | queryint=$queryint" round("$cu2", 1) as cu, round("$flux2", "$fluxprec") as flux, "
|
|---|
| 233 | queryint=$queryint" round("$excrateerr2", 1) as excrateerr, round("$correxcrateerr2", 1) as correxcrateerr, "
|
|---|
| 234 | queryint=$queryint" "$deltat2" as deltat, round("$ontime2", 1) as ontime, "
|
|---|
| 235 | queryint=$queryint" round("$cuerr2", 1) as cuerr, round("$fluxerr2", "$fluxprec") as fluxerr, "
|
|---|
| 236 | queryint=$queryint" round("$significance2", 1) as significance, "
|
|---|
| 237 | queryint=$queryint" avg(o.night) as night, "
|
|---|
| 238 | queryint=$queryint" "$numexc2" as numexc, "
|
|---|
| 239 | queryint=$queryint" "$numsig2" as numsig, "
|
|---|
| 240 | queryint=$queryint" "$numbg2" as numbg "
|
|---|
| 241 | #queryint=$queryint" now() as now "
|
|---|
| 242 |
|
|---|
| 243 | queryext="SELECT "
|
|---|
| 244 | queryext=$queryext" "$time2" as time, "$start2" as start, "$stop2" as stop, "
|
|---|
| 245 | queryext=$queryext" round("$correxcrate2", 1) as correxcrate, round("$flux2", "$fluxprec") as flux, "
|
|---|
| 246 | queryext=$queryext" "$deltat2" as deltat, round("$ontime2", 1) as ontime, "
|
|---|
| 247 | queryext=$queryext" round("$correxcrateerr2", 1) as correxcrateerr, round("$fluxerr2", "$fluxprec") as fluxerr, "
|
|---|
| 248 | queryext=$queryext" round("$significance2", 1) as significance "
|
|---|
| 249 | #queryext=$queryext" now() as now "
|
|---|
| 250 |
|
|---|
| 251 | querybase=" FROM (SELECT fNight, @ot:="$ontimeif" AS ot, fRunStart AS start, fRunStop AS stop, fNumSigEvts AS sigevts, fNumBgEvts AS bgevts, "
|
|---|
| 252 | querybase=$querybase" "$correvts" AS corevts, CUQLA(fNight) AS cu, "
|
|---|
| 253 | querybase=$querybase" IF (@night=fNight AND FLOOR((@os+@ot)/"$bin"./60.)<1, @bl, @bl := @bl + 1) AS block, "
|
|---|
| 254 | querybase=$querybase" IF (@night=fNight AND FLOOR((@os+@ot)/"$bin"./60.)<1, @os:=@os + @ot, @os := @ot) AS os, @night :=fNight AS night "
|
|---|
| 255 | querybase=$querybase$from" CROSS JOIN (SELECT @night :=0, @ot :=0, @os :=0, @bl:=0) PARAMS "
|
|---|
| 256 | querybase=$querybase$where" ORDER BY fRunStart) o GROUP BY block HAVING NOT sum(o.bgevts)=sum(o.sigevts) AND ontime>0.75*"$bin
|
|---|
| 257 | # AND NOT SUM(fNumBgEvts)=SUM(fNumSigEvts)
|
|---|
| 258 |
|
|---|
| 259 | queryint=$queryint" "$querybase
|
|---|
| 260 | queryext=$queryext" "$querybase
|
|---|
| 261 | fi
|
|---|
| 262 |
|
|---|
| 263 |
|
|---|
| 264 | fileint=$path"/data/FACT_preliminary_"$name"_internal.dat"
|
|---|
| 265 | if [ "$overwrite" = "yes" ]
|
|---|
| 266 | then
|
|---|
| 267 | echo "internal: "$fileint
|
|---|
| 268 | echo "# this file was created at "`date` > $fileint
|
|---|
| 269 | fi
|
|---|
| 270 | if [ $bin -le 0 ]
|
|---|
| 271 | then
|
|---|
| 272 | echo "# numbin time[mjd] start[mjd] stop[mjd] excrate[evts/h] corr.excrate[evts/h] flux[CU] flux[e-11/cm2/s] delta_time[mjd] ontime[min] excrate_err[evts/h] corr.excrate_err[evts/h] flux_err[CU] flux_err[e-11/cm2/s] significance nightmin, nightmax num_exc num_sig num_bg " >> $fileint
|
|---|
| 273 | else
|
|---|
| 274 | echo "# time[mjd] start[mjd] stop[mjd] excrate[evts/h] corr.excrate[evts/h] flux[CU] flux[e-11/cm2/s] delta_time[mjd] ontime[min] excrate_err[evts/h] corr.excrate_err[evts/h] flux_err[CU] flux_err[e-11/cm2/s] significance nightmin, nightmax num_exc num_sig num_bg " >> $fileint
|
|---|
| 275 | fi
|
|---|
| 276 | #echo "$queryint"
|
|---|
| 277 | mysql --defaults-file=$sqlpw -u root $dbname -s -e "$queryint" >> $fileint
|
|---|
| 278 | #mysql --defaults-file=$sqlpw -u root $dbname -e "$queryint"
|
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 | fileext=$path"/data/FACT_preliminary_"$name".dat"
|
|---|
| 282 | if [ "$overwrite" = "yes" ]
|
|---|
| 283 | then
|
|---|
| 284 | echo "external: "$fileext
|
|---|
| 285 | echo "# this file was created at "`date` > $fileext
|
|---|
| 286 | fi
|
|---|
| 287 | if [ $bin -lt 0 ]
|
|---|
| 288 | then
|
|---|
| 289 | echo "# numbin time[mjd] start[mjd] stop[mjd] corr.excrate[evts/h] flux[e-11/cm2/s] delta_time[mjd] ontime[min] corr.excrate_err[evts/h] flux_err[e-11/cm2/s] significance " >> $fileext
|
|---|
| 290 | else
|
|---|
| 291 | echo "# time[mjd] start[mjd] stop[mjd] corr.excrate[evts/h] flux[e-11/cm2/s] delta_time[mjd] ontime[min] corr.excrate_err[evts/h] flux_err[e-11/cm2/s] significance " >> $fileext
|
|---|
| 292 | fi
|
|---|
| 293 | #echo "$queryext"
|
|---|
| 294 | mysql --defaults-file=$sqlpw -u root $dbname -s -e "$queryext" >> $fileext
|
|---|
| 295 | #mysql --defaults-file=$sqlpw -u root $dbname -e "$queryext"
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | # setup
|
|---|
| 299 | # db
|
|---|
| 300 | sqlpw=/home/$USER/.mysql.pw
|
|---|
| 301 | dbname=factdata20170804
|
|---|
| 302 | # selection
|
|---|
| 303 | timeunit=mjd
|
|---|
| 304 | #bin=20 # min
|
|---|
| 305 | #bin=0 # period
|
|---|
| 306 | #bin=-365 # yearly
|
|---|
| 307 | bin=-1 # nightly
|
|---|
| 308 | zdmax=90
|
|---|
| 309 | thmax=1500
|
|---|
| 310 | path=`dirname $0`
|
|---|
| 311 | table="AnalysisResultsRunLP"
|
|---|
| 312 | table="AnalysisResultsAllQLA"
|
|---|
| 313 | overwrite="yes"
|
|---|
| 314 | bin=-1 # nightly
|
|---|
| 315 | nightmin=20111115
|
|---|
| 316 | nightmax=20171231
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 | # Mrk 421
|
|---|
| 320 | source=1
|
|---|
| 321 | name="Mrk421_nightly"
|
|---|
| 322 | bin=-1
|
|---|
| 323 | get_results
|
|---|
| 324 | name="Mrk421_20min"
|
|---|
| 325 | bin=20
|
|---|
| 326 | get_results
|
|---|
| 327 | name="Mrk421_3d"
|
|---|
| 328 | bin=-3
|
|---|
| 329 | get_results
|
|---|
| 330 | name="Mrk421_10d"
|
|---|
| 331 | bin=-10
|
|---|
| 332 | get_results
|
|---|
| 333 | name="Mrk421_period"
|
|---|
| 334 | bin=0
|
|---|
| 335 | get_results
|
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 | # Mrk 501
|
|---|
| 340 | source=2
|
|---|
| 341 | name="Mrk501_nightly"
|
|---|
| 342 | bin=-1
|
|---|
| 343 | get_results
|
|---|
| 344 | name="Mrk501_20min"
|
|---|
| 345 | bin=20
|
|---|
| 346 | get_results
|
|---|
| 347 | name="Mrk501_3d"
|
|---|
| 348 | bin=-3
|
|---|
| 349 | get_results
|
|---|
| 350 | name="Mrk501_10d"
|
|---|
| 351 | bin=-10
|
|---|
| 352 | get_results
|
|---|
| 353 | name="Mrk501_period"
|
|---|
| 354 | bin=0
|
|---|
| 355 | get_results
|
|---|
| 356 |
|
|---|
| 357 |
|
|---|
| 358 |
|
|---|
| 359 | # 2344
|
|---|
| 360 | source=3
|
|---|
| 361 | name="2344_nightly"
|
|---|
| 362 | bin=-1
|
|---|
| 363 | get_results
|
|---|
| 364 | name="2344_20min"
|
|---|
| 365 | bin=20
|
|---|
| 366 | get_results
|
|---|
| 367 | name="2344_period"
|
|---|
| 368 | bin=0
|
|---|
| 369 | get_results
|
|---|
| 370 |
|
|---|
| 371 |
|
|---|
| 372 |
|
|---|
| 373 | # 1959
|
|---|
| 374 | source=7
|
|---|
| 375 | name="1959_nightly"
|
|---|
| 376 | bin=-1
|
|---|
| 377 | get_results
|
|---|
| 378 | name="1959_20min"
|
|---|
| 379 | bin=20
|
|---|
| 380 | get_results
|
|---|
| 381 | name="1959_period"
|
|---|
| 382 | bin=0
|
|---|
| 383 | get_results
|
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 |
|
|---|
| 387 | # 0323
|
|---|
| 388 | source=12
|
|---|
| 389 | name="0323_nightly"
|
|---|
| 390 | bin=-1
|
|---|
| 391 | get_results
|
|---|
| 392 | name="0323_20min"
|
|---|
| 393 | bin=20
|
|---|
| 394 | get_results
|
|---|
| 395 | name="0323_period"
|
|---|
| 396 | bin=0
|
|---|
| 397 | get_results
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 | # crab
|
|---|
| 402 | source=5
|
|---|
| 403 | name="Crab_nightly"
|
|---|
| 404 | bin=-1
|
|---|
| 405 | get_results
|
|---|
| 406 | name="Crab_20min"
|
|---|
| 407 | bin=20
|
|---|
| 408 | get_results
|
|---|
| 409 | name="Crab_period"
|
|---|
| 410 | bin=0
|
|---|
| 411 | get_results
|
|---|
| 412 | name="Crab_season"
|
|---|
| 413 | bin=-365
|
|---|
| 414 | nightmin=20110716
|
|---|
| 415 | nightmax=20180716
|
|---|
| 416 | get_results
|
|---|
| 417 |
|
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 | exit
|
|---|
| 421 |
|
|---|
| 422 | # more examples
|
|---|
| 423 |
|
|---|
| 424 | name="1959_2016"
|
|---|
| 425 | source=7
|
|---|
| 426 | bin=-1
|
|---|
| 427 | nightmin=20160201
|
|---|
| 428 | nightmax=20161105
|
|---|
| 429 | get_results
|
|---|
| 430 |
|
|---|
| 431 | name="1959_all_variable"
|
|---|
| 432 | overwrite="no"
|
|---|
| 433 | source=7
|
|---|
| 434 | bin=-365
|
|---|
| 435 | nightmin=20120201
|
|---|
| 436 | nightmax=20130131
|
|---|
| 437 | get_results
|
|---|
| 438 | nightmin=20130201
|
|---|
| 439 | nightmax=20140131
|
|---|
| 440 | get_results
|
|---|
| 441 | nightmin=20140201
|
|---|
| 442 | nightmax=20150131
|
|---|
| 443 | get_results
|
|---|
| 444 | bin=0
|
|---|
| 445 | nightmin=20150201
|
|---|
| 446 | nightmax=20160131
|
|---|
| 447 | get_results
|
|---|
| 448 | bin=-1
|
|---|
| 449 | nightmin=20160201
|
|---|
| 450 | nightmax=20170131
|
|---|
| 451 | get_results
|
|---|
| 452 | bin=0
|
|---|
| 453 | nightmin=20170201
|
|---|
| 454 | nightmax=20180131
|
|---|
| 455 | get_results
|
|---|
| 456 |
|
|---|
| 457 |
|
|---|
| 458 |
|
|---|
| 459 | overwrite="yes"
|
|---|
| 460 | name="1959_all_variable2"
|
|---|
| 461 | overwrite="no"
|
|---|
| 462 | source=7
|
|---|
| 463 | bin=-365
|
|---|
| 464 | nightmin=20120201
|
|---|
| 465 | nightmax=20130131
|
|---|
| 466 | get_results
|
|---|
| 467 | nightmin=20130201
|
|---|
| 468 | nightmax=20140131
|
|---|
| 469 | get_results
|
|---|
| 470 | nightmin=20140201
|
|---|
| 471 | nightmax=20150131
|
|---|
| 472 | get_results
|
|---|
| 473 | bin=0
|
|---|
| 474 | nightmin=20150201
|
|---|
| 475 | nightmax=20160131
|
|---|
| 476 | get_results
|
|---|
| 477 | bin=-1
|
|---|
| 478 | nightmin=20160201
|
|---|
| 479 | nightmax=20160817
|
|---|
| 480 | get_results
|
|---|
| 481 | bin=0
|
|---|
| 482 | nightmin=20160818
|
|---|
| 483 | nightmax=20180131
|
|---|
| 484 | get_results
|
|---|
| 485 |
|
|---|
| 486 |
|
|---|
| 487 |
|
|---|
| 488 | exit
|
|---|
| 489 |
|
|---|
| 490 | overwrite="yes"
|
|---|
| 491 |
|
|---|
| 492 | bin=0
|
|---|
| 493 | source=3
|
|---|
| 494 | name="2344period"
|
|---|
| 495 | get_results
|
|---|
| 496 |
|
|---|
| 497 | exit
|
|---|
| 498 |
|
|---|
| 499 | # flare night (HESS)
|
|---|
| 500 | name="Mrk501_10min_flarenight"
|
|---|
| 501 | source=2
|
|---|
| 502 | bin=10
|
|---|
| 503 | nightmin=20140623
|
|---|
| 504 | nightmax=20140623
|
|---|
| 505 | get_results
|
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 | exit
|
|---|
| 509 |
|
|---|
| 510 | # flare night (HESS)
|
|---|
| 511 | name="Mrk501_5min_flarenight"
|
|---|
| 512 | source=2
|
|---|
| 513 | bin=5
|
|---|
| 514 | nightmin=20140623
|
|---|
| 515 | nightmax=20140623
|
|---|
| 516 | get_results
|
|---|
| 517 |
|
|---|
| 518 |
|
|---|
| 519 | exit
|
|---|
| 520 |
|
|---|
| 521 |
|
|---|
| 522 | # full sample
|
|---|
| 523 | name="Mrk421_all_nightly"
|
|---|
| 524 | source=1
|
|---|
| 525 | get_results
|
|---|
| 526 |
|
|---|
| 527 | name="Mrk501_all_nightly"
|
|---|
| 528 | source=2
|
|---|
| 529 | get_results
|
|---|
| 530 |
|
|---|
| 531 | name="1959_all_nightly"
|
|---|
| 532 | source=7
|
|---|
| 533 | get_results
|
|---|
| 534 |
|
|---|
| 535 | name="2344_all_nightly"
|
|---|
| 536 | source=3
|
|---|
| 537 | get_results
|
|---|
| 538 |
|
|---|
| 539 | exit
|
|---|
| 540 |
|
|---|
| 541 |
|
|---|
| 542 | name="HESE20160427"
|
|---|
| 543 | source=19
|
|---|
| 544 | nightmin=20160425
|
|---|
| 545 | bin=-10
|
|---|
| 546 | get_results
|
|---|
| 547 |
|
|---|
| 548 | name="AMON20160731"
|
|---|
| 549 | source=21
|
|---|
| 550 | nightmin=20160730
|
|---|
| 551 | bin=-10
|
|---|
| 552 | get_results
|
|---|
| 553 |
|
|---|
| 554 |
|
|---|
| 555 | # full sample
|
|---|
| 556 | name="Mrk501_all_3d"
|
|---|
| 557 | source=2
|
|---|
| 558 | bin=-3
|
|---|
| 559 | get_results
|
|---|
| 560 |
|
|---|
| 561 | exit
|
|---|
| 562 |
|
|---|
| 563 | # full sample
|
|---|
| 564 | name="Mrk421_all_3d"
|
|---|
| 565 | source=1
|
|---|
| 566 | bin=-3
|
|---|
| 567 | get_results
|
|---|
| 568 |
|
|---|
| 569 | name="1959_2016_nightly"
|
|---|
| 570 | source=7
|
|---|
| 571 | nightmin=20160301
|
|---|
| 572 | nightmax=20160831
|
|---|
| 573 | get_results
|
|---|
| 574 |
|
|---|
| 575 | # full sample
|
|---|
| 576 | name="Mrk421_all_nightly"
|
|---|
| 577 | source=1
|
|---|
| 578 | get_results
|
|---|
| 579 |
|
|---|
| 580 | name="Mrk501_all_nightly"
|
|---|
| 581 | source=2
|
|---|
| 582 | get_results
|
|---|
| 583 |
|
|---|
| 584 | name="1959_all_nightly"
|
|---|
| 585 | source=7
|
|---|
| 586 | get_results
|
|---|
| 587 |
|
|---|
| 588 | bin=20 # min
|
|---|
| 589 |
|
|---|
| 590 | # full sample
|
|---|
| 591 | name="Mrk421_all_20min"
|
|---|
| 592 | source=1
|
|---|
| 593 | get_results
|
|---|
| 594 |
|
|---|
| 595 | name="Mrk501_all_20min"
|
|---|
| 596 | source=2
|
|---|
| 597 | get_results
|
|---|
| 598 |
|
|---|
| 599 | name="1959_all_20min"
|
|---|
| 600 | source=7
|
|---|
| 601 | get_results
|
|---|
| 602 |
|
|---|
| 603 | exit
|
|---|
| 604 |
|
|---|
| 605 | name="Mrk501_all_weekly"
|
|---|
| 606 | nightmin=20140524
|
|---|
| 607 | nightmax=20140930
|
|---|
| 608 | source=2
|
|---|
| 609 | bin=-7
|
|---|
| 610 | get_results
|
|---|
| 611 |
|
|---|
| 612 | exit
|
|---|
| 613 |
|
|---|
| 614 |
|
|---|