« lib/App/SeismicUnixGui/misc/manage_files_by2.pm
↑ Summary
lib/App/SeismicUnixGui/misc/save_button.pm »
| 1 | package App::SeismicUnixGui::configs::big_streams::immodpg_config; | ||
| 2 | |||
| 3 | =head1 DOCUMENTATION | ||
| 4 | |||
| 5 | =head2 SYNOPSIS | ||
| 6 | |||
| 7 | PERL PERL PROGRAM NAME: immodpg_config.pm | ||
| 8 | AUTHOR: Juan Lorenzo | ||
| 9 | DATE: Feb 24 2020 | ||
| 10 | DESCRIPTION: interactive raytraced modeling | ||
| 11 | of first arrivals | ||
| 12 | |||
| 13 | USED | ||
| 14 | |||
| 15 | BASED ON:PL_SEISMIC | ||
| 16 | mmodpg by Emilio Vera | ||
| 17 | |||
| 18 | |||
| 19 | Needs: Simple (ASCII) local configuration | ||
| 20 | file is immodpg.config | ||
| 21 | |||
| 22 | |||
| 23 | =cut | ||
| 24 | |||
| 25 | =head2 EXAMPLE | ||
| 26 | |||
| 27 | contains all the configuration variables | ||
| 28 | |||
| 29 | base_file_name = file (su format by default_path) | ||
| 30 | pre_digitized_XT_pairs = no | ||
| 31 | data_traces = yes | ||
| 32 | clip = 10.000000 | ||
| 33 | min_t_s = 0.000000 | ||
| 34 | min_x_m = 0.000000 | ||
| 35 | thickness_increment_m = 0.1000 | ||
| 36 | source_depth_m = 0. | ||
| 37 | receiver_depth_m = 0. | ||
| 38 | reducing_vel_mps = 0.000 | ||
| 39 | plot_min_x_m = 0. | ||
| 40 | plot_max_x_m = 10. | ||
| 41 | plot_min_t_s = 0.000 | ||
| 42 | plot_max_t_s = .1 | ||
| 43 | previous_model = yes | ||
| 44 | new_model = no | ||
| 45 | layer = 1 | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | use Moose; | ||
| 50 | our $VERSION = '0.0.1'; | ||
| 51 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 52 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 53 | use App::SeismicUnixGui::misc::SeismicUnix qw($in $out $on $go $to $suffix_ascii $off $suffix_su); | ||
| 54 | use aliased 'App::SeismicUnixGui::misc::config_superflows'; | ||
| 55 | use App::SeismicUnixGui::misc::control '0.0.3'; | ||
| 56 | use aliased 'App::SeismicUnixGui::misc::control'; | ||
| 57 | use aliased 'App::SeismicUnixGui::big_streams::immodpg_global_constants'; | ||
| 58 | use aliased 'App::SeismicUnixGui::misc::manage_files_by2'; | ||
| 59 | use aliased 'App::SeismicUnixGui::misc::files_LSU'; | ||
| 60 | |||
| 61 | my $Project = Project_config->new(); | ||
| 62 | my $control = control->new(); | ||
| 63 | my $config_superflows = config_superflows->new(); | ||
| 64 | my $get = L_SU_global_constants->new(); | ||
| 65 | my $manage_files_by2 = manage_files_by2->new(); | ||
| 66 | my $immodpg_global_constants = immodpg_global_constants->new(); | ||
| 67 | |||
| 68 | my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); | ||
| 69 | my $IMMODPG = $Project->IMMODPG(); | ||
| 70 | my $superflow_config_names = $get->superflow_config_names_aref(); | ||
| 71 | my $var = $immodpg_global_constants->var(); | ||
| 72 | |||
| 73 | my $GLOBAL_CONFIG_LIB = ( $get->global_libs )->{_configs_big_streams}; | ||
| 74 | |||
| 75 | # WARNING---- watch out for missing underscore!! | ||
| 76 | |||
| 77 | =head2 define private hash | ||
| 78 | |||
| 79 | =cut | ||
| 80 | |||
| 81 | my $immodpg_config = { | ||
| 82 | _prog_name => '', | ||
| 83 | _values_aref => '', | ||
| 84 | _model_file_text => '', | ||
| 85 | _GLOBAL_CONFIG_LIB => '', | ||
| 86 | }; | ||
| 87 | |||
| 88 | =head2 assign values to local variables | ||
| 89 | |||
| 90 | =cut | ||
| 91 | |||
| 92 | my $program_name = 'immodpg'; | ||
| 93 | my $config_file = $program_name . '.config'; | ||
| 94 | my $inbound_config = $IMMODPG . '/' . $config_file; | ||
| 95 | |||
| 96 | # my $outbound_config = . '/' . $config_file; | ||
| 97 | $immodpg_config->{_model_file_text} = $var->{_immodpg_model_file_text}; | ||
| 98 | $immodpg_config->{_GLOBAL_CONFIG_LIB} = $GLOBAL_CONFIG_LIB; | ||
| 99 | |||
| 100 | =head Create the configuration file | ||
| 101 | |||
| 102 | Create the configuration file if it does | ||
| 103 | not exist,using the default configuration | ||
| 104 | file | ||
| 105 | |||
| 106 | =cut | ||
| 107 | |||
| 108 | if ( $manage_files_by2->does_file_exist( \$inbound_config ) ) { | ||
| 109 | |||
| 110 | # print("immodpg_config, found configuration file\n"); | ||
| 111 | # print("immodpg_config, $inbound_config\n"); | ||
| 112 | # print("immodpg_config, NADA\n"); | ||
| 113 | |||
| 114 | } elsif ( not $manage_files_by2->does_file_exist( \$inbound_config ) ) { | ||
| 115 | |||
| 116 | # print("immodpg_config, missing immodpg config file\n"); | ||
| 117 | my $files_LSU = files_LSU->new(); | ||
| 118 | |||
| 119 | $files_LSU->set_config(); | ||
| 120 | $files_LSU->set_prog_name_sref( \$program_name ); # scalar ref | ||
| 121 | $files_LSU->outbound(); # scalar ref | ||
| 122 | $files_LSU->copy_default_config(); | ||
| 123 | |||
| 124 | } else { | ||
| 125 | print("immodpg.pl, unexpected config file\n"); | ||
| 126 | } | ||
| 127 | |||
| 128 | _set_model_file_text(); | ||
| 129 | |||
| 130 | =head2 Create a model test file as text | ||
| 131 | |||
| 132 | Create a basic model.txt file if it does not exist | ||
| 133 | in either or both the hidden and invisible working | ||
| 134 | directories. | ||
| 135 | copying over an example simple test file | ||
| 136 | |||
| 137 | =cut | ||
| 138 | |||
| 139 | sub _set_model_file_text { | ||
| 140 | my ($self) = @_; | ||
| 141 | |||
| 142 | if ( length( $immodpg_config->{_model_file_text} ) ) { | ||
| 143 | |||
| 144 | use File::Copy; | ||
| 145 | my ( $to, $from ); | ||
| 146 | |||
| 147 | my $inbound_model_file_text_extra | ||
| 148 | = ( $immodpg_config->{_GLOBAL_CONFIG_LIB} ) . '/' . $immodpg_config->{_model_file_text}; | ||
| 149 | my $inbound_model_file_text | ||
| 150 | = ( $immodpg_config->{_GLOBAL_CONFIG_LIB} ) . '/' . $immodpg_config->{_model_file_text}; | ||
| 151 | |||
| 152 | my $outbound_model_file_text = ( $Project->IMMODPG_INVISIBLE() ) . '/' . $immodpg_config->{_model_file_text}; | ||
| 153 | my $outbound_model_file_text_extra = ( $Project->IMMODPG() ) . '/' . $immodpg_config->{_model_file_text}; | ||
| 154 | |||
| 155 | if ( $manage_files_by2->does_file_exist( \$outbound_model_file_text ) | ||
| 156 | and $manage_files_by2->does_file_exist( \$outbound_model_file_text_extra ) ) { | ||
| 157 | |||
| 158 | # CASE 1 do nothing--files are there | ||
| 159 | # print("case 1, _set_model_file_text, found all model.text files\n"); | ||
| 160 | # print("case 1, _set_model_file_text, outbound_model_file_text=$outbound_model_file_text \n"); | ||
| 161 | # print("case 1, _set_model_file_text, outbound_model_file_text_extra=$outbound_model_file_text_extra \n"); | ||
| 162 | # print("_set_model_file_text, NADA\n"); | ||
| 163 | |||
| 164 | } elsif ( not $manage_files_by2->does_file_exist( \$outbound_model_file_text_extra ) | ||
| 165 | and $manage_files_by2->does_file_exist( \$outbound_model_file_text ) ) { | ||
| 166 | |||
| 167 | # CASE 2 copy the version in the hidden directory to the visible directory | ||
| 168 | # print("Case 2 immodpg_config, _set_model_file_text, one missing case of model.text config file\n"); | ||
| 169 | |||
| 170 | $from = $outbound_model_file_text; | ||
| 171 | $to = $outbound_model_file_text_extra; | ||
| 172 | copy( $from, $to ); | ||
| 173 | |||
| 174 | } elsif ( not $manage_files_by2->does_file_exist( \$outbound_model_file_text ) | ||
| 175 | and $manage_files_by2->does_file_exist( \$outbound_model_file_text_extra ) ) { | ||
| 176 | |||
| 177 | # CASE 3 copy the file in the visible directory to the hidden directory | ||
| 178 | print("case 3 _set_model_file_text, one missing case of model.text config file\n"); | ||
| 179 | $from = $outbound_model_file_text_extra; | ||
| 180 | $to = $outbound_model_file_text; | ||
| 181 | copy( $from, $to ); | ||
| 182 | |||
| 183 | } elsif ( not $manage_files_by2->does_file_exist( \$outbound_model_file_text ) | ||
| 184 | and ( not $manage_files_by2->does_file_exist( \$outbound_model_file_text_extra ) ) ) { | ||
| 185 | |||
| 186 | # CASE 4 copy the file in the hidden directory to the visible directory | ||
| 187 | # print("case 4 _set_model_file_text, no cases of model.text file exist\n"); | ||
| 188 | # print("case 4 _set_model_file_text, inbound_model_file_text=$inbound_model_file_text \n"); | ||
| 189 | |||
| 190 | $from = $inbound_model_file_text; | ||
| 191 | $to = $outbound_model_file_text; | ||
| 192 | copy( $from, $to ); | ||
| 193 | |||
| 194 | $from = $inbound_model_file_text_extra; | ||
| 195 | $to = $outbound_model_file_text_extra; | ||
| 196 | copy( $from, $to ); | ||
| 197 | |||
| 198 | } else { | ||
| 199 | print("immodpg.pl,_set_model_file_text, missing parameters\n"); | ||
| 200 | } | ||
| 201 | |||
| 202 | return (); | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | =head2 get_values | ||
| 207 | control for string quotes | ||
| 208 | |||
| 209 | =cut | ||
| 210 | |||
| 211 | # set the superflow name: 12 is for immodpg | ||
| 212 | |||
| 213 | sub get_values { | ||
| 214 | |||
| 215 | my ($self) = @_; | ||
| 216 | |||
| 217 | my $control = control->new(); | ||
| 218 | |||
| 219 | # Warning: set using a scalar reference | ||
| 220 | $immodpg_config->{_prog_name} = \@{$superflow_config_names}[12]; | ||
| 221 | |||
| 222 | # print("immodpg_config, prog_name : @{$superflow_config_names}[12]\n"); | ||
| 223 | |||
| 224 | $config_superflows->set_program_name( $immodpg_config->{_prog_name} ); | ||
| 225 | |||
| 226 | # parameter values from superflow configuration file | ||
| 227 | $immodpg_config->{_values_aref} = $config_superflows->get_values(); | ||
| 228 | |||
| 229 | # print("immodpg_config,values=--@{$immodpg_config->{_values_aref}}--\n"); | ||
| 230 | my $base_file_name = @{ $immodpg_config->{_values_aref} }[0]; | ||
| 231 | $base_file_name = $control->get_no_quotes($base_file_name); | ||
| 232 | |||
| 233 | my $pre_digitized_XT_pairs = @{ $immodpg_config->{_values_aref} }[1]; | ||
| 234 | $pre_digitized_XT_pairs = $control->get_no_quotes($pre_digitized_XT_pairs); | ||
| 235 | |||
| 236 | my $data_traces = @{ $immodpg_config->{_values_aref} }[2]; | ||
| 237 | $data_traces = $control->get_no_quotes($data_traces); | ||
| 238 | |||
| 239 | my $clip = @{ $immodpg_config->{_values_aref} }[3]; | ||
| 240 | my $min_t_s = @{ $immodpg_config->{_values_aref} }[4]; | ||
| 241 | my $min_x_m = @{ $immodpg_config->{_values_aref} }[5]; | ||
| 242 | my $data_x_inc_m = @{ $immodpg_config->{_values_aref} }[6]; | ||
| 243 | my $source_depth_m = @{ $immodpg_config->{_values_aref} }[7]; | ||
| 244 | my $receiver_depth_m = @{ $immodpg_config->{_values_aref} }[8]; | ||
| 245 | my $reducing_vel_mps = @{ $immodpg_config->{_values_aref} }[9]; | ||
| 246 | my $plot_min_x_m = @{ $immodpg_config->{_values_aref} }[10]; | ||
| 247 | my $plot_max_x_m = @{ $immodpg_config->{_values_aref} }[11]; | ||
| 248 | my $plot_min_t_s = @{ $immodpg_config->{_values_aref} }[12]; | ||
| 249 | my $plot_max_t_s = @{ $immodpg_config->{_values_aref} }[13]; | ||
| 250 | |||
| 251 | my $previous_model = @{ $immodpg_config->{_values_aref} }[14]; | ||
| 252 | $previous_model = $control->get_no_quotes($previous_model); | ||
| 253 | |||
| 254 | my $new_model = @{ $immodpg_config->{_values_aref} }[15]; | ||
| 255 | $new_model = $control->get_no_quotes($new_model); | ||
| 256 | |||
| 257 | my $layer = @{ $immodpg_config->{_values_aref} }[16]; | ||
| 258 | my $VbotNtop_factor = @{ $immodpg_config->{_values_aref} }[17]; | ||
| 259 | my $Vincrement_mps = @{ $immodpg_config->{_values_aref} }[18]; | ||
| 260 | my $thickness_increment_m = @{ $immodpg_config->{_values_aref} }[19]; | ||
| 261 | |||
| 262 | # print("1. immodpg_config,base_file_name=$base_file_name\n");\ | ||
| 263 | # print("1. immodpg_config,Vincrement_mps=$Vincrement_mps\n"); | ||
| 264 | # print("1. immodpg_config,data_x_inc_m =$data_x_inc_m \n"); | ||
| 265 | $base_file_name = $control->su_data_name( \$base_file_name ); | ||
| 266 | $new_model = $control->get_no_quotes($new_model); | ||
| 267 | $previous_model = $control->get_no_quotes($previous_model); | ||
| 268 | $data_traces = $control->get_no_quotes($data_traces); | ||
| 269 | $pre_digitized_XT_pairs = $control->get_no_quotes($pre_digitized_XT_pairs); | ||
| 270 | |||
| 271 | # print("2. immodpg_config,new_model=$new_model\n"); | ||
| 272 | # print("immodpg_config, plot_min_t_s: $plot_min_t_s\n"); | ||
| 273 | # print("2. immodpg_config,base_file_name=$base_file_name\n"); | ||
| 274 | |||
| 275 | =head2 Example LOCAL VARIABLES FOR THIS PROJECT | ||
| 276 | |||
| 277 | =cut | ||
| 278 | |||
| 279 | my $CFG = { | ||
| 280 | immodpg => { | ||
| 281 | 1 => { | ||
| 282 | base_file_name => $base_file_name, | ||
| 283 | pre_digitized_XT_pairs => $pre_digitized_XT_pairs, | ||
| 284 | data_traces => $data_traces, | ||
| 285 | clip => $clip, | ||
| 286 | min_t_s => $min_t_s, | ||
| 287 | min_x_m => $min_x_m, | ||
| 288 | data_x_inc_m => $data_x_inc_m, | ||
| 289 | source_depth_m => $source_depth_m, | ||
| 290 | receiver_depth_m => $receiver_depth_m, | ||
| 291 | reducing_vel_mps => $reducing_vel_mps, | ||
| 292 | plot_min_x_m => $plot_min_x_m, | ||
| 293 | plot_max_x_m => $plot_max_x_m, | ||
| 294 | plot_min_t_s => $plot_min_t_s, | ||
| 295 | plot_max_t_s => $plot_max_t_s, | ||
| 296 | previous_model => $previous_model, | ||
| 297 | new_model => $new_model, | ||
| 298 | layer => $layer, | ||
| 299 | VbotNtop_factor => $VbotNtop_factor, | ||
| 300 | Vincrement_mps => $Vincrement_mps, | ||
| 301 | thickness_increment_m => $thickness_increment_m, | ||
| 302 | |||
| 303 | } | ||
| 304 | } | ||
| 305 | }; # end of CFG hash | ||
| 306 | # print("immodpg_config,base_file_name=$CFG->{immodpg}{1}{base_file_name}\n"); | ||
| 307 | # print("immodpg_config,data_x_inc_m=$CFG->{immodpg}{1}{data_x_inc_m/data_x}\n"); | ||
| 308 | return ( $CFG, $immodpg_config->{_values_aref} ); # hash and arrary reference | ||
| 309 | }; # end of sub get_values | ||
| 310 | |||
| 311 | =head2 sub get_max_index | ||
| 312 | |||
| 313 | max index = number of input variables -1 | ||
| 314 | |||
| 315 | =cut | ||
| 316 | |||
| 317 | sub get_max_index { | ||
| 318 | my ($self) = @_; | ||
| 319 | my $max_index = 19; | ||
| 320 | |||
| 321 | return ($max_index); | ||
| 322 | } | ||
| 323 | |||
| 324 | 1; |