« lib/App/SeismicUnixGui/sunix/header/suchart.pm
↑ Summary
lib/App/SeismicUnixGui/sunix/migration/sumigpspi.pm »
| 1 | package App::SeismicUnixGui::sunix::header::surandhw; | ||
| 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 | surandhw - set header word to random variable | ||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | surandhw <stdin >stdout key=tstat a=0 min=0 max=1 | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | Required parameters: | ||
| 33 | |||
| 34 | none (no op) | ||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | Optional parameters: | ||
| 39 | |||
| 40 | key=tstat header key word to set | ||
| 41 | |||
| 42 | a=0 =1 flag to add original value to final key | ||
| 43 | |||
| 44 | noise=gauss noise probability distribution | ||
| 45 | |||
| 46 | =flat for uniform; default Gaussian | ||
| 47 | |||
| 48 | seed=from_clock random number seed (integer) | ||
| 49 | |||
| 50 | min=0 minimum random number | ||
| 51 | |||
| 52 | max=1 maximum radnom number | ||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | NOTES: | ||
| 57 | |||
| 58 | The value of header word key is computed using the formula: | ||
| 59 | |||
| 60 | val(key) = a * val(key) + rand | ||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | Example: | ||
| 65 | |||
| 66 | surandhw <indata key=tstat a=0 min=0 max=10 > outdata | ||
| 67 | |||
| 68 | |||
| 69 | |||
| 70 | =head2 User's notes (Juan Lorenzo) | ||
| 71 | untested | ||
| 72 | |||
| 73 | =cut | ||
| 74 | |||
| 75 | |||
| 76 | =head2 CHANGES and their DATES | ||
| 77 | |||
| 78 | =cut | ||
| 79 | |||
| 80 | use Moose; | ||
| 81 | our $VERSION = '0.0.1'; | ||
| 82 | |||
| 83 | |||
| 84 | =head2 Import packages | ||
| 85 | |||
| 86 | =cut | ||
| 87 | |||
| 88 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 89 | |||
| 90 | use App::SeismicUnixGui::misc::SeismicUnix qw($go $in $off $on $out $ps $to $suffix_ascii $suffix_bin $suffix_ps $suffix_segy $suffix_su); | ||
| 91 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 92 | |||
| 93 | |||
| 94 | =head2 instantiation of packages | ||
| 95 | |||
| 96 | =cut | ||
| 97 | |||
| 98 | my $get = L_SU_global_constants->new(); | ||
| 99 | my $Project = Project_config->new(); | ||
| 100 | my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); | ||
| 101 | my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN(); | ||
| 102 | my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT(); | ||
| 103 | |||
| 104 | my $PS_SEISMIC = $Project->PS_SEISMIC(); | ||
| 105 | |||
| 106 | my $var = $get->var(); | ||
| 107 | my $on = $var->{_on}; | ||
| 108 | my $off = $var->{_off}; | ||
| 109 | my $true = $var->{_true}; | ||
| 110 | my $false = $var->{_false}; | ||
| 111 | my $empty_string = $var->{_empty_string}; | ||
| 112 | |||
| 113 | =head2 Encapsulated | ||
| 114 | hash of private variables | ||
| 115 | |||
| 116 | =cut | ||
| 117 | |||
| 118 | my $surandhw = { | ||
| 119 | _a => '', | ||
| 120 | _key => '', | ||
| 121 | _max => '', | ||
| 122 | _min => '', | ||
| 123 | _noise => '', | ||
| 124 | _seed => '', | ||
| 125 | _Step => '', | ||
| 126 | _note => '', | ||
| 127 | |||
| 128 | }; | ||
| 129 | |||
| 130 | =head2 sub Step | ||
| 131 | |||
| 132 | collects switches and assembles bash instructions | ||
| 133 | by adding the program name | ||
| 134 | |||
| 135 | =cut | ||
| 136 | |||
| 137 | sub Step { | ||
| 138 | |||
| 139 | $surandhw->{_Step} = 'surandhw'.$surandhw->{_Step}; | ||
| 140 | return ( $surandhw->{_Step} ); | ||
| 141 | |||
| 142 | } | ||
| 143 | |||
| 144 | |||
| 145 | =head2 sub note | ||
| 146 | |||
| 147 | collects switches and assembles bash instructions | ||
| 148 | by adding the program name | ||
| 149 | |||
| 150 | =cut | ||
| 151 | |||
| 152 | sub note { | ||
| 153 | |||
| 154 | $surandhw->{_note} = 'surandhw'.$surandhw->{_note}; | ||
| 155 | return ( $surandhw->{_note} ); | ||
| 156 | |||
| 157 | } | ||
| 158 | |||
| 159 | |||
| 160 | |||
| 161 | =head2 sub clear | ||
| 162 | |||
| 163 | =cut | ||
| 164 | |||
| 165 | sub clear { | ||
| 166 | |||
| 167 | $surandhw->{_a} = ''; | ||
| 168 | $surandhw->{_key} = ''; | ||
| 169 | $surandhw->{_max} = ''; | ||
| 170 | $surandhw->{_min} = ''; | ||
| 171 | $surandhw->{_noise} = ''; | ||
| 172 | $surandhw->{_seed} = ''; | ||
| 173 | $surandhw->{_Step} = ''; | ||
| 174 | $surandhw->{_note} = ''; | ||
| 175 | } | ||
| 176 | |||
| 177 | |||
| 178 | =head2 sub a | ||
| 179 | |||
| 180 | |||
| 181 | =cut | ||
| 182 | |||
| 183 | sub a { | ||
| 184 | |||
| 185 | my ( $self,$a ) = @_; | ||
| 186 | if ( $a ne $empty_string ) { | ||
| 187 | |||
| 188 | $surandhw->{_a} = $a; | ||
| 189 | $surandhw->{_note} = $surandhw->{_note}.' a='.$surandhw->{_a}; | ||
| 190 | $surandhw->{_Step} = $surandhw->{_Step}.' a='.$surandhw->{_a}; | ||
| 191 | |||
| 192 | } else { | ||
| 193 | print("surandhw, a, missing a,\n"); | ||
| 194 | } | ||
| 195 | } | ||
| 196 | |||
| 197 | |||
| 198 | =head2 sub key | ||
| 199 | |||
| 200 | |||
| 201 | =cut | ||
| 202 | |||
| 203 | sub key { | ||
| 204 | |||
| 205 | my ( $self,$key ) = @_; | ||
| 206 | if ( $key ne $empty_string ) { | ||
| 207 | |||
| 208 | $surandhw->{_key} = $key; | ||
| 209 | $surandhw->{_note} = $surandhw->{_note}.' key='.$surandhw->{_key}; | ||
| 210 | $surandhw->{_Step} = $surandhw->{_Step}.' key='.$surandhw->{_key}; | ||
| 211 | |||
| 212 | } else { | ||
| 213 | print("surandhw, key, missing key,\n"); | ||
| 214 | } | ||
| 215 | } | ||
| 216 | |||
| 217 | |||
| 218 | =head2 sub max | ||
| 219 | |||
| 220 | |||
| 221 | =cut | ||
| 222 | |||
| 223 | sub max { | ||
| 224 | |||
| 225 | my ( $self,$max ) = @_; | ||
| 226 | if ( $max ne $empty_string ) { | ||
| 227 | |||
| 228 | $surandhw->{_max} = $max; | ||
| 229 | $surandhw->{_note} = $surandhw->{_note}.' max='.$surandhw->{_max}; | ||
| 230 | $surandhw->{_Step} = $surandhw->{_Step}.' max='.$surandhw->{_max}; | ||
| 231 | |||
| 232 | } else { | ||
| 233 | print("surandhw, max, missing max,\n"); | ||
| 234 | } | ||
| 235 | } | ||
| 236 | |||
| 237 | |||
| 238 | =head2 sub min | ||
| 239 | |||
| 240 | |||
| 241 | =cut | ||
| 242 | |||
| 243 | sub min { | ||
| 244 | |||
| 245 | my ( $self,$min ) = @_; | ||
| 246 | if ( $min ne $empty_string ) { | ||
| 247 | |||
| 248 | $surandhw->{_min} = $min; | ||
| 249 | $surandhw->{_note} = $surandhw->{_note}.' min='.$surandhw->{_min}; | ||
| 250 | $surandhw->{_Step} = $surandhw->{_Step}.' min='.$surandhw->{_min}; | ||
| 251 | |||
| 252 | } else { | ||
| 253 | print("surandhw, min, missing min,\n"); | ||
| 254 | } | ||
| 255 | } | ||
| 256 | |||
| 257 | |||
| 258 | =head2 sub noise | ||
| 259 | |||
| 260 | |||
| 261 | =cut | ||
| 262 | |||
| 263 | sub noise { | ||
| 264 | |||
| 265 | my ( $self,$noise ) = @_; | ||
| 266 | if ( $noise ne $empty_string ) { | ||
| 267 | |||
| 268 | $surandhw->{_noise} = $noise; | ||
| 269 | $surandhw->{_note} = $surandhw->{_note}.' noise='.$surandhw->{_noise}; | ||
| 270 | $surandhw->{_Step} = $surandhw->{_Step}.' noise='.$surandhw->{_noise}; | ||
| 271 | |||
| 272 | } else { | ||
| 273 | print("surandhw, noise, missing noise,\n"); | ||
| 274 | } | ||
| 275 | } | ||
| 276 | |||
| 277 | |||
| 278 | =head2 sub seed | ||
| 279 | |||
| 280 | |||
| 281 | =cut | ||
| 282 | |||
| 283 | sub seed { | ||
| 284 | |||
| 285 | my ( $self,$seed ) = @_; | ||
| 286 | if ( $seed ne $empty_string ) { | ||
| 287 | |||
| 288 | $surandhw->{_seed} = $seed; | ||
| 289 | $surandhw->{_note} = $surandhw->{_note}.' seed='.$surandhw->{_seed}; | ||
| 290 | $surandhw->{_Step} = $surandhw->{_Step}.' seed='.$surandhw->{_seed}; | ||
| 291 | |||
| 292 | } else { | ||
| 293 | print("surandhw, seed, missing seed,\n"); | ||
| 294 | } | ||
| 295 | } | ||
| 296 | |||
| 297 | |||
| 298 | =head2 sub get_max_index | ||
| 299 | |||
| 300 | max index = number of input variables -1 | ||
| 301 | |||
| 302 | =cut | ||
| 303 | |||
| 304 | sub get_max_index { | ||
| 305 | my ($self) = @_; | ||
| 306 | my $max_index = 5; | ||
| 307 | |||
| 308 | return($max_index); | ||
| 309 | } | ||
| 310 | |||
| 311 | |||
| 312 | 1; |