"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "IO/FlexRaw/FlexRaw.pm" between
PDL-2.076.tar.gz and PDL-2.077.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

FlexRaw.pm  (PDL-2.076):FlexRaw.pm  (PDL-2.077)
skipping to change at line 107 skipping to change at line 107
$header = [ $header = [
{Type => 'f77'}, {Type => 'f77'},
{Type => 'float', NDims => 3, Dims => [ 4,600,600 ] } {Type => 'float', NDims => 3, Dims => [ 4,600,600 ] }
]; ];
@a = readflex('banana',$header); @a = readflex('banana',$header);
reads our example file again. As a special case, when NDims is 1, Dims reads our example file again. As a special case, when NDims is 1, Dims
may be given as a scalar. may be given as a scalar.
The highest dimension can be given as C<undef>, which will read as many
frames as possible of the given size (but only if only one hash-ref is given):
$video = readflex('frames.raw', [
{ Type=>'byte', NDims=>4, Dims=>[4,640,480,undef] },
]);
Within PDL, readflex and writeflex can be used to write several pdls Within PDL, readflex and writeflex can be used to write several pdls
to a single file -- e.g. to a single file -- e.g.
use PDL; use PDL;
use PDL::IO::FlexRaw; use PDL::IO::FlexRaw;
@pdls = ($pdl1, $pdl2, ...); @pdls = ($pdl1, $pdl2, ...);
$hdr = writeflex("fname",@pdls); $hdr = writeflex("fname",@pdls);
@pdl2 = readflex("fname",$hdr); @pdl2 = readflex("fname",$hdr);
skipping to change at line 179 skipping to change at line 186
vary depending on the setting of the `uac' flag on any given machine). vary depending on the setting of the `uac' flag on any given machine).
You may have run into similar problems with common blocks in FORTRAN. You may have run into similar problems with common blocks in FORTRAN.
For instance, floating point numbers may have to align on 4 byte For instance, floating point numbers may have to align on 4 byte
boundaries -- if the data file consists of 3 bytes then a float, it boundaries -- if the data file consists of 3 bytes then a float, it
cannot be read. C<mapflex> will warn about this problem when it occurs, cannot be read. C<mapflex> will warn about this problem when it occurs,
and return the PDLs mapped before the problem arose. This can be and return the PDLs mapped before the problem arose. This can be
dealt with either by reorganizing the data file (large types first dealt with either by reorganizing the data file (large types first
helps, as a rule-of-thumb), or more simply by using C<readflex>. helps, as a rule-of-thumb), or more simply by using C<readflex>.
=head1 BUGS
The test on two dimensional byte arrays fail using g77 2.7.2, but not
Sun f77. I hope this isn't my problem!
Assumes gzip is on the PATH.
Can't auto-swap compressed files, because it can't seek on them.
The header format may not agree with that used elsewhere.
Should it handle handles?
Mapflex should warn and fallback to reading on SEGV? Would have to
make sure that the data was written back after it was `destroyed'.
=head1 FUNCTIONS =head1 FUNCTIONS
=head2 readflex
=for ref
Read a binary file with flexible format specification
=for usage
Usage:
($x,$y,...) = readflex("filename" [, $hdr])
($x,$y,...) = readflex(FILEHANDLE [, $hdr])
=head2 writeflex
=for ref
Write a binary file with flexible format specification
=for usage
Usage:
$hdr = writeflex($file, $pdl1, $pdl2,...) # or
$hdr = writeflex(FILEHANDLE, $pdl1, $pdl2,...)
# now you must call writeflexhdr()
writeflexhdr($file, $hdr)
or
$PDL::IO::FlexRaw::writeflexhdr = 1; # set so we don't have to call writefl
exhdr
$hdr = writeflex($file, $pdl1, $pdl2,...) # remember, $file must be filenam
e
writeflex($file, $pdl1, $pdl2,...) # remember, $file must be filenam
e
=head2 writeflexhdr
=for ref
Write the header file corresponding to a previous writeflex call
=for usage
Usage:
writeflexhdr($file, $hdr)
$file or "filename" is the filename used in a previous writeflex
If $file is actually a "filename" then writeflexhdr() will be
called automatically if $PDL::IO::FlexRaw::writeflexhdr is true.
If writeflex() was to a FILEHANDLE, you will need to call
writeflexhdr() yourself since the filename cannot be determined
(at least easily).
=head2 mapflex
=for ref
Memory map a binary file with flexible format specification
=for usage
Usage:
($x,$y,...) = mapflex("filename" [, $hdr] [, $opts])
=for options
All of these options default to false unless set true:
ReadOnly - Data should be readonly
Creat - Create file if it doesn't exist
Trunc - File should be truncated to a length that conforms
with the header
=head2 _read_flexhdr
Read a FlexRaw header file and return a header structure.
=for usage
Usage:
$hdr = PDL::IO::FlexRaw::_read_flexhdr($file)
Note that C<_read_flexhdr> is supposed to be an internal function. It
was not originally documented and it is not tested. However, there
appeared to be no other method for obtaining a header structure from
a file, so I figured I would write a small bit of documentation on it.
=head1 Bad Value Support
As of PDL-2.4.8, L<PDL::IO::FlexRaw> has support for reading and writing
pdls with L<bad|PDL::Bad> values in them.
On C<writeflex>, an ndarray
argument with C<< $pdl->badflag == 1 >> will have the keyword/token "badvalue"
added to the header file after the dimension list and an additional token
with the bad value for that pdl if C<< $pdl->badvalue != $pdl->orig_badvalue >>.
On C<readflex>, a pdl with the "badvalue" token in the header will
automatically have its L<badflag|PDL::Bad/#badflag> set and its
L<badvalue|PDL::Bad/#badvalue> as well if it is not the standard default for tha
t type.
=for example
The new badvalue support required some additions to the header
structure. However, the interface is still being finalized. For
reference the current C<$hdr> looks like this:
$hdr = {
Type => 'byte', # data type
NDims => 2, # number of dimensions
Dims => [640,480], # dims
BadFlag => 1, # is set/set badflag
BadValue => undef, # undef==default
};
$badpdl = readflex('badpdl', [$hdr]);
If you use bad values and try the new L<PDL::IO::FlexRaw> bad value
support, please let us know via the perldl mailing list.
Suggestions and feedback are also welcome.
=head1 AUTHOR
Copyright (C) Robin Williams <rjrw@ast.leeds.ac.uk> 1997.
All rights reserved. There is no warranty. You are allowed
to redistribute this software / documentation under certain
conditions. For details, see the file COPYING in the PDL
distribution. If this file is separated from the PDL distribution,
the copyright notice should be included in the file.
Documentation contributions copyright (C) David Mertens, 2010.
=cut =cut
package PDL::IO::FlexRaw; package PDL::IO::FlexRaw;
use strict; use strict;
use warnings; use warnings;
use PDL; use PDL;
use Exporter; use Exporter;
use PDL::Types ':All'; use PDL::Types ':All';
use PDL::IO::Misc qw(bswap4); use PDL::IO::Misc qw(bswap4);
our @ISA = qw/Exporter/; our @ISA = qw/Exporter/;
our @EXPORT = qw/writeflex writeflexhdr readflex mapflex/; our @EXPORT = qw/writeflex writeflexhdr readflex mapflex glueflex/;
# Cast type numbers in concrete, for external file's sake... # Cast type numbers in concrete, for external file's sake...
my %flexnames = map +($_->enum => $_->ioname), types(); my %flexnames = map +($_->enum => $_->ioname), types();
my %flextypes = map +($_->ioname => $_->enum, my %flextypes = map +($_->ioname => $_->enum,
$_->enum => $_->enum, $_->enum => $_->enum,
$_->ppsym => $_->enum, $_->ppsym => $_->enum,
), types(); ), types();
my %flexswap = map { my %flexswap = map {
my $nb = PDL::Core::howbig(my $val = $_->enum); my $nb = PDL::Core::howbig(my $val = $_->enum);
($val => $nb > 1 ? "bswap$nb" : undef)} ($val => $nb > 1 ? "bswap$nb" : undef)}
skipping to change at line 484 skipping to change at line 340
$pdl->freedata; $pdl->freedata;
$pdl->set_data_by_offset($orig,$offset); $pdl->set_data_by_offset($orig,$offset);
local $flexmapok=1; local $flexmapok=1;
local $SIG{BUS} = \&myhandler unless $^O =~ /MSWin32/i; local $SIG{BUS} = \&myhandler unless $^O =~ /MSWin32/i;
local $SIG{FPE} = \&myhandler; local $SIG{FPE} = \&myhandler;
eval {$pdl->clump(-1)->at(0)}; eval {$pdl->clump(-1)->at(0)};
$_[4] += $len; # mutate input $_[4] += $len; # mutate input
$flexmapok; $flexmapok;
} }
=head2 glueflex
=for ref
Append a single data item to an existing binary file written by
L</writeflex>. Must be to the last data item in that file. Error if
dims not compatible with existing data.
=for usage
$hdr = glueflex($file, $pdl[, $hdr]); # or
$hdr = glueflex(FILEHANDLE, $pdl[, $hdr]);
# now you must call writeflexhdr()
writeflexhdr($file, $hdr);
or
$PDL::IO::FlexRaw::writeflexhdr = 1; # set so we don't have to call writefle
xhdr
$hdr = glueflex($file, $pdl[, $hdr]) # remember, $file must be filename
glueflex($file, $pdl[, $hdr]) # remember, $file must be filename
=cut
sub glueflex {
my $usage = 'Usage $hdr = glueflex("filename"|FILEHANDLE,$pdl[,$hdr])';
my ($name,$pdl,$hdr) = @_;
barf $usage if @_ < 2 or @_ > 3 or !UNIVERSAL::isa($pdl, 'PDL');
my $isname = 0;
my $d;
# Test if $name is a file handle
if (defined fileno($name)) {
$d = $name;
} else {
barf $usage if ref $name;
barf "'$name' must be real filename: $!" if !-f $name;
$isname = 1;
open $d, '>>', $name or barf "Couldn't open '$name' for appending: $!";
}
binmode $d;
$hdr ||= _read_flexhdr("$name.hdr");
my $hash = $hdr->[-1] || barf "glueflex: need valid header-hash";
barf "glueflex: ndarray has type '@{[$pdl->type]}' but last hash has type '$ha
sh->{Type}'"
if $pdl->type != PDL::Type->new($hash->{Type});
my @dims = ref $hash->{Dims} ? @{$hash->{Dims}} : $hash->{Dims};
barf "glueflex: header dims needs at least 2 dims, got (@dims)" if @dims < 2;
my @ldims = @dims[0..$#dims-1];
barf "glueflex: incompatible lower dims, ndarray (@{[$pdl->dims]}) vs header (
@ldims)"
if !all($pdl->shape == pdl(@ldims));
print $d ${$pdl->get_dataref};
$dims[-1]++;
$hash->{Dims} = \@dims;
if (defined wantarray) {
# list or scalar context
writeflexhdr($name, $hdr) if $isname and $writeflexhdr;
return $hdr;
} else {
# void context so write header file
writeflexhdr($name, $hdr) if $isname;
return;
}
}
=head2 readflex
=for ref
Read a binary file with flexible format specification
=for usage
Usage:
($x,$y,...) = readflex("filename" [, $hdr])
($x,$y,...) = readflex(FILEHANDLE [, $hdr])
=cut
sub readflex { sub readflex {
barf 'Usage ($x,$y,...) = readflex("filename"|FILEHANDLE [, \@hdr])' barf 'Usage ($x,$y,...) = readflex("filename"|FILEHANDLE [, \@hdr])'
if $#_ > 1; if $#_ > 1;
my ($name,$h) = @_; my ($name,$h) = @_;
my ($hdr, $pdl, $len, @out, $chunk, $chunkread, $data); my ($hdr, $pdl, $len, @out, $chunk, $chunkread, $data);
my $offset = 0; my $offset = 0;
my ($newfile, $swapbyte, $f77mode, $zipt) = (1,0,0,0); my ($newfile, $swapbyte, $f77mode, $zipt) = (1,0,0,0);
my $d; my $d;
# print("readflex: name is $name\n"); # print("readflex: name is $name\n");
# Test if $name is a file handle # Test if $name is a file handle
if (defined fileno($name)) { if (defined fileno($name)) {
$d = $name; $d = $name;
binmode($d);
} }
else { else {
$name =~ s/\.(gz|Z)$//; # strip any trailing compression suffix $name =~ s/\.(gz|Z)$//; # strip any trailing compression suffix
$data = $name; $data = $name;
if(! -e $name ) { # If it's still not found, then... if(! -e $name ) { # If it's still not found, then...
suffix: for my $suffix('gz','Z') { suffix: for my $suffix('gz','Z') {
if( -e "$name.$suffix" ) { if( -e "$name.$suffix" ) {
## This little fillip detects gzip if we need it, and caches ## This little fillip detects gzip if we need it, and caches
## the version in a package-global variable. The return string ## the version in a package-global variable. The return string
skipping to change at line 537 skipping to change at line 469
} }
$zipt = 1; $zipt = 1;
last suffix; last suffix;
} }
} }
} }
my ($size) = (stat $name)[7]; my ($size) = (stat $name)[7];
open $d, $data open $d, $data
or barf "Couldn't open '$data' for reading: $!"; or barf "Couldn't open '$data' for reading: $!";
binmode $d; $h ||= _read_flexhdr("$name.hdr");
$h = _read_flexhdr("$name.hdr")
unless $h;
} }
binmode $d;
barf "Last dim given as undef but >1 header-hash given"
if ref $h->[0]{Dims} and @{$h->[0]{Dims}} and !defined $h->[0]{Dims}[-1] a
nd @$h > 1;
# Go through headers which reconfigure # Go through headers which reconfigure
foreach $hdr (@$h) { foreach $hdr (@$h) {
my ($type) = $hdr->{Type}; my ($type) = $hdr->{Type};
if ($type eq 'swap') { if ($type eq 'swap') {
$swapbyte = 1; $swapbyte = 1;
} elsif ($type ne 'f77') { } elsif ($type ne 'f77') {
last; last;
} }
} }
skipping to change at line 577 skipping to change at line 511
next READ; next READ;
} else { } else {
$newfile = 0; $newfile = 0;
} }
} }
if ($#_ == 1) { if ($#_ == 1) {
barf("Bad typename '$type' in readflex") barf("Bad typename '$type' in readflex")
if (!defined($flextypes{$type})); if (!defined($flextypes{$type}));
$type = $flextypes{$type}; $type = $flextypes{$type};
} }
$pdl = PDL->zeroes ((new PDL::Type($type)), my @dims = ref $hdr->{Dims} ? @{$hdr->{Dims}} : $hdr->{Dims};
ref $hdr->{Dims} ? @{$hdr->{Dims}} : $hdr->{Dims}); my @rdims = @dims[0..($#dims - (defined $dims[-1] ? 0 : 1))];
$len = length $ {$pdl->get_dataref}; $len = pdl(PDL::Core::howbig($type), @rdims)->prodover->sclr;
if (@dims and !defined $dims[-1]) {
$offset += readchunk($d,$pdl,$len,$name, $offset); my ($count, @pdls) = 0;
while (!eof $d) {
push @pdls, PDL->zeroes(PDL::Type->new($type), @rdims);
$offset += readchunk($d,$pdls[-1],$len,$name, $offset);
$count++;
}
$pdl = pdl(@pdls);
$len *= $count;
} else {
$pdl = PDL->zeroes(PDL::Type->new($type), @dims);
$offset += readchunk($d,$pdl,$len,$name, $offset);
}
$chunkread += $len; $chunkread += $len;
if ($swapbyte) { if ($swapbyte) {
my $method = $flexswap{$type}; my $method = $flexswap{$type};
$pdl->$method if $method; $pdl->$method if $method;
# $pdl->type->bswap($pdl); # $pdl->type->bswap->($pdl);
} }
if ($newfile && $f77mode) { if ($newfile && $f77mode) {
if ($zipt || $swapbyte) { if ($zipt || $swapbyte) {
$chunk = $pdl->copy; $chunk = $pdl->copy;
$chunkread = 0; $chunkread = 0;
next READ; next READ;
} else { } else {
SWAP: SWAP:
foreach (0,1) { foreach (0,1) {
seek($d,4,0); seek($d,4,0);
$swapbyte = $_; $swapbyte = $_;
bswap4($pdl) if $swapbyte; bswap4($pdl) if $swapbyte;
$chunk = $pdl->copy; $chunk = $pdl->copy;
next SWAP if ! seek($d,$pdl->at,1); next SWAP if ! seek($d,$pdl->at,1);
next SWAP if next SWAP if
read($d,$ {$chunk->get_dataref},$len) != $len; read($d,${$chunk->get_dataref},$len) != $len;
$chunk->upd_data; $chunk->upd_data;
bswap4($chunk) if $swapbyte; bswap4($chunk) if $swapbyte;
next SWAP if ($pdl->at != $chunk->at); next SWAP if ($pdl->at != $chunk->at);
$chunkread = 0; $chunkread = 0;
barf "Error can't rewind" if !seek($d,4,0); barf "Error can't rewind" if !seek($d,4,0);
# print "OK".($swapbyte?", swapped":""),"\n"; # print "OK".($swapbyte?", swapped":""),"\n";
next READ; next READ;
} }
barf "Error: Doesn't look like f77 file (even swapped)"; barf "Error: Doesn't look like f77 file (even swapped)";
} }
skipping to change at line 641 skipping to change at line 586
$offset += readchunk($d,$chunk,4,$name,$offset); $offset += readchunk($d,$chunk,4,$name,$offset);
bswap4($chunk) if $swapbyte; bswap4($chunk) if $swapbyte;
} else { } else {
last READ; last READ;
} }
} }
} }
wantarray ? @out : $out[0]; wantarray ? @out : $out[0];
} }
=head2 mapflex
=for ref
Memory map a binary file with flexible format specification
=for usage
Usage:
($x,$y,...) = mapflex("filename" [, $hdr] [, $opts])
=for options
All of these options default to false unless set true:
ReadOnly - Data should be readonly
Creat - Create file if it doesn't exist
Trunc - File should be truncated to a length that conforms
with the header
=cut
sub mapflex { sub mapflex {
my ($usage) my ($usage)
= 'Usage ($x,$y,...) = mapflex("filename" [, \@hdr] [,\%opts])'; = 'Usage ($x,$y,...) = mapflex("filename" [, \@hdr] [,\%opts])';
my $name = shift; my $name = shift;
# reference to header array # reference to header array
my ($h, $size); my ($h, $size);
# reference to options array, with defaults # reference to options array, with defaults
my (%opts) = ( 'ReadOnly' => 0, 'Creat' => 0, 'Trunc' => 0 ); my (%opts) = ( 'ReadOnly' => 0, 'Creat' => 0, 'Trunc' => 0 );
my ($hdr, $d, $pdl, $len, @out, $chunk, $chunkread); my ($hdr, $d, $pdl, $len, @out, $chunk, $chunkread);
skipping to change at line 777 skipping to change at line 745
last READ; last READ;
} }
} }
barf "Will only map first f77 data statement" if $offset < $size; barf "Will only map first f77 data statement" if $offset < $size;
last READ; last READ;
} }
} }
wantarray ? @out : $out[0]; wantarray ? @out : $out[0];
} }
=head2 writeflex
=for ref
Write a binary file with flexible format specification
=for usage
Usage:
$hdr = writeflex($file, $pdl1, $pdl2,...) # or
$hdr = writeflex(FILEHANDLE, $pdl1, $pdl2,...)
# now you must call writeflexhdr()
writeflexhdr($file, $hdr)
or
$PDL::IO::FlexRaw::writeflexhdr = 1; # set so we don't have to call writefl
exhdr
$hdr = writeflex($file, $pdl1, $pdl2,...) # remember, $file must be filenam
e
writeflex($file, $pdl1, $pdl2,...) # remember, $file must be filenam
e
=cut
sub writeflex { sub writeflex {
my $usage = 'Usage $hdr = writeflex("filename"|FILEHANDLE,$pdl,...)'; my $usage = 'Usage $hdr = writeflex("filename"|FILEHANDLE,$pdl,...)';
barf $usage if $#_<0; barf $usage if $#_<0;
my($name) = shift; my($name) = shift;
my $isname = 0; my $isname = 0;
my $hdr; my $hdr;
my $d; my $d;
# Test if $name is a file handle # Test if $name is a file handle
if (defined fileno($name)) { if (defined fileno($name)) {
$d = $name; $d = $name;
binmode $d;
} }
else { else {
barf $usage if ref $name; barf $usage if ref $name;
$isname = 1; $isname = 1;
my $modename = ($name =~ /^[+]?[><|]/) ? $name : ">$name"; my $modename = ($name =~ /^[+]?[><|]/) ? $name : ">$name";
open $d, $modename open $d, $modename
or barf "Couldn't open '$name' for writing: $!"; or barf "Couldn't open '$name' for writing: $!";
binmode $d;
} }
binmode $d;
foreach my $pdl (@_) { foreach my $pdl (@_) {
barf $usage if ! ref $pdl; barf $usage if ! ref $pdl;
# print join(' ',$pdl->getndims,$pdl->dims),"\n"; # print join(' ',$pdl->getndims,$pdl->dims),"\n";
push @{$hdr}, { push @{$hdr}, {
Type => $flexnames{$pdl->get_datatype}, Type => $flexnames{$pdl->get_datatype},
Dims => [ $pdl->dims ], Dims => [ $pdl->dims ],
NDims => $pdl->getndims, NDims => $pdl->getndims,
BadFlag => $pdl->badflag, BadFlag => $pdl->badflag,
BadValue => (($pdl->badvalue == $pdl->orig_badvalue) ? undef : $pdl->ba dvalue), BadValue => (($pdl->badvalue == $pdl->orig_badvalue) ? undef : $pdl->ba dvalue),
}; };
skipping to change at line 821 skipping to change at line 812
# list or scalar context # list or scalar context
writeflexhdr($name, $hdr) if $isname and $writeflexhdr; writeflexhdr($name, $hdr) if $isname and $writeflexhdr;
return $hdr; return $hdr;
} else { } else {
# void context so write header file # void context so write header file
writeflexhdr($name, $hdr) if $isname; writeflexhdr($name, $hdr) if $isname;
return; return;
} }
} }
=head2 writeflexhdr
=for ref
Write the header file corresponding to a previous writeflex call
=for usage
Usage:
writeflexhdr($file, $hdr)
$file or "filename" is the filename used in a previous writeflex
If $file is actually a "filename" then writeflexhdr() will be
called automatically if $PDL::IO::FlexRaw::writeflexhdr is true.
If writeflex() was to a FILEHANDLE, you will need to call
writeflexhdr() yourself since the filename cannot be determined
(at least easily).
=cut
sub writeflexhdr { sub writeflexhdr {
barf 'Usage writeflex("filename", $hdr)' if $#_!=1 || !ref $_[1]; barf 'Usage writeflex("filename", $hdr)' if $#_!=1 || !ref $_[1];
my($name) = shift; my ($hdr) = shift; my($name) = shift; my ($hdr) = shift;
my $hname = "$name.hdr"; my $hname = "$name.hdr";
open my $h, '>', $hname open my $h, '>', $hname
or barf "Couldn't open '$hname' for writing: $!"; or barf "Couldn't open '$hname' for writing: $!";
binmode $h; binmode $h;
print $h print $h
"# Output from PDL::IO::writeflex, data in $name\n"; "# Output from PDL::IO::writeflex, data in $name\n";
foreach (@$hdr) { foreach (@$hdr) {
skipping to change at line 843 skipping to change at line 855
barf "Writeflexhdr: will only print data elements, not $type"; barf "Writeflexhdr: will only print data elements, not $type";
next; next;
} }
print $h join("\n",$_->{Type}, print $h join("\n",$_->{Type},
$_->{NDims}, $_->{NDims},
(join ' ',ref $_->{Dims} ? @{$_->{Dims}} : $_->{Dims}) . (( $_->{BadFlag}) ? " badvalue $_->{BadValue}" : '')), (join ' ',ref $_->{Dims} ? @{$_->{Dims}} : $_->{Dims}) . (( $_->{BadFlag}) ? " badvalue $_->{BadValue}" : '')),
"\n\n"; "\n\n";
} }
} }
=head1 BAD VALUE SUPPORT
As of PDL-2.4.8, L<PDL::IO::FlexRaw> has support for reading and writing
pdls with L<bad|PDL::Bad> values in them.
On C<writeflex>, an ndarray
argument with C<< $pdl->badflag == 1 >> will have the keyword/token "badvalue"
added to the header file after the dimension list and an additional token
with the bad value for that pdl if C<< $pdl->badvalue != $pdl->orig_badvalue >>.
On C<readflex>, a pdl with the "badvalue" token in the header will
automatically have its L<badflag|PDL::Bad/#badflag> set and its
L<badvalue|PDL::Bad/#badvalue> as well if it is not the standard default for tha
t type.
=for example
The new badvalue support required some additions to the header
structure. However, the interface is still being finalized. For
reference the current C<$hdr> looks like this:
$hdr = {
Type => 'byte', # data type
NDims => 2, # number of dimensions
Dims => [640,480], # dims
BadFlag => 1, # is set/set badflag
BadValue => undef, # undef==default
};
$badpdl = readflex('badpdl', [$hdr]);
If you use bad values and try the new L<PDL::IO::FlexRaw> bad value
support, please let us know via the perldl mailing list.
Suggestions and feedback are also welcome.
=head1 BUGS
The test on two dimensional byte arrays fail using g77 2.7.2, but not
Sun f77. I hope this isn't my problem!
Assumes gzip is on the PATH.
Can't auto-swap compressed files, because it can't seek on them.
The header format may not agree with that used elsewhere.
Should it handle handles?
Mapflex should warn and fallback to reading on SEGV? Would have to
make sure that the data was written back after it was `destroyed'.
=head1 AUTHOR
Copyright (C) Robin Williams <rjrw@ast.leeds.ac.uk> 1997.
All rights reserved. There is no warranty. You are allowed
to redistribute this software / documentation under certain
conditions. For details, see the file COPYING in the PDL
distribution. If this file is separated from the PDL distribution,
the copyright notice should be included in the file.
Documentation contributions copyright (C) David Mertens, 2010.
=cut
1; 1;
 End of changes. 18 change blocks. 
169 lines changed or deleted 248 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)