« lib/App/SeismicUnixGui/sunix/transform/suicepstrum.pm
↑ Summary
lib/App/SeismicUnixGui/specs/NMO_Vel_Stk/dzdv_spec.pm »
| 1 | package App::SeismicUnixGui::misc::su_spectral_analysis; | ||
| 2 | use Moose; | ||
| 3 | our $VERSION = '0.0.1'; | ||
| 4 | |||
| 5 | =head1 DOCUMENTATION | ||
| 6 | |||
| 7 | =head2 SYNOPSIS | ||
| 8 | |||
| 9 | PERL PROGRAM NAME:su_spectral_analysis.pm | ||
| 10 | Purpose: Spectral analysis | ||
| 11 | of spectral_analysised waveforms in su format | ||
| 12 | AUTHOR: Juan M. Lorenzo | ||
| 13 | DEPENDS: Seismic Unix modules from CSM | ||
| 14 | DATE: July 8 2016 V0.1 | ||
| 15 | DESCRIPTION: | ||
| 16 | |||
| 17 | =head 2 USES | ||
| 18 | |||
| 19 | (for subroutines) | ||
| 20 | manage_files_by | ||
| 21 | System_Variables (for subroutines) | ||
| 22 | |||
| 23 | (for variable definitions) | ||
| 24 | SeismicUnix (Seismic Unix modules) | ||
| 25 | |||
| 26 | |||
| 27 | =head2 NOTES | ||
| 28 | |||
| 29 | We are using moose | ||
| 30 | moose already declares that you need debuggers turned on | ||
| 31 | so you don't need a line like the following: | ||
| 32 | |||
| 33 | use warnings; | ||
| 34 | |||
| 35 | =head2 USES | ||
| 36 | |||
| 37 | (for subroutines) | ||
| 38 | manage_files_by | ||
| 39 | System_Variables (for subroutines) | ||
| 40 | |||
| 41 | (for variable definitions) | ||
| 42 | SeismicUnix (Seismic Unix modules) | ||
| 43 | |||
| 44 | |||
| 45 | use App::SeismicUnixGui::misc::SeismicUnix qw($in $out $on $go $to $suffix_ascii $off $suffix_su) ; | ||
| 46 | |||
| 47 | =head3 STEPS IN THE PROGRAM | ||
| 48 | |||
| 49 | =cut | ||
| 50 | |||
| 51 | =head2 Create | ||
| 52 | |||
| 53 | hash of shared variables and | ||
| 54 | subroutine to clear them | ||
| 55 | |||
| 56 | Do not clear: absclip_phase or absclip_freq | ||
| 57 | |||
| 58 | =cut | ||
| 59 | |||
| 60 | my $spectral_analysis = { | ||
| 61 | _agc_gain_width => '', | ||
| 62 | _filter_freq => '', | ||
| 63 | _inbound => '', | ||
| 64 | _outbound => '', | ||
| 65 | _absclip_phase => 1, | ||
| 66 | _absclip_freq => 1, | ||
| 67 | _absclip => 1, | ||
| 68 | _window_title => '', | ||
| 69 | _title => '' | ||
| 70 | }; | ||
| 71 | |||
| 72 | sub clear { | ||
| 73 | $spectral_analysis->{_agc_gain_width} = ''; | ||
| 74 | $spectral_analysis->{_absclip_phase} = '', | ||
| 75 | $spectral_analysis->{_absclip_freq} = ''; | ||
| 76 | $spectral_analysis->{_absclip} = ''; | ||
| 77 | $spectral_analysis->{_filter_freq} = ''; | ||
| 78 | $spectral_analysis->{_inbound} = ''; | ||
| 79 | $spectral_analysis->{_outbound} = ''; | ||
| 80 | $spectral_analysis->{_window_title} = ''; | ||
| 81 | $spectral_analysis->{_title} = ''; | ||
| 82 | } | ||
| 83 | |||
| 84 | =head2 sub picks_file | ||
| 85 | |||
| 86 | set picks_file | ||
| 87 | waveform file | ||
| 88 | |||
| 89 | =cut | ||
| 90 | |||
| 91 | sub picks_file { | ||
| 92 | my ( $variable, $picks_file ) = @_; | ||
| 93 | if ($picks_file) { | ||
| 94 | $spectral_analysis->{_picks_file} = $picks_file; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | =head2 sub agc_gain_width | ||
| 99 | |||
| 100 | set agc_gain_width | ||
| 101 | waveform file | ||
| 102 | |||
| 103 | =cut | ||
| 104 | |||
| 105 | sub agc_gain_width { | ||
| 106 | my ( $variable, $agc_gain_width ) = @_; | ||
| 107 | if ($agc_gain_width) { | ||
| 108 | $spectral_analysis->{_agc_gain_width} = $agc_gain_width; | ||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 112 | =head2 sub filter_freq | ||
| 113 | |||
| 114 | set filter_freq | ||
| 115 | waveform file | ||
| 116 | |||
| 117 | =cut | ||
| 118 | |||
| 119 | sub filter_freq { | ||
| 120 | my ( $variable, $filter_freq ) = @_; | ||
| 121 | if ($filter_freq) { | ||
| 122 | $spectral_analysis->{_filter_freq} = $filter_freq; | ||
| 123 | } | ||
| 124 | } | ||
| 125 | |||
| 126 | =head2 sub window_title | ||
| 127 | |||
| 128 | set window_title for suxwigb | ||
| 129 | |||
| 130 | =cut | ||
| 131 | |||
| 132 | sub window_title { | ||
| 133 | my ( $variable, $window_title ) = @_; | ||
| 134 | if ($window_title) { | ||
| 135 | $spectral_analysis->{_window_title} = $window_title; | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | =head2 sub title | ||
| 140 | |||
| 141 | set title for suxwigb | ||
| 142 | |||
| 143 | =cut | ||
| 144 | |||
| 145 | sub title { | ||
| 146 | my ( $variable, $title ) = @_; | ||
| 147 | if ($title) { | ||
| 148 | $spectral_analysis->{_title} = $title; | ||
| 149 | } | ||
| 150 | } | ||
| 151 | |||
| 152 | =head2 sub absclip | ||
| 153 | |||
| 154 | set absclip for XT data | ||
| 155 | |||
| 156 | =cut | ||
| 157 | |||
| 158 | sub absclip { | ||
| 159 | my ( $variable, $absclip) = @_; | ||
| 160 | if ($absclip) { | ||
| 161 | $spectral_analysis->{_absclip} = $absclip; | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | =head2 sub absclip_phase | ||
| 166 | |||
| 167 | set absclip for phase | ||
| 168 | |||
| 169 | =cut | ||
| 170 | |||
| 171 | sub absclip_phase { | ||
| 172 | my ( $variable, $absclip_phase ) = @_; | ||
| 173 | if ($absclip_phase) { | ||
| 174 | $spectral_analysis->{_absclip_phase} = $absclip_phase; | ||
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 178 | =head2 sub absclip_freq | ||
| 179 | |||
| 180 | set absclip for phase | ||
| 181 | |||
| 182 | =cut | ||
| 183 | |||
| 184 | sub absclip_freq { | ||
| 185 | my ( $variable, $absclip_freq ) = @_; | ||
| 186 | if ($absclip_freq) { | ||
| 187 | $spectral_analysis->{_absclip_freq} = $absclip_freq; | ||
| 188 | } | ||
| 189 | } | ||
| 190 | |||
| 191 | =head2 sub inbound | ||
| 192 | |||
| 193 | set _inbound seismic-unix | ||
| 194 | -formatted file name | ||
| 195 | including directory path as well | ||
| 196 | |||
| 197 | =cut | ||
| 198 | |||
| 199 | sub inbound { | ||
| 200 | my ( $variable, $inbound ) = @_; | ||
| 201 | if ($inbound) { | ||
| 202 | $spectral_analysis->{_inbound} = $inbound; | ||
| 203 | |||
| 204 | # print("inbound is $spectral_analysis->{_inbound}\n\n"); | ||
| 205 | } | ||
| 206 | } | ||
| 207 | |||
| 208 | =head2 sub Step | ||
| 209 | |||
| 210 | Selection of waveform | ||
| 211 | |||
| 212 | =cut | ||
| 213 | |||
| 214 | sub Step { | ||
| 215 | |||
| 216 | use App::SeismicUnixGui::misc::SeismicUnix qw($in $out $on $go $to $suffix_ascii $off $suffix_su); | ||
| 217 | |||
| 218 | use aliased 'App::SeismicUnixGui::misc::message'; | ||
| 219 | use aliased 'App::SeismicUnixGui::misc::flow'; | ||
| 220 | use aliased 'App::SeismicUnixGui::sunix::plot::suxwigb'; | ||
| 221 | use aliased 'App::SeismicUnixGui::sunix::plot::suximage'; | ||
| 222 | use aliased 'App::SeismicUnixGui::sunix::filter::sufilter'; | ||
| 223 | use aliased 'App::SeismicUnixGui::sunix::shapeNcut::sugain'; | ||
| 224 | use aliased 'App::SeismicUnixGui::sunix::transform::sufft'; | ||
| 225 | use aliased 'App::SeismicUnixGui::sunix::transform::suamp'; | ||
| 226 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 227 | use aliased 'App::SeismicUnixGui::sunix::shapeNcut::suwind'; | ||
| 228 | |||
| 229 | =pod | ||
| 230 | |||
| 231 | 1. Instantiate classes | ||
| 232 | Create a new version of the package | ||
| 233 | Personalize to give it a new name if you wish | ||
| 234 | Use classes: | ||
| 235 | |||
| 236 | message | ||
| 237 | flow | ||
| 238 | sufilter | ||
| 239 | sugain | ||
| 240 | suxwigb | ||
| 241 | suximage | ||
| 242 | suwind | ||
| 243 | suximage | ||
| 244 | suamp | ||
| 245 | sufft | ||
| 246 | |||
| 247 | =cut | ||
| 248 | |||
| 249 | my $log = message->new(); | ||
| 250 | my $run = flow->new(); | ||
| 251 | my $suxwigb = suxwigb->new(); | ||
| 252 | my $suximage = suximage->new(); | ||
| 253 | my $suwind = suwind->new(); | ||
| 254 | my $sufft = sufft->new(); | ||
| 255 | my $suamp = suamp->new(); | ||
| 256 | my $sufilter = sufilter->new(); | ||
| 257 | my $sugain = sugain->new(); | ||
| 258 | my $Project = Project_config->new(); | ||
| 259 | |||
| 260 | my ($DATA_SEISMIC_SU) = $Project->DATA_SEISMIC_SU(); | ||
| 261 | |||
| 262 | =pod | ||
| 263 | |||
| 264 | 3. Declare local variables | ||
| 265 | |||
| 266 | =cut | ||
| 267 | |||
| 268 | my (@flow); | ||
| 269 | my ( @suxwigb, @sufilter, @suximage ); | ||
| 270 | my ( @sugain, @items ); | ||
| 271 | my ( @suamp, @sufft ); | ||
| 272 | |||
| 273 | =head2 Declare | ||
| 274 | |||
| 275 | file names | ||
| 276 | |||
| 277 | =cut | ||
| 278 | |||
| 279 | =pod | ||
| 280 | |||
| 281 | 5. sugain | ||
| 282 | |||
| 283 | this is how to use a subroutine from the sugain 'package' | ||
| 284 | $on =1 | ||
| 285 | $width is the width of the window in seconds | ||
| 286 | $sugain-> Step() generates the instructions to run this single module with | ||
| 287 | the correct syntax for perl | ||
| 288 | |||
| 289 | $sugain -> agc($on); | ||
| 290 | $sugain -> width_s(2.6); | ||
| 291 | $sugain[2] = $sugain->Step(); | ||
| 292 | |||
| 293 | =cut | ||
| 294 | |||
| 295 | $sugain->clear(); | ||
| 296 | $sugain->pbal($on); | ||
| 297 | $sugain[1] = $sugain->Step(); | ||
| 298 | |||
| 299 | $sugain->clear(); | ||
| 300 | $sugain->agc($on); | ||
| 301 | $sugain->width_s( $spectral_analysis->{_agc_gain_width} ); | ||
| 302 | $sugain[2] = $sugain->Step(); | ||
| 303 | |||
| 304 | =head2 Set | ||
| 305 | |||
| 306 | filtering parameters | ||
| 307 | |||
| 308 | =cut | ||
| 309 | |||
| 310 | $sufilter->freq( $spectral_analysis->{_filter_freq} ); | ||
| 311 | $sufilter[1] = $sufilter->Step(); | ||
| 312 | |||
| 313 | =head2 Set | ||
| 314 | |||
| 315 | 5. set suxwigb parameters | ||
| 316 | In the perl module for suxwigb we should | ||
| 317 | have (but we do not yet) an explanation of each of these parameters | ||
| 318 | |||
| 319 | =cut | ||
| 320 | |||
| 321 | $suxwigb->clear(); | ||
| 322 | |||
| 323 | #$suxwigb-> d1(1); | ||
| 324 | #$suxwigb-> d2(1); | ||
| 325 | #$suxwigb-> f1(1); | ||
| 326 | #$suxwigb-> f2(1); | ||
| 327 | $suxwigb->xcur(1); | ||
| 328 | |||
| 329 | #$suxwigb-> va(2.5); | ||
| 330 | $suxwigb->n2tic(1); | ||
| 331 | $suxwigb->d2num(20); | ||
| 332 | $suxwigb->windowtitle( $spectral_analysis->{_window_title} ); | ||
| 333 | $suxwigb->title( $spectral_analysis->{_window_title} ); | ||
| 334 | $suxwigb->xlabel( quotemeta('No.traces') ); | ||
| 335 | $suxwigb->ylabel( quotemeta('TWTT s') ); | ||
| 336 | $suxwigb->box_width(300); | ||
| 337 | $suxwigb->box_height(500); | ||
| 338 | $suxwigb->box_X0(250); | ||
| 339 | $suxwigb->box_Y0(600); | ||
| 340 | $suxwigb->absclip( $spectral_analysis->{_absclip} ); | ||
| 341 | $suxwigb[1] = $suxwigb->Step(); | ||
| 342 | |||
| 343 | =head2 Set | ||
| 344 | |||
| 345 | suxwigb parameters | ||
| 346 | for Frequency spectrum | ||
| 347 | |||
| 348 | =cut | ||
| 349 | |||
| 350 | $suxwigb->clear(); | ||
| 351 | |||
| 352 | #$suxwigb-> d1(0.5); | ||
| 353 | $suxwigb->d2(1); | ||
| 354 | $suxwigb->f1(0); | ||
| 355 | $suxwigb->f2(1); | ||
| 356 | $suxwigb->xcur(1); | ||
| 357 | $suxwigb->n2tic(1); | ||
| 358 | $suxwigb->d2num(20); | ||
| 359 | $suxwigb->windowtitle( $spectral_analysis->{_window_title} ); | ||
| 360 | $suxwigb->title( $spectral_analysis->{_title} ); | ||
| 361 | $suxwigb->xlabel( quotemeta('Amplitude') ); | ||
| 362 | $suxwigb->ylabel( quotemeta('Frequency (Hz)') ); | ||
| 363 | $suxwigb->box_width(300); | ||
| 364 | $suxwigb->box_height(500); | ||
| 365 | $suxwigb->box_X0(575); | ||
| 366 | $suxwigb->box_Y0(600); | ||
| 367 | $suxwigb->absclip( $spectral_analysis->{_absclip_freq} ); | ||
| 368 | |||
| 369 | #$suxwigb-> wigclip(1); | ||
| 370 | $suxwigb[2] = $suxwigb->Step(); | ||
| 371 | |||
| 372 | =head2 Set | ||
| 373 | |||
| 374 | suxwigb parameters | ||
| 375 | for phase spectrum | ||
| 376 | |||
| 377 | =cut | ||
| 378 | |||
| 379 | $suxwigb->clear(); | ||
| 380 | |||
| 381 | #$suxwigb-> d1(0.5); | ||
| 382 | $suxwigb->d2(1); | ||
| 383 | $suxwigb->f1(0); | ||
| 384 | $suxwigb->f2(1); | ||
| 385 | $suxwigb->xcur(1); | ||
| 386 | $suxwigb->n2tic(1); | ||
| 387 | $suxwigb->d2num(20); | ||
| 388 | $suxwigb->windowtitle( $spectral_analysis->{_window_title} ); | ||
| 389 | $suxwigb->title( $spectral_analysis->{_title} ); | ||
| 390 | $suxwigb->xlabel( quotemeta('Phase') ); | ||
| 391 | $suxwigb->ylabel( quotemeta('Frequency (Hz)') ); | ||
| 392 | $suxwigb->box_width(300); | ||
| 393 | $suxwigb->box_height(500); | ||
| 394 | $suxwigb->box_X0(900); | ||
| 395 | $suxwigb->box_Y0(600); | ||
| 396 | $suxwigb->absclip( $spectral_analysis->{_absclip_phase} ); | ||
| 397 | |||
| 398 | #$suxwigb-> wigclip(1); | ||
| 399 | $suxwigb[3] = $suxwigb->Step(); | ||
| 400 | |||
| 401 | =head2 fft | ||
| 402 | |||
| 403 | |||
| 404 | |||
| 405 | =cut | ||
| 406 | |||
| 407 | $sufft->clear(); | ||
| 408 | $sufft->verbose($on); | ||
| 409 | $sufft[1] = $sufft->Step(); | ||
| 410 | |||
| 411 | =head2 extract f spectra | ||
| 412 | |||
| 413 | |||
| 414 | =cut | ||
| 415 | |||
| 416 | $suamp->clear(); | ||
| 417 | $suamp->mode('amp'); | ||
| 418 | $suamp[1] = $suamp->Step(); | ||
| 419 | |||
| 420 | =head2 extract phase spectra | ||
| 421 | |||
| 422 | |||
| 423 | =cut | ||
| 424 | |||
| 425 | $suamp->clear(); | ||
| 426 | |||
| 427 | # $suamp -> mode('phase'); | ||
| 428 | $suamp->mode('ouphase'); | ||
| 429 | $suamp[2] = $suamp->Step(); | ||
| 430 | |||
| 431 | =head2 DEFINE FLOW(S) | ||
| 432 | |||
| 433 | |||
| 434 | =cut | ||
| 435 | |||
| 436 | @items = ( $suxwigb[1], $in, $spectral_analysis->{_inbound}, $go ); | ||
| 437 | $flow[1] = $run->modules( \@items ); | ||
| 438 | |||
| 439 | @items = ( | ||
| 440 | $sufft[1], $in, $spectral_analysis->{_inbound}, | ||
| 441 | $to, $suamp[1], $to, $suxwigb[2], $go | ||
| 442 | ); | ||
| 443 | $flow[2] = $run->modules( \@items ); | ||
| 444 | |||
| 445 | @items = ( | ||
| 446 | $sufft[1], $in, $spectral_analysis->{_inbound}, | ||
| 447 | $to, $suamp[2], $to, $suxwigb[3], $go | ||
| 448 | ); | ||
| 449 | $flow[3] = $run->modules( \@items ); | ||
| 450 | |||
| 451 | return \@flow; | ||
| 452 | |||
| 453 | =pod LOG FLOW(S)TO SCREEN AND FILE | ||
| 454 | |||
| 455 | |||
| 456 | =cut | ||
| 457 | |||
| 458 | #print "$flow[1]\n"; | ||
| 459 | |||
| 460 | } # end of sub Step | ||
| 461 | |||
| 462 | =pod | ||
| 463 | |||
| 464 | place 1; at end of a package | ||
| 465 | |||
| 466 | =cut | ||
| 467 | |||
| 468 | 1; |