« lib/App/SeismicUnixGui/sunix/transform/suphasevel.pm
↑ Summary
lib/App/SeismicUnixGui/sunix/NMO_Vel_Stk/surelanan.pm »
| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | package App::SeismicUnixGui::misc::smooth2; | ||
| 4 | use Moose; | ||
| 5 | our $VERSION = '0.0.1'; | ||
| 6 | |||
| 7 | =head1 DOCUMENTATION | ||
| 8 | |||
| 9 | =head2 SYNOPSIS | ||
| 10 | |||
| 11 | PROGRAM NAME: smooth2 | ||
| 12 | AUTHOR: Juan Lorenzo | ||
| 13 | DATE: July 11 2016, | ||
| 14 | |||
| 15 | DESCRIPTION: | ||
| 16 | Version: 0.1 | ||
| 17 | |||
| 18 | =head2 USE | ||
| 19 | |||
| 20 | =head3 NOTES | ||
| 21 | |||
| 22 | =head4 | ||
| 23 | Examples | ||
| 24 | |||
| 25 | =head3 SEISMIC UNIX NOTES | ||
| 26 | SMOOTH2 --- SMOOTH a uniformly sampled 2d array of data, within a user- | ||
| 27 | defined window, via a damped least squares technique | ||
| 28 | |||
| 29 | smooth2 < stdin n1= n2= [optional parameters ] > stdout | ||
| 30 | |||
| 31 | Required Parameters: | ||
| 32 | n1= number of samples in the 1st (fast) dimension | ||
| 33 | n2= number of samples in the 2nd (slow) dimension | ||
| 34 | |||
| 35 | Optional Parameters: | ||
| 36 | r1=0 smoothing parameter in the 1 direction | ||
| 37 | r2=0 smoothing parameter in the 2 direction | ||
| 38 | win=0,n1,0,n2 array for window range | ||
| 39 | rw=0 smoothing parameter for window function | ||
| 40 | efile= =efilename if set write relative error(x1) to | ||
| 41 | efilename | ||
| 42 | |||
| 43 | Notes: | ||
| 44 | Larger r1 and r2 result in a smoother data. Recommended ranges of r1 | ||
| 45 | and r2 are from 1 to 20. | ||
| 46 | |||
| 47 | The file verror gives the relative error between the original velocity | ||
| 48 | and the smoothed one, as a function of depth. If the error is | ||
| 49 | between 0.01 and 0.1, the smoothing parameters are suitable. Otherwise, | ||
| 50 | consider increasing or decreasing the smoothing parameter values. | ||
| 51 | |||
| 52 | Smoothing can be implemented in a selected window. The range of 1st | ||
| 53 | dimension for window is from win[0] to win[1]; the range of 2nd | ||
| 54 | dimension is from win[2] to win[3]. | ||
| 55 | |||
| 56 | Smoothing the window function (i.e. blurring the edges of the window) | ||
| 57 | may be done by setting a nonzero value for rw, otherwise the edges | ||
| 58 | of the window will be sharp. | ||
| 59 | |||
| 60 | =head4 CHANGES and their DATES | ||
| 61 | |||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | =pod | ||
| 66 | |||
| 67 | =head3 Build a list or hash | ||
| 68 | |||
| 69 | with all the possible variable | ||
| 70 | names you may use and you can even change them | ||
| 71 | |||
| 72 | =cut | ||
| 73 | |||
| 74 | my $smooth2 = { | ||
| 75 | _n1 => '', | ||
| 76 | _n2 => '', | ||
| 77 | _r1 => '', | ||
| 78 | _r2 => '', | ||
| 79 | _rw => '', | ||
| 80 | _efile => '', | ||
| 81 | _win => '', | ||
| 82 | _note => '', | ||
| 83 | _Step => '' | ||
| 84 | }; | ||
| 85 | |||
| 86 | # define a value | ||
| 87 | my $newline = ' | ||
| 88 | '; | ||
| 89 | |||
| 90 | sub test { | ||
| 91 | my ( $test, @value ) = @_; | ||
| 92 | print( | ||
| 93 | "\$test or the first scalar 'holds' a HASH $test | ||
| 94 | that represents the name of the | ||
| 95 | subroutine you are trying to use and all its needed components\n" | ||
| 96 | ); | ||
| 97 | print( | ||
| 98 | "\@value, the second scalar is something 'real' you put in, i.e., @value\n\n" | ||
| 99 | ); | ||
| 100 | print("new line is $newline\n"); | ||
| 101 | |||
| 102 | #my ($smooth2->{_Step}) = $smooth2->{_Step} +1; | ||
| 103 | #print("Share step is first $smooth2->{_Step}\n"); | ||
| 104 | } | ||
| 105 | |||
| 106 | =head2 subroutine clear | ||
| 107 | |||
| 108 | sets all variable strings to '' | ||
| 109 | |||
| 110 | =cut | ||
| 111 | |||
| 112 | sub clear { | ||
| 113 | $smooth2->{_n1} = ''; | ||
| 114 | $smooth2->{_n2} = ''; | ||
| 115 | $smooth2->{_r1} = ''; | ||
| 116 | $smooth2->{_r2} = ''; | ||
| 117 | $smooth2->{_rw} = ''; | ||
| 118 | $smooth2->{_efile} = ''; | ||
| 119 | $smooth2->{_note} = ''; | ||
| 120 | $smooth2->{_Step} = ''; | ||
| 121 | } | ||
| 122 | |||
| 123 | =head2 subroutine n1 | ||
| 124 | |||
| 125 | number of samples in the 1st (fast) dimension | ||
| 126 | |||
| 127 | =cut | ||
| 128 | |||
| 129 | sub n1 { | ||
| 130 | my ( $variable, $n1 ) = @_; | ||
| 131 | $smooth2->{_n1} = $n1 if defined($n1); | ||
| 132 | $smooth2->{_note} = $smooth2->{_note} . ' n1=' . $smooth2->{_n1}; | ||
| 133 | $smooth2->{_Step} = $smooth2->{_Step} . ' n1=' . $smooth2->{_n1}; | ||
| 134 | } | ||
| 135 | |||
| 136 | =head2 subroutine n2 | ||
| 137 | |||
| 138 | number of samples in the 2nd (slow) dimension | ||
| 139 | |||
| 140 | =cut | ||
| 141 | |||
| 142 | sub n2 { | ||
| 143 | my ( $variable, $n2 ) = @_; | ||
| 144 | $smooth2->{_n2} = $n2 if defined($n2); | ||
| 145 | $smooth2->{_note} = $smooth2->{_note} . ' n2=' . $smooth2->{_n2}; | ||
| 146 | $smooth2->{_Step} = $smooth2->{_Step} . ' n2=' . $smooth2->{_n2}; | ||
| 147 | } | ||
| 148 | |||
| 149 | =head2 subroutine r1 | ||
| 150 | |||
| 151 | smoothing parameter in the 1 direction | ||
| 152 | |||
| 153 | =cut | ||
| 154 | |||
| 155 | sub r1 { | ||
| 156 | my ( $variable, $r1 ) = @_; | ||
| 157 | $smooth2->{_r1} = $r1 if defined($r1); | ||
| 158 | $smooth2->{_note} = $smooth2->{_note} . ' r1=' . $smooth2->{_r1}; | ||
| 159 | $smooth2->{_Step} = $smooth2->{_Step} . ' r1=' . $smooth2->{_r1}; | ||
| 160 | } | ||
| 161 | |||
| 162 | =head2 subroutine r2 | ||
| 163 | |||
| 164 | smoothing parameter in the 2 direction | ||
| 165 | |||
| 166 | =cut | ||
| 167 | |||
| 168 | sub r2 { | ||
| 169 | my ( $variable, $r2 ) = @_; | ||
| 170 | $smooth2->{_r2} = $r2 if defined($r2); | ||
| 171 | $smooth2->{_note} = $smooth2->{_note} . ' r2=' . $smooth2->{_r2}; | ||
| 172 | $smooth2->{_Step} = $smooth2->{_Step} . ' r2=' . $smooth2->{_r2}; | ||
| 173 | } | ||
| 174 | |||
| 175 | =head2 subroutine rw | ||
| 176 | |||
| 177 | smoothing parameter for window function | ||
| 178 | |||
| 179 | =cut | ||
| 180 | |||
| 181 | sub rw { | ||
| 182 | my ( $variable, $rw ) = @_; | ||
| 183 | $smooth2->{_rw} = $rw if defined($rw); | ||
| 184 | $smooth2->{_note} = $smooth2->{_note} . ' rw=' . $smooth2->{_rw}; | ||
| 185 | $smooth2->{_Step} = $smooth2->{_Step} . ' rw=' . $smooth2->{_rw}; | ||
| 186 | } | ||
| 187 | |||
| 188 | =head2 subroutine efile | ||
| 189 | |||
| 190 | efilename if set write relative error(x1) to | ||
| 191 | |||
| 192 | |||
| 193 | =cut | ||
| 194 | |||
| 195 | sub efile { | ||
| 196 | my ( $variable, $efile ) = @_; | ||
| 197 | $smooth2->{_efile} = $efile if defined($efile); | ||
| 198 | $smooth2->{_note} = $smooth2->{_note} . ' efile=' . $smooth2->{_efile}; | ||
| 199 | $smooth2->{_Step} = $smooth2->{_Step} . ' efile=' . $smooth2->{_efile}; | ||
| 200 | } | ||
| 201 | |||
| 202 | =head2 subroutine win | ||
| 203 | |||
| 204 | array for window range | ||
| 205 | |||
| 206 | =cut | ||
| 207 | |||
| 208 | sub win { | ||
| 209 | my ( $variable, $win ) = @_; | ||
| 210 | $smooth2->{_win} = $win if defined($win); | ||
| 211 | $smooth2->{_note} = $smooth2->{_note} . ' win=' . $smooth2->{_win}; | ||
| 212 | $smooth2->{_Step} = $smooth2->{_Step} . ' win=' . $smooth2->{_win}; | ||
| 213 | } | ||
| 214 | |||
| 215 | sub Step { | ||
| 216 | $smooth2->{_Step} = 'smooth2' . $smooth2->{_Step}; | ||
| 217 | return $smooth2->{_Step}; | ||
| 218 | } | ||
| 219 | |||
| 220 | =head2 subroutine | ||
| 221 | |||
| 222 | =cut | ||
| 223 | |||
| 224 | sub note { | ||
| 225 | $smooth2->{_note} = $smooth2->{_note}; | ||
| 226 | return $smooth2->{_note}; | ||
| 227 | } | ||
| 228 | |||
| 229 | =pod | ||
| 230 | |||
| 231 | =head3 Warnings for programmers | ||
| 232 | |||
| 233 | packages must end with | ||
| 234 | 1; | ||
| 235 | |||
| 236 | =cut | ||
| 237 | |||
| 238 | 1; |