"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "IO/FITS/FITS.pm" between
PDL-2.074.tar.gz and PDL-2.075.tar.gz

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

FITS.pm  (PDL-2.074):FITS.pm  (PDL-2.075)
skipping to change at line 225 skipping to change at line 225
datatypes are supported: byte, short, ushort, long, float, and datatypes are supported: byte, short, ushort, long, float, and
double. At present ushort() data is written as a long rather than double. At present ushort() data is written as a long rather than
as a short with TSCAL/ZERO; this may change. as a short with TSCAL/ZERO; this may change.
The return value for a binary table is a hash ref containing the names The return value for a binary table is a hash ref containing the names
of the columns in the table (in UPPER CASE as per the FITS standard). of the columns in the table (in UPPER CASE as per the FITS standard).
Each element of the hash contains a PDL (for numerical values) or a Each element of the hash contains a PDL (for numerical values) or a
perl list (for string values). The PDL's 0th dimension runs across perl list (for string values). The PDL's 0th dimension runs across
rows; the 1st dimension runs across the repeat index within the row rows; the 1st dimension runs across the repeat index within the row
(for rows with more than one value). (Note that this is different from (for rows with more than one value). (Note that this is different from
standard threading order - but it allows Least Surprise to work when standard broadcasting order - but it allows Least Surprise to work when
adding more complicated objects such as collections of numbers (via adding more complicated objects such as collections of numbers (via
the repeat count) or variable length arrays.) the repeat count) or variable length arrays.)
Thus, if your table contains a column named C<FOO> with type C<5D>, Thus, if your table contains a column named C<FOO> with type C<5D>,
the expression the expression
$x->{FOO}->((2)) $x->{FOO}->((2))
returns a 5-element double-precision PDL containing the values of FOO returns a 5-element double-precision PDL containing the values of FOO
from the third row of the table. from the third row of the table.
skipping to change at line 1347 skipping to change at line 1347
my $patchup = which($tbl->{len_COMPRESSED_DATA} <= 0); my $patchup = which($tbl->{len_COMPRESSED_DATA} <= 0);
if($patchup->nelem) { if($patchup->nelem) {
die "rfits: need some uncompressed data for missing compressed rows, but none were found!\n" die "rfits: need some uncompressed data for missing compressed rows, but none were found!\n"
unless defined $tbl->{UNCOMPRESSED_DATA}; unless defined $tbl->{UNCOMPRESSED_DATA};
die "rfits: tile size is $tilesize, but uncompressed data rows have size ".$tbl->{UNCOMPRESSED_DATA}->dim(1)."\n" die "rfits: tile size is $tilesize, but uncompressed data rows have size ".$tbl->{UNCOMPRESSED_DATA}->dim(1)."\n"
if $tbl->{UNCOMPRESSED_DATA}->dim(1) != $tilesize; if $tbl->{UNCOMPRESSED_DATA}->dim(1) != $tilesize;
$tiles->dice_axis(1,$patchup) .= $tbl->{UNCOMPRESSED_DATA}->dice_axis(0,$ patchup)->transpose; $tiles->dice_axis(1,$patchup) .= $tbl->{UNCOMPRESSED_DATA}->dice_axis(0,$ patchup)->transpose;
} }
########## ##########
# Slice up the output image plane into tiles, and use the threading engine # Slice up the output image plane into tiles, and use the broadcasting engin e
# to assign everything to them. # to assign everything to them.
my $cutup = $pdl->range( $tiledex, [@tiledims], 't') # < ntiles, tilesize0.. tilesizen > my $cutup = $pdl->range( $tiledex, [@tiledims], 't') # < ntiles, tilesize0.. tilesizen >
->mv(0,-1) # < tilesize0..tilesizen , ntiles > ->mv(0,-1) # < tilesize0..tilesizen , ntiles >
->clump($tiledims->nelem); # < tilesize, ntiles > ->clump($tiledims->nelem); # < tilesize, ntiles >
$cutup .= $tiles; # dump all the tiles at once into the image - they flow ba ck to $pdl. $cutup .= $tiles; # dump all the tiles at once into the image - they flow ba ck to $pdl.
$cutup->sever; # sever connection to prevent expensive future dataflow. $cutup->sever; # sever connection to prevent expensive future dataflow.
########## ##########
# Perform scaling if necessary ( Just the ZIMAGE quantization step ) # Perform scaling if necessary ( Just the ZIMAGE quantization step )
# bscaling is handled farther down with treat_bscale. # bscaling is handled farther down with treat_bscale.
skipping to change at line 1483 skipping to change at line 1483
If you feed in a hash ref instead of a PDL, then the hash ref is If you feed in a hash ref instead of a PDL, then the hash ref is
written out as a binary table extension. The hash ref keys are written out as a binary table extension. The hash ref keys are
treated as column names, and their values are treated as the data to treated as column names, and their values are treated as the data to
be put in each column. be put in each column.
For numeric information, the hash values should contain PDLs. The 0th For numeric information, the hash values should contain PDLs. The 0th
dim of the PDL runs across rows, and higher dims are written as dim of the PDL runs across rows, and higher dims are written as
multi-value entries in the table (e.g. a 7x5 PDL will yield a single multi-value entries in the table (e.g. a 7x5 PDL will yield a single
named column with 7 rows and 5 numerical entries per row, in a binary named column with 7 rows and 5 numerical entries per row, in a binary
table). Note that this is slightly different from the usual concept table). Note that this is slightly different from the usual concept
of threading, in which dimension 1 runs across rows. of broadcasting, in which dimension 1 runs across rows.
ASCII tables only allow one entry per column in each row, so ASCII tables only allow one entry per column in each row, so
if you plan to write an ASCII table then all of the values of C<$hash> if you plan to write an ASCII table then all of the values of C<$hash>
should have at most one dim. should have at most one dim.
All of the columns' 0 dims must agree in the threading sense. That is to All of the columns' 0 dims must agree in the broadcasting sense. That is to
say, the 0th dimension of all of the values of C<$hash> should be the say, the 0th dimension of all of the values of C<$hash> should be the
same (indicating that all columns have the same number of rows). As same (indicating that all columns have the same number of rows). As
an exception, if the 0th dim of any of the values is 1, or if that an exception, if the 0th dim of any of the values is 1, or if that
value is a PDL scalar (with 0 dims), then that value is "threaded" value is a PDL scalar (with 0 dims), then that value is "broadcasted"
over -- copied into all rows. over -- copied into all rows.
Data dimensions higher than 2 are preserved in binary tables, Data dimensions higher than 2 are preserved in binary tables,
via the TDIMn field (e.g. a 7x5x3 PDL is stored internally as via the TDIMn field (e.g. a 7x5x3 PDL is stored internally as
seven rows with 15 numerical entries per row, and reconstituted seven rows with 15 numerical entries per row, and reconstituted
as a 7x5x3 PDL on read). as a 7x5x3 PDL on read).
Non-PDL Perl scalars are treated as strings, even if they contain Non-PDL Perl scalars are treated as strings, even if they contain
numerical values. For example, a list ref containing 7 values is numerical values. For example, a list ref containing 7 values is
treated as 7 rows containing one string each. There is no such thing treated as 7 rows containing one string each. There is no such thing
skipping to change at line 2397 skipping to change at line 2397
? &{$converters[$c]}($x->slice("$r")->flat->sever, $r, $c) ? &{$converters[$c]}($x->slice("$r")->flat->sever, $r, $c)
: $x->slice("$r")->flat->sever ; : $x->slice("$r")->flat->sever ;
## This would go faster if moved outside the loop but I'm too ## This would go faster if moved outside the loop but I'm too
## lazy to do it Right just now. Perhaps after it actually works. ## lazy to do it Right just now. Perhaps after it actually works.
$tmp->type->bswap->($tmp) if !isbigendian(); $tmp->type->bswap->($tmp) if !isbigendian();
my $t = $tmp->get_dataref; my $t = $tmp->get_dataref;
$tmp = $$t; $tmp = $$t;
} else { # Only other case is ASCII just now... } else { # Only other case is ASCII just now...
$tmp = ( ref $x eq 'ARRAY' ) ? # Switch on array or string $tmp = ( ref $x eq 'ARRAY' ) ? # Switch on array or string
( $#$x == 0 ? $x->[0] : $x->[$r] ) # Thread arrays as needed ( $#$x == 0 ? $x->[0] : $x->[$r] ) # broadcast arrays as needed
: $x; : $x;
$tmp .= " " x ($field_len[$c] - length($tmp)); $tmp .= " " x ($field_len[$c] - length($tmp));
} }
# Now $tmp contains the bytes to be written out... # Now $tmp contains the bytes to be written out...
# #
$row .= substr($tmp,0,$field_len[$c]); $row .= substr($tmp,0,$field_len[$c]);
} # for: $c } # for: $c
$table .= $row; $table .= $row;
 End of changes. 6 change blocks. 
6 lines changed or deleted 6 lines changed or added

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