in reply to Interpolating data using pdl

pdl> $x = sequence( 3, 3)-> float pdl> p $x [ [0 1 2] [3 4 5] [6 7 8] ] pdl> $i = PDL::IO::Image-> new_from_pdl( $x ) pdl> $i-> rescale(5, 5, 2) pdl> $x_new = $i-> pixels_to_pdl pdl> p $x_new [ [ 0 0.4 1 1.6 2] [ 1.2 1.6 2.2 2.8 3.2] [ 3 3.4 4 4.6 5] [ 4.8 5.2 5.8 6.4 6.8] [ 6 6.4 7 7.6 8] ]

Note, that "float" is important instead of default "double". Also, check possible interpolation methods.

Replies are listed 'Best First'.
Re^2: Interpolating data using pdl
by karthik248 (Acolyte) on Mar 15, 2017 at 16:35 UTC

    Many thanks for the solution.

    I might be able to use this. Can you also help me with the further processing?

    The data-values can be categorized into three ranges and now i have a pdl with data for each point(pixel) of the map(as described here). And now i have to plot these points onto a image, with different colors based on the ranges. Can you provide a script for generating such image.

      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?

        Thanks for the update. I meant a 2-D image with RGB or ARGB.