in reply to Re^2: Interpolating data using pdl
in thread Interpolating data using pdl

Actually, looking back at results in my answer, this bilinear is "somewhat" strange (and other interpolation methods are probably useless for the given task).

pdl> $x = sequence 3,3 pdl> $y = zeroes 5,5 pdl> bilin2d( $x, $y ) pdl> p $y [ [ 0 0.5 1 1.5 2] [1.5 2 2.5 3 3.5] [ 3 3.5 4 4.5 5] [4.5 5 5.5 6 6.5] [ 6 6.5 7 7.5 8] ]

That's better now. We can even visualize it with mesh3d [$y].

karthik248, it's not clear what kind of plot do you mean? 3-D? Over-impose some visualization onto a world map? Or just 2-D image with 3 different colors?

Replies are listed 'Best First'.
Re^4: Interpolating data using pdl
by karthik248 (Acolyte) on Mar 15, 2017 at 17:53 UTC
    Thanks for the update. I meant a 2-D image with RGB or ARGB.
      use strict; use warnings; use PDL; use PDL::IO::Image; # data my $x = sequence( 100, 100 ); # ranges my $range1 = $x < 3000; my $range2 = ( $x >= 3000 ) * ( $x <= 7000 ); my $range3 = $x > 7000; my $bytes = ( $range1 + 2 * $range2 + 3 * $range3 )-> byte; my $palette = byte [ [ 0, 0, 0 ], [ 255, 50, 50 ], [ 128, 255, 0 ], [ 255, 215, 0 ] ]; $bytes-> wimage( 'test.png', { palette => $palette });

      Not sure if I understand what you need, but, "from the top of my head", this code produces rather dull looking image with three colorful stripes (no time to invent some "smart" data). You have your conditions, combine them, associate with palette of the same length + 1.

        I'm able to use your solution. When I try to initiate a piddle with zeroes(5400,2700) it works fine, but zeroes(21600,10800) doesn't work. It shows an error as Probably false alloc of over 1Gb PDL! (set $PDL::BIGPDL = 1 to enable). I tried setting $PDL::BIGPDL=1, but then it crashes. How can we solve this?