"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "GENERATED/PDL/Transform.pm" between
PDL-2.082.tar.gz and PDL-2.083.tar.gz

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

Transform.pm  (PDL-2.082):Transform.pm  (PDL-2.083)
skipping to change at line 27 skipping to change at line 27
#line 2 "transform.pd" #line 2 "transform.pd"
=head1 NAME =head1 NAME
PDL::Transform - Coordinate transforms, image warping, and N-D functions PDL::Transform - Coordinate transforms, image warping, and N-D functions
=head1 SYNOPSIS =head1 SYNOPSIS
use PDL::Transform; use PDL::Transform;
my $t = new PDL::Transform::<type>(<opt>) my $t = PDL::Transform::<type>->new(<opt>)
$out = $t->apply($in) # Apply transform to some N-vectors (Transform method) $out = $t->apply($in) # Apply transform to some N-vectors (Transform method)
$out = $in->apply($t) # Apply transform to some N-vectors (PDL method) $out = $in->apply($t) # Apply transform to some N-vectors (PDL method)
$im1 = $t->map($im); # Transform image coordinates (Transform method) $im1 = $t->map($im); # Transform image coordinates (Transform method)
$im1 = $im->map($t); # Transform image coordinates (PDL method) $im1 = $im->map($t); # Transform image coordinates (PDL method)
$t2 = $t->compose($t1); # compose two transforms $t2 = $t->compose($t1); # compose two transforms
$t2 = $t x $t1; # compose two transforms (by analogy to matrix mult.) $t2 = $t x $t1; # compose two transforms (by analogy to matrix mult.)
skipping to change at line 73 skipping to change at line 73
In keeping with standard practice, but somewhat counterintuitively, In keeping with standard practice, but somewhat counterintuitively,
the L</map> engine uses the inverse transform to map coordinates the L</map> engine uses the inverse transform to map coordinates
FROM the destination dataspace (or image plane) TO the source dataspace; FROM the destination dataspace (or image plane) TO the source dataspace;
hence PDL::Transform keeps track of both the forward and inverse transform. hence PDL::Transform keeps track of both the forward and inverse transform.
For terseness and convenience, most of the constructors are exported For terseness and convenience, most of the constructors are exported
into the current package with the name C<< t_<transform> >>, so the following into the current package with the name C<< t_<transform> >>, so the following
(for example) are synonyms: (for example) are synonyms:
$t = new PDL::Transform::Radial(); # Long way $t = PDL::Transform::Radial->new; # Long way
$t = t_radial(); # Short way $t = t_radial(); # Short way
Several math operators are overloaded, so that you can compose and Several math operators are overloaded, so that you can compose and
invert functions with expression syntax instead of method syntax (see below). invert functions with expression syntax instead of method syntax (see below).
=head1 EXAMPLE =head1 EXAMPLE
Coordinate transformations and mappings are a little counterintuitive Coordinate transformations and mappings are a little counterintuitive
at first. Here are some examples of transforms in action: at first. Here are some examples of transforms in action:
skipping to change at line 309 skipping to change at line 309
if(UNIVERSAL::isa($me,'PDL::Transform') && UNIVERSAL::isa($from,'PDL')){ if(UNIVERSAL::isa($me,'PDL::Transform') && UNIVERSAL::isa($from,'PDL')){
croak "Applying a PDL::Transform with no func! Oops.\n" unless(defined($me ->{func}) and ref($me->{func}) eq 'CODE'); croak "Applying a PDL::Transform with no func! Oops.\n" unless(defined($me ->{func}) and ref($me->{func}) eq 'CODE');
my $result = &{$me->{func}}($from,$me->{params}); my $result = &{$me->{func}}($from,$me->{params});
$result->is_inplace(0); # clear inplace flag, just in case. $result->is_inplace(0); # clear inplace flag, just in case.
return $result; return $result;
} else { } else {
croak "apply requires both a PDL and a PDL::Transform.\n"; croak "apply requires both a PDL and a PDL::Transform.\n";
} }
} }
#line 327 "Transform.pm"
#line 366 "transform.pd" #line 366 "transform.pd"
=head2 invert =head2 invert
=for sig =for sig
Signature: (data(); PDL::Transform t) Signature: (data(); PDL::Transform t)
=for usage =for usage
$out = $t->invert($data); $out = $t->invert($data);
$out = $data->invert($t); $out = $data->invert($t);
skipping to change at line 356 skipping to change at line 354
if(UNIVERSAL::isa($me,'PDL::Transform') && UNIVERSAL::isa($data,'PDL')){ if(UNIVERSAL::isa($me,'PDL::Transform') && UNIVERSAL::isa($data,'PDL')){
croak "Inverting a PDL::Transform with no inverse! Oops.\n" unless(defined ($me->{inv}) and ref($me->{inv}) eq 'CODE'); croak "Inverting a PDL::Transform with no inverse! Oops.\n" unless(defined ($me->{inv}) and ref($me->{inv}) eq 'CODE');
my $result = &{$me->{inv}}($data, $me->{params}); my $result = &{$me->{inv}}($data, $me->{params});
$result->is_inplace(0); # make sure inplace flag is clear. $result->is_inplace(0); # make sure inplace flag is clear.
return $result; return $result;
} else { } else {
croak("invert requires a PDL and a PDL::Transform (did you want 'inverse' instead?)\n"); croak("invert requires a PDL and a PDL::Transform (did you want 'inverse' instead?)\n");
} }
} }
#line 377 "Transform.pm" #line 367 "Transform.pm"
#line 958 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
=head2 map =head2 map
=for sig =for sig
Signature: (k0(); pdl *in; pdl *out; pdl *map; SV *boundary; SV *method; Signature: (k0(); pdl *in; pdl *out; pdl *map; SV *boundary; SV *method;
long big; double blur; double sv_min; char flux; SV *bv) long big; double blur; double sv_min; char flux; SV *bv)
=head2 match =head2 match
skipping to change at line 550 skipping to change at line 546
input FITS transformation *before* autoscaling the pixels. In the special input FITS transformation *before* autoscaling the pixels. In the special
case of linear transformations, this preserves the rectangular shape of the case of linear transformations, this preserves the rectangular shape of the
original pixel grid and makes output pixel coordinate proportional to input original pixel grid and makes output pixel coordinate proportional to input
coordinate. coordinate.
=item m, method, Method =item m, method, Method
This option controls the interpolation method to be used. This option controls the interpolation method to be used.
Interpolation greatly affects both speed and quality of output. For Interpolation greatly affects both speed and quality of output. For
most cases the option is directly passed to most cases the option is directly passed to
L<interpND|PDL::Primitive/interpnd> for interpolation. Possible L<interpND|PDL::Primitive/interpND> for interpolation. Possible
options, in order from fastest to slowest, are: options, in order from fastest to slowest, are:
=over 3 =over 3
=item * s, sample (default for ints) =item * s, sample (default for ints)
Pixel values in the output plane are sampled from the closest data value Pixel values in the output plane are sampled from the closest data value
in the input plane. This is very fast but not very accurate for either in the input plane. This is very fast but not very accurate for either
magnification or decimation (shrinking). It is the default for templates magnification or decimation (shrinking). It is the default for templates
of integer type. of integer type.
skipping to change at line 701 skipping to change at line 697
do some smoothing over bad values: if more than 1/3 of the weighted do some smoothing over bad values: if more than 1/3 of the weighted
input-array footprint of a given output pixel is bad, then the output input-array footprint of a given output pixel is bad, then the output
pixel gets marked bad. pixel gets marked bad.
=for bad =for bad
map does not process bad values. map does not process bad values.
It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
=cut =cut
#line 731 "Transform.pm"
#line 959 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
#line 1573 "transform.pd" #line 1573 "transform.pd"
sub PDL::match { sub PDL::match {
# Set default for rectification to 0 for simple matching... # Set default for rectification to 0 for simple matching...
push @_, {} if ref($_[-1]) ne 'HASH'; push @_, {} if ref($_[-1]) ne 'HASH';
my @k = grep(m/^r(e(c(t)?)?)?/,sort keys %{$_[-1]}); my @k = grep(m/^r(e(c(t)?)?)?/,sort keys %{$_[-1]});
#line 744 "Transform.pm"
#line 967 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
#line 746 "Transform.pm"
#line 1578 "transform.pd" #line 1578 "transform.pd"
unless(@k) { unless(@k) {
$_[-1]->{rectify} = 0; $_[-1]->{rectify} = 0;
} }
t_identity()->map(@_); t_identity()->map(@_);
} }
*PDL::map = \&map; *PDL::map = \&map;
sub map { sub map {
my ($me, $in, $tmp, $opt) = @_; my ($me, $in, $tmp, $opt) = @_;
skipping to change at line 744 skipping to change at line 734
croak("PDL::Transform::map: Option 'p' was ambiguous and has been removed. You probably want 'pix' or 'phot'.") if exists($opt->{'p'}); croak("PDL::Transform::map: Option 'p' was ambiguous and has been removed. You probably want 'pix' or 'phot'.") if exists($opt->{'p'});
$tmp = [$in->dims] unless defined $tmp; # no //= because of Devel::Cover bug $tmp = [$in->dims] unless defined $tmp; # no //= because of Devel::Cover bug
# Generate an appropriate output ndarray for values to go in # Generate an appropriate output ndarray for values to go in
my ($out, @odims, $ohdr); my ($out, @odims, $ohdr);
if(UNIVERSAL::isa($tmp,'PDL')) { if(UNIVERSAL::isa($tmp,'PDL')) {
@odims = $tmp->dims; @odims = $tmp->dims;
my($x); my($x);
if(defined ($x = $tmp->gethdr)) { if(defined ($x = $tmp->gethdr)) {
my(%b) = %{$x}; my(%b) = %{$x};
#line 778 "Transform.pm"
#line 999 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
#line 780 "Transform.pm"
#line 1608 "transform.pd" #line 1608 "transform.pd"
$ohdr = \%b; $ohdr = \%b;
} }
} elsif(ref $tmp eq 'HASH') { } elsif(ref $tmp eq 'HASH') {
# (must be a fits header -- or would be filtered above) # (must be a fits header -- or would be filtered above)
for my $i(1..$tmp->{NAXIS}){ for my $i(1..$tmp->{NAXIS}){
push(@odims,$tmp->{"NAXIS$i"}); push(@odims,$tmp->{"NAXIS$i"});
} }
# deep-copy fits header into output # deep-copy fits header into output
my %foo = %{$tmp}; my %foo = %{$tmp};
#line 791 "Transform.pm"
#line 1010 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
#line 793 "Transform.pm"
#line 1617 "transform.pd" #line 1617 "transform.pd"
$ohdr = \%foo; $ohdr = \%foo;
} elsif(ref $tmp eq 'ARRAY') { } elsif(ref $tmp eq 'ARRAY') {
@odims = @$tmp; @odims = @$tmp;
} else { } else {
barf("map: confused about dimensions of the output array...\n"); barf("map: confused about dimensions of the output array...\n");
} }
if(scalar(@odims) < scalar($in->dims)) { if(scalar(@odims) < scalar($in->dims)) {
my @idims = $in->dims; my @idims = $in->dims;
skipping to change at line 955 skipping to change at line 939
} }
$out->hdr->{"NAXIS"} = $nd; $out->hdr->{"NAXIS"} = $nd;
$out->hdr->{"SIMPLE"} = 'T'; $out->hdr->{"SIMPLE"} = 'T';
$out->hdr->{"HISTORY"} .= "Header written by PDL::Transform::Cartograp hy::map"; $out->hdr->{"HISTORY"} .= "Header written by PDL::Transform::Cartograp hy::map";
### Eliminate fancy newfangled output header pointing tags if they exi st ### Eliminate fancy newfangled output header pointing tags if they exi st
### These are the CROTA<n>, PCi_j, and CDi_j. ### These are the CROTA<n>, PCi_j, and CDi_j.
delete @{$out->hdr}{ delete @{$out->hdr}{
grep /(^CROTA\d*$)|(^(CD|PC)\d+_\d+[A-Z]?$)/, keys %{$out->hdr} grep /(^CROTA\d*$)|(^(CD|PC)\d+_\d+[A-Z]?$)/, keys %{$out->hdr}
#line 992 "Transform.pm"
#line 1209 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
#line 994 "Transform.pm"
#line 1814 "transform.pd" #line 1814 "transform.pd"
}; };
} else { } else {
# Non-rectified output -- generate a CDi_j matrix instead of the simpl e formalism. # Non-rectified output -- generate a CDi_j matrix instead of the simpl e formalism.
# We have to deal with a linear transformation: we've got: (scaling) x !input x (t x input), # We have to deal with a linear transformation: we've got: (scaling) x !input x (t x input),
# where input is a linear transformation with offset and scaling is a simple scaling. We have # where input is a linear transformation with offset and scaling is a simple scaling. We have
# the scaling parameters and the matrix for !input -- we have only to merge them and then we # the scaling parameters and the matrix for !input -- we have only to merge them and then we
# can write out the FITS header in CDi_j form. # can write out the FITS header in CDi_j form.
print "non-rectify\n" if($PDL::Transform::debug); print "non-rectify\n" if($PDL::Transform::debug);
my $midpoint_val = (pdl(($out->dims)[0..$nd-1])/2 * $scale)->apply( $f _in ); my $midpoint_val = (pdl(($out->dims)[0..$nd-1])/2 * $scale)->apply( $f _in );
skipping to change at line 1003 skipping to change at line 984
|| ""); || "");
for my $e(1..$nd) { for my $e(1..$nd) {
$out->hdr->{"CD${d}_${e}"} = $mat->at($d-1,$e-1); $out->hdr->{"CD${d}_${e}"} = $mat->at($d-1,$e-1);
print "setting CD${d}_${e} to ".$mat->at($d-1,$e-1)."\n" if($P DL::Transform::debug); print "setting CD${d}_${e} to ".$mat->at($d-1,$e-1)."\n" if($P DL::Transform::debug);
} }
} }
## Eliminate competing header pointing tags if they exist ## Eliminate competing header pointing tags if they exist
delete @{$out->hdr}{ delete @{$out->hdr}{
grep /(^CROTA\d*$)|(^(PC)\d+_\d+[A-Z]?$)|(CDELT\d*$)/, keys %{$out ->hdr} grep /(^CROTA\d*$)|(^(PC)\d+_\d+[A-Z]?$)|(CDELT\d*$)/, keys %{$out ->hdr}
#line 1040 "Transform.pm"
#line 1255 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
#line 1042 "Transform.pm"
#line 1858 "transform.pd" #line 1858 "transform.pd"
}; };
} }
} }
$out->hdrcpy(1); $out->hdrcpy(1);
############################## ##############################
# Sandwich the transform between the input and output plane FITS headers. # Sandwich the transform between the input and output plane FITS headers.
unless($nofits) { unless($nofits) {
skipping to change at line 1117 skipping to change at line 1095
$in2, $o2, $idx, $in2, $o2, $idx,
$bound, $method, $big, $blur, $svmin, $flux, $bv); $bound, $method, $big, $blur, $svmin, $flux, $bv);
my @rdims = (@iddims[1..$#iddims], @idims[$#iddims..$#idims]); my @rdims = (@iddims[1..$#iddims], @idims[$#iddims..$#idims]);
{ {
my $tmp; # work around perl -d "feature" my $tmp; # work around perl -d "feature"
($tmp = $out->slice(":")) .= $o2->reshape(@rdims); ($tmp = $out->slice(":")) .= $o2->reshape(@rdims);
} }
return $out; return $out;
} }
#line 1154 "Transform.pm" #line 1112 "Transform.pm"
#line 1155 "Transform.pm"
#line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm"
*map = \&PDL::map; *map = \&PDL::map;
#line 1162 "Transform.pm"
#line 1975 "transform.pd" #line 1975 "transform.pd"
###################################################################### ######################################################################
=head2 unmap =head2 unmap
=for sig =for sig
Signature: (data(); PDL::Transform a; template(); \%opt) Signature: (data(); PDL::Transform a; template(); \%opt)
skipping to change at line 1164 skipping to change at line 1138
my(@params) = @_; my(@params) = @_;
if(UNIVERSAL::isa($data,'PDL::Transform') && UNIVERSAL::isa($me,'PDL')) { if(UNIVERSAL::isa($data,'PDL::Transform') && UNIVERSAL::isa($me,'PDL')) {
my $x = $data; my $x = $data;
$data = $me; $data = $me;
$me = $x; $me = $x;
} }
return $me->inverse->map($data,@params); return $me->inverse->map($data,@params);
} }
#line 1206 "Transform.pm"
#line 2018 "transform.pd" #line 2018 "transform.pd"
=head2 t_inverse =head2 t_inverse
=for usage =for usage
$t2 = t_inverse($t); $t2 = t_inverse($t);
$t2 = $t->inverse; $t2 = $t->inverse;
$t2 = $t ** -1; $t2 = $t ** -1;
$t2 = !$t; $t2 = !$t;
=for ref =for ref
skipping to change at line 1209 skipping to change at line 1181
unless defined $me->{inv}; unless defined $me->{inv};
bless { bless {
%$me, # force explicit copy of top-level %$me, # force explicit copy of top-level
inv => $me->{func}, inv => $me->{func},
func => $me->{inv}, func => $me->{inv},
(map +("o$_"=>$me->{"i$_"}, "i$_"=>$me->{"o$_"}), qw(dim type unit)), (map +("o$_"=>$me->{"i$_"}, "i$_"=>$me->{"o$_"}), qw(dim type unit)),
name => "(inverse ".$me->{name}.")", name => "(inverse ".$me->{name}.")",
is_inverse => !($me->{is_inverse}), is_inverse => !($me->{is_inverse}),
}, ref $me; }, ref $me;
} }
#line 1254 "Transform.pm"
#line 2065 "transform.pd" #line 2065 "transform.pd"
=head2 t_compose =head2 t_compose
=for usage =for usage
$f2 = t_compose($f, $g,[...]); $f2 = t_compose($f, $g,[...]);
$f2 = $f->compose($g[,$h,$i,...]); $f2 = $f->compose($g[,$h,$i,...]);
$f2 = $f x $g x ...; $f2 = $f x $g x ...;
=for ref =for ref
skipping to change at line 1306 skipping to change at line 1276
my($ip) = $data->is_inplace; my($ip) = $data->is_inplace;
for my $t ( @{$p->{clist}} ) { for my $t ( @{$p->{clist}} ) {
croak("Error: tried to invert a non-invertible PDL::Transform inside a com position!\n offending transform: $t\n") croak("Error: tried to invert a non-invertible PDL::Transform inside a com position!\n offending transform: $t\n")
unless(defined($t->{inv}) and ref($t->{inv}) eq 'CODE'); unless(defined($t->{inv}) and ref($t->{inv}) eq 'CODE');
$data = &{$t->{inv}}($ip ? $data->inplace : $data, $t->{params}); $data = &{$t->{inv}}($ip ? $data->inplace : $data, $t->{params});
} }
$data; $data;
}; };
return bless($me,'PDL::Transform::Composition'); return bless($me,'PDL::Transform::Composition');
} }
#line 1354 "Transform.pm"
#line 2164 "transform.pd" #line 2164 "transform.pd"
=head2 t_wrap =head2 t_wrap
=for usage =for usage
$g1fg = $f->wrap($g); $g1fg = $f->wrap($g);
$g1fg = t_wrap($f,$g); $g1fg = t_wrap($f,$g);
=for ref =for ref
Shift a transform into a different space by 'wrapping' it with a second. Shift a transform into a different space by 'wrapping' it with a second.
skipping to change at line 1374 skipping to change at line 1342
return $x if(abs($y) == 1); return $x if(abs($y) == 1);
return new PDL::Transform if(abs($y) == 0); return new PDL::Transform if(abs($y) == 0);
my(@l); my(@l);
for my $i(1..abs($y)) { for my $i(1..abs($y)) {
push(@l,$x); push(@l,$x);
} }
t_compose(@l); t_compose(@l);
} }
#line 1427 "Transform.pm"
#line 2237 "transform.pd" #line 2237 "transform.pd"
=head2 t_identity =head2 t_identity
=for usage =for usage
my $xform = t_identity my $xform = t_identity
my $xform = new PDL::Transform; my $xform = PDL::Transform->new;
=for ref =for ref
Generic constructor generates the identity transform. Generic constructor generates the identity transform.
This constructor really is trivial -- it is mainly used by the other transform This constructor really is trivial -- it is mainly used by the other transform
constructors. It takes no parameters and returns the identity transform. constructors. It takes no parameters and returns the identity transform.
=cut =cut
skipping to change at line 1409 skipping to change at line 1375
my $me = {name=>'identity', my $me = {name=>'identity',
idim => 0, idim => 0,
odim => 0, odim => 0,
func=>\&PDL::Transform::_identity, func=>\&PDL::Transform::_identity,
inv=>\&PDL::Transform::_identity, inv=>\&PDL::Transform::_identity,
params=>{} params=>{}
}; };
return bless $me,$class; return bless $me,$class;
} }
#line 1465 "Transform.pm"
#line 2275 "transform.pd" #line 2275 "transform.pd"
=head2 t_lookup =head2 t_lookup
=for usage =for usage
$f = t_lookup($lookup, {<options>}); $f = t_lookup($lookup, {<options>});
=for ref =for ref
Transform by lookup into an explicit table. Transform by lookup into an explicit table.
skipping to change at line 1439 skipping to change at line 1403
interpolation method to be used. The linear scaling stuff is a little interpolation method to be used. The linear scaling stuff is a little
primitive; if you want more, try composing the linear transform with primitive; if you want more, try composing the linear transform with
this one. this one.
The prescribed values in the lookup table are treated as The prescribed values in the lookup table are treated as
pixel-centered: that is, if your input array has N elements per row pixel-centered: that is, if your input array has N elements per row
then valid data exist between the locations (-0.5) and (N-0.5) in then valid data exist between the locations (-0.5) and (N-0.5) in
lookup pixel space, because the pixels (which are numbered from 0 to lookup pixel space, because the pixels (which are numbered from 0 to
N-1) are centered on their locations. N-1) are centered on their locations.
Lookup is done using L<interpND|PDL::Primitive/interpnd>, so the boundary condit ions Lookup is done using L<interpND|PDL::Primitive/interpND>, so the boundary condit ions
and broadcasting behaviour follow from that. and broadcasting behaviour follow from that.
The indexed-over dimensions come first in the table, followed by a The indexed-over dimensions come first in the table, followed by a
single dimension containing the column vector to be output for each single dimension containing the column vector to be output for each
set of other dimensions -- ie to output 2-vectors from 2 input set of other dimensions -- ie to output 2-vectors from 2 input
parameters, each of which can range from 0 to 49, you want an index parameters, each of which can range from 0 to 49, you want an index
that has dimension list (50,50,2). For the identity lookup table that has dimension list (50,50,2). For the identity lookup table
you could use C<cat(xvals(50,50),yvals(50,50))>. you could use C<cat(xvals(50,50),yvals(50,50))>.
If you want to output a single value per input vector, you still need If you want to output a single value per input vector, you still need
skipping to change at line 1663 skipping to change at line 1627
$p->{itable} = $itable; $p->{itable} = $itable;
} }
&$lookup_func($data,$p, $p->{itable},$p->{iscale},$p->{ioffset}) ; &$lookup_func($data,$p, $p->{itable},$p->{iscale},$p->{ioffset}) ;
}; };
$me->{name} = 'Lookup'; $me->{name} = 'Lookup';
return $me; return $me;
} }
#line 1726 "Transform.pm"
#line 2535 "transform.pd" #line 2535 "transform.pd"
=head2 t_linear =head2 t_linear
=for usage =for usage
$f = t_linear({options}); $f = t_linear({options});
=for ref =for ref
Linear (affine) transformations with optional offset Linear (affine) transformations with optional offset
skipping to change at line 1975 skipping to change at line 1937
if(defined $mp->{inverse}); if(defined $mp->{inverse});
$out .= "Inverse matrix:".($mp->{matrix}) $out .= "Inverse matrix:".($mp->{matrix})
if(defined $mp->{matrix}); if(defined $mp->{matrix});
} }
$out =~ s/\n/\n /go; $out =~ s/\n/\n /go;
$out; $out;
} }
} }
#line 2041 "Transform.pm"
#line 2849 "transform.pd" #line 2849 "transform.pd"
=head2 t_scale =head2 t_scale
=for usage =for usage
$f = t_scale(<scale>) $f = t_scale(<scale>)
=for ref =for ref
Convenience interface to L</t_linear>. Convenience interface to L</t_linear>.
t_scale produces a transform that scales around the origin by a fixed t_scale produces a transform that scales around the origin by a fixed
amount. It acts exactly the same as C<t_linear(Scale=>\<scale\>)>. amount. It acts exactly the same as C<t_linear(Scale=>\<scale\>)>.
=cut =cut
sub t_scale { sub t_scale {
my($scale) = shift; my($scale) = shift;
my($y) = shift; my($y) = shift;
return t_linear(scale=>$scale,%{$y}) return t_linear(scale=>$scale,%{$y})
#line 2067 "Transform.pm"
#line 2870 "transform.pd" #line 2870 "transform.pd"
if(ref $y eq 'HASH'); if(ref $y eq 'HASH');
t_linear(Scale=>$scale,$y,@_); t_linear(Scale=>$scale,$y,@_);
} }
#line 2072 "Transform.pm"
#line 2877 "transform.pd" #line 2877 "transform.pd"
=head2 t_offset =head2 t_offset
=for usage =for usage
$f = t_offset(<shift>) $f = t_offset(<shift>)
=for ref =for ref
Convenience interface to L</t_linear>. Convenience interface to L</t_linear>.
t_offset produces a transform that shifts the origin to a new location. t_offset produces a transform that shifts the origin to a new location.
It acts exactly the same as C<t_linear(Pre=>\<shift\>)>. It acts exactly the same as C<t_linear(Pre=>\<shift\>)>.
=cut =cut
sub t_offset { sub t_offset {
my($pre) = shift; my($pre) = shift;
my($y) = shift; my($y) = shift;
return t_linear(pre=>$pre,%{$y}) return t_linear(pre=>$pre,%{$y})
#line 2098 "Transform.pm"
#line 2898 "transform.pd" #line 2898 "transform.pd"
if(ref $y eq 'HASH'); if(ref $y eq 'HASH');
t_linear(pre=>$pre,$y,@_); t_linear(pre=>$pre,$y,@_);
} }
#line 2104 "Transform.pm"
#line 2906 "transform.pd" #line 2906 "transform.pd"
=head2 t_rot =head2 t_rot
=for usage =for usage
$f = t_rot(\@rotation_in_degrees) $f = t_rot(\@rotation_in_degrees)
=for ref =for ref
Convenience interface to L</t_linear>. Convenience interface to L</t_linear>.
t_rot produces a rotation transform in 2-D (scalar), 3-D (3-vector), or t_rot produces a rotation transform in 2-D (scalar), 3-D (3-vector), or
N-D (matrix). It acts exactly the same as C<t_linear(rot=>shift)>. N-D (matrix). It acts exactly the same as C<t_linear(rot=>shift)>.
=cut =cut
*t_rot = \&t_rotate; *t_rot = \&t_rotate;
sub t_rotate { sub t_rotate {
my $rot = shift; my $rot = shift;
my($y) = shift; my($y) = shift;
return t_linear(rot=>$rot,%{$y}) return t_linear(rot=>$rot,%{$y})
#line 2131 "Transform.pm"
#line 2928 "transform.pd" #line 2928 "transform.pd"
if(ref $y eq 'HASH'); if(ref $y eq 'HASH');
t_linear(rot=>$rot,$y,@_); t_linear(rot=>$rot,$y,@_);
} }
#line 2137 "Transform.pm"
#line 2938 "transform.pd" #line 2938 "transform.pd"
=head2 t_fits =head2 t_fits
=for usage =for usage
$f = t_fits($fits,[option]); $f = t_fits($fits,[option]);
=for ref =for ref
FITS pixel-to-scientific transformation with inverse FITS pixel-to-scientific transformation with inverse
skipping to change at line 2227 skipping to change at line 2178
$me->{ounit} = \@ounit; $me->{ounit} = \@ounit;
$me->{iunit} = \@iunit; $me->{iunit} = \@iunit;
# Check for nonlinear projection... # Check for nonlinear projection...
# if($hdr->{CTYPE1} =~ m/(\w\w\w\w)\-(\w\w\w)/) { # if($hdr->{CTYPE1} =~ m/(\w\w\w\w)\-(\w\w\w)/) {
# print "Nonlinear transformation found... ignoring nonlinear part...\n"; # print "Nonlinear transformation found... ignoring nonlinear part...\n";
# } # }
return $me; return $me;
} }
#line 2306 "Transform.pm"
#line 3110 "transform.pd" #line 3110 "transform.pd"
=head2 t_code =head2 t_code
=for usage =for usage
$f = t_code(<func>,[<inv>],[options]); $f = t_code(<func>,[<inv>],[options]);
=for ref =for ref
Transform implementing arbitrary perl code. Transform implementing arbitrary perl code.
skipping to change at line 2321 skipping to change at line 2270
$me->{params} = _opt($o,['p','params','Params']) || {}; $me->{params} = _opt($o,['p','params','Params']) || {};
$me->{idim} = _opt($o,['i','idim']) || 2; $me->{idim} = _opt($o,['i','idim']) || 2;
$me->{odim} = _opt($o,['o','odim']) || 2; $me->{odim} = _opt($o,['o','odim']) || 2;
$me->{itype} = _opt($o,['itype']) || []; $me->{itype} = _opt($o,['itype']) || [];
$me->{otype} = _opt($o,['otype']) || []; $me->{otype} = _opt($o,['otype']) || [];
$me->{iunit} = _opt($o,['iunit']) || []; $me->{iunit} = _opt($o,['iunit']) || [];
$me->{ounit} = _opt($o,['ounit']) || []; $me->{ounit} = _opt($o,['ounit']) || [];
$me; $me;
} }
#line 2403 "Transform.pm"
#line 3209 "transform.pd" #line 3209 "transform.pd"
=head2 t_cylindrical =head2 t_cylindrical
C<t_cylindrical> is an alias for C<t_radial> C<t_cylindrical> is an alias for C<t_radial>
=head2 t_radial =head2 t_radial
=for usage =for usage
$f = t_radial(<options>); $f = t_radial(<options>);
skipping to change at line 2494 skipping to change at line 2441
my($os) = $out->slice("0:1"); my($os) = $out->slice("0:1");
$os .= append(cos($d0)->dummy(0,1),-sin($d0)->dummy(0,1)); $os .= append(cos($d0)->dummy(0,1),-sin($d0)->dummy(0,1));
$os *= defined $o->{r0} ? ($o->{r0} * exp($d1)) : $d1; $os *= defined $o->{r0} ? ($o->{r0} * exp($d1)) : $d1;
$os += $o->{origin}; $os += $o->{origin};
$out; $out;
}; };
$me; $me;
} }
#line 2582 "Transform.pm"
#line 3387 "transform.pd" #line 3387 "transform.pd"
=head2 t_quadratic =head2 t_quadratic
=for usage =for usage
$t = t_quadratic(<options>); $t = t_quadratic(<options>);
=for ref =for ref
Quadratic scaling -- cylindrical pincushion (n-d; with inverse) Quadratic scaling -- cylindrical pincushion (n-d; with inverse)
skipping to change at line 2610 skipping to change at line 2555
/ 2 / $s * $l) * (1 - 2*($d < $o)); / 2 / $s * $l) * (1 - 2*($d < $o));
$d += $o; $d += $o;
if($data->is_inplace) { if($data->is_inplace) {
$data .= $dd; $data .= $dd;
return $data; return $data;
} }
$dd; $dd;
}; };
$me; $me;
} }
#line 2702 "Transform.pm"
#line 3506 "transform.pd" #line 3506 "transform.pd"
=head2 t_cubic =head2 t_cubic
=for usage =for usage
$t = t_cubic(<options>); $t = t_cubic(<options>);
=for ref =for ref
Cubic scaling - cubic pincushion (n-d; with inverse) Cubic scaling - cubic pincushion (n-d; with inverse)
skipping to change at line 2751 skipping to change at line 2694
if($data->is_inplace) { if($data->is_inplace) {
$data .= $dd; $data .= $dd;
return $data; return $data;
} else { } else {
return $dd; return $dd;
} }
}; };
$me; $me;
} }
#line 2848 "Transform.pm"
#line 3652 "transform.pd" #line 3652 "transform.pd"
=head2 t_quartic =head2 t_quartic
=for usage =for usage
$t = t_quartic(<options>); $t = t_quartic(<options>);
=for ref =for ref
Quartic scaling -- cylindrical pincushion (n-d; with inverse) Quartic scaling -- cylindrical pincushion (n-d; with inverse)
skipping to change at line 2871 skipping to change at line 2812
/ 2 / $s * $l) * (1 - 2*($d < $o)); / 2 / $s * $l) * (1 - 2*($d < $o));
$d += $o; $d += $o;
if($data->is_inplace) { if($data->is_inplace) {
$data .= $dd; $data .= $dd;
return $data; return $data;
} }
$dd; $dd;
}; };
$me; $me;
} }
#line 2972 "Transform.pm"
#line 3775 "transform.pd" #line 3775 "transform.pd"
=head2 t_spherical =head2 t_spherical
=for usage =for usage
$t = t_spherical(<options>); $t = t_spherical(<options>);
=for ref =for ref
Convert Cartesian to spherical coordinates. (3-D; with inverse) Convert Cartesian to spherical coordinates. (3-D; with inverse)
skipping to change at line 3006 skipping to change at line 2945
$x .= $r * cos($ph); $x .= $r * cos($ph);
$y .= $x * sin($th); $y .= $x * sin($th);
$x *= cos($th); $x *= cos($th);
$out += $o->{origin}; $out += $o->{origin};
$out; $out;
}; };
$me; $me;
} }
#line 3111 "Transform.pm"
#line 3913 "transform.pd" #line 3913 "transform.pd"
=head2 t_projective =head2 t_projective
=for usage =for usage
$t = t_projective(<options>); $t = t_projective(<options>);
=for ref =for ref
Projective transformation Projective transformation
skipping to change at line 3160 skipping to change at line 3097
$me->{inv} = sub { $me->{inv} = sub {
my($data,$o) = @_; my($data,$o) = @_;
my($id) = $data->dim(0); my($id) = $data->dim(0);
my($d) = $data->glue(0,ones($data->slice("0"))); my($d) = $data->glue(0,ones($data->slice("0")));
my($out) = ($o->{matinv} x $d->slice("*1"))->slice("(0)"); my($out) = ($o->{matinv} x $d->slice("*1"))->slice("(0)");
return ($out->slice("0:".($id-1))/$out->slice("$id")); return ($out->slice("0:".($id-1))/$out->slice("$id"));
}; };
$me; $me;
} }
#line 3269 "Transform.pm"
#line 244 "transform.pd" #line 244 "transform.pd"
=head1 AUTHOR =head1 AUTHOR
Copyright 2002, 2003 Craig DeForest. There is no warranty. You are allowed Copyright 2002, 2003 Craig DeForest. There is no warranty. You are allowed
to redistribute this software under certain conditions. For details, to redistribute this software under certain conditions. For details,
see the file COPYING in the PDL distribution. If this file is see the file COPYING in the PDL distribution. If this file is
separated from the PDL distribution, the copyright notice should be separated from the PDL distribution, the copyright notice should be
included in the file. included in the file.
=cut =cut
skipping to change at line 3227 skipping to change at line 3162
# call this routine first then append auxiliary information. # call this routine first then append auxiliary information.
# #
sub stringify { sub stringify {
my($me) = shift; my($me) = shift;
my($mestr) = (ref $me); my($mestr) = (ref $me);
$mestr =~ s/PDL::Transform:://; $mestr =~ s/PDL::Transform:://;
my $out = $mestr . " (" . $me->{name} . "): "; my $out = $mestr . " (" . $me->{name} . "): ";
$out .= "fwd ". ((defined ($me->{func})) ? ( (ref($me->{func}) eq 'CODE') ? "o k" : "non-CODE(!!)" ): "missing")."; "; $out .= "fwd ". ((defined ($me->{func})) ? ( (ref($me->{func}) eq 'CODE') ? "o k" : "non-CODE(!!)" ): "missing")."; ";
$out .= "inv ". ((defined ($me->{inv})) ? ( (ref($me->{inv}) eq 'CODE') ? "ok " : "non-CODE(!!)" ):"missing").".\n"; $out .= "inv ". ((defined ($me->{inv})) ? ( (ref($me->{inv}) eq 'CODE') ? "ok " : "non-CODE(!!)" ):"missing").".\n";
} }
#line 3342 "Transform.pm" #line 3183 "Transform.pm"
# Exit with OK status # Exit with OK status
1; 1;
 End of changes. 56 change blocks. 
73 lines changed or deleted 8 lines changed or added

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