| 1 | package Text::NASA_Ames::FFIx010; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use base qw(Text::NASA_Ames); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use 5.00600; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | 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 | 10 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=20.4
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 10 | my ($class, $fileObj) = @_; | |||||||||||||||||||||||||||
| 35 | 10 | ▶ | $class = ref $class || $class; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 36 | 10 | ▶ | if (! (ref $fileObj && (ref($fileObj) eq 'Text::NASA_Ames'))) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $fileObj and ref $fileObj eq "Text::NASA_Ames"
MC/DC0%0/2
ref $fileObj and ref $fileObj eq "Text::NASA_Ames"
ref $fileObj
ref $fileObj eq "Text::NASA_Ames"
Truth table33%1/3
A and B
A= ref $fileObjB= ref $fileObj eq "Text::NASA_Ames"
| |||||||||||||||||||||||||||||
| 37 | 0 | return new Text::NASA_Ames($fileObj); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 10 | my $self = $fileObj; | |||||||||||||||||||||||||||
| 40 | 10 | bless $self, $class; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 10 | $self->_parseList('dX', $self->nIV); | |||||||||||||||||||||||||||
| 43 | 10 | $self->_parseList('nX', ($self->nIV - 1)); | |||||||||||||||||||||||||||
| 44 | 10 | push @{ $self->nX }, undef; | |||||||||||||||||||||||||||
| 45 | 10 | $self->_parseList('nXDef', ($self->nIV - 1)); | |||||||||||||||||||||||||||
| 46 | 10 | push @{ $self->nXDef }, undef; | |||||||||||||||||||||||||||
| 47 | 10 | $self->x([]); | |||||||||||||||||||||||||||
| 48 | 10 | ▶ | for (my $i = 0; $i < ($self->nIV - 1); $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 16 | my $expected = $self->nXDef()->[$i]; | |||||||||||||||||||||||||||
| 50 | 16 | ▶ | if ($expected > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 16 | my @xVals = split ' ', $self->nextLine; | |||||||||||||||||||||||||||
| 52 | 16 | ▶ | if (@xVals != $expected) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | $self->_carp("got ".scalar @xVals . | |||||||||||||||||||||||||||
| 54 | " values for X$i, expected $expected\n"); | ||||||||||||||||||||||||||||
| 55 | 0 | return; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 16 | push @{ $self->x }, \@xVals; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 10 | $self->_parseLines('xName', $self->nIV); | |||||||||||||||||||||||||||
| 61 | 10 | $self->_parseVDeclaration; | |||||||||||||||||||||||||||
| 62 | 10 | $self->_parseAuxDeclaration; | |||||||||||||||||||||||||||
| 63 | 10 | $self->_parseTailHeader; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 10 | return $self; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 28 | ▶ | sub _refillBuffer { | ||||||||||||||||||||||||||
|
Subroutine
_refillBuffer: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||
| 69 | 28 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 28 | my $line = $self->nextLine; | |||||||||||||||||||||||||||
| 72 | 28 | ▶ | return unless defined $line; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 23 | my ($xLast, @a) = split ' ', $line; | |||||||||||||||||||||||||||
| 75 | 23 | ▶ | if (@a != $self->nAuxV) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 0 | $self->_carp("not enough elements for Aux, expected ". | |||||||||||||||||||||||||||
| 77 | $self->nAuxV() . ", got ". scalar @a); | ||||||||||||||||||||||||||||
| 78 | 0 | return; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 23 | ▶ | $self->_cleanAndScaleVals($self->aMiss, $self->aScal, \@a) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | if $self->nAuxV > 0; | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 23 | my @vHelp; | |||||||||||||||||||||||||||
| 84 | my @keys; | ||||||||||||||||||||||||||||
| 85 | # wrong for 1010, there v-values are in the line | ||||||||||||||||||||||||||||
| 86 | 23 | ▶ | for (my $n = 0; $n < $self->nV; $n++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 23 | $vHelp[$n] = {}; | |||||||||||||||||||||||||||
| 88 | 23 | $self->_readBlock($self->nIV - 2, "", $vHelp[$n], \@keys); | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 23 | foreach my $key (@keys) { | |||||||||||||||||||||||||||
| 92 | 591 | my @pos = split '_', $key; | |||||||||||||||||||||||||||
| 93 | 591 | my @xList; | |||||||||||||||||||||||||||
| 94 | 591 | ▶ | for (my $i = 0; $i < ($self->nIV - 1); $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 1375 | $xList[$i] = $self->getXatPos($i, $pos[$i]); | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | 591 | my @v; | |||||||||||||||||||||||||||
| 98 | 591 | ▶ | for (my $j = 0; $j < $self->nV; $j++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 591 | push @v, delete $vHelp[$j]{$key}; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | 591 | $self->_cleanAndScaleVals($self->vMiss, $self->vScal, \@v); | |||||||||||||||||||||||||||
| 102 | 591 | push @{ $self->dataBuffer }, | |||||||||||||||||||||||||||
| 103 | new Text::NASA_Ames::DataEntry({X => [ (@xList, $xLast) ], | ||||||||||||||||||||||||||||
| 104 | V => \@v, | ||||||||||||||||||||||||||||
| 105 | A => \@a}); | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 63 | ▶ | sub _readBlock { | ||||||||||||||||||||||||||
|
Subroutine
_readBlock: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||
| 110 | 63 | my ($self, $xi, $key, $block, $keys) = @_; | |||||||||||||||||||||||||||
| 111 | 63 | ▶ | if ($xi > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | # wrong for 1010, there v-values are in the line | ||||||||||||||||||||||||||||
| 113 | 8 | ▶ | for (my $i = 0; $i < $self->nX->[$xi]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 40 | ▶ | my $newkey = ($key eq "") ? $i : "$i\_$key"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 40 | $self->_readBlock($xi - 1, $newkey, $block, $keys); | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | } else { | ||||||||||||||||||||||||||||
| 118 | 55 | my $line = $self->nextLine; | |||||||||||||||||||||||||||
| 119 | 55 | ▶ | unless ($line) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 0 | $self->_carp("not enough elements for XI $xi". | |||||||||||||||||||||||||||
| 121 | " in row ". $self->currentLine); | ||||||||||||||||||||||||||||
| 122 | 0 | return; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | # wrong for 1010, there v-values are in the line | ||||||||||||||||||||||||||||
| 125 | 55 | my @vi = split ' ', $line; | |||||||||||||||||||||||||||
| 126 | 55 | ▶ | if (@vi != $self->nX->[0]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 0 | $self->_carp("not enough elements for nX1, expected ". | |||||||||||||||||||||||||||
| 128 | $self->nX->[0] . ", got ". scalar @vi . | ||||||||||||||||||||||||||||
| 129 | " in row ". $self->currentLine); | ||||||||||||||||||||||||||||
| 130 | 0 | return; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 55 | ▶ | for (my $i = 0; $i < $self->nX->[0]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 591 | ▶ | my $newkey = ($key eq "") ? $i : "$i\_$key"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 591 | push @{ $keys }, $newkey; | |||||||||||||||||||||||||||
| 135 | 591 | $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 | 1375 | ▶ | sub getXatPos { | ||||||||||||||||||||||||||
|
Subroutine
getXatPos: called CC=7 SCAR=25.2
Pod
documented
| |||||||||||||||||||||||||||||
| 152 | 1375 | my ($self, $i, $currentPos) = @_; | |||||||||||||||||||||||||||
| 153 | 1375 | ▶ | unless (($i >= 0) && ($i <= ($self->nIV - 2))) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$i >= 0 and $i <= $self->nIV - 2
MC/DC0%0/2
$i >= 0 and $i <= $self->nIV - 2
$i >= 0
$i <= $self->nIV - 2
Truth table33%1/3
A and B
A= $i >= 0B= $i <= $self->nIV - 2
| |||||||||||||||||||||||||||||
| 154 | 0 | $self->_carp("cannot get i-pos: $i"); | |||||||||||||||||||||||||||
| 155 | 0 | return; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | 1375 | ▶ | unless (($currentPos >= 0) && ($currentPos < $self->nX->[$i])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$currentPos >= 0 and $currentPos < $self->nX->[$i]
MC/DC0%0/2
$currentPos >= 0 and $currentPos < $self->nX->[$i]
$currentPos >= 0
$currentPos < $self->nX->[$i]
Truth table33%1/3
A and B
A= $currentPos >= 0B= $currentPos < $self->nX->[$i]
| |||||||||||||||||||||||||||||
| 158 | 0 | $self->_carp("undefined position in getXatPos: $currentPos"); | |||||||||||||||||||||||||||
| 159 | 0 | return; | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | 1375 | ▶ | if ($self->nXDef->[$i] > $currentPos) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 375 | return $self->x->[$i]->[$currentPos]; | |||||||||||||||||||||||||||
| 163 | } else { | ||||||||||||||||||||||||||||
| 164 | 1000 | ▶ | unless ($self->dX->[$i]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 0 | $self->_carp("dX($i) not defined or 0, cannot extrapolate". | |||||||||||||||||||||||||||
| 166 | " getXatPos"); | ||||||||||||||||||||||||||||
| 167 | 0 | return; | |||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | 1000 | return $self->x->[$i]->[0] + ($currentPos * $self->dX->[$i]); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 3 | 1; | |||||||||||||||||||||||||||
| 174 | __END__ | ||||||||||||||||||||||||||||