-
Notifications
You must be signed in to change notification settings - Fork 0
/
xtes2ex.sh
executable file
·88 lines (62 loc) · 3.04 KB
/
xtes2ex.sh
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
#!/bin/bash
# |----------------------------------------------------------------------|
# |------------------------------XTE S2-EX-------------------------------|
# |----------------------------------------------------------------------|
# Call as ./xtegxex.sh
# Requirements:
# fkeyprint and make_se from FTools: http://heasarc.gsfc.nasa.gov/ftools/
# Takes raw RXTE PCA data in the current working directory, searches it for any labelled as GoodXenon
# data, and copies it into a subdirectory named 'gx0'. Event data is then made from these files
# and saved as EVENT_gx#.fits using make_se
#
# WARNING! If run in a directory containing a subdirectory named 's20', the contents of that
# subdirectory will be removed.
#
#-----Welcoming Header-------------------------------------------------------------------------------------------------
echo ''
echo '-------Running XTE S2-Ex: J.M.Court, 2015--------'
echo ''
#-----Setting Switches-------------------------------------------------------------------------------------------------
heainit
s2=0 # Counter of GoodXenon1 events
#-----Creating s20 Directory-------------------------------------------------------------------------------------------
echo 'Sorting FITS files, retrieving Standard2 Data products'
echo ''
echo 'Creating directories:'
if [ -d s20 ]
then
echo "Directory 's20' found: removing contents."
rm s20/* # Empty gx0 directory if it is found
else
mkdir s20 # Make gx0 directory if it is not found
fi
echo ''
#-----Seek and Copy Standard Files-------------------------------------------------------------------------------------
for f in *;
do
dm=$(fkeyprint $f+1 DATAMODE 2> /dev/null ) # Collecting DATAMODE from FITS file, suppressing error from opening non FITS files
if [[ $dm =~ .*Standard2.* ]]
then
echo $f 'is Standard 2 data' # Increasing Standard2 counter
cp $f ./s20/$f
rm *.bg >/dev/null # Kill it if its a bg file
if [[ -a $f ]];
then
mv ./s20/$f ./s20/EVENT_s2$s2.fits # If DATAMODE is Standard2, move this file to /s2
s2=$((s2+1))
fi
fi
done
#-----Return Warnings and Clean Up if GoodXenon not Found--------------------------------------------------------------
if [ $s2 == 0 ]
then
rm -r s20 # Remove s2 if no Standard2 data found
echo 'No Standard2 files found!'
echo 'Removing s2 directory'
else # Remove any stray background files
rm s20/*.bg
fi
#-----Footer-----------------------------------------------------------------------------------------------------------
echo ''
echo '------------------------------------------------'
echo ''