source: branches/trigger_burst_research/Archive/associateRunsAndCalibs.sh@ 18481

Last change on this file since 18481 was 12871, checked in by lyard, 13 years ago
added more scripts
  • Property svn:executable set to *
File size: 35.8 KB
Line 
1#!/bin/bash
2
3#####################################
4#
5# CONFIGURATION VARIABLES
6#
7#####################################
8#temporary text files
9colDescFile="coldesc.lis"
10dataFile="data.lis"
11keywordsFile="keywords.lis"
12logfile="logfile.txt"
13#date for which the script should be run
14year=$1
15month=$2
16day=$3
17#target folders
18#sourceFolder="/data00/fact-construction"
19sourceFolder="/archive/fact/rev_1"
20targetFolder=`pwd`
21
22#make source folder relative to target
23common_part=$targetFolder
24back=
25while [ "$common_part" != "/" ] && [ "${sourceFolder#$common_part}" == "$sourceFolder" ]
26do
27 common_part=`dirname $common_part`
28 back="../${back}"
29# echo $common_part $back
30done
31baseFolder=$back${sourceFolder#$common_part}
32
33#remove useless artifacts from baseFolder
34pathChanged="true"
35while [ "$pathChanged" == "true" ]
36do
37 pathChanged="false"
38 newBaseFolder=`echo $baseFolder | sed -e 's/\/\//\//g'`
39 if [ "$newBaseFolder" != "$baseFolder" ]
40 then
41 pathChanged="true"
42 echo "$baseFolder >>> $newBaseFolder"
43 fi
44 baseFolder=$newBaseFolder
45done
46
47rawFolder=$baseFolder"/raw/"$year"/"$month"/"$day
48auxFolder=$baseFolder"/aux/"$year"/"$month"/"$day
49tempFile="./tempFile.txt"
50tempFits="./tempFits.fits"
51#input aux files
52trackingTable="DRIVE_CONTROL_TRACKING_POSITION"
53trackingFile=$auxFolder"/"$year$month$day"."$trackingTable".fits"
54triggerTable="FTM_CONTROL_TRIGGER_RATES"
55triggerFile=$auxFolder"/"$year$month$day"."$triggerTable".fits"
56staticTable="FTM_CONTROL_STATIC_DATA"
57staticFile=$auxFolder"/"$year$month$day"."$staticTable".fits"
58voltagesTable="BIAS_CONTROL_VOLTAGE"
59voltagesFile=$auxFolder"/"$year$month$day"."$voltagesTable".fits"
60currentsTable="BIAS_CONTROL_CURRENT"
61currentFile=$auxFolder"/"$year$month$day"."$currentsTable".fits"
62
63basePathAux=$auxFolder"/"$year$month$day
64
65auxTable="BIAS_CONTROL_NOMINAL"
66auxDesc="Some_Description"
67auxFile=$basePathAux"."$auxTable".fits"
68
69###########################################
70#
71# WRITE EXTRA AUX FILE
72# Writes an extra entry to the data file
73# Also checks for existence of said file
74#
75##########################################
76function writeExtraAuxFile() {
77
78 auxFile=$basePathAux"."$auxTable".fits"
79 if ! [ -e $auxFile ]
80 then
81 dummy=3
82 #echo "WARNING: Optionnal aux file "$auxFile" not found." | tee -a $logfile 2>&1
83 else
84 echo $auxTable" BINTABLE URL ../../../"$auxFile" 1 1 "$auxDesc >> $dataFile
85 fi
86}
87
88currentEntry=""
89roi=-1
90roiTM=-1
91runnumber=-1
92doNotDoThisEntry="false"
93###########################################
94#
95# WRITE HEADER KEYS TO INPUT FILE
96# Extract and write the header keywords to the above devined output text files.
97# These text files are then meant to feed the fits creation tool fcreate
98# Large parts of this function code were retaken from Daniela's scripts
99#
100###########################################
101function writeHeaderKeysToInputFile () {
102#echo "Writing header keys for "$currentEntry
103 #get all the missing data (everything appart from roi and roiTM)
104 runtype=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep RUNTYPE | grep -E -o "['][a-z-]+[']" | sed -e "s/'//g"`
105 numevents=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep Events | grep -E -o '[0-9]+'`
106 numphys=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'NTRG ' | grep -E -o '[0-9]+'`
107 numext1=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'NTRGEXT1' | grep -E -o "'[0-9]+'" | grep -E -o '[0-9]+'`
108 numext2=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'NTRGEXT2' | grep -E -o "'[0-9]+'" | grep -E -o '[0-9]+'`
109 numelp=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'NTRGLPE' | grep -E -o '[0-9]+'`
110 numilp=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'NTRGLPI' | grep -E -o '[0-9]+'`
111 numoth=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'NTRGMISC' | grep -E -o '[0-9]+'`
112 numped=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'NTRGPED' | grep -E -o '[0-9]+'`
113 numtime=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'NTRGTIM' | grep -E -o '[0-9]+'`
114 dateRaw=$year$month$day
115
116 if [ "$runtype" == "" ]
117 then
118 runtype="N/A"
119 fi
120 if [ "$numevents" == "" ]
121 then
122 numevents="0"
123 fi
124
125# dateRaw=`echo $currentEntry | grep -E -o '20[1-3][0-9][01][0-9][012][0-9]'`
126#echo "dateRaw: "$dateRaw" yearmonthday: "$year$month$day
127
128 # in newest data start time is in DATE-OBS
129 # in older data start time is in TSTART
130 # in the beginning TSTART was empty
131 runstart=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep DATE-OBS | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
132 runstart2=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep TSTART | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
133 if [ "$runstart" == "" ]
134 then
135 if [ "$runstart2" == "" ]
136 then
137 runstart=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep DATE | grep -v 'DATE-' | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
138 else
139 runstart=$runstart2
140 fi
141 fi
142 # in newest data start time is in DATE-END
143 # in older data start time is in TSTOP
144 # in the beginning TSTOP was empty
145 runstop=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep DATE-END | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
146 runstop2=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep TSTOP | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
147 if [ "$runstop" == "" ]
148 then
149 if [ "$runstop2" == "" ]
150 then
151 runstop=`stat $currentEntry 2>/dev/null | grep Modify | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9][ ][0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{9}'`
152 else
153 runstop=$runstop2
154 fi
155 fi
156
157 # set runtype to 'unknown' if no runtype could be queried
158 if [ "$runtype" == "" ]
159 then
160 runtype="n/a"
161 fi
162 # on 15.11.2011 the runtypes had different names
163 if [ "$date" == "2011/11/15" ]
164 then
165 if [ "$runtype" == "drs-calib" ]
166 then
167 runtype="drs-gain"
168 fi
169 if [ "$runtype" == "drs-time-calib" ]
170 then
171 runtype="drs-time"
172 fi
173 if [ "$runtype" == "pedestal" ]
174 then
175 runtype="drs-pedestal"
176 fi
177 if [ "$runtype" == "light-pulser" ]
178 then
179 runtype="light-pulser-ext"
180 fi
181 if [ "$runtype" == "pedestal-on" ]
182 then
183 runtype="pedestal"
184 fi
185 fi
186 #now take care of the slow control data.
187 #first get the start and stop time of the raw file
188
189 mjdref=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'`
190 tstarti=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'`
191 tstartf=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'`
192 tstopi=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'TSTOPI' | grep -E -o '[0-9]{5}'`
193 tstopf=`/opt/FACT++/fitsdump -h -t Events $currentEntry 2>/dev/null | grep 'TSTOPF' | grep -E -o '0[.][0-9]+'`
194 doNotDoThisEntry="false"
195 if [ "$tstarti" == "0" ] || [ "$tstopi" == "0" ] || [ "$mjdref" == "0" ]
196 then
197 echo "ERROR: "$currentEntry" has tstart, tstop or mjdref = 0"
198 fi
199
200 if [ "$tstartf" == "" ]
201 then
202 doNotDoThisEntry="true"
203 echo $currentEntry >> problemWithTSTART.txt
204 echo "WARNING: "$currentEntry" Has problems with Dates"
205 fi
206 if [ "$tstarti" == "" ]
207 then
208 tstarti="0"
209 fi
210 if [ "$tstopi" == "" ]
211 then
212 tstopi="0"
213 fi
214 if [ "$mjdref" == "" ]
215 then
216 mjdref="0"
217 fi
218 if [ "$tstartf" == "" ]
219 then
220 tstartf="0"
221 fi
222 if [ "$tstopf" == "" ]
223 then
224 tstopf="0"
225 fi
226
227 tstart=`echo " $tstarti + $mjdref + $tstartf " | bc -l`
228 tstop=`echo " $tstopi + $mjdref + $tstopf " | bc -l`
229 exposure=`echo "$tstop - $tstart " | bc -l`
230 exposure=`echo "$exposure * 86400" | bc -l `
231
232 #now get relevant data from daily files
233 #first get mjdref for the aux file and adapt start time accordingly
234 auxmjdref=`/opt/FACT++/fitsdump -h -t $trackingTable $trackingFile 2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'`
235 if [ "$auxmjdref" == "" ]
236 then
237 echo "ERROR: "$trackingFile" has no mjdref available. Aborting script"
238 exit
239 fi
240
241 tstartaux=`echo " $tstart - $auxmjdref " | bc -l`
242 tstopaux=`echo " $tstop - $auxmjdref " | bc -l`
243 ftcopy $trackingFile'[Time> '${tstartaux}' && Time< '${tstopaux}'][col Ra;Dec;Zd;Az;Time]' history=NO !$tempFits
244 /opt/FACT++/fitsdump $tempFits -c Ra --stat -o $tempFile 2>/dev/null
245 ramin=`grep 'Min' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
246 ramax=`grep 'Max' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
247 ramean=`grep 'Mea' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
248 if [ "$ramin" != "" ]
249 then
250 ramin=`echo "$ramin * 15" | bc -l`
251 ramax=`echo "$ramax * 15" | bc -l`
252 ramean=`echo "$ramean * 15" | bc -l`
253 fi
254 /opt/FACT++/fitsdump $tempFits -c Dec --stat -o $tempFile 2>/dev/null
255 decmin=`grep 'Min' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
256 decmax=`grep 'Max' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
257 decmean=`grep 'Mea' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
258 /opt/FACT++/fitsdump $tempFits -c Zd --stat -o $tempFile 2>/dev/null
259 zdmin=`grep 'Min' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
260 zdmax=`grep 'Max' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
261 zdmean=`grep 'Mea' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
262 /opt/FACT++/fitsdump $tempFits -c Az --stat -o $tempFile 2>/dev/null
263 azmin=`grep 'Min' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
264 azmax=`grep 'Max' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
265 azmean=`grep 'Mea' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
266
267 auxmjdref=`/opt/FACT++/fitsdump -h -t $triggerTable $triggerFile 2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'`
268 if [ "$auxmjdref" == "" ]
269 then
270 echo "ERROR: "$triggerFile" has no mjdref available. Aborting script"
271 exit
272 fi
273 tstartaux=`echo " $tstart - $auxmjdref " | bc -l`
274 tstopaux=`echo " $tstop - $auxmjdref " | bc -l`
275 ftcopy $triggerFile'[Time> '${tstartaux}' && Time< '${tstopaux}'][col TriggerRate;Time]' history=NO !$tempFits
276 /opt/FACT++/fitsdump $tempFits -c TriggerRate --stat -o $tempFile 2>/dev/null
277 ratemin=`grep 'Min' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
278 ratemax=`grep 'Max' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
279 ratemean=`grep 'Mea' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
280 ratemedian=`grep 'Med' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
281
282 auxmjdref=`/opt/FACT++/fitsdump -h -t $staticTable $staticFile 2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'`
283 if [ "$auxmjdref" == "" ]
284 then
285 echo "ERROR: "$staticFile" has no mjdref available. Aborting script"
286 exit
287 fi
288 iter=0
289 timeShift=0
290 threshmin=""
291 while [ "$threshmin" == "" ] && [ "$iter" != "10" ]
292 do
293 tstartaux=`echo " $tstart - $auxmjdref - $timeShift " | bc -l`
294 tstopaux=`echo " $tstop - $auxmjdref " | bc -l`
295 ftcopy $staticFile'[Time> '${tstartaux}' && Time< '${tstopaux}'][col PatchThresh;Time]' history=NO !$tempFits
296 /opt/FACT++/fitsdump $tempFits -c PatchThresh --stat -o $tempFile 2>/dev/null
297 threshmin=`grep 'Min' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
298 threshmax=`grep 'Max' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
299 threshmean=`grep 'Mea' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
300 threshmedian=`grep 'Med' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
301
302 timeShift=`echo " $timeShift + 0.00011574 " | bc -l`
303 iter=`echo " $iter + 1 " | bc -l`
304 done
305
306 #########################################################################################################################################################
307 auxmjdref=`/opt/FACT++/fitsdump -h -t $voltagesTable $voltagesFile 2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'`
308 if [ "$auxmjdref" == "" ]
309 then
310 echo "ERROR: "$voltagesFile" has no mjdref available. Aborting script"
311 exit
312 fi
313 iter=0
314 timeShift=0
315 biasvoltmin=""
316 while [ "$biasvoltmin" == "" ] && [ "$iter" != "10" ]
317 do
318 tstartaux=`echo " $tstart - $auxmjdref " | bc -l`
319 tstopaux=`echo " $tstop - $auxmjdref " | bc -l`
320 ftcopy $voltagesFile'[Time> '${tstartaux}' && Time< '${tstopaux}'][col U;Time]' !$tempFits
321 /opt/FACT++/fitsdump $tempFits -c U[0:319] --stat -o $tempFile 2>/dev/null
322 biasvoltmin=`grep 'Min' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
323 biasvoltmax=`grep 'Max' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
324 biasvoltmean=`grep 'Mea' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
325 biasvoltmedian=`grep 'Med' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
326 timeShift=`echo " $timeShift + 0.00011574 " | bc -l`
327 iter=`echo " $iter + 1 " | bc -l`
328
329 done
330
331 auxmjdref=`/opt/FACT++/fitsdump -h -t $currentsTable $currentFile 2>/dev/null | grep 'MJDREF' | grep -E -o '[0-9]{5}'`
332 if [ "$auxmjdref" == "" ]
333 then
334 echo "ERROR: "$currentFile" has no mjdref available. Aborting script"
335 exit
336 fi
337 iter=0
338 timeShift=0
339 biascurrentmin=""
340 while [ "$biascurrentmin" == "" ] && [ "$iter" != "10" ]
341 do
342 tstartaux=`echo " $tstart - $auxmjdref " | bc -l`
343 tstopaux=`echo " $tstop - $auxmjdref " | bc -l`
344 ftcopy $currentFile'[Time> '${tstartaux}' && Time< '${tstopaux}'][col I;Time]' !$tempFits
345 /opt/FACT++/fitsdump $tempFits -c I[0:319] --stat -o $tempFile 2>/dev/null
346 biascurrentmin=`grep 'Min' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
347 biascurrentmax=`grep 'Max' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
348 biascurrentmean=`grep 'Mea' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
349 biascurrentmedian=`grep 'Med' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
350 timeShift=`echo " $timeShift + 0.00011574 " | bc -l`
351 iter=`echo " $iter + 1 " | bc -l`
352
353#echo "biascurrent min, max. mean, median: "$biascurrentmin" "$biascurrentmax" "$biascurrentmean" "$biascurrentmedian
354 done
355
356 #write the retrieved data to the input file for creating fits afterwards
357 echo "RUNTYPE "$runtype" / run type" >> $keywordsFile
358 echo "ROI "$roi" / region of interest" >> $keywordsFile
359 echo "ROITM "$roiTM" / Roi for time markers" >> $keywordsFile
360 echo "NUMEVENT "$numevents" / number of events" >> $keywordsFile
361 echo "NUMPHYS "$numphys" / num of physical triggers" >> $keywordsFile
362 echo "NUMEXT1 "$numext1" / num of Light pulser 1 triggers" >> $keywordsFile
363 echo "NUMEXT2 "$numext2" / num of Light pulser 2 triggers" >> $keywordsFile
364 echo "NUMELP "$numelp" / num of external Light pulser triggers" >> $keywordsFile
365 echo "NUMILP "$numilp" / num of internal Light pulser triggers" >> $keywordsFile
366 echo "NUMOTH "$numoth" / num of other triggers" >> $keywordsFile
367 echo "NUMPED "$numped" / num of pedestal triggers" >> $keywordsFile
368 echo "NUMTIME "$numtime" / num of time calibration triggers" >> $keywordsFile
369 echo "DATEOBS "$runstart" / start of observation" >> $keywordsFile
370 echo "MJDREF "$mjdref" / reference of MjD values" >> $keywordsFile
371 echo "EXPOSURE "$exposure" /duration of run" >> $keywordsFile
372 echo "TSTARTI "$tstarti" / first event arrival time (int)" >> $keywordsFile
373 echo "TSTARTF "$tstartf" / first event arrival time (frac)" >> $keywordsFile
374 echo "TSTOPI "$tstopi" / last event arrival time (int)" >> $keywordsFile
375 echo "TSTOPF "$tstopf" / last event arrival time (frac)" >> $keywordsFile
376 echo "RAMIN "$ramin" / min value of right ascension" >> $keywordsFile
377 echo "RAMAX "$ramax" / max value of right ascension" >> $keywordsFile
378 echo "RAMEAN "$ramean" / mean value of right ascension" >> $keywordsFile
379 echo "DECMIN "$decmin" / min value of declination" >> $keywordsFile
380 echo "DECMAX "$decmax" / max value of declination" >> $keywordsFile
381 echo "DECMEAN "$decmean" / mean value of declination" >> $keywordsFile
382 echo "ZDMIN "$zdmin" / min value of zenith distance" >> $keywordsFile
383 echo "ZDMAX "$zdmax" / max value of zenith distance" >> $keywordsFile
384 echo "ZDMEAN "$zdmean" / mean value of zenith distance" >> $keywordsFile
385 echo "AZMIN "$azmin" / min value of azimuth" >> $keywordsFile
386 echo "AZMAX "$azmax" / max value of azimuth" >> $keywordsFile
387 echo "AZMEAN "$azmean" / mean value of azimuth" >> $keywordsFile
388 echo "RATEMIN "$ratemin" / min value of trigger rates" >> $keywordsFile
389 echo "RATEMAX "$ratemax" / max value of trigger rates" >> $keywordsFile
390 echo "RATEMEAN "$ratemean" / mean value of trigger rates" >> $keywordsFile
391 echo "RATEMED "$ratemedian" / median value of trigger rates" >> $keywordsFile
392 echo "THRESMIN "$threshmin" / min threshold value" >> $keywordsFile
393 echo "THRESMAX "$threshmax" / max threshold value" >> $keywordsFile
394 echo "THRESMEA "$threshmean" / mean threshold value" >> $keywordsFile
395 echo "THRESMED "$threshmedian" / max threshold value" >> $keywordsFile
396 echo "BIASVMIN "$biasvoltmin" / min bias voltage (V)" >> $keywordsFile
397 echo "BIASVMAX "$biasvoltmax" / max bias voltage (V)" >> $keywordsFile
398 echo "BIASVMEA "$biasvoltmean" / mean bias voltage (V)" >> $keywordsFile
399 echo "BIASVMED "$biasvoltmedian" / median bias voltage (V)" >> $keywordsFile
400 echo "BIASAMIN "$biascurrentmin" / min bias current (uA)" >> $keywordsFile
401 echo "BIASAMAX "$biascurrentmax" / max bias current (uA)" >> $keywordsFile
402 echo "BIASAMEA "$biascurrentmean" / mean bias current (uA)" >> $keywordsFile
403 echo "BIASAMED "$biascurrentmedian" / median bias current (uA)" >> $keywordsFile
404
405
406 echo "EXTNAME GROUPING / grouping table" >> $keywordsFile
407 echo "GRPNAME FACT-RAW / name of group" >> $keywordsFile
408 echo "RUNNUM "$runnumber" / run number" >> $keywordsFile
409 echo "RUNID "$dateRaw"_"$runnumber" / Run Id" >> $keywordsFile
410
411}
412
413#today=`date +%F`
414#alias alsoToLog='tee -a $logfile 2>&1'
415
416#echo "" | tee -a $logfile 2>&1
417#echo "" | tee -a $logfile 2>&1
418#echo "" | tee -a $logfile 2>&1
419
420#cleanup logfile
421rm -f $logfile
422
423#echo `date`" executing "$0 | tee -a $logfile 2>&1
424
425
426
427#first of all, let's make sure that required slow control files are present
428if ! [ -e $trackingFile ]
429then
430 echo "ERROR: Required aux file "$trackingFile" not found. Aborting script" | tee -a $logfile 2>&1
431 exit
432fi
433if ! [ -e $triggerFile ]
434then
435 echo "ERROR: Required aux file "$triggerFile" not found. Aborting script" | tee -a $logfile 2>&1
436 exit
437fi
438if ! [ -e $staticFile ]
439then
440 echo "ERROR: Required aux file "$staticFile" not found. Aborting script" | tee -a $logfile 2>&1
441 exit
442fi
443if ! [ -e $voltagesFile ]
444then
445 echo "ERROR: Required aux file "$voltagesFile" not found. Aborting script" | tee -a $logfile 2>&1
446 exit
447fi
448if ! [ -e $currentFile ]
449then
450 echo "ERROR: Required aux file "$currentFile" not found. Aborting script" | tee -a $logfile 2>&1
451 exit
452fi
453
454#next define the format of the grouping file
455
456rm -f $colDescFile
457echo "MEMBER_NAME 60A" >> $colDescFile
458echo "MEMBER_XTENSION 8A" >> $colDescFile
459echo "MEMBER_URI_TYPE 3A" >> $colDescFile
460echo "MEMBER_LOCATION 256A" >> $colDescFile
461echo "MEMBER_VERSION 1J" >> $colDescFile
462echo "MEMBER_POSITION 1J" >> $colDescFile
463echo "DATA_TYPE 60A" >> $colDescFile
464
465entries=`find $rawFolder -type f -name '*.fits.gz' | sort`
466calibs=""
467calibFiles=""
468calibDrsFiles=""
469calibDrsPedestalFiles=""
470calibsRoi=""
471calibsRoiTM=""
472
473#data=""
474#correspondingCalib=""
475numCalibs=0
476#numData=0
477
478if [ "$year" == "" ]
479then
480 echo "Missing year argument"
481 exit
482fi
483
484if [ "$month" == "" ]
485then
486 echo "Missing month argument"
487 exit
488fi
489
490if [ "$day" == "" ]
491then
492 echo "Missing day argument"
493 exit
494fi
495
496numEntries=0
497for item in ${entries[@]}
498do
499 numEntries=`expr $numEntries + 1`
500done
501
502echo "There are "$numEntries" entries to examine in folder "$rawFolder | tee -a $logfile 2>&1
503
504#echo "Will now erase entries generated previously..."
505#toDelete=`find $targetFolder -type f -name '*_raw.fits' | sort`
506#for delete in ${toDelete[@]}
507#do
508# echo "removing "$delete
509# rm $delete
510#done
511#toDelete=`find $targetFolder -type f -name '*_raw.txt' | sort`
512#for delete in ${toDelete[@]}
513#do
514# echo "removing $delete"
515# rm $delete
516#done
517#echo "done"
518
519for entry in ${entries[@]}
520do
521 filename=`echo $entry | grep -E -o '20[1-9][0-9][01][0-9][0-3][0-9]_[0-9]{3}'`
522 filedate=`echo $filename | cut -d_ -f1`
523 runnumberInter=`echo $filename | cut -d_ -f2 | sed -e 's/^0//g' -e 's/^0//g'`
524 runnumber=`printf %03d $runnumberInter`
525 #figure out whether this is a drs calib
526 if [ "`echo $entry | grep drs`" != "" ]
527 then
528 #check if this is the pedestal run. for this, grep the associated raw data file and check for previous calibrations (drs pedestal and drs gain)
529 minusOne=`expr $runnumber - 1`
530 minusOne=`printf %03d $minusOne`
531 minusTwo=`expr $runnumber - 2`
532 minusTwo=`printf %03d $minusTwo`
533 pedestalRaw=$rawFolder/$filename.fits.gz
534 DrsGainRaw=$rawFolder/$filedate"_"$minusOne.fits.gz
535 DrsPedestalRaw=$rawFolder/$filedate"_"$minusTwo.fits.gz
536 DrsGain=$rawFolder/$filedate"_"$minusOne.drs.fits.gz
537 DrsPedestal=$rawFolder/$filedate"_"$minusTwo.drs.fits.gz
538 pedestalkey=""
539 drsGainKey=""
540 drsPedestalKey=""
541 if [ -f $pedestalRaw ]
542 then
543 pedestalKey=`/opt/FACT++/fitsdump -h $pedestalRaw 2>/dev/null | grep "'pedestal'"`
544 fi
545 if [ "$pedestalKey" == "" ]
546 then #the current drs file is NOT a pedestal. Continue
547 continue
548 fi
549# echo "Found Pedestal entry "$entry
550 if [ -f $DrsGainRaw ] && [ -f $DrsGain ]
551 then
552 drsGainKey=`/opt/FACT++/fitsdump -h $DrsGainRaw 2>/dev/null | grep "'drs-gain'"`
553 else
554 DrsGain=""
555 fi
556 if [ -f $DrsPedestalRaw ] && [ -f $DrsPedestal ]
557 then
558 drsPedestalKey=`/opt/FACT++/fitsdump -h $DrsPedestalRaw 2>/dev/null | grep "'drs-pedestal'"`
559 else
560 DrsPedestal=""
561 fi
562
563 if [ "$drsPedestalKey" != "" ]
564 then
565 calibtstarti=`/opt/FACT++/fitsdump -h $DrsPedestalRaw 2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'`
566 calibtstartf=`/opt/FACT++/fitsdump -h $DrsPedestalRaw 2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'`
567 else
568 if [ "$drsGainKey" != "" ]
569 then
570 calibtstarti=`/opt/FACT++/fitsdump -h $DrsGainRaw 2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'`
571 calibtstartf=`/opt/FACT++/fitsdump -h $DrsGainRaw 2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'`
572 else
573 calibtstarti=`/opt/FACT++/fitsdump -h $pedestalRaw 2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'`
574 calibtstartf=`/opt/FACT++/fitsdump -h $pedestalRaw 2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'`
575 fi
576 fi
577 calibtstopi=`/opt/FACT++/fitsdump -h $pedestalRaw 2>/dev/null | grep 'TSTOPI' | grep -E -o '[0-9]{5}'`
578 calibtstopf=`/opt/FACT++/fitsdump -h $pedestalRaw 2>/dev/null | grep 'TSTOPF' | grep -E -o '0[.][0-9]+'`
579
580 auxstarti=`/opt/FACT++/fitsdump -h $voltagesFile 2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'`
581 auxstartf=`/opt/FACT++/fitsdump -h $voltagesFile 2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'`
582
583 if [ "$auxstarti" == "" ]
584 then
585 auxstarti="0"
586 fi
587 if [ "$auxstartf" == "" ]
588 then
589 auxstartf="0"
590 fi
591 if [ "$calibtstarti" == "" ]
592 then
593 calibtstarti="0"
594 fi
595 if [ "$calibtstartf" == "" ]
596 then
597 calibtstartf="0"
598 fi
599 if [ "$calibtstopi" == "" ]
600 then
601 calibtstopi="0"
602 fi
603 if [ "$calibtstopf" == "" ]
604 then
605 calibtstopf="0"
606 fi
607
608 auxstart=`echo " $auxstarti + 40587 + $auxstartf " | bc -l`
609 calibtstart=`echo " $calibtstarti + 40587 + $calibtstartf " | bc -l`
610 calibtstop=`echo " $calibtstopi + 40587 + $calibtstopf " | bc -l`
611 iter=0
612 timeShift=0
613 biasvoltmean=""
614 tstartaux=`echo " $calibtstart - 40587 - $timeShift" | bc -l`
615 compare=`echo " $tstartaux >= $auxstart " | bc -l`
616
617 while [ "$biasvoltmean" == "" ] && [ "$iter" != "10" ] && [ "$compare" == "1" ]
618 do
619 tstartaux=`echo " $calibtstart - 40587 - $timeShift" | bc -l`
620 compare=`echo " $tstartaux >= $auxstart " | bc -l`
621 tstopaux=`echo " $calibtstop - 40587 " | bc -l`
622 ftcopy $voltagesFile'[Time> '${tstartaux}' && Time< '${tstopaux}'][col U;Time]' !$tempFits
623 /opt/FACT++/fitsdump $tempFits -c U[0:319] --stat -o $tempFile 2>/dev/null
624 biasvoltmean=`grep 'Mea' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
625 timeShift=`echo " $timeShift + 0.000011574 " | bc -l`
626 iter=`echo " $iter + 1 " | bc -l`
627 done
628 auxstarti=`/opt/FACT++/fitsdump -h $currentFile 2>/dev/null | grep 'TSTARTI' | grep -E -o '[0-9]{5}'`
629 auxstartf=`/opt/FACT++/fitsdump -h $currentFile 2>/dev/null | grep 'TSTARTF' | grep -E -o '0[.][0-9]+'`
630 auxstart=`echo " $auxstarti + $auxstartf " | bc -l`
631 iter=0
632 timeShift=0
633 biascurrentmean=""
634 tstartaux=`echo " $calibtstart - 40587 - $timeShift" | bc -l`
635 compare=`echo " $tstartaux >= $auxstart " | bc -l`
636 while [ "$biascurrentmean" == "" ] && [ "$iter" != "10" ] && [ "$compare" == "1" ]
637 do
638 tstartaux=`echo " $calibtstart - 40587 - $timeShift " | bc -l`
639 compare=`echo " $tstartaux >= $auxstart " | bc -l`
640 tstopaux=`echo " $calibtstop - 40587 " | bc -l`
641 ftcopy $currentFile'[Time> '${tstartaux}' && Time< '${tstopaux}'][col I;Time]' !$tempFits
642 /opt/FACT++/fitsdump $tempFits -c I[0:319] --stat -o $tempFile 2>/dev/null
643 biascurrentmean=`grep 'Mea' $tempFile | grep -E -o '[-]*[0-9]*[.]*[0-9]+'`
644 timeShift=`echo " $timeShift + 0.000011574 " | bc -l`
645 iter=`echo " $iter + 1 " | bc -l`
646 done
647
648 if [ "$biasvoltmean" == "" ]
649 then
650 biasvoltmean=0
651 fi
652# echo "Bias voltage: "$biasvoltmean
653 if [ "$biascurrentmean" == "" ]
654 then
655 biascurrentmean=0
656 fi
657 compare=`echo " $biascurrentmean < 5 " | bc -l`
658 if [ "$pedestalKey" != "" ] && [ "$drsGainKey" != "" ] && [ "$drsPedestalKey" != "" ] && [ "$biasvoltmean" == "0" ] && [ "$compare" == "1" ]
659 then
660 calibFiles[$numCalibs]=$entry
661 calibs[$numCalibs]=$runnumber
662 calibDrsFiles[$numCalibs]=$DrsGain
663 calibDrsPedestalFiles[$numCalibs]=$DrsPedestal
664 calibsRoi[$numCalibs]=`/opt/FACT++/fitsdump -h -t DrsCalibration $entry 2>/dev/null | grep NROI | grep -v NROITM | grep -E -o '[0-9]{1,4}'`
665 calibsRoiTM[$numCalibs]=`/opt/FACT++/fitsdump -h -t DrsCalibration $entry 2>/dev/null | grep NTM | grep -E -o '[0-9]{1,4}'`
666 #echo "Calib file #"$runnumber" found. Roi=${calibsRoi[$numCalibs]} RoiTM="${calibsRoiTM[$numCalibs]}
667 numCalibs=`expr $numCalibs + 1`
668 fi
669 continue
670 fi
671
672 #if not calib, then look if this is a calibration run (i.e. run that created the drs calib)
673 correspondingDrs=$rawFolder/$filename.drs.fits.gz
674 if [ -f $correspondingDrs ]
675 then
676 continue
677 fi
678 #if regular run, add its run number, and figure out a proper calibration file
679 data[$numData]=$runnumber
680 calibFound="false"
681 partialCalibFound="false"
682 calibIndex=`expr $numCalibs - 1`
683
684 #if there is no calib available, report error
685 if [ "$numCalibs" == "0" ]
686 then
687 calibFound="notFound"
688 fi
689 while [ "$calibFound" == "false" ]
690 do
691 roi=`/opt/FACT++/fitsdump -h -t Events $entry 2>/dev/null | grep NROI | grep -v NROITM | grep -E -o '[0-9]{1,4}'`
692 roiTM=`/opt/FACT++/fitsdump -h -t Events $entry 2>/dev/null | grep NROITM | grep -E -o '[0-9]{1,4}'`
693 if [ "$roi" == "${calibsRoi[$calibIndex]}" ] && [ "$roiTM" == "${calibsRoiTM[$calibIndex]}" ]
694 then
695 if [ "${calibDrsFiles[$calibIndex]}" != "" ] && [ "${calibDrsPedestalFiles[$calibIndex]}" != "" ]
696 then
697 calibFound="true"
698 break
699 else
700 if [ "$partialCalibFound" == "false" ]
701 then
702 partialCalibFound=$calibIndex
703 fi
704 fi
705 fi
706 calibIndex=`expr $calibIndex - 1`
707 if [ "$calibIndex" == "-1" ]
708 then
709 calibFound="notFound"
710 fi
711 done
712
713 if [ "$partialCalibFound" != "false" ] && [ "$calibFound" != "true" ]
714 then
715 calibFound=""
716 calibIndex=$partialCalibFound
717 fi
718
719 if [ "$calibFound" == "true" ]
720 then
721 calibFound="complete"
722 fi
723
724 if [ "$calibFound" == "notFound" ]
725 then
726 echo "No suitable calibration file could be found for run $runnumber" | tee -a $logfile 2>&1
727 calibFileString="NULL"
728 calibDrsString="NULL"
729 calibDrsPedestalString="NULL"
730 else
731 echo "Found $calibFound calibration "${calibs[$calibIndex]}" for run "$runnumber" with Roi="$roi" and roiTM="$roiTM | tee -a $logfile 2>&1
732 calibFileString=${calibFiles[$calibIndex]}
733 calibDrsString=${calibDrsFiles[$calibIndex]}
734 calibDrsPedestalString=${calibDrsPedestalFiles[$calibIndex]}
735 if [ "$calibDrsString" == "" ]
736 then
737 calibDrsString="NULL"
738 fi
739 if [ "$calibDrsPedestalString" == "" ]
740 then
741 calibDrsPedestalString="NULL"
742 fi
743 fi
744
745 #File is valid. get its related informations
746 currentEntry=$entry
747 rm -f $keywordsFile
748 rm -f $dataFile
749 writeHeaderKeysToInputFile
750 if [ "$doNotDoThisEntry" == "true" ]
751 then
752 continue
753 fi
754 #Header keys written for raw data. do the same for related aux data
755 echo "Events BINTABLE URL ../../../"$entry" 1 1 Events" >> $dataFile
756 if [ "$calibFileString" != "NULL" ]
757 then
758 echo "DrsCalibration BINTABLE URL ../../../"$calibFileString" 1 1 Pedestal" >> $dataFile
759 fi
760 if [ "$calibDrsString" != "NULL" ]
761 then
762 echo "DrsCalibration BINTABLE URL ../../../"$calibDrsString" 1 1 Drs_Gain" >> $dataFile
763 fi
764 if [ "$calibDrsPedestalString" != "NULL" ]
765 then
766 echo "DrsCalibration BINTABLE URL ../../../"$calibDrsPedestalString" 1 1 Drs_Pedestal" >> $dataFile
767 fi
768 echo "DRIVE_CONTROL_TRACKING_POSITION BINTABLE URL ../../../"$trackingFile" 1 1 Tracking_Position" >> $dataFile
769 echo "FTM_CONTROL_TRIGGER_RATE BINTABLE URL ../../../"$triggerFile" 1 1 Trigger_Rate" >> $dataFile
770 echo "FTM_CONTROL_STATIC_DATA BINTABLE URL ../../../"$staticFile" 1 1 Thresholds" >> $dataFile
771 echo "BIAS_CONTROL_VOLTAGE BINTABLE URL ../../../"$voltagesFile" 1 1 Voltages" >> $dataFile
772 echo "BIAS_CONTROL_CURRENT BINTABLE URL ../../../"$currentFile" 1 1 Currents" >> $dataFile
773
774 if [ "$calibFound" != "notFound" ]
775 then
776 #write info to Werner's file
777 if [ "$runtype" == "custom" ]
778 then
779 runtype="custom____________"
780 fi
781 if [ "$runtype" == "data" ]
782 then
783 runtype="data______________"
784 fi
785 if [ "$runtype" == "drs-gain" ]
786 then
787 runtype="drs-gain__________"
788 fi
789 if [ "$runtype" == "drs-gain-ext" ]
790 then
791 runtype="drs-gain-ext______"
792 fi
793 if [ "$runtype" == "drs-pedestal" ]
794 then
795 runtype="drs-pedestal______"
796 fi
797 if [ "$runtype" == "drs-pedestal-ext" ]
798 then
799 runtype="drs-pedestal-ext__"
800 fi
801 if [ "$runtype" == "drs-time" ]
802 then
803 runtype="drs-time__________"
804 fi
805 if [ "$runtype" == "drs-time-delay15" ]
806 then
807 runtype="drs-time-delay15__"
808 fi
809 if [ "$runtype" == "drs-time-delay05" ]
810 then
811 runtype="drs-time-delay05__"
812 fi
813 if [ "$runtype" == "drs-time-delay20" ]
814 then
815 runtype="drs-time-delay20__"
816 fi
817 if [ "$runtype" == "drs-time-upshifted" ]
818 then
819 runtype="drs-time-upshifted"
820 fi
821 if [ "$runtype" == "light-pulser-ext" ]
822 then
823 runtype="light-pulser-ext__"
824 fi
825 if [ "$runtype" == "n/a" ]
826 then
827 runtype="n/a_______________"
828 fi
829 if [ "$runtype" == "ped-and-lp-ext" ]
830 then
831 runtype="ped-and-lp-ex_____"
832 fi
833 if [ "$runtype" == "pedestal" ]
834 then
835 runtype="pedestal__________"
836 fi
837 targetWerner=$targetFolder"/"$year"/"$month
838 if [ ! -d $targetWerner ]
839 then
840 mkdir -p $targetWerner
841 fi
842 wernerFile=$targetWerner"/"$year$month"_001.txt"
843 if [ ! -f $wernerFile ]
844 then
845 echo "creating "$wernerFile
846 echo "# DRS DAT DD MM YYYY TYPE " >> $wernerFile
847 fi
848 echo " "${calibs[$calibIndex]}" "$runnumber" "$day" "$month" "$year" "$runtype >> $wernerFile
849 fi
850
851 #now add the "other" slow control files, i.e. the ones that are not mandatory for analysis
852 auxTable="BIAS_CONTROL_NOMINAL"
853 auxDesc="Bias_Control"
854 writeExtraAuxFile
855 auxTable="BIAS_CONTROL_STATE"
856 auxDesc="Bias_State"
857 writeExtraAuxFile
858 auxTable="DATA_LOGGER_FILENAME_NIGHTLY"
859 auxDesc="Logger_Filename_Night"
860 writeExtraAuxFile
861 auxTable="DATA_LOGGER_FILENAME_RUN"
862 auxDesc="Logger_Filename_Run"
863 writeExtraAuxFile
864 auxTable="DATA_LOGGER_NUM_SUBS"
865 auxDesc="Logger_num_subs"
866 writeExtraAuxFile
867 auxTable="DATA_LOGGER_STATE"
868 auxDesc="Logger_State"
869 writeExtraAuxFile
870 auxTable="DATA_LOGGER_STATS"
871 auxDesc="Logger_Statistics"
872 writeExtraAuxFile
873 auxTable="DRIVE_CONTROL_POINTING_POSITION"
874 auxDesc="Pointing_Position"
875 writeExtraAuxFile
876 auxTable="DRIVE_CONTROL_STATE"
877 auxDesc="Drive_State"
878 writeExtraAuxFile
879 auxTable="DRIVE_CONTROL_STATUS"
880 auxDesc="Drive_Status"
881 writeExtraAuxFile
882 auxTable="FAD_CONTROL_DAC"
883 auxDesc="FAD_DAC"
884 writeExtraAuxFile
885 auxTable="FAD_CONTROL_DNA"
886 auxDesc="FAD_DNA"
887 writeExtraAuxFile
888 auxTable="FAD_CONTROL_DRS_CALIBRATION"
889 auxDesc="FAD_Drs_Calibration"
890 writeExtraAuxFile
891 auxTable="FAD_CONTROL_EVENTS"
892 auxDesc="FAD_Events"
893 writeExtraAuxFile
894 auxTable="FAD_CONTROL_FEEDBACK_DATA"
895 auxDesc="FAD_Feedback_Data"
896 writeExtraAuxFile
897 auxTable="FAD_CONTROL_FILE_FORMAT"
898 auxDesc="FAD_File_Format"
899 writeExtraAuxFile
900 auxTable="FAD_CONTROL_FIRMWARE_VERSION"
901 auxDesc="FAD_Firmware_Version"
902 writeExtraAuxFile
903 auxTable="FAD_CONTROL_PRESCALER"
904 auxDesc="FAD_Prescaler"
905 writeExtraAuxFile
906 auxTable="FAD_CONTROL_REFERENCE_CLOCK"
907 auxDesc="FAD_Reference_Clock"
908 writeExtraAuxFile
909 auxTable="FAD_CONTROL_REGION_OF_INTEREST"
910 auxDesc="FAD_ROI"
911 writeExtraAuxFile
912 auxTable="FAD_CONTROL_RUN_NUMBER"
913 auxDesc="FAD_Run_Number"
914 writeExtraAuxFile
915 auxTable="FAD_CONTROL_RUNS"
916 auxDesc="FAD_Runs"
917 writeExtraAuxFile
918 auxTable="FAD_CONTROL_START_RUN"
919 auxDesc="FAD_Start_Run"
920 writeExtraAuxFile
921 auxTable="FAD_CONTROL_STATE"
922 auxDesc="FAD_State"
923 writeExtraAuxFile
924 auxTable="FAD_CONTROL_STATISTICS1"
925 auxDesc="FAD_Statistics_1"
926 writeExtraAuxFile
927 auxTable="FAD_CONTROL_STATISTICS2"
928 auxDesc="FAD_Statistics_2"
929 writeExtraAuxFile
930 auxTable="FAD_CONTROL_STATS"
931 auxDesc="FAD_Stats"
932 writeExtraAuxFile
933 auxTable="FAD_CONTROL_STATUS"
934 auxDesc="FAD_Status"
935 writeExtraAuxFile
936 auxTable="FAD_CONTROL_TEMPERATURE"
937 auxDesc="FAD_Temperatures"
938 writeExtraAuxFile
939 auxTable="FEEDBACK_DEVIATION"
940 auxDesc="Feedback_Deviation"
941 writeExtraAuxFile
942 auxTable="FEEDBACK_STATE"
943 auxDesc="Feedback_State"
944 writeExtraAuxFile
945 auxTable="FSC_CONTROL_HUMIDITY"
946 auxDesc="FSC_Humidity"
947 writeExtraAuxFile
948 auxTable="FSC_CONTROL_STATE"
949 auxDesc="FSC_State"
950 writeExtraAuxFile
951 auxTable="FSC_CONTROL_TEMPERATURE"
952 auxDesc="FSC_Temperature"
953 writeExtraAuxFile
954 auxTable="FTM_CONTROL_COUNTER"
955 auxDesc="FTM_Counter"
956 writeExtraAuxFile
957 auxTable="FTM_CONTROL_DYNAMIC_DATA"
958 auxDesc="FTM_Dynamic_Data"
959 writeExtraAuxFile
960 auxTable="FTM_CONTROL_FTU_LIST"
961 auxDesc="FTM_FTU_List"
962 writeExtraAuxFile
963 auxTable="FTM_CONTROL_PASSPORT"
964 auxDesc="FTM_Passeport"
965 writeExtraAuxFile
966 auxTable="FTM_CONTROL_STATE"
967 auxDesc="FTM_State"
968 writeExtraAuxFile
969 auxTable="MAGIC_WEATHER_DATA"
970 auxDesc="MAGIC_Weather_Data"
971 writeExtraAuxFile
972 auxTable="MAGIC_WEATHER_STATE"
973 auxDesc="MAGIC_Weather_State"
974 writeExtraAuxFile
975 auxTable="MCP_STATE"
976 auxDesc="MCP_State"
977 writeExtraAuxFile
978 auxTable="RATE_CONTROL_STATE"
979 auxDesc="Rate_Control_State"
980 writeExtraAuxFile
981 #create the fits file
982 targetNormal=$targetFolder"/"$year"/"$month"/"$day
983 if [ ! -d $targetNormal ]
984 then
985 mkdir -p $targetNormal
986 fi
987 targetFile=$targetNormal"/"$year$month$day"_"$runnumber"_001.fits"
988 if [ -f $targetFile ]
989 then
990 rm $targetFile
991 fi
992 fcreate $colDescFile $dataFile $targetFile "headfile="$keywordsFile
993 echo "Created "$targetFile | tee -a $logfile 2>&1
994
995done
Note: See TracBrowser for help on using the repository browser.