lib/App/SeismicUnixGui/misc/cps.pm untested

filter: Statementstmt 0.0% 0 / 57 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 74 CC 3 SCAR 15.5
CC
3
Cov
0%
get_model
12.0
set_file_in
2.0
set_directory_in
2.0
CRAP 4.7
1 package App::SeismicUnixGui::misc::cps;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6 Auxiliar modules for Computer
7 Programs in Seismology by
8 Hermann (2013)
9  
10 PROGRAM NAME:
11 AUTHOR: Juan Lorenzo
12 DATE: V 0.0.1 January 2024
13
14 DESCRIPTION:
15  
16 =head2 USE
17  
18 =head3 NOTES
19  
20 =head4
21 Examples
22  
23 =head3 NOTES
24  
25 =head4 CHANGES and their DATES
26  
27 =cut
28  
29 use PDL;
30 use Moose;
31 our $VERSION = '0.0.1';
32  
33 use App::SeismicUnixGui::misc::pm_io '0.0.1';
34 use aliased 'App::SeismicUnixGui::misc::pm_io';
35 use aliased 'App::SeismicUnixGui::misc::manage_files_by2';
36  
37  
38 =head2
39  
40 Define private hash
41 to share
42  
43 =cut
44  
45 my $cps = {
46 _directory_in => '',
47 _file_in => '',
48 _pathNfile_in => '',
49 };
50  
51  
52 =head2 Instantiation
53  
54 =cut
55  
56 my $pm_io = pm_io->new();
57 my $file = manage_files_by2->new();
58  
59 =head2 sub set_file_in
60  
61 =cut
62  
63 sub set_file_in {
64
65 my ($self, $file_in) = @_;
66
67 $pm_io->set_file_in($file_in);
68
69 return();
70 }
71  
72 =head2 sub set_directory_in
73  
74 =cut
75  
76 sub set_directory_in {
77
78 my ($self, $file_in) = @_;
79
80 $pm_io->set_directory_in($file_in);
81
82 return();
83 }
84  
85 =head2 sub get_fileNpath_in
86  
87 =cut
88  
89 sub _get_pathNfile_in {
90
91 my ($self) = @_;
92
93 $cps->{_pathNfile_in} = $pm_io->get_pathNfile_in();
94 # my $a = $cps->{_pathNfile_in};
95 # print("cps->{_pathNfile_in}:$a\n");
96
97 return($cps->{_pathNfile_in});
98 }
99
100  
101 =head2 sub read a model file
102  
103 =cut
104  
105 sub get_model {
106
107 my ($self) = @_;
108
109 =head2
110  
111 Definitions
112  
113 =cut
114
115 my $inbound = _get_pathNfile_in();
116 # print("$inbound\n");
117 my $skip = 12;
118 my $row_aref2 = $file->get_10cols_aref( $inbound, $skip );
119 my @row_aref = @$row_aref2;
120 my $num_rows = scalar @row_aref;
121 my $num_pdl = 0;
122 my $data_list_pdl;
123  
124 for ( my $i = 0 ; $i < $num_rows ; $i++ ) {
125  
126 my @data_block = @{ $row_aref[$i] };
127 my @data_list = split( '\s+', $data_block[0] );
128  
129 # convert data formats from the list
130 my $scientific_notationQp = $data_list[4];
131 my $decimal_notationQp = sprintf( "%.10g", $scientific_notationQp );
132 $data_list[4] = $decimal_notationQp;
133  
134 my $scientific_notationQs = $data_list[5];
135 my $decimal_notationQs = sprintf( "%.10g", $scientific_notationQs );
136 $data_list[5] = $decimal_notationQs;
137 my $temp_pdl = pdl @data_list;
138  
139 if ( $i == 0 ) {
140  
141 $data_list_pdl = $temp_pdl;
142  
143 }
144 elsif ( $i > 0 ) {
145  
146 $data_list_pdl = $data_list_pdl->glue( 1, $temp_pdl );
147  
148 }
149 else {
150 print("invert, unexpected value\n");
151 }
152  
153  
154 $num_pdl = $num_pdl + 1;
155 }
156
157 my $result = $data_list_pdl;
158 return($result);
159 }
160  
161 1;