-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroupall
85 lines (58 loc) · 1.44 KB
/
groupall
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
#!/bin/bash
# 'Bash' script to group a whole bunch of spectra
# using GRPPHA. Input parameter is the root name of the
# spectral files.
# Simon Vaughan, Leicester 2006
#
# Input files <root name>_<i>.fak
# Output files <root name>_<i>/fak.g
#
# v1.0 -- 09/12/2004 -- Simon Vaughan
# v1.1 -- 23/01/2006 -- fixed bug if <root name>_<i>/fak.g
# already exists.
# Check command-line input
if [ -z "$1" ] ; then
parm1="<root filename>"
echo Usage: $0 $parm1
exit
else
root=$1
fi
# make sure FTOOLS are initialised
which grppha 2> ftools.nothere > ftools.here
if [ ! -s ftools.here ] ; then
echo groupall: Make sure HEAsoft is initialised
exit $?
fi
# Make a list of all the appropriate files
rm -f file.list
ls -1 $root\_*.fak > file.list 2> errs.list
# Check if there are zero files
if [ ! -s file.list ] ; then
echo groupall: Missing files $root
exit $?
fi
# Main loop: for each file...
n=0
for fname in $( more file.list ); do
let n=n+1
# Set output filename
outp=$fname\.g
# remove file if it's already there
if [ -e $outp ] ; then
rm -rf $outp
fi
# Let user know what's happening
echo Grouping input file: $fname output file $outp
# bin spectrum (until N >= 20 ct/bin)
grppha infile=$fname outfile=$outp chatter=1 \
comm="group min 20 & exit" >& grppha.log
# end of loop
done
# Delete the listing files
rm -f file.list
rm ftools.nothere
rm ftools.here
# Finished
echo All Done
exit 0