Transform.pm (PDL-2.081) | : | Transform.pm (PDL-2.082) | ||
---|---|---|---|---|
skipping to change at line 358 | skipping to change at line 358 | |||
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 377 "Transform.pm" | |||
#line 949 "/home/osboxes/pdl-code/blib/lib/PDL/PP.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 703 | skipping to change at line 703 | |||
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 731 "Transform.pm" | |||
#line 950 "/home/osboxes/pdl-code/blib/lib/PDL/PP.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 958 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 744 "Transform.pm" | |||
#line 958 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 967 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | |||
#line 960 "/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 = \↦ | *PDL::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 744 | |||
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 992 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 778 "Transform.pm" | |||
#line 990 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 999 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | |||
#line 994 "/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 1005 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 791 "Transform.pm" | |||
#line 1001 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 1010 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | |||
#line 1007 "/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 955 | |||
} | } | |||
$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 1206 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 992 "Transform.pm" | |||
#line 1200 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 1209 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | |||
#line 1208 "/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 1003 | |||
|| ""); | || ""); | |||
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 1254 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 1040 "Transform.pm" | |||
#line 1246 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 1255 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | |||
#line 1256 "/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 1117 | |||
$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 1368 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 1154 "Transform.pm" | |||
#line 1155 "Transform.pm" | #line 1155 "Transform.pm" | |||
#line 951 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | #line 960 "/home/osboxes/pdl-code/blib/lib/PDL/PP.pm" | |||
*map = \&PDL::map; | *map = \&PDL::map; | |||
#line 1162 "Transform.pm" | #line 1162 "Transform.pm" | |||
#line 1975 "transform.pd" | #line 1975 "transform.pd" | |||
###################################################################### | ###################################################################### | |||
=head2 unmap | =head2 unmap | |||
End of changes. 9 change blocks. | ||||
19 lines changed or deleted | 19 lines changed or added |