« lib/App/SeismicUnixGui/sunix/NMO_Vel_Stk/suvelan_nsel.pm
↑ Summary
lib/App/SeismicUnixGui/sunix/header/suutm.pm »
| 1 | package App::SeismicUnixGui::sunix::filter::sufilter; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | =head2 SYNOPSIS | ||
| 6 | |||
| 7 | PERL PROGRAM NAME: SUFILTER - applies a zero-phase, sine-squared tapered filter | ||
| 8 | AUTHOR: Juan Lorenzo (Perl module only) | ||
| 9 | DATE: Nov 1 2012,July 27 2015 | ||
| 10 | DESCRIPTION: sufilter a lists of header words | ||
| 11 | or an single value | ||
| 12 | Version: 0.0.1 | ||
| 13 | 0.0.2 updated to Moose | ||
| 14 | 0.0.3 genearated by sudoc2pm.pl Sept 7 2018 | ||
| 15 | |||
| 16 | =head2 USE | ||
| 17 | |||
| 18 | =head3 NOTES | ||
| 19 | |||
| 20 | =head4 Examples | ||
| 21 | |||
| 22 | =head3 SEISMIC UNIX NOTESuse L_SU_global_constants(); | ||
| 23 | |||
| 24 | SUFILTER - applies a zero-phase, sine-squared tapered filter | ||
| 25 | |||
| 26 | sufilter <stdin >stdout [optional parameters] | ||
| 27 | |||
| 28 | Required parameters: | ||
| 29 | if dt is not set in header, then dt is mandatory | ||
| 30 | |||
| 31 | Optional parameters: | ||
| 32 | f=f1,f2,... array of filter frequencies(HZ) | ||
| 33 | amps=a1,a2,... array of filter amplitudes | ||
| 34 | dt = (from header) time sampling interval (sec) | ||
| 35 | verbose=0 =1 for advisory messages | ||
| 36 | |||
| 37 | Defaults:f=.10*(nyquist),.15*(nyquist),.45*(nyquist),.50*(nyquist) | ||
| 38 | (nyquist calculated internally) | ||
| 39 | amps=0.,1.,...,1.,0. trapezoid-like bandpass filter | ||
| 40 | |||
| 41 | Examples of filters: | ||
| 42 | Bandpass: sufilter <data f=10,20,40,50 | ... | ||
| 43 | Bandreject: sufilter <data f=10,20,30,40 amps=1.,0.,0.,1. | .. | ||
| 44 | Lowpass: sufilter <data f=10,20,40,50 amps=1.,1.,0.,0. | ... | ||
| 45 | Highpass: sufilter <data f=10,20,40,50 amps=0.,0.,1.,1. | ... | ||
| 46 | Notch: sufilter <data f=10,12.5,35,50,60 amps=1.,.5,0.,.5,1. |.. | ||
| 47 | |||
| 48 | Credits: | ||
| 49 | CWP: John Stockwell, Jack Cohen | ||
| 50 | CENPET: Werner M. Heigl - added well log support | ||
| 51 | |||
| 52 | Possible optimization: Do assignments instead of crmuls where | ||
| 53 | filter is 0.0. | ||
| 54 | |||
| 55 | Trace header fields accessed: ns, dt, d1 | ||
| 56 | |||
| 57 | =head2 CHANGES and their DATES | ||
| 58 | |||
| 59 | =cut | ||
| 60 | |||
| 61 | use Moose; | ||
| 62 | our $VERSION = '0.0.1'; | ||
| 63 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 64 | |||
| 65 | my $get = L_SU_global_constants->new(); | ||
| 66 | |||
| 67 | my $var = $get->var(); | ||
| 68 | my $empty_string = $var->{_empty_string}; | ||
| 69 | my $false = $var->{_false}; | ||
| 70 | my $true = $var->{_true}; | ||
| 71 | |||
| 72 | my $sufilter = { | ||
| 73 | _amps => '', | ||
| 74 | _dt => '', | ||
| 75 | _error => '', | ||
| 76 | _f => '', | ||
| 77 | _verbose => '', | ||
| 78 | _Step => '', | ||
| 79 | _note => '', | ||
| 80 | }; | ||
| 81 | |||
| 82 | =head2 sub Step | ||
| 83 | |||
| 84 | collects switches and assembles bash instructions | ||
| 85 | by adding the program name | ||
| 86 | |||
| 87 | =cut | ||
| 88 | |||
| 89 | sub Step { | ||
| 90 | |||
| 91 | my ($self) = @_; | ||
| 92 | |||
| 93 | if ( defined $sufilter->{_error} | ||
| 94 | or $sufilter->{_error} eq $false ) | ||
| 95 | { | ||
| 96 | |||
| 97 | $sufilter->{_Step} = 'sufilter' . $sufilter->{_Step}; | ||
| 98 | return ( $sufilter->{_Step} ); | ||
| 99 | |||
| 100 | } | ||
| 101 | else { | ||
| 102 | print("sufilter, Step, error either true or missing \n "); | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 106 | =head2 sub note | ||
| 107 | |||
| 108 | collects switches and assembles bash instructions | ||
| 109 | by adding the program name | ||
| 110 | |||
| 111 | =cut | ||
| 112 | |||
| 113 | sub note { | ||
| 114 | |||
| 115 | $sufilter->{_note} = 'sufilter' . $sufilter->{_note}; | ||
| 116 | return ( $sufilter->{_note} ); | ||
| 117 | |||
| 118 | } | ||
| 119 | |||
| 120 | =head2 sub clear | ||
| 121 | |||
| 122 | =cut | ||
| 123 | |||
| 124 | sub clear { | ||
| 125 | |||
| 126 | $sufilter->{_amps} = ''; | ||
| 127 | $sufilter->{_dt} = ''; | ||
| 128 | $sufilter->{_error} = ''; | ||
| 129 | $sufilter->{_f} = ''; | ||
| 130 | $sufilter->{_verbose} = ''; | ||
| 131 | $sufilter->{_Step} = ''; | ||
| 132 | $sufilter->{_note} = ''; | ||
| 133 | } | ||
| 134 | |||
| 135 | =head2 sub amps | ||
| 136 | |||
| 137 | |||
| 138 | =cut | ||
| 139 | |||
| 140 | sub amps { | ||
| 141 | |||
| 142 | my ( $self, $amps ) = @_; | ||
| 143 | if ( $amps ne $empty_string ) { | ||
| 144 | |||
| 145 | $sufilter->{_amps} = $amps; | ||
| 146 | $sufilter->{_note} = | ||
| 147 | $sufilter->{_note} . ' amps=' . $sufilter->{_amps}; | ||
| 148 | $sufilter->{_Step} = | ||
| 149 | $sufilter->{_Step} . ' amps=' . $sufilter->{_amps}; | ||
| 150 | |||
| 151 | } | ||
| 152 | else { | ||
| 153 | print("sufilter, amps, missing amps,\n"); | ||
| 154 | } | ||
| 155 | } | ||
| 156 | |||
| 157 | =head2 sub amplitude | ||
| 158 | |||
| 159 | |||
| 160 | =cut | ||
| 161 | |||
| 162 | sub amplitude { | ||
| 163 | |||
| 164 | my ( $self, $amps ) = @_; | ||
| 165 | if ( $amps ne $empty_string ) { | ||
| 166 | |||
| 167 | $sufilter->{_amps} = $amps; | ||
| 168 | $sufilter->{_note} = | ||
| 169 | $sufilter->{_note} . ' amps=' . $sufilter->{_amps}; | ||
| 170 | $sufilter->{_Step} = | ||
| 171 | $sufilter->{_Step} . ' amps=' . $sufilter->{_amps}; | ||
| 172 | |||
| 173 | } | ||
| 174 | else { | ||
| 175 | print("sufilter, amps, missing amps,\n"); | ||
| 176 | } | ||
| 177 | } | ||
| 178 | |||
| 179 | =head2 sub dt | ||
| 180 | |||
| 181 | |||
| 182 | =cut | ||
| 183 | |||
| 184 | sub dt { | ||
| 185 | |||
| 186 | my ( $self, $dt ) = @_; | ||
| 187 | if ( $dt ne $empty_string ) { | ||
| 188 | |||
| 189 | $sufilter->{_dt} = $dt; | ||
| 190 | $sufilter->{_note} = $sufilter->{_note} . ' dt=' . $sufilter->{_dt}; | ||
| 191 | $sufilter->{_Step} = $sufilter->{_Step} . ' dt=' . $sufilter->{_dt}; | ||
| 192 | |||
| 193 | } | ||
| 194 | else { | ||
| 195 | print("sufilter, dt, missing dt,\n"); | ||
| 196 | } | ||
| 197 | } | ||
| 198 | |||
| 199 | =head2 sub f | ||
| 200 | |||
| 201 | |||
| 202 | =cut | ||
| 203 | |||
| 204 | sub f { | ||
| 205 | |||
| 206 | my ( $self, $f ) = @_; | ||
| 207 | if ( $f ne $empty_string ) { | ||
| 208 | |||
| 209 | $sufilter->{_f} = $f; | ||
| 210 | $sufilter->{_note} = $sufilter->{_note} . ' f=' . $sufilter->{_f}; | ||
| 211 | $sufilter->{_Step} = $sufilter->{_Step} . ' f=' . $sufilter->{_f}; | ||
| 212 | |||
| 213 | } | ||
| 214 | else { | ||
| 215 | print("sufilter, f, missing f,\n"); | ||
| 216 | $sufilter->{_error} = $true; | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | =head2 sub freq | ||
| 221 | |||
| 222 | |||
| 223 | =cut | ||
| 224 | |||
| 225 | sub freq { | ||
| 226 | |||
| 227 | my ( $self, $f ) = @_; | ||
| 228 | if ( $f ne $empty_string ) { | ||
| 229 | |||
| 230 | $sufilter->{_f} = $f; | ||
| 231 | $sufilter->{_note} = $sufilter->{_note} . ' f=' . $sufilter->{_f}; | ||
| 232 | $sufilter->{_Step} = $sufilter->{_Step} . ' f=' . $sufilter->{_f}; | ||
| 233 | |||
| 234 | } | ||
| 235 | else { | ||
| 236 | print("sufilter, f, missing f,\n"); | ||
| 237 | $sufilter->{_error} = $true; | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | =head2 sub verbose | ||
| 242 | |||
| 243 | |||
| 244 | =cut | ||
| 245 | |||
| 246 | sub verbose { | ||
| 247 | |||
| 248 | my ( $self, $verbose ) = @_; | ||
| 249 | if ( $verbose ne $empty_string ) { | ||
| 250 | |||
| 251 | $sufilter->{_verbose} = $verbose; | ||
| 252 | $sufilter->{_note} = | ||
| 253 | $sufilter->{_note} . ' verbose=' . $sufilter->{_verbose}; | ||
| 254 | $sufilter->{_Step} = | ||
| 255 | $sufilter->{_Step} . ' verbose=' . $sufilter->{_verbose}; | ||
| 256 | |||
| 257 | } | ||
| 258 | else { | ||
| 259 | print("sufilter, verbose, missing verbose,\n"); | ||
| 260 | } | ||
| 261 | } | ||
| 262 | |||
| 263 | =head2 sub get_max_index | ||
| 264 | |||
| 265 | max index = number of input variables -1 | ||
| 266 | |||
| 267 | =cut | ||
| 268 | |||
| 269 | sub get_max_index { | ||
| 270 | my ($self) = @_; | ||
| 271 | |||
| 272 | # index=3 | ||
| 273 | my $max_index = 3; | ||
| 274 | |||
| 275 | return ($max_index); | ||
| 276 | } | ||
| 277 | |||
| 278 | 1; |