source: SH_SHM/trunk/util/prep_simfilters.csh @ 92

Revision 16, 3.0 KB checked in by marcus, 15 years ago (diff)

r1 | svn | 2007-12-13 11:10:29 +0100 (Do, 13 Dez 2007) | 2 lines

Initial import

  • Property svn:executable set to *
Line 
1#! /bin/csh
2#
3# file prep_simfilters.csh
4#      ===================
5#
6# version 3, 3-Dec-2005
7#
8# Prepare simulation filters for a broadband recording instrument.
9# K. Stammler, 15-May-2003
10
11if  ("$1" == "")  then
12        echo "Usage: $0 <bbname>"
13        echo "   Example $0 CMG40T"
14        exit
15endif
16
17# get parameters
18set bbname=$1
19
20# set constants
21set filist = ( G_WWSSN_SP WWSSN_LP WOODAND LRSM_SP LRSM_LP SRO_LP KIRNOS )
22#set filist = ( G_WWSSN_SP WWSSN_LP )
23set addfil="ADDFIL"
24
25if  ($?PSVIEW == 0)  then
26        echo "$0 : Environment variable PSVIEW (PostScript display program) not set."
27        exit
28endif
29set tmp=`$SH_UTIL/logseries 2 2 2 | cut -c1-3`
30if  ("$tmp" != "2.0")  then
31        echo "$0 : logseries not usable (in SH_UTIL)"
32        echo '   try'
33        echo '   cd $SH_UTIL'
34        echo '   make logseries'
35        exit
36endif
37
38# look for the transfer function of the input instrument
39set tf_inp=$SH_FILTER/TF_VEL_S+$bbname.FLF
40if  (-e $tf_inp)  then
41        echo ""
42        echo Using the following transfer function:
43        echo ""
44        cat $tf_inp
45        echo ""
46else
47        echo ""
48        echo "Need the following file: $tf_inp"
49        echo ""
50        exit
51endif
52
53# create new GMT defaults file
54echo "creating new .gmtdefaults file"
55if  (-e .gmtdefaults)  \rm .gmtdefaults
56gmtdefaults -Ds >.gmtdefaults
57
58echo ""
59foreach f ($filist)
60
61        set simfil=${bbname}_S+$f
62        echo "processing file $f (creating $simfil.FLF)"
63
64        set filtype=""
65        set frq=""
66        set frq2=""
67        set cmd=""
68        # loop until user accepts filter
69        while  ("$cmd" != "a")
70
71                if  (-e $simfil.FLF)  \rm $simfil.FLF
72                $SH_UTIL/catflf TF_VEL_S+$f div TF_VEL_S+$bbname >$simfil.FLF
73                if  ("$filtype" != "")  then
74                        # create additional HP or LP filter and apply it
75                        if  (-e ${simfil}_X.FLF)  \rm ${simfil}_X.FLF
76                        mv $simfil.FLF ${simfil}_X.FLF
77                        if  (-e $addfil.FLF)  \rm $addfil.FLF
78                        $SH_UTIL/butfreq $filtype $inptype $frq $frq2 -f=$addfil -o=$order
79                        $SH_UTIL/catflf ${simfil}_X mul $addfil >$simfil.FLF
80                        \rm ${simfil}_X.FLF
81                endif
82
83                # show current filter
84                $SH_UTIL/filtgraph.csh TF_VEL_S+$bbname,TF_VEL_S+$f,${bbname}_S+$f \
85                        1e-4 1e4 1e-7 100
86                echo ""
87                echo ""
88                echo "current filter $simfil is:"
89                echo ""
90                cat ${bbname}_S+$f.FLF
91                echo ""
92                echo -n "apply Highpass, Lowpass, Bandpass, Accept or Delete (hp,lp,bp,a,d): "
93                set filtype=$<
94                if  ("$filtype" == "a")  break
95                if  ("$filtype" == "d")  then
96                        echo "deleting filter $simfil and continue"
97                        \rm $simfil.FLF
98                        break
99                endif
100                if  ("$filtype" != "lp" && "$filtype" != "hp" && "$filtype" != "bp")  then
101                        set filtype=""
102                        set frq=""
103                        set order=""
104                        echo "illegal input.  Repeat"
105                        continue
106                endif
107                if  ("$filtype" == "hp")  then
108                        echo -n "enter Highpass frequency in s: "
109                        set inptype=t
110                        set frq=$<
111                        set frq2=""
112                else if  ("$filtype" == "lp")  then
113                        echo -n "enter Lowpass period in Hz: "
114                        set inptype=f
115                        set frq=$<
116                        set frq2=""
117                else
118                        echo -n "enter lower boundary in Hz: "
119                        set inptype=f
120                        set frq=$<
121                        echo -n "enter upper boundary in Hz: "
122                        set frq2=$<
123                endif
124                echo -n "enter order of filter (default: 2): "
125                set order=$<
126                if  ("$order" == "")  set order=2
127        end
128
129end
130
131if  (-e fg.ps)  \rm fg.ps
132if  (-e ADDFIL.FLF)  \rm ADDFIL.FLF
133
Note: See TracBrowser for help on using the repository browser.