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