1 | #!/bin/bash
|
---|
2 |
|
---|
3 |
|
---|
4 | source `dirname $0`/../Sourcefile.sh
|
---|
5 | printprocesslog "INFO starting $0"
|
---|
6 |
|
---|
7 | # list of sources
|
---|
8 | sources=( "MRK 421" "Mrk 421" "Mkn 421" "Mkn421" \
|
---|
9 | "1959" "V404" \
|
---|
10 | "1H 0323+342" "RXJ0324.6+3410" "RGBJ0324+3410" "SWIFTJ0325.3-5916"
|
---|
11 | "Crab" "CRAB" \
|
---|
12 | "Mrk 501" "Mkn 501" \
|
---|
13 | "1ES 2344+514" "1ES2344+514" )
|
---|
14 |
|
---|
15 | # target ids:
|
---|
16 | # http://www.swift.ac.uk/swift_live/index.php
|
---|
17 |
|
---|
18 | # 0323: 90415, 36533, 34137, 35372, 35630
|
---|
19 | # http://www.swift.ac.uk/swift_live/doSimpleSearch.php?catname=swiftmastr&searchpos=1H+0323%2B342&searchrad=12&searchepoch=2000&getWhat=1&sortBy=_r&dandr=on&coordType=0&retEpoch=2000&retType=0&retWhere=1
|
---|
20 |
|
---|
21 | # Mrk421: 30352, 35014, 215769, 31202, 80050, 31540, 91137, 34228, tbc
|
---|
22 | # http://www.swift.ac.uk/swift_live/doSimpleSearch.php?catname=swiftmastr&searchpos=Mrk+421&searchrad=12&searchepoch=2000&getWhat=1&sortBy=_r&dandr=on&coordType=0&retEpoch=2000&retType=0&retWhere=2
|
---|
23 |
|
---|
24 | # get dates
|
---|
25 | if [ "$certaindate" != "" ]
|
---|
26 | then
|
---|
27 | getdates $certaindate
|
---|
28 | else
|
---|
29 | if [ "$1" = "" ]
|
---|
30 | then
|
---|
31 | # get next 3 night
|
---|
32 | getdates +3
|
---|
33 | else
|
---|
34 | getdates $1
|
---|
35 | fi
|
---|
36 | fi
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 | for date in ${dates[@]}
|
---|
41 | do
|
---|
42 | printprocesslog "INFO getting Swift schedule for the night of "$date
|
---|
43 | #echo "INFO getting Swift schedule for the night of "$date
|
---|
44 | # paths and files needed to store schedule
|
---|
45 | date2=`echo $date | sed -e 's/\//-/g'`
|
---|
46 | schedulepath=/home/factwww/scheduling/$date
|
---|
47 | if [ ! -d $schedulepath ]
|
---|
48 | then
|
---|
49 | printprocesslog "WARNING "$schedulingpath" does not exist."
|
---|
50 | echo "WARNING "$schedulingpath" does not exist."
|
---|
51 | continue
|
---|
52 | fi
|
---|
53 | schedulefile=$schedulepath/swift.schedule
|
---|
54 | schedulefile2=$schedulepath/swift.schedule.formated
|
---|
55 | schedulefile3=$schedulepath/swift.schedule.txt
|
---|
56 | schedulefile4=$schedulepath/swift.schedule-cut.txt
|
---|
57 |
|
---|
58 | # overwrite already existing file
|
---|
59 | echo "" > $schedulefile
|
---|
60 | # Get Swift Data
|
---|
61 | # for the date of sunset
|
---|
62 | printprocesslog "INFO Checking "$date2
|
---|
63 | #lynx -width 200 -nolist -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$date2 | grep $date2 >> $schedulefile
|
---|
64 | links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$date2 | grep $date2 >> $schedulefile
|
---|
65 | # for the date of sunrise
|
---|
66 | nextday=`date +%Y-%m-%d --date=$date2"+24hour"`
|
---|
67 | printprocesslog "INFO Checking "$nextday
|
---|
68 | #lynx -width 200 -nolist -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$nextday | grep $nextday >> $schedulefile
|
---|
69 | links -width 300 -ssl.certificates 0 -dump https://www.swift.psu.edu/operations/obsSchedule.php?d=$nextday | grep $nextday >> $schedulefile
|
---|
70 |
|
---|
71 | # check if schedule is empty
|
---|
72 | checkcontent=`cat $schedulefile`
|
---|
73 | if [ "$checkcontent" = "" ]
|
---|
74 | then
|
---|
75 | printprocesslog "INFO No Schedule found for the night of "$date
|
---|
76 | continue
|
---|
77 | fi
|
---|
78 |
|
---|
79 | # grep only the columns which are needed
|
---|
80 | #cat $schedulefile | sed -r -e 's/[0-9]{5,6}[\ ]{1,4}[0-9]{1,3}[\ ]{1,6}//' | grep -o -E '^[\ ]{1,20}20[1-9][0-9]-[01][0-9]-[0-3][0-9]\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ \ \ 20[1-9][0-9]-[01][0-9]-[0-3][0-9]\ [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\ \ \ [A-Z1-4]([A-Za-z0-9][\ \.\+\-]?){3,20}' > $schedulefile2
|
---|
81 | cat $schedulefile | awk '{ print $1" "$2" "$3" "$4" "$7" "$8" "$9}' | sed -r -e 's/[-]?[0-9]{1,3}[.][0-9]{5}$//' | sed -r -e 's/[-]?[0-9]{1,3}[.][0-9]{5}\ $//' > $schedulefile2
|
---|
82 |
|
---|
83 | # output list of sources
|
---|
84 | echo -n "Searched the schedule for the following source names: " >$schedulefile3
|
---|
85 | for (( i=0; i<${#sources[@]}; i++ ))
|
---|
86 | do
|
---|
87 | echo -n ${sources[$i]} >>$schedulefile3
|
---|
88 | i2=`echo " $i + 1" | bc -l`
|
---|
89 | if [ $i2 -lt ${#sources[@]} ]
|
---|
90 | then
|
---|
91 | echo -n ", " >>$schedulefile3
|
---|
92 | else
|
---|
93 | echo "" >>$schedulefile3
|
---|
94 | fi
|
---|
95 | done
|
---|
96 |
|
---|
97 | printprocesslog "INFO searching the Swift schedule for the following sources: "${sources[@]}
|
---|
98 | # search for source names in schedule file
|
---|
99 | for (( i=0; i<${#sources[@]}; i++ ))
|
---|
100 | do
|
---|
101 | sourceline=`grep "${sources[$i]}" $schedulefile2`
|
---|
102 | if [ "$sourceline" = "" ]
|
---|
103 | then
|
---|
104 | continue
|
---|
105 | fi
|
---|
106 | dat=`echo $sourceline | awk '{ print $1 }' | sed -e 's/-/\//g'`
|
---|
107 | #echo $dat
|
---|
108 | hour=`echo $sourceline | awk '{ print $2 }' | awk -F':' '{ print $1 }'`
|
---|
109 | if [ $hour -gt 12 ] && [ "$dat" != "$date" ]
|
---|
110 | then
|
---|
111 | continue
|
---|
112 | fi
|
---|
113 | if [ $hour -lt 12 ] && [ "$dat" == "$date" ]
|
---|
114 | then
|
---|
115 | continue
|
---|
116 | fi
|
---|
117 | #echo "--"$hour"--"
|
---|
118 | echo $sourceline >>$schedulefile3
|
---|
119 | done
|
---|
120 |
|
---|
121 | # check if a source was found
|
---|
122 | numfound=`cat $schedulefile3 | wc -l`
|
---|
123 | if [ $numfound -eq 1 ]
|
---|
124 | then
|
---|
125 | echo -e "\nNone of the sources was found in the Swift schedule." >> $schedulefile3
|
---|
126 | else
|
---|
127 | echo -n $date": " && cat $schedulefile3 | grep -v Searched
|
---|
128 | fi
|
---|
129 |
|
---|
130 | # output link to full schedule
|
---|
131 | echo -e "\nThe full schedule can be found <a href='../scheduling/"$date"/"`basename $schedulefile2`"'>here</a>\n" >>$schedulefile3
|
---|
132 |
|
---|
133 | printprocesslog "INFO schedule output stored to "$schedulefile3
|
---|
134 | done
|
---|
135 |
|
---|
136 | finish
|
---|