line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::NASA_Ames::FFIx010; |
2
|
3
|
|
|
3
|
|
23
|
use base qw(Text::NASA_Ames); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2185
|
|
3
|
3
|
|
|
3
|
|
30
|
use Carp; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
216
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
70
|
use 5.00600; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
101
|
|
6
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
4038
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf " %d." . "%02d" x $#r, @r }; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Text::NASA_Ames::FFIx010 - Implementation of FFIx010 NASA_Ames format |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class should normally not be called directly. It is the base class |
21
|
|
|
|
|
|
|
for FFI2010, FFI3010 and FFI4010, but not FFI1010! |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 PUBLIC METHODS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over 4 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item new (Text::NASA_Ames-object || options for new NASA_Ames) |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
parses the (rest of the) header (body and comments) |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { |
34
|
10
|
|
|
10
|
1
|
19
|
my ($class, $fileObj) = @_; |
35
|
10
|
|
33
|
|
|
53
|
$class = ref $class || $class; |
36
|
10
|
50
|
33
|
|
|
67
|
if (! (ref $fileObj && (ref($fileObj) eq 'Text::NASA_Ames'))) { |
37
|
0
|
|
|
|
|
0
|
return new Text::NASA_Ames($fileObj); |
38
|
|
|
|
|
|
|
} |
39
|
10
|
|
|
|
|
16
|
my $self = $fileObj; |
40
|
10
|
|
|
|
|
23
|
bless $self, $class; |
41
|
|
|
|
|
|
|
|
42
|
10
|
|
|
|
|
50
|
$self->_parseList('dX', $self->nIV); |
43
|
10
|
|
|
|
|
136
|
$self->_parseList('nX', ($self->nIV - 1)); |
44
|
10
|
|
|
|
|
100
|
push @{ $self->nX }, undef; |
|
10
|
|
|
|
|
38
|
|
45
|
10
|
|
|
|
|
91
|
$self->_parseList('nXDef', ($self->nIV - 1)); |
46
|
10
|
|
|
|
|
99
|
push @{ $self->nXDef }, undef; |
|
10
|
|
|
|
|
24
|
|
47
|
10
|
|
|
|
|
124
|
$self->x([]); |
48
|
10
|
|
|
|
|
107
|
for (my $i = 0; $i < ($self->nIV - 1); $i++) { |
49
|
16
|
|
|
|
|
199
|
my $expected = $self->nXDef()->[$i]; |
50
|
16
|
50
|
|
|
|
147
|
if ($expected > 0) { |
51
|
16
|
|
|
|
|
48
|
my @xVals = split ' ', $self->nextLine; |
52
|
16
|
50
|
|
|
|
46
|
if (@xVals != $expected) { |
53
|
0
|
|
|
|
|
0
|
$self->_carp("got ".scalar @xVals . |
54
|
|
|
|
|
|
|
" values for X$i, expected $expected\n"); |
55
|
0
|
|
|
|
|
0
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
16
|
|
|
|
|
23
|
push @{ $self->x }, \@xVals; |
|
16
|
|
|
|
|
43
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
10
|
|
|
|
|
163
|
$self->_parseLines('xName', $self->nIV); |
61
|
10
|
|
|
|
|
132
|
$self->_parseVDeclaration; |
62
|
10
|
|
|
|
|
118
|
$self->_parseAuxDeclaration; |
63
|
10
|
|
|
|
|
120
|
$self->_parseTailHeader; |
64
|
|
|
|
|
|
|
|
65
|
10
|
|
|
|
|
144
|
return $self; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _refillBuffer { |
69
|
28
|
|
|
28
|
|
38
|
my $self = shift; |
70
|
|
|
|
|
|
|
|
71
|
28
|
|
|
|
|
74
|
my $line = $self->nextLine; |
72
|
28
|
100
|
|
|
|
70
|
return unless defined $line; |
73
|
|
|
|
|
|
|
|
74
|
23
|
|
|
|
|
68
|
my ($xLast, @a) = split ' ', $line; |
75
|
23
|
50
|
|
|
|
68
|
if (@a != $self->nAuxV) { |
76
|
0
|
|
|
|
|
0
|
$self->_carp("not enough elements for Aux, expected ". |
77
|
|
|
|
|
|
|
$self->nAuxV() . ", got ". scalar @a); |
78
|
0
|
|
|
|
|
0
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
23
|
100
|
|
|
|
237
|
$self->_cleanAndScaleVals($self->aMiss, $self->aScal, \@a) |
81
|
|
|
|
|
|
|
if $self->nAuxV > 0; |
82
|
|
|
|
|
|
|
|
83
|
23
|
|
|
|
|
103
|
my @vHelp; |
84
|
|
|
|
|
|
|
my @keys; |
85
|
|
|
|
|
|
|
# wrong for 1010, there v-values are in the line |
86
|
23
|
|
|
|
|
74
|
for (my $n = 0; $n < $self->nV; $n++) { |
87
|
23
|
|
|
|
|
211
|
$vHelp[$n] = {}; |
88
|
23
|
|
|
|
|
67
|
$self->_readBlock($self->nIV - 2, "", $vHelp[$n], \@keys); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
23
|
|
|
|
|
469
|
foreach my $key (@keys) { |
92
|
591
|
|
|
|
|
1738
|
my @pos = split '_', $key; |
93
|
591
|
|
|
|
|
699
|
my @xList; |
94
|
591
|
|
|
|
|
1636
|
for (my $i = 0; $i < ($self->nIV - 1); $i++) { |
95
|
1375
|
|
|
|
|
21676
|
$xList[$i] = $self->getXatPos($i, $pos[$i]); |
96
|
|
|
|
|
|
|
} |
97
|
591
|
|
|
|
|
10998
|
my @v; |
98
|
591
|
|
|
|
|
1736
|
for (my $j = 0; $j < $self->nV; $j++) { |
99
|
591
|
|
|
|
|
7073
|
push @v, delete $vHelp[$j]{$key}; |
100
|
|
|
|
|
|
|
} |
101
|
591
|
|
|
|
|
5905
|
$self->_cleanAndScaleVals($self->vMiss, $self->vScal, \@v); |
102
|
591
|
|
|
|
|
804
|
push @{ $self->dataBuffer }, |
|
591
|
|
|
|
|
1373
|
|
103
|
|
|
|
|
|
|
new Text::NASA_Ames::DataEntry({X => [ (@xList, $xLast) ], |
104
|
|
|
|
|
|
|
V => \@v, |
105
|
|
|
|
|
|
|
A => \@a}); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _readBlock { |
110
|
63
|
|
|
63
|
|
316
|
my ($self, $xi, $key, $block, $keys) = @_; |
111
|
63
|
100
|
|
|
|
109
|
if ($xi > 0) { |
112
|
|
|
|
|
|
|
# wrong for 1010, there v-values are in the line |
113
|
8
|
|
|
|
|
29
|
for (my $i = 0; $i < $self->nX->[$xi]; $i++) { |
114
|
40
|
100
|
|
|
|
782
|
my $newkey = ($key eq "") ? $i : "$i\_$key"; |
115
|
40
|
|
|
|
|
115
|
$self->_readBlock($xi - 1, $newkey, $block, $keys); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} else { |
118
|
55
|
|
|
|
|
141
|
my $line = $self->nextLine; |
119
|
55
|
50
|
|
|
|
134
|
unless ($line) { |
120
|
0
|
|
|
|
|
0
|
$self->_carp("not enough elements for XI $xi". |
121
|
|
|
|
|
|
|
" in row ". $self->currentLine); |
122
|
0
|
|
|
|
|
0
|
return; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
# wrong for 1010, there v-values are in the line |
125
|
55
|
|
|
|
|
300
|
my @vi = split ' ', $line; |
126
|
55
|
50
|
|
|
|
174
|
if (@vi != $self->nX->[0]) { |
127
|
0
|
|
|
|
|
0
|
$self->_carp("not enough elements for nX1, expected ". |
128
|
|
|
|
|
|
|
$self->nX->[0] . ", got ". scalar @vi . |
129
|
|
|
|
|
|
|
" in row ". $self->currentLine); |
130
|
0
|
|
|
|
|
0
|
return; |
131
|
|
|
|
|
|
|
} |
132
|
55
|
|
|
|
|
569
|
for (my $i = 0; $i < $self->nX->[0]; $i++) { |
133
|
591
|
100
|
|
|
|
5144
|
my $newkey = ($key eq "") ? $i : "$i\_$key"; |
134
|
591
|
|
|
|
|
587
|
push @{ $keys }, $newkey; |
|
591
|
|
|
|
|
1047
|
|
135
|
591
|
|
|
|
|
2443
|
$block->{$newkey} = $vi[$i]; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item X |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
list of list of X->[i][pos]. call getXatPos to retrieve auto-expanded values |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item getXatPos (i,pos) |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
get Xi at the position pos (this will modify currentXPos1). positions start |
147
|
|
|
|
|
|
|
at 0, i starts at 0, defined until nIV - 2! |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub getXatPos { |
152
|
1375
|
|
|
1375
|
1
|
2294
|
my ($self, $i, $currentPos) = @_; |
153
|
1375
|
50
|
33
|
|
|
4496
|
unless (($i >= 0) && ($i <= ($self->nIV - 2))) { |
154
|
0
|
|
|
|
|
0
|
$self->_carp("cannot get i-pos: $i"); |
155
|
0
|
|
|
|
|
0
|
return; |
156
|
|
|
|
|
|
|
} |
157
|
1375
|
50
|
33
|
|
|
15927
|
unless (($currentPos >= 0) && ($currentPos < $self->nX->[$i])) { |
158
|
0
|
|
|
|
|
0
|
$self->_carp("undefined position in getXatPos: $currentPos"); |
159
|
0
|
|
|
|
|
0
|
return; |
160
|
|
|
|
|
|
|
} |
161
|
1375
|
100
|
|
|
|
14807
|
if ($self->nXDef->[$i] > $currentPos) { |
162
|
375
|
|
|
|
|
3154
|
return $self->x->[$i]->[$currentPos]; |
163
|
|
|
|
|
|
|
} else { |
164
|
1000
|
50
|
|
|
|
8725
|
unless ($self->dX->[$i]) { |
165
|
0
|
|
|
|
|
0
|
$self->_carp("dX($i) not defined or 0, cannot extrapolate". |
166
|
|
|
|
|
|
|
" getXatPos"); |
167
|
0
|
|
|
|
|
0
|
return; |
168
|
|
|
|
|
|
|
} |
169
|
1000
|
|
|
|
|
13679
|
return $self->x->[$i]->[0] + ($currentPos * $self->dX->[$i]); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; |
174
|
|
|
|
|
|
|
__END__ |