source: branches/Mars_McMismatchStudy/datacenter/scripts/findnewstars@ 18527

Last change on this file since 18527 was 8482, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.7 KB
Line 
1#!/bin/sh
2#
3# ========================================================================
4#
5# *
6# * This file is part of MARS, the MAGIC Analysis and Reconstruction
7# * Software. It is distributed to you in the hope that it can be a useful
8# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9# * It is distributed WITHOUT ANY WARRANTY.
10# *
11# * Permission to use, copy, modify and distribute this software and its
12# * documentation for any purpose is hereby granted without fee,
13# * provided that the above copyright notice appear in all copies and
14# * that both that copyright notice and this permission notice appear
15# * in supporting documentation. It is provided "as is" without express
16# * or implied warranty.
17# *
18#
19#
20# Author(s): Daniela Dorner 10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2007
23#
24#
25# ========================================================================
26#
27# This script checks from the DB which new starfiles have been produced
28# and sends it to the person in charge for building datasets
29#
30
31#source `dirname $0`/sourcefile
32#printprocesslog "INFO starting $0"
33function usage()
34{
35 echo "Usage: $0 [options]"
36 echo "options:"
37 echo -n " --sequ sequence# "
38 echo -n " giving number of the sequence starting from which "
39 echo " sequences with star done are returned "
40 echo -n " --date "
41 echo -n " giving date starting from which sequences with star "
42 echo "done are returned"
43 echo ""
44 exit
45}
46
47
48while [ "$1" ]
49do
50 case $1 in
51 --sequ) shift
52 seq=$1
53 echo "Only sequences starting from sequence # $seq are considered"
54 ;;
55 --date) shift
56 date=$1
57 echo "Only star starting from date $date is considered"
58 ;;
59 -h) usage
60 ;;
61 *) echo "unknown option $1 "
62 usage
63 exit
64 ;;
65 esac
66 shift
67done
68
69alias mymysql='mysql -u MAGIC --password=d99swMT! --host=vela MyMagic -s -e'
70
71query="SELECT fSequenceFirst FROM SequenceProcessStatus WHERE NOT ISNULL(fStar) "
72cond=""
73if ! [ "$seq" = "" ]
74then
75 cond=$cond" AND SequenceProcessStatus.fSequenceFirst > $seq "
76fi
77if ! [ "$date" = "" ]
78then
79 cond=$cond" AND fStar > '$date'"
80fi
81query=$query$cond
82
83sequences=`mymysql " $query "`
84if [ "$sequences" = "" ]
85then
86 echo "no sequences with new star files found "
87 exit
88fi
89sequences2=`echo $sequences | sed -e 's/ /,/g'`
90query="SELECT fSourceKEY FROM Sequences WHERE fSequenceFirst IN ($sequences2) GROUP BY fSourceKEY"
91sources=`mymysql " $query "`
92sources2=`echo $sources | sed -e 's/ /,/g'`
93query="SELECT fSourceName FROM Source WHERE fSourceKEY IN ($sources2)"
94sourcenames=`mymysql " $query "`
95#echo "for the following sources new starfiles have been produced: $sourcenames"
96#echo ""
97for sourcename in $sourcenames
98do
99 query="SELECT Sequences.fSequenceFirst FROM Sequences "
100 query=$query" LEFT JOIN Source ON Source.fSourceKEY=Sequences.fSourceKEY "
101 query=$query" LEFT JOIN SequenceProcessStatus ON SequenceProcessStatus.fSequenceFirst=Sequences.fSequenceFirst "
102 query=$query"WHERE fSourceName='$sourcename'"
103 query=$query$cond
104 seqspersource=`mymysql " $query "`
105 seqs=`echo $seqspersource | sed -e 's/ /,/g'`
106 printf "star done for %12s the following new sequences: %s \n" $sourcename $seqs
107done
108
109for sourcename in $sourcenames
110do
111 echo "searching datasets for $sourcename"
112 if ! grep $sourcename /magic/test/bu.2006.10.10/datasets/*/*.txt 2>/dev/null
113 then
114 echo "sorry, no dataset found for $sourcename, please create a new dataset"
115 fi
116done
117
118
119#nail -s 'found warnings in '$oldprocesslog $erradrs
120
121#printprocesslog "INFO finished $0"
122
Note: See TracBrowser for help on using the repository browser.