« lib/App/SeismicUnixGui/sunix/header/surange.pm
↑ Summary
lib/App/SeismicUnixGui/big_streams/iTopMute.pl »
| 1 | package App::SeismicUnixGui::big_streams::iPicks2par; | ||
| 2 | |||
| 3 | use Moose; | ||
| 4 | our $VERSION = '0.0.1'; | ||
| 5 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 6 | use App::SeismicUnixGui::misc::control '0.0.3'; | ||
| 7 | use aliased 'App::SeismicUnixGui::misc::control'; | ||
| 8 | use aliased 'App::SeismicUnixGui::misc::message'; | ||
| 9 | use aliased 'App::SeismicUnixGui::misc::flow'; | ||
| 10 | use aliased 'App::SeismicUnixGui::misc::mkparfile'; | ||
| 11 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 12 | |||
| 13 | =head1 DOCUMENTATION | ||
| 14 | |||
| 15 | =head2 SYNOPSIS System_Variables:: | ||
| 16 | |||
| 17 | PERL PROGRAM NAME:iPicks2par.pm | ||
| 18 | AUTHOR: Juan Lorenzo | ||
| 19 | DATE: June 14 2019 | ||
| 20 | |||
| 21 | DESCRIPTION: | ||
| 22 | |||
| 23 | Purpose: write data pairs to par format for input | ||
| 24 | into another progam | ||
| 25 | |||
| 26 | |||
| 27 | =head2 USE | ||
| 28 | _taup_inbound =>'', | ||
| 29 | _taup_outbound =>'', | ||
| 30 | =head3 NOTES | ||
| 31 | |||
| 32 | =head4 | ||
| 33 | Examples | ||
| 34 | |||
| 35 | =head3 SEISMIC UNIX NOTES | ||
| 36 | |||
| 37 | =head4 CHANGES and their DATES | ||
| 38 | |||
| 39 | |||
| 40 | =head3 STEPS | ||
| 41 | |||
| 42 | 1. define the types of variables you are using | ||
| 43 | these would be the values you enter into | ||
| 44 | each of the Seismic Unix programs each of the | ||
| 45 | Seismic Unix programs | ||
| 46 | |||
| 47 | 2. build a list or hash with all the possible variable | ||
| 48 | names you may use and you canSystem_Variables:: even change them | ||
| 49 | |||
| 50 | =cut | ||
| 51 | |||
| 52 | =pod | ||
| 53 | |||
| 54 | instantiate classes | ||
| 55 | |||
| 56 | =cut | ||
| 57 | |||
| 58 | my $control = control->new(); | ||
| 59 | my $get = L_SU_global_constants->new(); | ||
| 60 | my $log = message->new(); | ||
| 61 | my $run = flow->new(); | ||
| 62 | my $mkparfile = mkparfile->new(); | ||
| 63 | my $Project = Project_config->new(); | ||
| 64 | |||
| 65 | my $var = $get->var(); | ||
| 66 | my $empty_string = $var->{_empty_string}; | ||
| 67 | |||
| 68 | =pod | ||
| 69 | |||
| 70 | declare variables types | ||
| 71 | establish just the locally scoped variables | ||
| 72 | |||
| 73 | =cut | ||
| 74 | |||
| 75 | my @mkparfile; | ||
| 76 | my ( $mkparfile_in, $mkparfile_inbound ); | ||
| 77 | my ( $mkparfile_out, $mkparfile_outbound ); | ||
| 78 | my ( @items, @flow ); | ||
| 79 | |||
| 80 | =pod | ||
| 81 | |||
| 82 | create hash with important variables | ||
| 83 | |||
| 84 | =cut | ||
| 85 | |||
| 86 | my $iPicks2par = { | ||
| 87 | _TX_inbound => '', | ||
| 88 | _TX_outbound => '', | ||
| 89 | _taup_inbound => '', | ||
| 90 | _taup_outbound => '', | ||
| 91 | _gather_num => '', | ||
| 92 | _exists => '', | ||
| 93 | _textfile_in => '', | ||
| 94 | _textfile_out => '', | ||
| 95 | _type => '' | ||
| 96 | }; | ||
| 97 | |||
| 98 | =head3 | ||
| 99 | |||
| 100 | Import file-name and directory definitions | ||
| 101 | |||
| 102 | =cut | ||
| 103 | |||
| 104 | use App::SeismicUnixGui::misc::SeismicUnix qw($true $false $in $out $to $ipicks_par_ | ||
| 105 | $itemp_picks_ $itemp_picks_sorted_par_ | ||
| 106 | $out $suffix_su); | ||
| 107 | |||
| 108 | my ($DATA_SEISMIC_TXT) = $Project->DATA_SEISMIC_TXT(); | ||
| 109 | |||
| 110 | =head2 subroutine clear | ||
| 111 | |||
| 112 | sets all variable strings to '' | ||
| 113 | |||
| 114 | =cut | ||
| 115 | |||
| 116 | sub clear { | ||
| 117 | $iPicks2par->{_TX_inbound} = ''; | ||
| 118 | $iPicks2par->{_TX_outbound} = ''; | ||
| 119 | $iPicks2par->{_taup_inbound} = ''; | ||
| 120 | $iPicks2par->{_taup_outbound} = ''; | ||
| 121 | $iPicks2par->{_gather_num} = ''; | ||
| 122 | $iPicks2par->{_exists} = ''; | ||
| 123 | $iPicks2par->{_textfile_in} = ''; | ||
| 124 | $iPicks2par->{_textfile_out} = ''; | ||
| 125 | $iPicks2par->{_type} = ''; | ||
| 126 | } | ||
| 127 | |||
| 128 | =head2 subroutine file_in | ||
| 129 | |||
| 130 | Required file name | ||
| 131 | on which to pick x,t values | ||
| 132 | |||
| 133 | =cut | ||
| 134 | |||
| 135 | sub file_in { | ||
| 136 | |||
| 137 | my ( $self, $file_in ) = @_; | ||
| 138 | |||
| 139 | if ( defined $file_in | ||
| 140 | && $file_in ne $empty_string ) | ||
| 141 | { | ||
| 142 | |||
| 143 | # e.g., 'sp1' becomes sp1 | ||
| 144 | $control->set_infection($file_in); | ||
| 145 | $file_in = control->get_ticksBgone(); | ||
| 146 | $iPicks2par->{_file_in} = $file_in; | ||
| 147 | |||
| 148 | # print("iPicks2par, file_in: $iPicks2par->{_file_in} \n"); | ||
| 149 | |||
| 150 | } | ||
| 151 | else { | ||
| 152 | print("iPicks2par, file_in: unexpected file_in \n"); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | =head2 sub type | ||
| 157 | |||
| 158 | switches for old data of two different types | ||
| 159 | |||
| 160 | for type: tx or taup | ||
| 161 | |||
| 162 | |||
| 163 | =cut | ||
| 164 | |||
| 165 | sub type { | ||
| 166 | my ( $variable, $type ) = @_; | ||
| 167 | $iPicks2par->{_type} = $iPicks2par if defined($iPicks2par); | ||
| 168 | } | ||
| 169 | |||
| 170 | =head2 subroutine calc | ||
| 171 | |||
| 172 | main processing flow | ||
| 173 | reformats data | ||
| 174 | MAKE PARAMETER FILE | ||
| 175 | CONVERT TEXT FILE TO PAR FILE | ||
| 176 | |||
| 177 | In the old manner: | ||
| 178 | $mkparfile = ("mkparfile \\ | ||
| 179 | string1=t \\ | ||
| 180 | string2=x \\ | ||
| 181 | "); | ||
| 182 | |||
| 183 | =cut | ||
| 184 | |||
| 185 | sub calc { | ||
| 186 | |||
| 187 | =head2 establish par file names | ||
| 188 | |||
| 189 | TODO if no sorting is ever needed | ||
| 190 | rm file name from $itemp_picks_sorted_par to itemp_picks | ||
| 191 | |||
| 192 | =cut | ||
| 193 | |||
| 194 | $mkparfile_in = $itemp_picks_ . $iPicks2par->{_file_in}; | ||
| 195 | |||
| 196 | $mkparfile_out = $itemp_picks_sorted_par_ . $iPicks2par->{_file_in}; | ||
| 197 | |||
| 198 | $iPicks2par->{_TX_inbound} = $DATA_SEISMIC_TXT . '/' . $mkparfile_in; | ||
| 199 | $iPicks2par->{_TX_outbound} = $DATA_SEISMIC_TXT . '/' . $mkparfile_out; | ||
| 200 | |||
| 201 | # print("iPicks2par,calc,inbound is: $iPicks2par->{_TX_inbound} \n"); | ||
| 202 | |||
| 203 | $mkparfile->clear(); | ||
| 204 | $mkparfile->string1('t'); | ||
| 205 | $mkparfile->string2('x'); | ||
| 206 | $mkparfile[1] = $mkparfile->Step(); | ||
| 207 | |||
| 208 | # SORT a TEXT FILE | ||
| 209 | my @sort; | ||
| 210 | $sort[1] = ( | ||
| 211 | " sort \\ | ||
| 212 | -n \\ | ||
| 213 | " | ||
| 214 | ); | ||
| 215 | |||
| 216 | =head2 DEFINE FLOW(S) | ||
| 217 | |||
| 218 | |||
| 219 | In the old manner (non oops): | ||
| 220 | |||
| 221 | $flow[1] = (" \\ | ||
| 222 | $mkparfile[1] \\ | ||
| 223 | < $mkparfile_inbound[1] \\ | ||
| 224 | >$mkparfile_outbound[1] \\ | ||
| 225 | \\ | ||
| 226 | "); | ||
| 227 | |||
| 228 | =cut | ||
| 229 | |||
| 230 | # print("Regular xt data\n\n"); | ||
| 231 | |||
| 232 | @items = ( | ||
| 233 | $sort[1], $in, $iPicks2par->{_TX_inbound}, | ||
| 234 | $to, $mkparfile[1], $out, $iPicks2par->{_TX_outbound} | ||
| 235 | ); | ||
| 236 | |||
| 237 | $flow[1] = $run->modules( \@items ); | ||
| 238 | |||
| 239 | =head2 | ||
| 240 | |||
| 241 | RUN FLOW(S) | ||
| 242 | output copy of picked data points | ||
| 243 | only occurs after the number of tries | ||
| 244 | is updated | ||
| 245 | |||
| 246 | =cut | ||
| 247 | |||
| 248 | $run->flow( \$flow[1] ); | ||
| 249 | |||
| 250 | =pod | ||
| 251 | |||
| 252 | LOG FLOW(S)TO SCREEN AND FILE | ||
| 253 | |||
| 254 | =cut | ||
| 255 | |||
| 256 | # print "$flow[1]\n"; | ||
| 257 | # $log->file($flow[1]); | ||
| 258 | |||
| 259 | } # end calc subroutine | ||
| 260 | |||
| 261 | 1; |