Skip to content

Commit

Permalink
fits handle real FITS RGB data
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Jul 29, 2024
1 parent 54b8b6c commit 2abec6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/PDL/Graphics/Gnuplot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7802,7 +7802,7 @@ sub _with_fits_prefrobnicator {
)];
}
$with->[0] = 'image';
(ndcoords(map $data->dim($_), 0,1)->apply(t_fits($h))->mv(0,-1)->dog, $data);
(ndcoords(map $data->dim($_), 0,1)->apply(t_fits($h, {ignore_rgb=>1}))->mv(0,-1)->dog, $data);
}

##########
Expand Down
11 changes: 5 additions & 6 deletions t/plot.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use Test::More;
use PDL::Graphics::Gnuplot qw(plot gpwin);
use File::Temp qw(tempfile);
use PDL;
use PDL::Transform::Cartography; # t_raster2fits

##########
# Uncomment these to test error handling on Microsoft Windows, from within POSIX....
Expand Down Expand Up @@ -154,21 +155,19 @@ unlink($testoutput) or warn "\$!: $! for '$testoutput'";
eval {$w->plot({with => 'image'},$r9->xvals,$r9->yvals,rvals(@$dims))};
is($@, '', "regularising image succeeded (@$dims)");
}
my @dims = $r9->dims;
my $h = PDL::Graphics::Gnuplot::_make_fits_hdr(@dims[0,1], 1, 1, 0, 0, @dims[0,1], qw(X Y Pixels Pixels));
eval {$w->plot({with => 'fits'},$r9)};
isnt $@, '', "with 'fits' only if FITS header";
my @dims = $r9->dims;
my $h = PDL::Graphics::Gnuplot::_make_fits_hdr(@dims[0,1], 1, 1, 0, 0, @dims[0,1], qw(X Y Pixels Pixels));
$r9->sethdr($h);
eval {$w->plot({with => 'fits'},$r9)};
is($@, '', "with 'fits'");
eval {$w->plot({with => 'fits', resample=>1},$r9)};
is($@, '', "with 'fits', resample");
eval {$w->plot({with => 'fits', resample=>[100,100]},$r9)};
is($@, '', "with 'fits', resample [100,100]");
my $r9_rgb = pdl(0,$r9,$r9);
$r9_rgb->slice(',,0') .= 6;
$r9_rgb->sethdr($h); $r9_rgb *= 20;
eval {$w->plot({with => 'fits'},$r9_rgb)};
my $r9_rgb = pdl(0,$r9,$r9)->mv(-1,0); $r9_rgb->slice(0) .= 6; $r9_rgb *= 20;
eval {$w->plot({with => 'fits'}, t_raster2fits()->apply($r9_rgb))};
is($@, '', "with 'fits', rgb");
}

Expand Down

0 comments on commit 2abec6c

Please sign in to comment.