Maybe not an answer you were expecting, it appears PDL does not provide interface to some GSL functions. The PDL::GSL::INTERP describes 1D interpolation only. However, there are 2D interpolation functions for irregular/non-uniform X-Y grid, exactly as you require. Then, after interpolating for points on regular grid, you could proceed to visualization on a 2D image, etc.
There is "gsl_interp2d.h" in my Strawberry Perl installation, so it must be possible to call these functions from existing libgsl dll. Writing PDL bindings is beyond my scope, but perhaps it's not prohibitively difficult to use FFI in this case.
Another possibility, I had in mind even before finding the above, is that irregular grid is just a specific case of any random set (not a grid) of (X,Y) points for which f(X,Y) is known. From f(X,Y) for any set, to f on regular grid, for reasonably well-behaving function and if linear interpolation is good enough -- I did that before, though it's not PDL. First, triangulate X-Y plane, then interpolate for regular grid points inside each triangle.
| [reply] |
Come on in, the water's lovely! (really, it's not that difficult)
One thing to note would be after one adds a pp_def, one needs to re-run perl Makefile.PL because the "multi-C" feature bakes the available function names into the generated Makefile so that only things actually changed need rebuilding. A way to "cheat" here is to copy-paste similar functions and just rename them, so the recreating of Makefiles only needs doing once.
I'd suggest calling this function eval2d. You'd need 2D versions of init, new_spline, etc.
| [reply] [d/l] [select] |
Could you provide some example data? This would help clarify what you mean by not uniform. Do you mean you have point observations, and so many elements of the array are empty?
| [reply] |
$t = sequence(10)+1;
$x = log($t)->dummy(1,10);
$y = ($t**2)->dummy(0,10);
$x = $x + $y/10;
$z = $x+$y;
now I want generate a figure like pcolor($x,$y,$z);
| [reply] [d/l] |
It works for me, insofar as I understand your question.
When I run imag($z) I see a two dimensional plot with light values at the top and dark values at the bottom.
This is all run in the pdl2 shell under Strawberry Perl 5.30.0 (PDL version, via its portableshell.bat).
use PDL::Graphics::Simple;
$t = sequence(10)+1;
$x = log($t)->dummy(1,10);
$y = ($t**2)->dummy(0,10);
$x = $x + $y/10;
$z = $x+$y;
imag($z);
Some caveats are that I had to force install PDL::Graphics::Simple due to a failing test, and that the plot window seems to hang. Closing the plot window kills the pdl2 shell, but you can interact with the shell while the plot is open.
| [reply] [d/l] [select] |
This works for me on both Linux and latest PDL with Strawberry Perl, albeit using an actual 3D Z-axis rather than colours:
use PDL::Graphics::TriD;
$t = sequence(10)+1;
$x = log($t)->dummy(1,10);
$y = ($t**2)->dummy(0,10);
$x = $x + $y/10;
$z = $x+$y;
points3d [$x,$y,$z];
| [reply] [d/l] |