Text::NASA_Ames::FFI1020 - Implementation of FFI1020 NASA_Ames format


Text-NASA_Ames documentation Contained in the Text-NASA_Ames distribution.

Index


Code Index:

NAME

Top

Text::NASA_Ames::FFI1020 - Implementation of FFI1020 NASA_Ames format

SYNOPSIS

Top

DESCRIPTION

Top

This class should normally not be called directly but through the Text::NASA_Ames class indirectly.

PUBLIC METHODS

Top

new (Text::NASA_Ames-object || options for new NASA_Ames)

parses the (rest of the) header (body and comments)

VERSION

Top

$Id: FFI1020.pm,v 1.1 2004/02/18 09:25:04 heikok Exp $

AUTHOR

Top

Heiko Klein, <H.Klein@gmx.net>

SEE ALSO

Top

http://cloud1.arc.nasa.gov/solve/archiv/archive.tutorial.html, Text::NASA_Ames


Text-NASA_Ames documentation Contained in the Text-NASA_Ames distribution.
package Text::NASA_Ames::FFI1020;
use base qw(Text::NASA_Ames);
use Carp;

use 5.00600;
use strict;

our $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf " %d." . "%02d" x $#r, @r };


sub new {
    my ($class, $fileObj) = @_;
    $class = ref $class || $class;
    if (! (ref $fileObj && (ref($fileObj) eq 'Text::NASA_Ames'))) {
	return new Text::NASA_Ames($fileObj);
    }
    my $self = $fileObj;
    bless $self, $class;

    $self->_parseList('dX', $self->nIV);
    unless ($self->dX()->[0]) {
	$self->_carp("dX must be defined and != 0 for ".ref $self);
	return;
    }
    $self->_parseList('nVPM', $self->nIV);
    unless ($self->nVPM()->[0] > 0) {
	$self->_carp("nVPM must be > 0 for ".ref $self . " was: ".
		    $self->nVPM()->[0]);
	return;
    }
    $self->_parseLines('xName', $self->nIV);
    $self->_parseVDeclaration;
    $self->_parseAuxDeclaration;
    $self->_parseTailHeader;

    return $self;
}

sub _refillBuffer {
    my $self = shift;

    my $line = $self->nextLine;
    return unless defined $line;

    my ($x, @a) = split ' ', $line;
    if (@a != $self->nAuxV) {
	$self->_carp("not enough elements for Aux, expected ".
		     $self->nAuxV() . ", got ". scalar @a);
	return;
    }
    $self->_cleanAndScaleVals($self->aMiss, $self->aScal, \@a)
	if $self->nAuxV > 0;

    my @vHelp;
    for (my $i = 0; $i < $self->nV; $i++) {
	$line = $self->nextLine;
	unless ($line) {
	    $self->_carp("not enough elements for V".
			 " in row ". $self->currentLine);
	    return;
	}
	
	return unless defined $line;
	my @vi = split ' ', $line;
	if (@vi != $self->nVPM()->[0]) {
	    $self->_carp("not enough elements for nVPM, expected ".
			 $self->nVPM()->[0] . ", got ". scalar @vi .
			 " in row ". $self->currentLine);
	    return;
	}
	# transposing for faster access
	for (my $j = 0; $j < $self->nVPM()->[0]; $j++) {
	    $vHelp[$j][$i] = $vi[$j];
	}
    }

    for (my $j = 0; $j < $self->nVPM()->[0]; $j++) {
	$self->_cleanAndScaleVals($self->vMiss, $self->vScal, $vHelp[$j]);
	push @{ $self->dataBuffer },
	    new Text::NASA_Ames::DataEntry({X => [ $x + ($j * $self->dX()->[0]) ],
				      V => $vHelp[$j],
				      A => \@a});
    }
}

1;
__END__