diff --git a/CHANGES b/CHANGES index 840b79e..e85854b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +- move PDL::Graphics::LUT to this distro + 2.30 2024-07-29 - restructure .pm under "lib", CI and doc tweaks diff --git a/MANIFEST b/MANIFEST index 4b4f2aa..61423e8 100644 --- a/MANIFEST +++ b/MANIFEST @@ -11,6 +11,61 @@ INSTALL-MacOSX INSTALL-Win32 lib/PDL/Demos/PGPLOT.pm lib/PDL/Demos/PGPLOT_OO.pm +lib/PDL/Graphics/LUT.pm +lib/PDL/Graphics/LUT/ramps/equa.fits +lib/PDL/Graphics/LUT/ramps/expo.fits +lib/PDL/Graphics/LUT/ramps/gamma.fits +lib/PDL/Graphics/LUT/ramps/jigsaw.fits +lib/PDL/Graphics/LUT/ramps/lasritt.fits +lib/PDL/Graphics/LUT/ramps/log.fits +lib/PDL/Graphics/LUT/ramps/neg.fits +lib/PDL/Graphics/LUT/ramps/neglog.fits +lib/PDL/Graphics/LUT/ramps/null.fits +lib/PDL/Graphics/LUT/ramps/ramp.fits +lib/PDL/Graphics/LUT/ramps/stairs.fits +lib/PDL/Graphics/LUT/tables/aips0.fits +lib/PDL/Graphics/LUT/tables/backgr.fits +lib/PDL/Graphics/LUT/tables/bgyrw.fits +lib/PDL/Graphics/LUT/tables/blue.fits +lib/PDL/Graphics/LUT/tables/blulut.fits +lib/PDL/Graphics/LUT/tables/color.fits +lib/PDL/Graphics/LUT/tables/green.fits +lib/PDL/Graphics/LUT/tables/heat.fits +lib/PDL/Graphics/LUT/tables/idl11.fits +lib/PDL/Graphics/LUT/tables/idl12.fits +lib/PDL/Graphics/LUT/tables/idl14.fits +lib/PDL/Graphics/LUT/tables/idl15.fits +lib/PDL/Graphics/LUT/tables/idl2.fits +lib/PDL/Graphics/LUT/tables/idl4.fits +lib/PDL/Graphics/LUT/tables/idl5.fits +lib/PDL/Graphics/LUT/tables/idl6.fits +lib/PDL/Graphics/LUT/tables/isophot.fits +lib/PDL/Graphics/LUT/tables/light.fits +lib/PDL/Graphics/LUT/tables/manycol.fits +lib/PDL/Graphics/LUT/tables/pastel.fits +lib/PDL/Graphics/LUT/tables/rainbow.fits +lib/PDL/Graphics/LUT/tables/rainbow1.fits +lib/PDL/Graphics/LUT/tables/rainbow2.fits +lib/PDL/Graphics/LUT/tables/rainbow3.fits +lib/PDL/Graphics/LUT/tables/rainbow4.fits +lib/PDL/Graphics/LUT/tables/ramp.fits +lib/PDL/Graphics/LUT/tables/random.fits +lib/PDL/Graphics/LUT/tables/random1.fits +lib/PDL/Graphics/LUT/tables/random2.fits +lib/PDL/Graphics/LUT/tables/random3.fits +lib/PDL/Graphics/LUT/tables/random4.fits +lib/PDL/Graphics/LUT/tables/random5.fits +lib/PDL/Graphics/LUT/tables/random6.fits +lib/PDL/Graphics/LUT/tables/real.fits +lib/PDL/Graphics/LUT/tables/red.fits +lib/PDL/Graphics/LUT/tables/smooth.fits +lib/PDL/Graphics/LUT/tables/smooth1.fits +lib/PDL/Graphics/LUT/tables/smooth2.fits +lib/PDL/Graphics/LUT/tables/smooth3.fits +lib/PDL/Graphics/LUT/tables/staircase.fits +lib/PDL/Graphics/LUT/tables/stairs8.fits +lib/PDL/Graphics/LUT/tables/stairs9.fits +lib/PDL/Graphics/LUT/tables/standard.fits lib/PDL/Graphics/PGPLOT.pm lib/PDL/Graphics/PGPLOT/Window.pm lib/PDL/Graphics/PGPLOTOptions.pm @@ -23,6 +78,7 @@ pgcompatbility.p pgfun.c PGPLOT.xs README +t/lut.t t/pdl-graphics.t t/t1.t t/t10.t diff --git a/README b/README index 8313e6d..53600ab 100644 --- a/README +++ b/README @@ -1,5 +1,3 @@ - - PGPLOT module for Perl ---------------------- @@ -51,3 +49,8 @@ Problems - see the file HELP News - see the file CHANGES for new features/bug fixes. +NOTES FOR LUT TABLES +-------------------- +The colour tables were taken from STARLINK's GAIA distribution, where they +have the GNU copyleft. Further information on STARLINK and GAIA can be found +via http://star-www.rl.ac.uk/ and http://star-www.dur.ac.uk/~pdraper/. diff --git a/lib/PDL/Graphics/LUT.pm b/lib/PDL/Graphics/LUT.pm new file mode 100644 index 0000000..c8dbd61 --- /dev/null +++ b/lib/PDL/Graphics/LUT.pm @@ -0,0 +1,231 @@ +=head1 NAME + +PDL::Graphics::LUT - provides access to a number of look-up tables + +=head1 SYNOPSIS + + use PDL::Graphics::PGPLOT; + use PDL::Graphics::LUT; + + # what tables are available + my @tables = lut_names(); + + # get the reversed colour table 'smooth', + # with the gamma intensity ramp + my ( $l, $r, $g, $b ) = lut_data( 'smooth', 1, 'gamma' ); + + # use the table idl5 in ctab + ctab( lut_data('idl5') ); + +=head1 DESCRIPTION + +PDL::Graphics::LUT contains a number of colour look-up tables +(in rgb format) and intensity ramps, and provides routines to +access this data. +The format of the data is suitable for use by +L. + +Unlike the initial release of the package, the data tables are +now stored within the PDL distribution as FITS files +(see L and L), +rather than in the module itself. +Changes to these directories will be picked up on the next call +to one of the package functions. + +=head1 FUNCTIONS + +=head2 lut_names() + +=for ref + +Return, as a list, the names of the available colour tables. + +=for usage + + @tables = lut_names(); + +=head2 lut_ramps() + +=for ref + +Return, as a list, the names of the available intensity ramps. + +=for usage + + @ramps = lut_ramps(); + +=head2 lut_data() + +=for ref + +Load in the requested colour table and intensity ramp. + +=for usage + + my ( $l, $r, $g, $b ) = lut_data( $table, [ $reverse, [ $ramp ] ] ); + +Returns the levels and r, g, b components of the colour table +C<$table>. If C<$reverse> is 1 (defaults to B<0> +if not supplied), +then the r, g, and b components are reversed before being +returned. +If not supplied, C<$ramp> defaults to B<"ramp"> +(this is a linear intensity ramp). + +The returned values are ndarrays containing values in the range +0 to 1 inclusive, and are floats. + +=head1 VARIABLES + +=head2 $tabledir + +=for ref + +The directory in which the colour tables (in rgb format) +are stored. + +=head2 $rampdir + +=for ref + +The directory in which the intensity ramps are stored. + +=head2 $suffix + +=for ref + +The suffix for the data files in C<$tabledir> and +C<$rampdir>. + +=head1 FURTHER INFORMATION + +The colour tables were taken from the STARLINK GAIA package, +and are provided under the GNU copyleft. +See http://star-www.rl.ac.uk/ and +http://star-www.dur.ac.uk/~pdraper/ for more details. + +=head1 AUTHOR + +Doug Burke (djburke@cpan.org), with thanks to +Peter Draper/STARLINK for providing the colour-table data, +and Christian Soeller and Karl Glazebrook for their help. + +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. + +=cut + +package PDL::Graphics::LUT; + +use strict; +use warnings; +# Just a plain function exporting package +use Exporter; +use Carp; + +# attempt to avoid Unix-specific file/directory names +use File::Spec; +use File::Basename; + +use PDL::Core qw/:Func :Internal/; # Grab the Core names +use PDL::Basic; +use PDL::Types; +use PDL::Slices; +use PDL::IO::Misc; +use PDL::IO::FITS; + +# should be careful that $suffix is a valid length on non-Unix systems +our ($suffix, $tabledir, $rampdir) = ".fits"; + +# should really use EXPORT_OK +our @EXPORT = qw( lut_names lut_ramps lut_data ); +our @EXPORT_OK = qw( $tabledir $rampdir $suffix ); +our @ISA = qw( Exporter ); + +# can we find the data? +my $d = File::Spec->catdir( "PDL", "Graphics", "LUT" ); +my $lutdir = undef; +foreach my $path ( @INC ) { + my $check = File::Spec->catdir( $path, $d ); + if ( -d $check ) { $lutdir = $check; last; } +} +barf "Unable to find directory ${d} within the perl libraries.\n" + unless defined $lutdir; +$tabledir = File::Spec->catdir( $lutdir, "tables" ); +$rampdir = File::Spec->catdir( $lutdir, "ramps" ); +barf "Unable to find directory $tabledir within the perl libraries.\n" + unless -d $tabledir; +barf "Unable to find directory $rampdir within the perl libraries.\n" + unless -d $rampdir; + +############################################################################ + +sub _lsdir_basename { + my ($dir, $suffix) = @_; + confess "called with undef dir" if !defined $dir; + opendir my $fh, $dir or barf "$dir: $!"; + map basename($_, $suffix), grep /\Q$suffix\E\z/, readdir $fh; +} + +# exported functions + +# Return the list of available tables +sub lut_names () { _lsdir_basename $tabledir, $suffix } + +# Return the list of available ramps +sub lut_ramps () { _lsdir_basename $rampdir, $suffix } + +# Return the requested colour table +sub lut_data ($;$$) { + my $table = shift; + my $reverse = $#_ != -1 ? shift : 0; + my $ramp = $#_ != -1 ? shift : "ramp"; + + my $lfile = File::Spec->catfile( $tabledir, "$table$suffix" ); + my $rfile = File::Spec->catfile( $rampdir, "$ramp$suffix" ); + print "Reading colour table and intensity ramp from:\n $lfile\n $rfile\n" + if $PDL::verbose; + + # unknown table? + unless ( -e $lfile ) { + my @names = lut_names(); + barf <<"EOD"; +Unknown colour table $table +Available tables: + @names +EOD + } + + # unknown ramp? + unless ( -e $rfile ) { + my @names = lut_ramps(); + barf <<"EOD"; +Unknown intensity ramp $ramp +Available ramps: + @names +EOD + } + + # read in rgb data + my $rgb = rfits $lfile; + $rgb = float($rgb) if $rgb->get_datatype != $PDL_F; + my ( @ldims ) = $rgb->dims; + barf "LUT file $lfile is not the correct format (ie n by 3)\n" + unless $#ldims == 1 and $ldims[1] == 3; + + # read in intensity data + my $l = rfits $rfile; + $l = float($l) if $l->get_datatype != $PDL_F; + barf "Ramp file $rfile does not match the colour table size.\n" + unless $l->nelem == $ldims[0]; + + my $s = $reverse ? "-1:0" : ""; + return ( $l, $rgb->slice("${s},(0)"), $rgb->slice("${s},(1)"), $rgb->slice("${s},(2)") ); + +} # sub: lut_data() + +# Exit with OK status +1; diff --git a/lib/PDL/Graphics/LUT/ramps/equa.fits b/lib/PDL/Graphics/LUT/ramps/equa.fits new file mode 100644 index 0000000..b7f82ad Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/equa.fits differ diff --git a/lib/PDL/Graphics/LUT/ramps/expo.fits b/lib/PDL/Graphics/LUT/ramps/expo.fits new file mode 100644 index 0000000..3349adc Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/expo.fits differ diff --git a/lib/PDL/Graphics/LUT/ramps/gamma.fits b/lib/PDL/Graphics/LUT/ramps/gamma.fits new file mode 100644 index 0000000..381873c Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/gamma.fits differ diff --git a/lib/PDL/Graphics/LUT/ramps/jigsaw.fits b/lib/PDL/Graphics/LUT/ramps/jigsaw.fits new file mode 100644 index 0000000..b4d67c3 Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/jigsaw.fits differ diff --git a/lib/PDL/Graphics/LUT/ramps/lasritt.fits b/lib/PDL/Graphics/LUT/ramps/lasritt.fits new file mode 100644 index 0000000..ba600be Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/lasritt.fits differ diff --git a/lib/PDL/Graphics/LUT/ramps/log.fits b/lib/PDL/Graphics/LUT/ramps/log.fits new file mode 100644 index 0000000..62ffe95 Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/log.fits differ diff --git a/lib/PDL/Graphics/LUT/ramps/neg.fits b/lib/PDL/Graphics/LUT/ramps/neg.fits new file mode 100644 index 0000000..7dbb3d4 Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/neg.fits differ diff --git a/lib/PDL/Graphics/LUT/ramps/neglog.fits b/lib/PDL/Graphics/LUT/ramps/neglog.fits new file mode 100644 index 0000000..49c6d55 Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/neglog.fits differ diff --git a/lib/PDL/Graphics/LUT/ramps/null.fits b/lib/PDL/Graphics/LUT/ramps/null.fits new file mode 100644 index 0000000..9213a19 Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/null.fits differ diff --git a/lib/PDL/Graphics/LUT/ramps/ramp.fits b/lib/PDL/Graphics/LUT/ramps/ramp.fits new file mode 100644 index 0000000..30db904 Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/ramp.fits differ diff --git a/lib/PDL/Graphics/LUT/ramps/stairs.fits b/lib/PDL/Graphics/LUT/ramps/stairs.fits new file mode 100644 index 0000000..6f66aa7 Binary files /dev/null and b/lib/PDL/Graphics/LUT/ramps/stairs.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/aips0.fits b/lib/PDL/Graphics/LUT/tables/aips0.fits new file mode 100644 index 0000000..4884866 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/aips0.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/backgr.fits b/lib/PDL/Graphics/LUT/tables/backgr.fits new file mode 100644 index 0000000..74b9092 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/backgr.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/bgyrw.fits b/lib/PDL/Graphics/LUT/tables/bgyrw.fits new file mode 100644 index 0000000..3f9c1d6 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/bgyrw.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/blue.fits b/lib/PDL/Graphics/LUT/tables/blue.fits new file mode 100644 index 0000000..9615e9e Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/blue.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/blulut.fits b/lib/PDL/Graphics/LUT/tables/blulut.fits new file mode 100644 index 0000000..ff43587 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/blulut.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/color.fits b/lib/PDL/Graphics/LUT/tables/color.fits new file mode 100644 index 0000000..3c3bd80 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/color.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/green.fits b/lib/PDL/Graphics/LUT/tables/green.fits new file mode 100644 index 0000000..2405171 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/green.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/heat.fits b/lib/PDL/Graphics/LUT/tables/heat.fits new file mode 100644 index 0000000..a14196e Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/heat.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/idl11.fits b/lib/PDL/Graphics/LUT/tables/idl11.fits new file mode 100644 index 0000000..5063553 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/idl11.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/idl12.fits b/lib/PDL/Graphics/LUT/tables/idl12.fits new file mode 100644 index 0000000..9dd4c4f Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/idl12.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/idl14.fits b/lib/PDL/Graphics/LUT/tables/idl14.fits new file mode 100644 index 0000000..c05edea Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/idl14.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/idl15.fits b/lib/PDL/Graphics/LUT/tables/idl15.fits new file mode 100644 index 0000000..1737918 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/idl15.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/idl2.fits b/lib/PDL/Graphics/LUT/tables/idl2.fits new file mode 100644 index 0000000..62a223a Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/idl2.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/idl4.fits b/lib/PDL/Graphics/LUT/tables/idl4.fits new file mode 100644 index 0000000..2e42ea4 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/idl4.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/idl5.fits b/lib/PDL/Graphics/LUT/tables/idl5.fits new file mode 100644 index 0000000..0affa79 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/idl5.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/idl6.fits b/lib/PDL/Graphics/LUT/tables/idl6.fits new file mode 100644 index 0000000..da9edfc Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/idl6.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/isophot.fits b/lib/PDL/Graphics/LUT/tables/isophot.fits new file mode 100644 index 0000000..37d4a49 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/isophot.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/light.fits b/lib/PDL/Graphics/LUT/tables/light.fits new file mode 100644 index 0000000..94701d9 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/light.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/manycol.fits b/lib/PDL/Graphics/LUT/tables/manycol.fits new file mode 100644 index 0000000..15246ac Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/manycol.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/pastel.fits b/lib/PDL/Graphics/LUT/tables/pastel.fits new file mode 100644 index 0000000..7f9c0a9 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/pastel.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/rainbow.fits b/lib/PDL/Graphics/LUT/tables/rainbow.fits new file mode 100644 index 0000000..9d5f0b6 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/rainbow.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/rainbow1.fits b/lib/PDL/Graphics/LUT/tables/rainbow1.fits new file mode 100644 index 0000000..9b284a6 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/rainbow1.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/rainbow2.fits b/lib/PDL/Graphics/LUT/tables/rainbow2.fits new file mode 100644 index 0000000..144f347 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/rainbow2.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/rainbow3.fits b/lib/PDL/Graphics/LUT/tables/rainbow3.fits new file mode 100644 index 0000000..ea48f1b Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/rainbow3.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/rainbow4.fits b/lib/PDL/Graphics/LUT/tables/rainbow4.fits new file mode 100644 index 0000000..7f39f23 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/rainbow4.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/ramp.fits b/lib/PDL/Graphics/LUT/tables/ramp.fits new file mode 100644 index 0000000..8156457 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/ramp.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/random.fits b/lib/PDL/Graphics/LUT/tables/random.fits new file mode 100644 index 0000000..87a0d32 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/random.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/random1.fits b/lib/PDL/Graphics/LUT/tables/random1.fits new file mode 100644 index 0000000..765b61f Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/random1.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/random2.fits b/lib/PDL/Graphics/LUT/tables/random2.fits new file mode 100644 index 0000000..5843b66 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/random2.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/random3.fits b/lib/PDL/Graphics/LUT/tables/random3.fits new file mode 100644 index 0000000..ffdae4e Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/random3.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/random4.fits b/lib/PDL/Graphics/LUT/tables/random4.fits new file mode 100644 index 0000000..47effdd Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/random4.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/random5.fits b/lib/PDL/Graphics/LUT/tables/random5.fits new file mode 100644 index 0000000..8e50fb2 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/random5.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/random6.fits b/lib/PDL/Graphics/LUT/tables/random6.fits new file mode 100644 index 0000000..0a3dc08 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/random6.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/real.fits b/lib/PDL/Graphics/LUT/tables/real.fits new file mode 100644 index 0000000..5237521 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/real.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/red.fits b/lib/PDL/Graphics/LUT/tables/red.fits new file mode 100644 index 0000000..1eb194b Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/red.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/smooth.fits b/lib/PDL/Graphics/LUT/tables/smooth.fits new file mode 100644 index 0000000..1aaf6cd Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/smooth.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/smooth1.fits b/lib/PDL/Graphics/LUT/tables/smooth1.fits new file mode 100644 index 0000000..dcbc416 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/smooth1.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/smooth2.fits b/lib/PDL/Graphics/LUT/tables/smooth2.fits new file mode 100644 index 0000000..5d38af0 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/smooth2.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/smooth3.fits b/lib/PDL/Graphics/LUT/tables/smooth3.fits new file mode 100644 index 0000000..9f19261 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/smooth3.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/staircase.fits b/lib/PDL/Graphics/LUT/tables/staircase.fits new file mode 100644 index 0000000..c3fc5bb Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/staircase.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/stairs8.fits b/lib/PDL/Graphics/LUT/tables/stairs8.fits new file mode 100644 index 0000000..e588cf0 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/stairs8.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/stairs9.fits b/lib/PDL/Graphics/LUT/tables/stairs9.fits new file mode 100644 index 0000000..6f2ab15 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/stairs9.fits differ diff --git a/lib/PDL/Graphics/LUT/tables/standard.fits b/lib/PDL/Graphics/LUT/tables/standard.fits new file mode 100644 index 0000000..a364606 Binary files /dev/null and b/lib/PDL/Graphics/LUT/tables/standard.fits differ diff --git a/t/lut.t b/t/lut.t new file mode 100644 index 0000000..4968a3f --- /dev/null +++ b/t/lut.t @@ -0,0 +1,39 @@ +use strict; +use warnings; +use Test::More; +BEGIN { + eval {require PDL}; + plan skip_all => "No PDL, can't test this ($@)" if $@; +} +use PDL::LiteF; +use PDL::Types; +use PDL::Graphics::LUT; + +my @names = lut_names(); +isnt scalar(@names), 0, "lut_names returns non-empty list"; + +my @cols = lut_data( $names[0] ); +is( scalar(@cols), 4, "lut_data returns 4 columns" ); +is( $cols[0]->nelem, $cols[1]->nelem, "equal number of elements in cols 0 and 1"); +is( $cols[2]->get_datatype, $PDL_F, "datatype of col 2 is float"); + +# check we can reverse things +my @cols2 = lut_data( $names[0], 1 ); +ok( all( approx($cols[3]->slice('-1:0'),$cols2[3])), "reverse lut works"); + +# check we know about the intensity ramps +my @ramps = lut_ramps(); +isnt scalar(@ramps), 0, "lut_ramps returns some ramps"; + +# load in a different intensity ramp +my @cols3 = lut_data( $names[0], 0, $ramps[0] ); +is( $cols3[0]->nelem, $cols3[1]->nelem, "intensity ramp nelem check"); +ok( all(approx($cols[1],$cols3[1], 1e-6)), "intensity ramp vals check") + or diag '[ difference, subtract, c[1], c3[1] ]: ', explain [ + abs($cols[1] - $cols3[1]).'', + ($cols[1] - $cols3[1]).'', + $cols[1].'', + $cols3[1].'', + ]; + +done_testing;