1 | #! /bin/csh |
---|
2 | # |
---|
3 | # file seed_copy.csh |
---|
4 | # ============= |
---|
5 | # |
---|
6 | # version 8, 9-May-2007 |
---|
7 | # |
---|
8 | # copies Mini-SEED files to output directory |
---|
9 | # K. Stammler, 5-Jul-95 |
---|
10 | |
---|
11 | if ("$1" == "help" || "$1" == "-help") then |
---|
12 | echo "Usage: $0 <sfdfile> <streamlist> <from> <to> <workdir> <outfile> [<exact>]" |
---|
13 | exit |
---|
14 | endif |
---|
15 | |
---|
16 | #setenv QUIET_STARTUP |
---|
17 | #source /usr/local/common_startup |
---|
18 | #unsetenv QUIET_STARTUP |
---|
19 | |
---|
20 | #set echo |
---|
21 | |
---|
22 | # set constants |
---|
23 | set scrdir=tmp_dir_$$ |
---|
24 | set seedspec="/programs/sol2/seed/own/src" |
---|
25 | setenv HEADER_INPUT $seedspec/inputs |
---|
26 | set jkpath="JK:" |
---|
27 | |
---|
28 | # get parameters from command line |
---|
29 | set sfdfile="$1" |
---|
30 | set streamwild="$2" |
---|
31 | set fromtime="$3" |
---|
32 | set totime="$4" |
---|
33 | set outdir="$5" |
---|
34 | set outfile="$6" |
---|
35 | set exact="$7" |
---|
36 | |
---|
37 | # store original directory |
---|
38 | set startdir=$PWD |
---|
39 | |
---|
40 | # inquire empty parameters |
---|
41 | while ("$sfdfile" == "") |
---|
42 | echo -n "sfd-file directory [/cdrom]: " |
---|
43 | set sfdfile="$<" |
---|
44 | if ("$sfdfile" == "") set sfdfile="/cdrom" |
---|
45 | set sfdfile="`eval echo $sfdfile`"/sfdfile.sfd |
---|
46 | #if ("$sfdfile" == '$ARCH') set sfdfile="$ARCH/sfdfile.sfd" |
---|
47 | if (! -e $sfdfile && "$sfdfile" != "$jkpath" && "$sfdfile" != "DB:") then |
---|
48 | if (-e $sfdfile/sfdfile.sfd) then |
---|
49 | set sfdfile="$sfdfile/sfdfile.sfd" |
---|
50 | else |
---|
51 | echo "file $sfdfile does not exist" |
---|
52 | set sfdfile="" |
---|
53 | endif |
---|
54 | endif |
---|
55 | end |
---|
56 | if ("$streamwild" == "") then |
---|
57 | echo -n "streamlist [grf]: " |
---|
58 | set streamwild="$<" |
---|
59 | if ("$streamwild" == "") set streamwild="grf" |
---|
60 | endif |
---|
61 | while ("$fromtime" == "") |
---|
62 | echo -n "from time [23-jul-95_8:23 or 23,7,95,8,23]: " |
---|
63 | set fromtime="$<" |
---|
64 | end |
---|
65 | while ("$totime" == "") |
---|
66 | echo -n "to time [23-jul-95_8:23 or 23,7,95,8,23]: " |
---|
67 | set totime="$<" |
---|
68 | end |
---|
69 | while ("$outdir" == "") |
---|
70 | echo -n "working directory: " |
---|
71 | set outdir="$<" |
---|
72 | if (! -d $outdir) then |
---|
73 | echo "$outdir is an illegal directory" |
---|
74 | set outdir="" |
---|
75 | continue |
---|
76 | endif |
---|
77 | if (! -w $outdir) then |
---|
78 | echo "cannot write to $outdir" |
---|
79 | set outdir="" |
---|
80 | endif |
---|
81 | end |
---|
82 | if ("$outfile" == "") then |
---|
83 | echo -n "output file [seedout.sed]: " |
---|
84 | set outfile="$<" |
---|
85 | if ("$outfile" == "") set outfile="seedout.sed" |
---|
86 | endif |
---|
87 | |
---|
88 | ## get list of streams |
---|
89 | #if ("$streamwild" == "grf") set streamwild='gr[a-c]?-bh-?' |
---|
90 | #if ("$streamwild" == "grf-bh-?") set streamwild='gr[a-c]?-bh-?' |
---|
91 | #if ("$streamwild" == "grf-bh-z") set streamwild='gr[a-c]?-bh-z' |
---|
92 | #if ("$streamwild" == "grsn") set streamwild='[a-f,h-z]*-bh-? grfo-bh-? gsh-bh-?' |
---|
93 | #if ("$streamwild" == "grsn-hh-?") set streamwild='[a-f,h-z]*-hh-? gsh-hh-?' |
---|
94 | #if ("$streamwild" == "grsn-hh-z") set streamwild='[a-f,h-z]*-hh-z gsh-hh-z' |
---|
95 | #if ("$streamwild" == "grsn-bh-?") set streamwild='[a-f,h-z]*-bh-? grfo-bh-? gsh-bh-?' |
---|
96 | #if ("$streamwild" == "grsn-bh-z") set streamwild='[a-f,h-z]*-bh-z grfo-bh-z gsh-bh-z' |
---|
97 | #if ("$streamwild" == "grsn-lh-?") set streamwild='[a-f,h-z]*-lh-? grfo-lh-? gsh-lh-?' |
---|
98 | #if ("$streamwild" == "grsn-lh-z") set streamwild='[a-f,h-z]*-lh-z grfo-lh-z gsh-lh-z' |
---|
99 | # |
---|
100 | #set streamlist=`(chdir $SEED_PROG/streams; ls $streamwild)` |
---|
101 | |
---|
102 | set streamlist="" |
---|
103 | if ("$streamwild" == "grf") set streamlist=`$DPROG/list_streams.csh grf-bh` |
---|
104 | if ("$streamwild" == "grf-bh-?") set streamlist=`$DPROG/list_streams.csh grf-bh` |
---|
105 | if ("$streamwild" == "grf-bh-z") set streamlist=`$DPROG/list_streams.csh grf-bh | grep z$` |
---|
106 | if ("$streamwild" == "grsn") set streamlist=`$DPROG/list_streams.csh grsn-bh-all` |
---|
107 | if ("$streamwild" == "grsn-hh-?") set streamlist=`$DPROG/list_streams.csh grsn-hh-all` |
---|
108 | if ("$streamwild" == "grsn-hh-z") set streamlist=`$DPROG/list_streams.csh grsn-hh-all | grep z$` |
---|
109 | if ("$streamwild" == "grsn-bh-?") set streamlist=`$DPROG/list_streams.csh grsn-bh-all` |
---|
110 | if ("$streamwild" == "grsn-bh-z") set streamlist=`$DPROG/list_streams.csh grsn-bh-all | grep z$` |
---|
111 | if ("$streamwild" == "grsn-lh-?") set streamlist=`$DPROG/list_streams.csh grsn-lh-all` |
---|
112 | if ("$streamwild" == "grsn-lh-z") set streamlist=`$DPROG/list_streams.csh grsn-lh-all | grep z$` |
---|
113 | if ("$streamwild" == "sxnet") set streamlist=`$DPROG/list_streams.csh sxnet-bh-all` |
---|
114 | if ("$streamwild" == "sxnet-bh-?") set streamlist=`$DPROG/list_streams.csh sxnet-bh-all` |
---|
115 | if ("$streamwild" == "sxnet-bh-z") set streamlist=`$DPROG/list_streams.csh sxnet-bh-all | grep z$` |
---|
116 | |
---|
117 | if ("$streamlist" == "") then |
---|
118 | set streamlist=`(chdir $SEED_PROG/streams; ls $streamwild)` |
---|
119 | endif |
---|
120 | |
---|
121 | # copy data to temporary directory |
---|
122 | chdir $outdir |
---|
123 | mkdir $scrdir |
---|
124 | chdir $scrdir |
---|
125 | if ("$sfdfile" == "$jkpath") then |
---|
126 | set loc_sfdfile="$sfdfile" |
---|
127 | set pathcache="" |
---|
128 | set f_pathcache="" |
---|
129 | else if ("$sfdfile" == "DB:") then |
---|
130 | set loc_sfdfile=/tmp/seed_copy_$$.sfd |
---|
131 | if (-e $loc_sfdfile) \rm $loc_sfdfile |
---|
132 | if ("`uname`" == "Linux") then |
---|
133 | echo "station chan comp pathid relpath sdate stime edate etime recnum hswap recsize offset dataflags priority dataformat" >$loc_sfdfile |
---|
134 | $SH_UTIL/sfdb/sfd_from_sfdb.py $fromtime $totime >>$loc_sfdfile |
---|
135 | set pathcache="" |
---|
136 | set f_pathcache="" |
---|
137 | else |
---|
138 | $SEED_PROG/sfd_from_sfdb.csh $fromtime $totime >$loc_sfdfile |
---|
139 | set f_pathcache=/tmp/seed_pathcache_$$.000 |
---|
140 | if (-e $f_pathcache) \rm $f_pathcache |
---|
141 | $SH_UTIL/sol_sql_call.csh szpc35 "select * from pathtab order by id" >$f_pathcache |
---|
142 | set pathcache="-pathcache=$f_pathcache" |
---|
143 | endif |
---|
144 | else |
---|
145 | set pathcache="" |
---|
146 | set f_pathcache="" |
---|
147 | set loc_sfdfile=$startdir/$sfdfile |
---|
148 | if (! -e $loc_sfdfile) set loc_sfdfile=$sfdfile |
---|
149 | endif |
---|
150 | if ("$exact" == "exact") then |
---|
151 | set exact="-exact" |
---|
152 | else |
---|
153 | set exact="" |
---|
154 | endif |
---|
155 | foreach stream ($streamlist) |
---|
156 | echo "copying stream $stream" |
---|
157 | $SEED_PROG/copy_recs $pathcache -defaultnet=GR $exact $loc_sfdfile $stream \ |
---|
158 | $fromtime $totime standard |
---|
159 | end |
---|
160 | |
---|
161 | if ("$sfdfile" == "DB:") \rm $loc_sfdfile |
---|
162 | if ("$f_pathcache" != "") \rm $f_pathcache |
---|
163 | |
---|
164 | if ("$outfile" == "mini-seed") then |
---|
165 | mv * .. |
---|
166 | chdir .. |
---|
167 | rmdir $scrdir |
---|
168 | exit |
---|
169 | endif |
---|
170 | |
---|
171 | # create seed-volume |
---|
172 | $seedspec/seed_volume.csh '*' $outfile |
---|
173 | |
---|
174 | # remove scratch dir |
---|
175 | if (-f ./$outfile) mv $outfile .. |
---|
176 | chdir .. |
---|
177 | \rm -rf $scrdir |
---|