« lib/App/SeismicUnixGui/big_streams/check.pm
↑ Summary
lib/App/SeismicUnixGui/big_streams/immodpg_global_constants.pm »
| 1 | package App::SeismicUnixGui::big_streams::iSpectralAnalysis; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | =head2 SYNOPSIS | ||
| 6 | |||
| 7 | PROGRAM NAME: iSpectralAnalysis.pm | ||
| 8 | Purpose: Simple viewing of an su file | ||
| 9 | extract waveforms an analysze in the spectral domain | ||
| 10 | AUTHOR: Juan M. Lorenzo | ||
| 11 | DEPENDS: Seismic Unix modules from CSM | ||
| 12 | DATE: Aigust 1 2016 V1. | ||
| 13 | DESCRIPTION: based upon non-oop Xtract.pl | ||
| 14 | |||
| 15 | =head2 NOTES | ||
| 16 | |||
| 17 | We are using Moose | ||
| 18 | Moose already declares that you need debuggers turned on | ||
| 19 | so you don't need a line like the following: | ||
| 20 | |||
| 21 | use warnings; | ||
| 22 | |||
| 23 | =head2 USES | ||
| 24 | |||
| 25 | (for subroutines) | ||
| 26 | System_Variables (for subroutines) | ||
| 27 | |||
| 28 | (for variable definitions) | ||
| 29 | SeismicUnix (Seismic Unix modules) | ||
| 30 | |||
| 31 | |||
| 32 | =head3 STEPS IN THE PROGRAM | ||
| 33 | |||
| 34 | |||
| 35 | =head2 REQUIRES | ||
| 36 | |||
| 37 | /usr/local/pl/iSpectralAnalysis.pl to bring configuration values (TODO) | ||
| 38 | configuration file is local (~/iSpectralAnalysis.config) | ||
| 39 | |||
| 40 | =head2 USED by | ||
| 41 | |||
| 42 | /usr/local/pl/iSA (Tk control) to interact with user (TODO) | ||
| 43 | |||
| 44 | =cut | ||
| 45 | |||
| 46 | use Moose; | ||
| 47 | our $VERSION = '1.0.0'; | ||
| 48 | use aliased 'App::SeismicUnixGui::configs::big_streams::iSpectralAnalysis_config'; | ||
| 49 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 50 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 51 | use App::SeismicUnixGui::misc::SeismicUnix | ||
| 52 | qw($in $out $on $go $to $off $suffix_su $iSpectralAnalysisPickFile); | ||
| 53 | use aliased 'App::SeismicUnixGui::misc::flow'; | ||
| 54 | use aliased 'App::SeismicUnixGui::misc::message'; | ||
| 55 | use aliased 'App::SeismicUnixGui::misc::readfiles'; | ||
| 56 | use aliased 'App::SeismicUnixGui::misc::su_xtract_waveform'; | ||
| 57 | use aliased 'App::SeismicUnixGui::misc::su_select_waveform'; | ||
| 58 | use aliased 'App::SeismicUnixGui::misc::su_spectral_analysis'; | ||
| 59 | |||
| 60 | =head2 | ||
| 61 | |||
| 62 | 1. Instantiate classes | ||
| 63 | Create a new version of the package | ||
| 64 | Personalize to give it a new name if you wish | ||
| 65 | |||
| 66 | Use classes: | ||
| 67 | flow | ||
| 68 | log | ||
| 69 | message | ||
| 70 | readfiles | ||
| 71 | su_xtract_waveform | ||
| 72 | su_select_waveform | ||
| 73 | su_spectral_analysis | ||
| 74 | |||
| 75 | =cut | ||
| 76 | |||
| 77 | my $iSpectralAnalysis_config = iSpectralAnalysis_config->new(); | ||
| 78 | my $log = message->new(); | ||
| 79 | my $Project = Project_config->new(); | ||
| 80 | my $run = flow->new(); | ||
| 81 | my $read = readfiles->new(); | ||
| 82 | my $xtract = su_xtract_waveform->new(); | ||
| 83 | my $select = su_select_waveform->new(); | ||
| 84 | my $analyze = su_spectral_analysis->new(); | ||
| 85 | my $get = L_SU_global_constants->new(); | ||
| 86 | my $var = $get->var(); | ||
| 87 | my ($DATA_SEISMIC_SU) = $Project->DATA_SEISMIC_SU(); | ||
| 88 | |||
| 89 | =head2 | ||
| 90 | |||
| 91 | 3. Declare local variables | ||
| 92 | |||
| 93 | =cut | ||
| 94 | |||
| 95 | my ( @flow, @file_in, @sufile_in, @xtract_sufile, @sufile_out ); | ||
| 96 | my ( @inbound, @outbound ); | ||
| 97 | my (@items); | ||
| 98 | my ( @read, @xtract, @select, @analyze ); | ||
| 99 | my ($ref_flows); | ||
| 100 | my $picks_file; | ||
| 101 | |||
| 102 | $picks_file = $iSpectralAnalysisPickFile; | ||
| 103 | |||
| 104 | # print("iSpectralAnalysis, picks file is $picks_file\n\n"); | ||
| 105 | |||
| 106 | =head2 Get configuration information | ||
| 107 | |||
| 108 | |||
| 109 | =cut | ||
| 110 | |||
| 111 | my ( $CFG_h, $CFG_aref ) = $iSpectralAnalysis_config->get_values(); | ||
| 112 | |||
| 113 | my $base_file_name = $CFG_h->{base_file_name}; | ||
| 114 | my $freq = $CFG_h->{sufilter}{1}{freq}; | ||
| 115 | my $agc_gain_width = $CFG_h->{sugain}{1}{agc_gain_width}; | ||
| 116 | my $absclip = $CFG_h->{suxwigb}{1}{absclip}; | ||
| 117 | my $headerWord = $CFG_h->{suxwigb}{1}{headerWord}; | ||
| 118 | my $absclip_phase = $CFG_h->{suxwigb}{1}{absclip_phase}; | ||
| 119 | my $absclip_freq = $CFG_h->{suxwigb}{1}{absclip_freq}; | ||
| 120 | |||
| 121 | # print ("iSpectralAnalysis,freq is $freq\n\n"); | ||
| 122 | # print ("iSpectralAnalysis,base_file_name is $base_file_name\n\n"); | ||
| 123 | # print("iSpectralAnalysis,absclip is $absclip\n\n"); | ||
| 124 | |||
| 125 | =head2 Declare | ||
| 126 | |||
| 127 | file names | ||
| 128 | |||
| 129 | =cut | ||
| 130 | |||
| 131 | $file_in[1] = $base_file_name; | ||
| 132 | $sufile_in[1] = $file_in[1] . $suffix_su; | ||
| 133 | $inbound[1] = $DATA_SEISMIC_SU . '/' . $sufile_in[1]; | ||
| 134 | |||
| 135 | =head2 sub SELECT | ||
| 136 | |||
| 137 | waveform | ||
| 138 | |||
| 139 | =cut | ||
| 140 | |||
| 141 | sub select { | ||
| 142 | |||
| 143 | $select->clear(); | ||
| 144 | $select->picks_file($picks_file); | ||
| 145 | $select->inbound( $inbound[1] ); | ||
| 146 | $select->window_title( $file_in[1] ); | ||
| 147 | $select->title( $file_in[1] ); | ||
| 148 | $select->absclip($absclip); | ||
| 149 | |||
| 150 | =head3 Set | ||
| 151 | |||
| 152 | filtering parameters | ||
| 153 | |||
| 154 | =cut | ||
| 155 | |||
| 156 | $select->filter_freq($freq); | ||
| 157 | $select->agc_gain_width($agc_gain_width); | ||
| 158 | $ref_flows = $select->Step(); | ||
| 159 | |||
| 160 | =head2 View waveform in suxwimage | ||
| 161 | |||
| 162 | then pick in suxwigb | ||
| 163 | |||
| 164 | =cut | ||
| 165 | |||
| 166 | $select[1] = @$ref_flows[1]; | ||
| 167 | $select[2] = @$ref_flows[2]; | ||
| 168 | |||
| 169 | =head2 DEFINE FLOW(S) | ||
| 170 | |||
| 171 | =cut | ||
| 172 | |||
| 173 | $flow[1] = $select[1]; | ||
| 174 | $flow[2] = $select[2]; | ||
| 175 | |||
| 176 | =head2 | ||
| 177 | |||
| 178 | RUN FLOW(S) | ||
| 179 | flow 3 should not run until flow | ||
| 180 | is completed | ||
| 181 | |||
| 182 | =cut | ||
| 183 | |||
| 184 | $run->flow( \$flow[1] ); | ||
| 185 | $run->flow( \$flow[2] ); | ||
| 186 | |||
| 187 | =head2 | ||
| 188 | |||
| 189 | LOG FLOW(S)TO SCREEN AND FILE | ||
| 190 | |||
| 191 | =cut | ||
| 192 | |||
| 193 | # print "iSpectralAnalysis, flow1= $flow[1]\n"; | ||
| 194 | # $log->file($flow[1]); | ||
| 195 | |||
| 196 | # print "iSpectralAnalysis,flow2= $flow[2]\n"; | ||
| 197 | # $log->file($flow[2]); | ||
| 198 | |||
| 199 | } | ||
| 200 | |||
| 201 | =head2 sub xtract | ||
| 202 | |||
| 203 | waveform to a file and QC the waveform | ||
| 204 | flow 3 saves a copy of the file to disk | ||
| 205 | |||
| 206 | =cut | ||
| 207 | |||
| 208 | sub xtract { | ||
| 209 | |||
| 210 | =head2 Prepare | ||
| 211 | |||
| 212 | to Extract waveform | ||
| 213 | |||
| 214 | =cut | ||
| 215 | |||
| 216 | $xtract->clear(); | ||
| 217 | $xtract->ref_picks_file( \$picks_file ); | ||
| 218 | $xtract->header_word($headerWord); # critical | ||
| 219 | $xtract->inbound( $inbound[1] ); | ||
| 220 | $xtract->window_title( $file_in[1] ); | ||
| 221 | $xtract->absclip($absclip); | ||
| 222 | |||
| 223 | $xtract_sufile[1] = $xtract->file_out( \$picks_file, $inbound[1] ); | ||
| 224 | $ref_flows = $xtract->Step(); | ||
| 225 | $xtract[1] = $$ref_flows[1]; | ||
| 226 | $flow[3] = $xtract[1]; | ||
| 227 | |||
| 228 | $run->flow( \$flow[3] ); | ||
| 229 | |||
| 230 | =head2 LOG FLOW(S) | ||
| 231 | |||
| 232 | TO SCREEN AND FILE | ||
| 233 | |||
| 234 | =cut | ||
| 235 | |||
| 236 | print "$flow[3]\n"; | ||
| 237 | |||
| 238 | #$log->file($flow[3]); | ||
| 239 | |||
| 240 | } | ||
| 241 | |||
| 242 | =head2 Spectral Analysis of Waveform | ||
| 243 | |||
| 244 | do not start flow 4 until | ||
| 245 | flow 3 is complete | ||
| 246 | |||
| 247 | flow 4 plots the extracted waveform | ||
| 248 | flow 5 plots the frequency analysis | ||
| 249 | flow 6 plots the phase analysis | ||
| 250 | |||
| 251 | We placed a cmd line | ||
| 252 | prompt that requires user to press | ||
| 253 | return on keyboard. | ||
| 254 | |||
| 255 | =cut | ||
| 256 | |||
| 257 | sub analyze { | ||
| 258 | |||
| 259 | =head2 Prepare | ||
| 260 | |||
| 261 | to Analyze extracted waveform | ||
| 262 | |||
| 263 | =cut | ||
| 264 | |||
| 265 | my $inbound = $DATA_SEISMIC_SU . '/' . $xtract_sufile[1]; | ||
| 266 | $analyze->clear(); | ||
| 267 | $analyze->inbound($inbound); | ||
| 268 | $analyze->window_title( $file_in[1] ); | ||
| 269 | $analyze->absclip_phase($absclip_phase); | ||
| 270 | $analyze->absclip_freq($absclip_freq); | ||
| 271 | |||
| 272 | $ref_flows = $analyze->Step(); | ||
| 273 | $analyze[1] = $$ref_flows[1]; | ||
| 274 | $analyze[2] = $$ref_flows[2]; | ||
| 275 | $analyze[3] = $$ref_flows[3]; | ||
| 276 | |||
| 277 | $flow[4] = $analyze[1]; | ||
| 278 | $flow[5] = $analyze[2]; | ||
| 279 | $flow[6] = $analyze[3]; | ||
| 280 | |||
| 281 | $run->flow( \$flow[4] ); | ||
| 282 | $run->flow( \$flow[5] ); | ||
| 283 | $run->flow( \$flow[6] ); | ||
| 284 | |||
| 285 | =head2 LOG FLOW(S) | ||
| 286 | |||
| 287 | TO SCREEN AND FILE | ||
| 288 | |||
| 289 | =cut | ||
| 290 | |||
| 291 | # print "$flow[4]\n"; | ||
| 292 | #$log->file($flow[4]); | ||
| 293 | |||
| 294 | # print "$flow[5]\n"; | ||
| 295 | #$log->file($flow[5]); | ||
| 296 | |||
| 297 | # print "$flow[6]\n"; | ||
| 298 | #$log->file($flow[6]); | ||
| 299 | # | ||
| 300 | } |