source: branches/trigger_burst_research/DataCheck/InfoForMWL.sh@ 18803

Last change on this file since 18803 was 18064, checked in by Daniela Dorner, 10 years ago
added new years
  • Property svn:executable set to *
File size: 2.9 KB
Line 
1#!/bin/bash
2#
3# script to read observation information from the database
4# format: as given by David
5# MJD DATE START STOP FLUX COMMENT
6# for times before midnight: eg 22:33 -> -01:27
7
8
9source `dirname $0`/../Sourcefile.sh
10printprocesslog "INFO starting $0 $1"
11
12# getting db info for query
13getdbsetup
14
15function get_table()
16{
17 printprocesslog "INFO writing "$file
18 query="SELECT Datediff(Max(fRunStop), '1858-11-17') as MJD, "
19 query=$query" Date_format(Max(fRunStop), '%Y/%m/%d') as DATE, "
20 #query=$query" Date_format(Min(fRunStart), '%H:%i') as STARTOLD, "
21 query=$query" if(Hour(Min(fRunStart))>10, Concat('-', Time_format(Addtime(Timediff(Concat(STR_TO_DATE(fNight, '%Y%m%d'), ' 23:59:59'), Min(fRunStart)), '0 0:1:0.0'), '%H:%i')), Date_format(Min(fRunStart), '%H:%i')) as START, "
22 #query=$query" Date_format(Max(fRunStop), '%H:%i') as STOPOLD, "
23 query=$query" if(Hour(Max(fRunStop))>10, Concat('-', Time_format(Addtime(Timediff(Concat(STR_TO_DATE(fNight, '%Y%m%d'), ' 23:59:59'), Max(fRunStop)), '0 0:1:0.0'), '%H:%i')), Date_format(Max(fRunStop), '%H:%i')) as STOP, "
24 query=$query" CONCAT('---') as FLUX, "
25 #query=$query" CONCAT('#') as Comments"
26 #query=$query" CONCAT('# ', Timediff(Max(fRunStop), Min(fRunStart)), ' ontime: ', Convert(Sum(Time_to_sec(Timediff(fRunStop, fRunStart)))/60./60., decimal(2,1))) AS Comments"
27 query=$query" IF (ISNULL(Sum(fOnTime)), CONCAT('#'), CONCAT('# ontime: ', Convert(Sum(fOntime)/3600, decimal(2,1)), 'h')) AS Comments"
28 query=$query" FROM RunInfo "
29 query=$query" WHERE fSourceKEY="$sourcekey
30 query=$query" AND fRunTypeKEY=1 "
31 query=$query" AND fNight BETWEEN "$start" AND "$stop
32 query=$query" GROUP BY fNight "
33 query=$query" ORDER BY fNight "
34 #echo $query
35 #echo ""
36 printprocesslog "DEBUG sendquery QUERY: "$query
37 # sendquery can't be used as it writes everything into a variable
38 mysql -s -u $us --password=$pw --host=$ho $db -e " $query " > $file
39}
40
41##mrk501
42#sourcekey=2
43#file="Mrk501_FACT_observations_2014.txt"
44#start=20140101
45#stop=20141030
46#get_table
47#exit
48
49#mrk421
50sourcekey=1
51
52file="Mrk421_FACT_observations_all.txt"
53start=20111115
54stop=20200101
55get_table
56
57file="Mrk421_FACT_observations_2011_2012.txt"
58start=20120101
59stop=20120701
60get_table
61
62file="Mrk421_FACT_observations_2012_2013.txt"
63start=20121001
64stop=20130930
65get_table
66
67file="Mrk421_FACT_observations_2013_2014.txt"
68start=20131001
69stop=20140930
70get_table
71
72file="Mrk421_FACT_observations_2014_2015.txt"
73start=20141001
74stop=20150930
75get_table
76
77
78#mrk501
79sourcekey=2
80
81file="Mrk501_FACT_observations_all.txt"
82start=20120501 #really started at 19.5.2012
83stop=20200101
84get_table
85
86file="Mrk501_FACT_observations_2012.txt"
87start=20120501
88stop=20121030
89get_table
90
91file="Mrk501_FACT_observations_2013.txt"
92start=20130101
93stop=20131030
94get_table
95
96file="Mrk501_FACT_observations_2014.txt"
97start=20140101
98stop=20141030
99get_table
100
101file="Mrk501_FACT_observations_2015.txt"
102start=20150101
103stop=20151030
104get_table
105
Note: See TracBrowser for help on using the repository browser.