« lib/App/SeismicUnixGui/sunix/data/dt1tosu.pm
↑ Summary
lib/App/SeismicUnixGui/sunix/filter/supofilt.pm »
| 1 | package App::SeismicUnixGui::sunix::filter::sufxdecon; | ||
| 2 | |||
| 3 | =head2 SYNOPSIS | ||
| 4 | |||
| 5 | PERL PROGRAM NAME: | ||
| 6 | |||
| 7 | AUTHOR: Juan Lorenzo (Perl module only) | ||
| 8 | |||
| 9 | DATE: | ||
| 10 | |||
| 11 | DESCRIPTION: | ||
| 12 | |||
| 13 | Version: | ||
| 14 | |||
| 15 | =head2 USE | ||
| 16 | |||
| 17 | =head3 NOTES | ||
| 18 | |||
| 19 | =head4 Examples | ||
| 20 | |||
| 21 | =head2 SYNOPSIS | ||
| 22 | |||
| 23 | =head3 SEISMIC UNIX NOTES | ||
| 24 | SUFXDECON - random noise attenuation by FX-DECONvolution | ||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | sufxdecon <stdin >stdout [...] | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | Required Parameters: | ||
| 33 | |||
| 34 | |||
| 35 | |||
| 36 | Optional Parameters: | ||
| 37 | |||
| 38 | taper=.1 length of taper | ||
| 39 | |||
| 40 | fmin=6. minimum frequency to process in Hz (accord to twlen) | ||
| 41 | |||
| 42 | fmax=.6/(2*dt) maximum frequency to process in Hz | ||
| 43 | |||
| 44 | twlen=entire trace time window length (minimum .3 for lower freqs) | ||
| 45 | |||
| 46 | ntrw=10 number of traces in window | ||
| 47 | |||
| 48 | ntrf=4 number of traces for filter (smaller than ntrw) | ||
| 49 | |||
| 50 | verbose=0 =1 for diagnostic print | ||
| 51 | |||
| 52 | tmpdir= if non-empty, use the value as a directory path prefix | ||
| 53 | |||
| 54 | for storing temporary files; else, if the CWP_TMPDIR | ||
| 55 | |||
| 56 | environment variable is set, use its value for the path; | ||
| 57 | |||
| 58 | else use tmpfile() | ||
| 59 | |||
| 60 | |||
| 61 | |||
| 62 | Notes: Each trace is transformed to the frequency domain. | ||
| 63 | |||
| 64 | For each frequency, Wiener filtering, with unity prediction in | ||
| 65 | |||
| 66 | space, is used to predict the next sample. | ||
| 67 | |||
| 68 | At the end of the process, data is mapped back to t-x domain. ", | ||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | Credits: | ||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | CWP: Carlos E. Theodoro (10/07/97) | ||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | References: | ||
| 85 | |||
| 86 | Canales(1984):'Random noise reduction' 54th. SEGM | ||
| 87 | |||
| 88 | Gulunay(1986):'FXDECON and complex Wiener Predicition | ||
| 89 | |||
| 90 | filter' 56th. SEGM | ||
| 91 | |||
| 92 | Galbraith(1991):'Random noise attenuation by F-X | ||
| 93 | |||
| 94 | prediction: a tutorial' 61th. SEGM | ||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | Algorithm: | ||
| 99 | |||
| 100 | - read data | ||
| 101 | |||
| 102 | - loop over time windows | ||
| 103 | |||
| 104 | - select data | ||
| 105 | |||
| 106 | - FFT (t -> f) | ||
| 107 | |||
| 108 | - loop over space windows | ||
| 109 | |||
| 110 | - select data | ||
| 111 | |||
| 112 | - loop over frequencies | ||
| 113 | |||
| 114 | - autocorelation | ||
| 115 | |||
| 116 | - matrix problem | ||
| 117 | |||
| 118 | - construct filter | ||
| 119 | |||
| 120 | - filter data | ||
| 121 | |||
| 122 | - loop along space window | ||
| 123 | |||
| 124 | - FFT (f -> t) | ||
| 125 | |||
| 126 | - reconstruct data | ||
| 127 | |||
| 128 | - output data | ||
| 129 | |||
| 130 | |||
| 131 | |||
| 132 | Trace header fields accessed: ns, dt, d1 | ||
| 133 | |||
| 134 | Trace header fields modified: | ||
| 135 | |||
| 136 | |||
| 137 | |||
| 138 | |||
| 139 | |||
| 140 | =head2 User's notes (Juan Lorenzo) | ||
| 141 | untested | ||
| 142 | |||
| 143 | =cut | ||
| 144 | |||
| 145 | |||
| 146 | =head2 CHANGES and their DATES | ||
| 147 | |||
| 148 | =cut | ||
| 149 | |||
| 150 | use Moose; | ||
| 151 | our $VERSION = '0.0.1'; | ||
| 152 | |||
| 153 | |||
| 154 | =head2 Import packages | ||
| 155 | |||
| 156 | =cut | ||
| 157 | |||
| 158 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 159 | |||
| 160 | use App::SeismicUnixGui::misc::SeismicUnix qw($go $in $off $on $out $ps $to $suffix_ascii $suffix_bin $suffix_ps $suffix_segy $suffix_su); | ||
| 161 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 162 | |||
| 163 | |||
| 164 | =head2 instantiation of packages | ||
| 165 | |||
| 166 | =cut | ||
| 167 | |||
| 168 | my $get = L_SU_global_constants->new(); | ||
| 169 | my $Project = Project_config->new(); | ||
| 170 | my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); | ||
| 171 | my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN(); | ||
| 172 | my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT(); | ||
| 173 | |||
| 174 | my $PS_SEISMIC = $Project->PS_SEISMIC(); | ||
| 175 | |||
| 176 | my $var = $get->var(); | ||
| 177 | my $on = $var->{_on}; | ||
| 178 | my $off = $var->{_off}; | ||
| 179 | my $true = $var->{_true}; | ||
| 180 | my $false = $var->{_false}; | ||
| 181 | my $empty_string = $var->{_empty_string}; | ||
| 182 | |||
| 183 | =head2 Encapsulated | ||
| 184 | hash of private variables | ||
| 185 | |||
| 186 | =cut | ||
| 187 | |||
| 188 | my $sufxdecon = { | ||
| 189 | _fmax => '', | ||
| 190 | _fmin => '', | ||
| 191 | _ntrf => '', | ||
| 192 | _ntrw => '', | ||
| 193 | _taper => '', | ||
| 194 | _tmpdir => '', | ||
| 195 | _twlen => '', | ||
| 196 | _verbose => '', | ||
| 197 | _Step => '', | ||
| 198 | _note => '', | ||
| 199 | |||
| 200 | }; | ||
| 201 | |||
| 202 | =head2 sub Step | ||
| 203 | |||
| 204 | collects switches and assembles bash instructions | ||
| 205 | by adding the program name | ||
| 206 | |||
| 207 | =cut | ||
| 208 | |||
| 209 | sub Step { | ||
| 210 | |||
| 211 | $sufxdecon->{_Step} = 'sufxdecon'.$sufxdecon->{_Step}; | ||
| 212 | return ( $sufxdecon->{_Step} ); | ||
| 213 | |||
| 214 | } | ||
| 215 | |||
| 216 | |||
| 217 | =head2 sub note | ||
| 218 | |||
| 219 | collects switches and assembles bash instructions | ||
| 220 | by adding the program name | ||
| 221 | |||
| 222 | =cut | ||
| 223 | |||
| 224 | sub note { | ||
| 225 | |||
| 226 | $sufxdecon->{_note} = 'sufxdecon'.$sufxdecon->{_note}; | ||
| 227 | return ( $sufxdecon->{_note} ); | ||
| 228 | |||
| 229 | } | ||
| 230 | |||
| 231 | |||
| 232 | |||
| 233 | =head2 sub clear | ||
| 234 | |||
| 235 | =cut | ||
| 236 | |||
| 237 | sub clear { | ||
| 238 | |||
| 239 | $sufxdecon->{_fmax} = ''; | ||
| 240 | $sufxdecon->{_fmin} = ''; | ||
| 241 | $sufxdecon->{_ntrf} = ''; | ||
| 242 | $sufxdecon->{_ntrw} = ''; | ||
| 243 | $sufxdecon->{_taper} = ''; | ||
| 244 | $sufxdecon->{_tmpdir} = ''; | ||
| 245 | $sufxdecon->{_twlen} = ''; | ||
| 246 | $sufxdecon->{_verbose} = ''; | ||
| 247 | $sufxdecon->{_Step} = ''; | ||
| 248 | $sufxdecon->{_note} = ''; | ||
| 249 | } | ||
| 250 | |||
| 251 | |||
| 252 | =head2 sub fmax | ||
| 253 | |||
| 254 | |||
| 255 | =cut | ||
| 256 | |||
| 257 | sub fmax { | ||
| 258 | |||
| 259 | my ( $self,$fmax ) = @_; | ||
| 260 | if ( $fmax ne $empty_string ) { | ||
| 261 | |||
| 262 | $sufxdecon->{_fmax} = $fmax; | ||
| 263 | $sufxdecon->{_note} = $sufxdecon->{_note}.' fmax='.$sufxdecon->{_fmax}; | ||
| 264 | $sufxdecon->{_Step} = $sufxdecon->{_Step}.' fmax='.$sufxdecon->{_fmax}; | ||
| 265 | |||
| 266 | } else { | ||
| 267 | print("sufxdecon, fmax, missing fmax,\n"); | ||
| 268 | } | ||
| 269 | } | ||
| 270 | |||
| 271 | |||
| 272 | =head2 sub fmin | ||
| 273 | |||
| 274 | |||
| 275 | =cut | ||
| 276 | |||
| 277 | sub fmin { | ||
| 278 | |||
| 279 | my ( $self,$fmin ) = @_; | ||
| 280 | if ( $fmin ne $empty_string ) { | ||
| 281 | |||
| 282 | $sufxdecon->{_fmin} = $fmin; | ||
| 283 | $sufxdecon->{_note} = $sufxdecon->{_note}.' fmin='.$sufxdecon->{_fmin}; | ||
| 284 | $sufxdecon->{_Step} = $sufxdecon->{_Step}.' fmin='.$sufxdecon->{_fmin}; | ||
| 285 | |||
| 286 | } else { | ||
| 287 | print("sufxdecon, fmin, missing fmin,\n"); | ||
| 288 | } | ||
| 289 | } | ||
| 290 | |||
| 291 | |||
| 292 | =head2 sub ntrf | ||
| 293 | |||
| 294 | |||
| 295 | =cut | ||
| 296 | |||
| 297 | sub ntrf { | ||
| 298 | |||
| 299 | my ( $self,$ntrf ) = @_; | ||
| 300 | if ( $ntrf ne $empty_string ) { | ||
| 301 | |||
| 302 | $sufxdecon->{_ntrf} = $ntrf; | ||
| 303 | $sufxdecon->{_note} = $sufxdecon->{_note}.' ntrf='.$sufxdecon->{_ntrf}; | ||
| 304 | $sufxdecon->{_Step} = $sufxdecon->{_Step}.' ntrf='.$sufxdecon->{_ntrf}; | ||
| 305 | |||
| 306 | } else { | ||
| 307 | print("sufxdecon, ntrf, missing ntrf,\n"); | ||
| 308 | } | ||
| 309 | } | ||
| 310 | |||
| 311 | |||
| 312 | =head2 sub ntrw | ||
| 313 | |||
| 314 | |||
| 315 | =cut | ||
| 316 | |||
| 317 | sub ntrw { | ||
| 318 | |||
| 319 | my ( $self,$ntrw ) = @_; | ||
| 320 | if ( $ntrw ne $empty_string ) { | ||
| 321 | |||
| 322 | $sufxdecon->{_ntrw} = $ntrw; | ||
| 323 | $sufxdecon->{_note} = $sufxdecon->{_note}.' ntrw='.$sufxdecon->{_ntrw}; | ||
| 324 | $sufxdecon->{_Step} = $sufxdecon->{_Step}.' ntrw='.$sufxdecon->{_ntrw}; | ||
| 325 | |||
| 326 | } else { | ||
| 327 | print("sufxdecon, ntrw, missing ntrw,\n"); | ||
| 328 | } | ||
| 329 | } | ||
| 330 | |||
| 331 | |||
| 332 | =head2 sub taper | ||
| 333 | |||
| 334 | |||
| 335 | =cut | ||
| 336 | |||
| 337 | sub taper { | ||
| 338 | |||
| 339 | my ( $self,$taper ) = @_; | ||
| 340 | if ( $taper ne $empty_string ) { | ||
| 341 | |||
| 342 | $sufxdecon->{_taper} = $taper; | ||
| 343 | $sufxdecon->{_note} = $sufxdecon->{_note}.' taper='.$sufxdecon->{_taper}; | ||
| 344 | $sufxdecon->{_Step} = $sufxdecon->{_Step}.' taper='.$sufxdecon->{_taper}; | ||
| 345 | |||
| 346 | } else { | ||
| 347 | print("sufxdecon, taper, missing taper,\n"); | ||
| 348 | } | ||
| 349 | } | ||
| 350 | |||
| 351 | |||
| 352 | =head2 sub tmpdir | ||
| 353 | |||
| 354 | |||
| 355 | =cut | ||
| 356 | |||
| 357 | sub tmpdir { | ||
| 358 | |||
| 359 | my ( $self,$tmpdir ) = @_; | ||
| 360 | if ( $tmpdir ne $empty_string ) { | ||
| 361 | |||
| 362 | $sufxdecon->{_tmpdir} = $tmpdir; | ||
| 363 | $sufxdecon->{_note} = $sufxdecon->{_note}.' tmpdir='.$sufxdecon->{_tmpdir}; | ||
| 364 | $sufxdecon->{_Step} = $sufxdecon->{_Step}.' tmpdir='.$sufxdecon->{_tmpdir}; | ||
| 365 | |||
| 366 | } else { | ||
| 367 | print("sufxdecon, tmpdir, missing tmpdir,\n"); | ||
| 368 | } | ||
| 369 | } | ||
| 370 | |||
| 371 | |||
| 372 | =head2 sub twlen | ||
| 373 | |||
| 374 | |||
| 375 | =cut | ||
| 376 | |||
| 377 | sub twlen { | ||
| 378 | |||
| 379 | my ( $self,$twlen ) = @_; | ||
| 380 | if ( $twlen ne $empty_string ) { | ||
| 381 | |||
| 382 | $sufxdecon->{_twlen} = $twlen; | ||
| 383 | $sufxdecon->{_note} = $sufxdecon->{_note}.' twlen='.$sufxdecon->{_twlen}; | ||
| 384 | $sufxdecon->{_Step} = $sufxdecon->{_Step}.' twlen='.$sufxdecon->{_twlen}; | ||
| 385 | |||
| 386 | } else { | ||
| 387 | print("sufxdecon, twlen, missing twlen,\n"); | ||
| 388 | } | ||
| 389 | } | ||
| 390 | |||
| 391 | |||
| 392 | =head2 sub verbose | ||
| 393 | |||
| 394 | |||
| 395 | =cut | ||
| 396 | |||
| 397 | sub verbose { | ||
| 398 | |||
| 399 | my ( $self,$verbose ) = @_; | ||
| 400 | if ( $verbose ne $empty_string ) { | ||
| 401 | |||
| 402 | $sufxdecon->{_verbose} = $verbose; | ||
| 403 | $sufxdecon->{_note} = $sufxdecon->{_note}.' verbose='.$sufxdecon->{_verbose}; | ||
| 404 | $sufxdecon->{_Step} = $sufxdecon->{_Step}.' verbose='.$sufxdecon->{_verbose}; | ||
| 405 | |||
| 406 | } else { | ||
| 407 | print("sufxdecon, verbose, missing verbose,\n"); | ||
| 408 | } | ||
| 409 | } | ||
| 410 | |||
| 411 | |||
| 412 | =head2 sub get_max_index | ||
| 413 | |||
| 414 | max index = number of input variables -1 | ||
| 415 | |||
| 416 | =cut | ||
| 417 | |||
| 418 | sub get_max_index { | ||
| 419 | my ($self) = @_; | ||
| 420 | my $max_index = 7; | ||
| 421 | |||
| 422 | return($max_index); | ||
| 423 | } | ||
| 424 | |||
| 425 | |||
| 426 | 1; |