I had this exact problem. I made a routine that takes a list of x,y points
and makes a 100x100 intensity image, complete with the appropriate TRANSFORM
parameter to pass to imag(). Change $s in intensity() for a more detailed
image.
Let me know if you need any more info.
Cheers,
Matt
#!/usr/bin/perl -w
use PDL;
use PGPLOT;
use PDL::Graphics::PGPLOT;
use PDL::NiceSlice;
use PDL::Image2D;
use PDL::Fit::Polynomial;
use PDL::AutoLoader;
use strict;
dev("/xs",2,2,{Color=>1,AxisColour=>1, Linewidth=>1, HardLw => 3,
HardCH=>1.6, WindowWidth=>8, CH=>1.6, Aspect=>1});
# test list of points
my $x = grandom(10000);
my $y = grandom(10000);
env(-2,2,-2,2);
points $x, $y;
my ($out, $ee) = intensity(-5,5,-5,5,$x,$y);
release;
imag $out;
imag $out,{TRANSFORM=>$ee};
##############################################################
##############################################################
sub intensity {
use strict;
use PDL::NiceSlice;
my ($x1, $x2, $y1, $y2, $x, $y) = @_;
my $s = 101;
my $out = zeroes($s,$s);
my $xc = ($x - $x1) / ($x2 - $x1);
my $yc = ($y - $y1) / ($y2 - $y1);
# now, remove all below 0 and above 1, as they will be out of the
# plot
my ($xcc,$ycc) = where($xc, $yc,
(($xc > 0) * ($xc < 1) * ($yc > 0) * ($yc < 1)) );
my $xcci = $xcc * $s;
my $ycci = $ycc * $s;
for (my $p = 0; $p < nelem($xcci); $p++) {
$out($xcci($p),$ycci($p)) += 1;
}
# center of image is at (s-1)/2
my $tt1 = transf_tx(-($s-1)/2, -($s-1)/2);
my $tt2 = transf_sca(($x2-$x1)/($s-1),($y2-$y1)/($s-1));
my $tt3 = transf_tx(($x2+$x1)/2, ($y2+$y1)/2);
my $ee = mtform($tt3 x $tt2 x $tt1);
# env($x1, $x2, $y1, $y2); imag $out,{TRANSFORM=>$ee};
return ($out, $ee);
}
sub mtform {
use strict;
# (t1 t2 t0) I
# (t4 t5 t3) J
# (0 0 1) 1
use PDL::NiceSlice;
my ($m) = @_;
my $rem = rotate($m,1)->flat;
return($rem(0:5));
}
sub transf_tx {
use strict;
my ($x, $y) = @_;
my $tm = pdl [ [ 1, 0, $x],
[ 0, 1, $y],
[ 0, 0, 1 ] ];
return($tm);
}
sub transf_sca {
use strict;
my ($scx, $scy) = @_;
my $tm = pdl [ [ $scx, 0, 0],
[ 0, $scy, 0],
[ 0, 0, 1 ] ];
return($tm);
}
On Thu, May 21, 2009 at 3:48 PM, Karl Glazebrook <[email protected]>wrote:
> Try pgpnts() and not one at a time (sym = 1 or -1 helps). 250K should
> not be too bad.
>
> A better method would be to plot density contours and them add points
> only in the outliers, this would require a clever subroutine to be
> written though.
>
> Karl
>
>
>
> On 22/05/2009, at 7:44 AM, David Donovan wrote:
>
> > Hi All,
> >
> > I'm trying to plot something on the order of 250,000 points to a file,
> > but it's bring my machine (~2GB RAM) to its knees. I'm using
> > PDL::Graphics::PGPLOT in a loop 20,000 times to plot
> > approximately 100 values each time... the resulting .ps file is
> > essentially not convertible to a pdf. Any suggestions on how to deal
> > with something like this? I want to see the outliers, but obviously I
> > can't distinguish between 1000 or 10000 points if they're below the
> > printer's resolution. Is Plplot a little better about not adding any
> > more points than necessary?
> >
> > Any suggestions you might have would be greatly appreciated.
> >
> > Best Regards,
> > David Donovan
> >
> > _______________________________________________
> > Perldl mailing list
> > [email protected]
> > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
--
Matthew Kenworthy / Assistant Astronomer / Steward Observatory
933 N. Cherry Ave. / Tucson AZ 85721 / vox 520 626 6720
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl