-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicore_wrapper_executable.tcsh
More file actions
executable file
·727 lines (593 loc) · 28.6 KB
/
icore_wrapper_executable.tcsh
File metadata and controls
executable file
·727 lines (593 loc) · 28.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
#! /bin/tcsh -fe
#===============================================================================================================================================================
set wrapperDir = $PWD
set startTime = `date '+%m/%d/%Y %H:%M:%S'`
echo
echo Wrapper Started at:
echo $startTime
echo
echo Version 2.08
echo
echo This Wrapper will wrap around and run these 3 programs:
echo 1\) fbt3 and PSFavr8
echo 2\) ICORE
echo 3\) MDET
echo
set SNRthreshold = 1.8
#check hyphenated argument
@ i = 0
set arg_SNR = ""
set rsyncSet = "false"
while ($i < $# + 1)
#user input -SNR argument
if("$argv[$i]" == "-SNR") then
@ temp = $i + 1
if($temp < $# + 1) then
if($argv[$temp] != "") then
set arg_SNR = $argv[$temp]
set SNRthreshold = $arg_SNR
echo Custom SNR == $arg_SNR
else
echo please enter SNR after '-SNR'
endif
else
echo please enter SNR after '-SNR'
endif
else if("$argv[$i]" == "-p") then
#parallel mode, ignore setup environment
echo parallelmode3 called
set ParentDir = $2
set RadecID = $3
echo Parent Dir == $ParentDir
echo Tile Name == $RadecID
echo
goto ParallelMode3
else if("$argv[$i]" == "-rsync") then
echo Argument "-rsync" detected. Will rsync Tyto, Otus, and Athene.
set rsyncSet = "true"
endif
@ i += 1
end
if ($# < 2) then #($# != 2 && $# != 3) then
#Error handling
#Too many or too little arguments
echo ""
echo "ERROR: not enough arguments:"
echo Mode 1 call:
echo ./icore_wrapper_executable_opt1.tcsh 1 ParentDir/
echo Mode 2 call:
echo ./icore_wrapper_executable_opt1.tcsh 2 ParentDir/ ParentDir/
echo Mode 3 call:
echo ./icore_wrapper_executable_opt1.tcsh 3 ParentDir/ TileName
echo
echo Exiting...
exit
#Mode1
else if ($1 == 1) then
set ParentDir = $2
set InputsDir = ${ParentDir}/UnWISE/
set OutputsDir = ${ParentDir}/CatWISE/
echo Inputs directory == $InputsDir
echo Outputs directory == $OutputsDir
echo "Are these the correct input and output directories? (y/n)"
set userInput = $<
#Error handling
#if user input dir wrong
if($userInput != "Y" && $userInput != "y") then
echo Please execute program again with full Input Directory path as the 2nd parameter and the Ouput Directory path as your 3rd parameter
#TODO actually throw an error instead of just outputing to stdout... output to stderr
echo
echo Exiting...
exit
endif
#if directories dont exist, throw error
if(! -d $InputsDir) then
echo ERROR: Input Directory $InputsDir doest not exist.
echo
echo Exiting...
exit
endif
#Don't need to check since OutputsDir is made if DNE
# if (! -d $OutputsDir) then
# echo ERROR: Output Directory $OutputsDir does not exist.
# echo
# echo Exiting...
# exit
# endif
goto Mode1
#Mode2 List of Tiles Mode
else if ($1 == 2) then
set InputsList = $3
set ParentDir = $2
echo Inputs list == $InputsList
echo Parent directory == $ParentDir
echo
echo "Is this the correct input list and Parent directory? (y/n)"
set userInput = $<
#Error handling
#if user input dir wrong
if($userInput != "Y" && $userInput != "y") then
echo Please execute program again with full Input List file as the 2nd parameter and the Parent Directory path as your 3rd parameter
#TODO actually throw an error instead of just outputing to stdout... output to stderr
echo
echo Exiting...
exit
endif
#if directories dont exist, throw error
if(! -f $InputsList) then
echo ERROR: Input List file $InputsList doest not exist.
echo
echo Exiting...
exit
endif
if (! -d $ParentDir) then
echo ERROR: Parent Directory $ParentDir does not exist.
echo
echo Exiting...
exit
endif
goto Mode2
#Mode3 Single Tile Mode
else if ($1 == 3) then
set ParentDir = $2
set RadecID = $3
echo Parent Dir == $ParentDir
echo Tile Name == $RadecID
echo
echo "Is this the correct Parent Directory and Tile Name? (y/n)"
set userInput = $<
#Error handling
#if user input dir wrong
if($userInput != "Y" && $userInput != "y") then
echo Please execute program again with Parent Directory as the 2nd parameter and the Tile Name as your 3rd parameter
#TODO actually throw an error instead of just outputing to stdout... output to stderr
echo
echo Exiting...
exit
endif
#if directories dont exist, throw error
if(! -d $ParentDir) then
echo
echo ERROR: $ParentDir doest not exist.
echo
echo Exiting...
exit
endif
echo "going to Mode3"
goto Mode3
else
#Error handling
#mode 1/2 not second parameter. program exits.
echo ERROR: mode 1, 2, or 3 not selected
echo
echo Mode 1 call:
echo ./icore_wrapper_executable_opt1.tcsh 1 ParentDir/
echo Mode 2 call:
echo ./icore_wrapper_executable_opt1.tcsh 2 inputList.txt ParentDir/
echo Mode 3 call:
echo ./icore_wrapper_executable_opt1.tcsh 3 ParentDir/ TileName
echo
echo Exiting...
exit
endif
Mode1:
#===============================================================================================================================================================
# links parent and wrapper dir to run "tcsh" and "source SORUCEME" in parent dir
# this assumes tcsh is installed
echo Creating temp files...
cd ..
tcsh & source SOURCEME && cd $wrapperDir
# loops through all of the tiles and executes icore
set FulldepthDir = ${InputsDir}/
echo Wrapper now starting...
echo
echo
echo "NOTE: fbt3 and PSFavr8 will delete any existing PSFs you have in $InputsDir"
echo
echo "Do you want to run fbt3 and PSFavr8 (y/n)?"
set userInput = $<
if($userInput != "Y" && $userInput != "y") then
goto ICORE_Wrapper_Mode1
else
goto fbt3_PSFavr8_Wrapper_Mode1
endif
fbt3_PSFavr8_Wrapper_Mode1:
foreach RaRaRaDir ($FulldepthDir*/) #for each directory in FulldepthDir, get each RadecIDdir, run wrapper on RadecID tile
foreach RadecIDDir ($RaRaRaDir*/)
echo =============================== starting mdet wrapper loop iteration =================================
#Stops calling programs if number of scripts running is greater than number of threads on CPU
set tempSize = `echo $RadecIDDir | awk '{print length($0)}'`
@ tempIndex = ($tempSize - 8)
set RadecID = `echo $RadecIDDir | awk -v startIndex=$tempIndex '{print substr($0,startIndex,8)}'`
set RaRaRa = `echo $RadecID | awk '{print substr($0,0,3)}'`
set UnWISEDir = $ParentDir/UnWISE/$RaRaRa/$RadecID/
set CatWISEDir = $ParentDir/CatWISE/$RaRaRa/$RadecID/Full/
set OUTPUTdir = ${CatWISEDir}
set TileDir = $ParentDir/CatWISE/$RaRaRa/$RadecID/
echo $FulldepthDir
echo $RadecIDDir
echo RadecID == $RadecID
echo RaRaRa == $RaRaRa
echo calling mdet wrapper mode 3 on $RadecID
#call icore_wrapper
if($rsyncSet == "true") then
(echo y | ./icore_wrapper_executable.tcsh 3 $ParentDir $RadecID -SNR $SNRthreshold -rsync -p) & #&& (echo Wrapper Call for ${RadecID} success!)
else
(echo y | ./icore_wrapper_executable.tcsh 3 $ParentDir $RadecID -SNR $SNRthreshold -p) & #&& (echo Wrapper Call for ${RadecID} success!)
endif
if(`ps -ef | grep icore_wrapper_executable | wc -l` > 14) then
echo ${RadecID} More than 12 icore_wrapper_executable processes, waiting...
while(`ps -ef | grep icore_wrapper_executable | wc -l` > 14)
sleep 1
#echo IM WATING
#do nothing
end
echo ${RadecID} Done waiting!
endif
echo mdet wrapper for ${RadecID} done!
echo ================================ ending mdet wrapper loop iteration =================================
end
end
#===============================================================================================================================================================
#wait for background processes to finish
wait
echo wphot wrapper finished!
echo
goto Done
ICORE_Wrapper_Mode1:
foreach RaRaRaDir ($FulldepthDir*/) #for each directory in FulldepthDir, get each RadecIDdir, run wrapper on RadecID tile
foreach RadecIDDir ($RaRaRaDir*/)
echo =============================== starting mdet wrapper loop iteration =================================
#Stops calling programs if number of scripts running is greater than number of threads on CPU
set tempSize = `echo $RadecIDDir | awk '{print length($0)}'`
@ tempIndex = ($tempSize - 8)
set RadecID = `echo $RadecIDDir | awk -v startIndex=$tempIndex '{print substr($0,startIndex,8)}'`
set RaRaRa = `echo $RadecID | awk '{print substr($0,0,3)}'`
set UnWISEDir = $ParentDir/UnWISE/$RaRaRa/$RadecID/
set CatWISEDir = $ParentDir/CatWISE/$RaRaRa/$RadecID/Full/
set OUTPUTdir = ${CatWISEDir}
set TileDir = $ParentDir/CatWISE/$RaRaRa/$RadecID/
echo $FulldepthDir
echo $RadecIDDir
echo RadecID == $RadecID
echo RaRaRa == $RaRaRa
#call icore_wrapper
if($rsyncSet == "true") then
(echo y | ./icore_wrapper_executable.tcsh 3 $ParentDir $RadecID -SNR $SNRthreshold -rsync -p) & #&& (echo Wrapper Call for ${RadecID} success!)
else
(echo y | ./icore_wrapper_executable.tcsh 3 $ParentDir $RadecID -SNR $SNRthreshold -p) & #&& (echo Wrapper Call for ${RadecID} success!)
endif
if(`ps -ef | grep icore_wrapper_executable | wc -l` > 14) then
echo ${RadecID} More than 12 icore_wrapper_executable processes, waiting...
while(`ps -ef | grep icore_wrapper_executable | wc -l` > 14)
sleep 1
#echo IM WATING
#do nothing
end
echo ${RadecID} Done waiting!
endif
echo mdet wrapper for ${RadecID} done!
echo ================================ ending mdet wrapper loop iteration =================================
end
end
#===============================================================================================================================================================
#wait for background processes to finish
wait
echo wphot wrapper finished!
echo
goto Done
Mode2:
#===============================================================================================================================================================
# links parent and wrapper dir to run "tcsh" and "source SORUCEME" in parent dir
# this assumes tcsh is installed
echo Creating temp files...
cd ..
tcsh & source SOURCEME && cd $wrapperDir
# loops through all of the tiles and executes icore
echo Wrapper now starting...
echo
echo
echo "NOTE: fbt3 and PSFavr8 will delete any existing PSFs you have in ${ParentDir}/CatWISE"
echo
echo "Do you want to run fbt3 and PSFavr8 (y/n)?"
set userInput = $<
if($userInput != "Y" && $userInput != "y") then
goto ICORE_Wrapper_Mode2
else
goto fbt3_PSFavr8_Wrapper_Mode2
endif
fbt3_PSFavr8_Wrapper_Mode2:
foreach line (`cat $InputsList`)
echo =============================== starting mdet wrapper loop iteration =================================
set RadecID = `echo $line`
set RaRaRa = `echo $RadecID | awk '{print substr($0,0,3)}'`
set UnWISEDir = $ParentDir/UnWISE/$RaRaRa/$RadecID/
set CatWISEDir = $ParentDir/CatWISE/$RaRaRa/$RadecID/Full/
set OUTPUTdir = ${CatWISEDir}
set TileDir = $ParentDir/CatWISE/$RaRaRa/$RadecID/
echo RadecID == $RadecID
echo RaRaRa == $RaRaRa
#call icore_wrapper
if($rsyncSet == "true") then
(echo y | ./icore_wrapper_executable.tcsh 3 $ParentDir $RadecID -SNR $SNRthreshold -rsync -p) & #&& (echo Wrapper Call for ${RadecID} success!)
else
(echo y | ./icore_wrapper_executable.tcsh 3 $ParentDir $RadecID -SNR $SNRthreshold -p) & #&& (echo Wrapper Call for ${RadecID} success!)
endif
if(`ps -ef | grep icore_wrapper_executable | wc -l` > 14) then
echo ${RadecID} More than 12 icore_wrapper_executable processes, waiting...
while(`ps -ef | grep icore_wrapper_executable | wc -l` > 14)
sleep 1
#echo IM WATING
#do nothing
end
echo ${RadecID} Done waiting!
endif
echo mdet wrapper for ${RadecID} done!
echo ================================ ending mdet wrapper loop iteration =================================
end
#wait for background processes to finish
wait
echo wphot wrapper finished!
echo
goto Done
ICORE_Wrapper_Mode2:
foreach line (`cat $InputsList`)
echo =============================== starting mdet wrapper loop iteration =================================
set RadecID = `echo $line`
set RaRaRa = `echo $RadecID | awk '{print substr($0,0,3)}'`
set UnWISEDir = $ParentDir/UnWISE/$RaRaRa/$RadecID/
set CatWISEDir = $ParentDir/CatWISE/$RaRaRa/$RadecID/Full/
set OUTPUTdir = ${CatWISEDir}
set TileDir = $ParentDir/CatWISE/$RaRaRa/$RadecID/
echo RadecID == $RadecID
echo RaRaRa == $RaRaRa
#call icore_wrapper
if($rsyncSet == "true") then
(echo y | ./icore_wrapper_executable.tcsh 3 $ParentDir $RadecID -SNR $SNRthreshold -rsync -p) & #&& (echo Wrapper Call for ${RadecID} success!)
else
(echo y | ./icore_wrapper_executable.tcsh 3 $ParentDir $RadecID -SNR $SNRthreshold -p) & #&& (echo Wrapper Call for ${RadecID} success!)
endif
if(`ps -ef | grep icore_wrapper_executable | wc -l` > 14) then
echo ${RadecID} More than 12 icore_wrapper_executable processes, waiting...
while(`ps -ef | grep icore_wrapper_executable | wc -l` > 14)
sleep 1
#echo IM WATING
#do nothing
end
echo ${RadecID} Done waiting!
endif
echo mdet wrapper for ${RadecID} done!
echo ================================ ending mdet wrapper loop iteration =================================
end
#wait for background processes to finish
wait
echo wphot wrapper finished!
echo
goto Done
Mode3:
#===============================================================================================================================================================
# links parent and wrapper dir to run "tcsh" and "source SORUCEME" in parent dir
# this assumes tcsh is installed
echo Creating temp files...
cd ..
tcsh & source SOURCEME && cd $wrapperDir
ParallelMode3:
set RaRaRa = `echo $RadecID | awk '{print substr($0,0,3)}'`
set UnWISEDir = $ParentDir/UnWISE/$RaRaRa/$RadecID/
set CatWISEDir = $ParentDir/CatWISE/$RaRaRa/$RadecID/Full/
set OUTPUTdir = ${CatWISEDir}
set TileDir = $ParentDir/CatWISE/$RaRaRa/$RadecID/
#Error Checking
if(! -d $UnWISEDir) then
echo ERROR: $UnWISEDir does not exist.
echo
echo Exiting...
exit
endif
if(! -d $CatWISEDir) then
echo $CatWISEDir does not exist. Creating $CatWISEDir
mkdir -p $CatWISEDir
endif
echo UnWISEDir == $UnWISEDir
echo CatWISEDir == $CatWISEDir
# loops through all of the tiles and executes icore
echo Wrapper now starting...
echo
echo
echo "NOTE: fbt3 and PSFavr8 will delete any existing PSFs you have in $TileDir"
echo
echo "Do you want to run fbt3 and PSFavr8 (y/n)?"
set userInput = $<
if($userInput != "Y" && $userInput != "y") then
echo going to start run with ICORE
goto ICORE_Wrapper_Mode3
else
echo going to start run with MDET
goto fbt3_PSFavr8_Wrapper_Mode3
endif
fbt3_PSFavr8_Wrapper_Mode3:
#===============================================================================================================================================================
#fbt3 and PSFavr8 Wrapper
echo
echo
echo 1\) fbt3 and PSFavr8 programs now starting...
echo "--------------------------------------- start fbt3 and PSFavr8 wrapper ---------------------------------------"
set preworkINPUTdir = ${UnWISEDir}
echo fbt3 and PSFavr8 Input Dir === $preworkINPUTdir
set preworkOUTPUTdir = ${CatWISEDir}
if(`mkdir -p ${preworkOUTPUTdir}/ProgramTerminalOutput/`) then
echo creating ${preworkOUTPUTdir}/ProgramTerminalOutput/
endif
echo calling fbt3 and PSFavr8 on ${RadecID} tile
if(`mkdir -p ${preworkOUTPUTdir}`) then
echo Creating directory ${preworkOUTPUTdir}...
endif
if(`mkdir -p ${preworkOUTPUTdir}/Asce`) then
echo Creating directory ${preworkOUTPUTdir}/Asce...
endif
if(`mkdir -p ${preworkOUTPUTdir}/Desc`) then
echo Creating directory ${preworkOUTPUTdir}/Desc...
endif
#removes any existing psfs
echo
echo Deleting any PSFs if they exist...
if ( `find ${preworkOUTPUTdir} -maxdepth 1 -type f -name "*psf*" | wc -l` > 0 ) then
echo PSFs found in ${preworkOUTPUTdir}. Deleting...
rm -f ${preworkOUTPUTdir}/*psf*
else if ( `find ${preworkOUTPUTdir}/Asce/ -maxdepth 1 -type f -name "*psf*" | wc -l` > 0 ) then
echo ${preworkOUTPUTdir}/Asce/ has psfs. Deleting...
rm -f ${preworkOUTPUTdir}/Asce/*psf*
else if ( `find ${preworkOUTPUTdir}/Desc/ -maxdepth 1 -type f -name "*psf*" | wc -l` > 0 ) then
echo ${preworkOUTPUTdir}/Desc/ has psfs. Deleting...
rm -f ${preworkOUTPUTdir}/Desc/*psf*
endif
# fbt3 & PSFavr8 call
(/Users/CatWISE/fbt3 ${preworkINPUTdir}/unwise-${RadecID}-w1-frames.fits ${preworkOUTPUTdir}/ProgramTerminalOutput/fbt3_w1.txt )
(/Users/CatWISE/fbt3 ${preworkINPUTdir}/unwise-${RadecID}-w2-frames.fits ${preworkOUTPUTdir}/ProgramTerminalOutput/fbt3_w2.txt )
(/Users/CatWISE/PSFavr8 -i /Users/CatWISE/Focal_Plane_PSFs -o $preworkOUTPUTdir -a1 ${preworkOUTPUTdir}/ProgramTerminalOutput/fbt3_w1.txt -a2 ${preworkOUTPUTdir}/ProgramTerminalOutput/fbt3_w2.txt -t $RadecID -da )
echo fbt3 and PSFavr8 for ${RadecID} done!
echo "---------------------------------------- end fbt3 and PSFavr8 wrapper ----------------------------------------"
#===============================================================================================================================================================
echo fbt3 and PSFavr8 wrapper finished!
echo
ICORE_Wrapper_Mode3:
#===============================================================================================================================================================
echo 2\) ICORE program now starting...
echo "-------------------------------------------- start ICORE wrapper ---------------------------------------------"
set INPUTdir = ${UnWISEDir}
set OUTPUTdir = ${CatWISEDir}
#InputsDir used for icore_template... TODO make sure template depents on INPUTdir instead...
set InputsDir = $INPUTdir
echo Current Input Directory === $INPUTdir
echo Current Output Directory === $OUTPUTdir
mkdir -p $OUTPUTdir
mkdir -p ${OUTPUTdir}/ProgramTerminalOutput/
#===============================================================================================================================================
# Copies icore_template to make an icore_coadd script for w1 and w2
# NOTE: this assumes "band" variable is in the 4th line of icore_template
cp ${wrapperDir}/icore_template.tcsh ${OUTPUTdir}/ProgramTerminalOutput/icore_coadd_w1
cp ${wrapperDir}/icore_template.tcsh ${OUTPUTdir}/ProgramTerminalOutput/icore_coadd_w2
sed -i --follow-symlinks '4s/1/2/' ${OUTPUTdir}/ProgramTerminalOutput/icore_coadd_w2
# Sources/Runs Wrapper executables (one for band 1, other for band 2)
# This should run concurrently/in parallel
echo Running ICORE for $RadecID
#TODO: output error message if this doesnt execute!
echo Running ICORE for bands 1 and 2
(source ${OUTPUTdir}/ProgramTerminalOutput/icore_coadd_w1 >& ${OUTPUTdir}/ProgramTerminalOutput/icore_w1_output.txt)
(source ${OUTPUTdir}/ProgramTerminalOutput/icore_coadd_w2 >& ${OUTPUTdir}/ProgramTerminalOutput/icore_w2_output.txt)
if ($status != 0) then
echo ERROR: ICORE failed with an exit status of $status. Exitiing...
exit
endif
echo ICORE for $RadecID done!
echo "--------------------------------------------- end ICORE wrapper ----------------------------------------------"
#===============================================================================================================================================================
echo ICORE wrapper finished!
echo
#===============================================================================================================================================================
#MDET Wrapper
echo
echo
echo 3\) MDET program now starting...
echo "--------------------------------------------- start MDET wrapper ---------------------------------------------"
set MDETInputdir = ${CatWISEDir}
echo MDET Input Dir === $MDETInputdir
echo calling MDET on ${RadecID} tile
echo MDET image1 location ${MDETInputdir}/mosaic-w1-int.fits
echo MDET image2 location ${MDETInputdir}/mosaic-w2-int.fits
# MDET call
(${wrapperDir}/mdet -image1 ${MDETInputdir}/mosaic-w1-int.fits -image2 ${MDETInputdir}/mosaic-w2-int.fits -sigimage1 ${MDETInputdir}/mosaic-w1-unc.fits -sigimage2 ${MDETInputdir}/mosaic-w2-unc.fits -backwindow 400.0 -threshold $SNRthreshold -m -c -outlist ${MDETInputdir}/detlist.tbl -fwhm1 6.000 -fwhm2 6.000 >& ${MDETInputdir}/ProgramTerminalOutput/mdet_output.txt)
set date_t = `date +"%Y%m%d%H%M%S"`
cp ${MDETInputdir}/detlist.tbl ${MDETInputdir}/detlist_${RadecID}_${date_t}.tbl
if ($status != 0) then
echo ERROR: mdet failed with an exit status of $status. Exiting...
exit
endif
echo MDET for ${RadecID} done!
echo "---------------------------------------------- end MDET wrapper ----------------------------------------------"
#===============================================================================================================================================================
#rsync folders from Tyto, Athene, Otus
#===============================================================================================================================================================
#Deletes and cleans up files
cd $wrapperDir
echo Deleting Wrapper temp files...
#Deletes 2 scripts
rm -f ${OUTPUTdir}/ProgramTerminalOutput/icore_coadd_w1
rm -f ${OUTPUTdir}/ProgramTerminalOutput/icore_coadd_w2
#rm ./icore_coadd_w1--follow-symlinks
rm -f ${OUTPUTdir}/ProgramTerminalOutput/icore_coadd_w2--follow-symlinks
rm -f ${OUTPUTdir}/ProgramTerminalOutput/fbt3_w1.txt
rm -f ${OUTPUTdir}/ProgramTerminalOutput/fbt3_w2.txt
echo Done deleting!
if($rsyncSet == "true") then
#rsync
echo running rsync on tile $RadecID
set currIP = `curl ipecho.net/plain ; echo`
echo current IP = $currIP
if($currIP == "137.78.30.21") then #Tyto
set otus_CatWISEDir = `echo $CatWISEDir | sed 's/CatWISE1/otus1/g'`
set athene_CatWISEDir = `echo $CatWISEDir | sed 's/CatWISE1/athene1/g'`
set otus_CatWISEDir = `echo $otus_CatWISEDir | sed 's/tyto/otus/g'`
set athene_CatWISEDir = `echo $athene_CatWISEDir | sed 's/tyto/athene/g'`
set otus_CatWISEDir = `echo $otus_CatWISEDir | sed 's/CatWISE3/otus3/g'`
set athene_CatWISEDir = `echo $athene_CatWISEDir | sed 's/CatWISE3/athene3/g'`
echo On Tyto!
#Transfer to Otus
echo rsync Tyto\'s $CatWISEDir/detlist.tbl to Otus $otus_CatWISEDir
ssh ${user}@137.78.80.75 "mkdir -p $otus_CatWISEDir"
rsync -avu --include "detlist" $CatWISEDir ${user}@137.78.80.75:$otus_CatWISEDir
echo rsync Tyto\'s $CatWISEDir psfs to Otus $otus_CatWISEDir
rsync -avu --include "psf" $CatWISEDir ${user}@137.78.80.75:$otus_CatWISEDir
#Transfer to Athene
echo rsync Tyto\'s $CatWISEDir/detlist.tbl to Athene $athene_CatWISEDir
ssh ${user}@137.78.80.72 "mkdir -p $athene_CatWISEDir"
rsync -avu --include "detlist" $CatWISEDir ${user}@137.78.80.72:$athene_CatWISEDir
echo rsync Tyto\'s $CatWISEDir psfs to Athene $athene_CatWISEDir
rsync -avu --include "psf" $CatWISEDir ${user}@137.78.80.72:$athene_CatWISEDir
else if($currIP == "137.78.80.75") then #Otus
set tyto_CatWISEDir = `echo $CatWISEDir | sed 's/otus3/CatWISE3/g'`
set tyto_CatWISEDir = `echo $tyto_CatWISEDir | sed 's/otus/tyto/g'`
set athene_CatWISEDir = `echo $CatWISEDir | sed 's/otus/athene/g'`
echo On Otus!
#Transfer to Tyto
ssh ${user}@137.78.30.21 "mkdir -p $tyto_CatWISEDir"
echo rsync Otus\'s $CatWISEDir/detlist.tbl to Tyto $tyto_CatWISEDir
rsync -avu --include "detlist" $CatWISEDir ${user}@137.78.30.21:$tyto_CatWISEDir
echo rsync Otus\'s $CatWISEDir psfs to Tyto $tyto_CatWISEDir
rsync -avu --include "psf" $CatWISEDir ${user}@137.78.30.21:$tyto_CatWISEDir
#Transfer to Athene
ssh ${user}@137.78.80.72 "mkdir -p $athene_CatWISEDir"
echo rsync Otus\'s $CatWISEDir/detlist.tbl to Athene $athene_CatWISEDir
rsync -avu --include "detlist" $CatWISEDir ${user}@137.78.80.72:$athene_CatWISEDir
echo rsync Otus\'s $CatWISEDir psfs to Athene $athene_CatWISEDir
rsync -avu --include "psf" $CatWISEDir ${user}@137.78.80.72:$athene_CatWISEDir
else if($currIP == "137.78.80.72") then #Athene
set tyto_CatWISEDir = `echo $CatWISEDir | sed 's/athene3/CatWISE3/g'`
set tyto_CatWISEDir = `echo $tyto_CatWISEDir | sed 's/athene/tyto/g'`
set otus_CatWISEDir = `echo $CatWISEDir | sed 's/athene/otus/g'`
echo On Athene!
#Transfer to Tyto
ssh ${user}@137.78.30.21 "mkdir -p $tyto_CatWISEDir"
echo rsync Athene\'s $CatWISEDir/detlist.tbl to Tyto $tyto_CatWISEDir
rsync -avu --include "detlist" $CatWISEDir ${user}@137.78.30.21:$tyto_CatWISEDir
echo rsync Athene\'s $CatWISEDir psfs to Tyto $tyto_CatWISEDir
rsync -avu --include "psf" $CatWISEDir ${user}@137.78.30.21:$tyto_CatWISEDir
#Transfer to Otus
ssh ${user}@137.78.80.75 "mkdir -p $otus_CatWISEDir"
echo rsync Athene\'s $CatWISEDir/detlist.tbl to Otus $otus_CatWISEDir
rsync -avu --include "detlist" $CatWISEDir ${user}@137.78.80.75:$otus_CatWISEDir
echo rsync Athene\'s $CatWISEDir psfs to Otus $otus_CatWISEDir
rsync -avu --include "psf" $CatWISEDir ${user}@137.78.80.75:$otus_CatWISEDir
endif
endif
echo MDET wrapper finished!
echo
goto Done
Done:
#===============================================================================================================================================================
echo Wrapper finished!
set endTime = `date '+%m/%d/%Y %H:%M:%S'`
echo
echo Wrapper Ended at:
echo $endTime
echo