2008/12/4 Hazen Babcock <[EMAIL PROTECTED]>:
> Kaj Wiik wrote:
>> Contouring with user-supplied translation function (mypltr) is very
>> very slow probably because of the perl calling overheads. Is there a
...
> I believe that you can accomplish this using the built-in function pltr2. It
> maps the x,y matrix index to a user defined x,y point. You'd have to compute
> two (possibly large) matrices to defining the transform, but once these are
> created there would be no need for the Perl callback.
Yes, indeed! I was mislead somehow probably because in the example the
mypltr() did what I wanted so I assumed (without looking at the
built-in conversion functions..) that it is the only way.
For others who may stumble to this, here is what I did:
---------------------
Transformation parameters from the FITS header (from Dan Homan's
FITSplot scripts):
$h = $array->gethdr; # get fits header info
$degpp = $$h{CDELT2}; # degrees per pixel
$centx = $$h{CRPIX1}; # center pixel in x
$centy = $$h{CRPIX2}; # center pixel in y
$axisx = $$h{NAXIS1}; # pixels along x axis
$axisy = $$h{NAXIS2}; # pixels along y axis
$convert *= $degpp; # conversion is now pixels to world units
$tr->[0] = $shift->[0]+($centx)*$convert*cos($rotate)
+($centy)*$convert*sin($rotate);
$tr->[1] = -$convert*cos($rotate);
$tr->[2] = -$convert*sin($rotate);
$tr->[3] = $shift->[1]+($centx)*$convert*sin($rotate)
-($centy)*$convert*cos($rotate);
$tr->[4] = -$convert*sin($rotate);
$tr->[5] = $convert*cos($rotate);
....
$array holds the data to be contoured
my $xgrid = $array->xvals;
my $ygrid = $array->yvals;
my $cgrid2 = plAlloc2dGrid($tr->[0] + $tr->[1] * $xgrid + $tr->[2] * $ygrid,
$tr->[3] + $tr->[4] * $xgrid + $tr->[5] * $ygrid);
plcont($array,1,$axisx,1,$axisy, $positive_contours, \&pltr2, $cgrid2);
plFree2dGrid ($cgrid2);
-------------------
Contouring is over 20 times faster when using \&pltr2 instead of perl
sub, so interactive scaling and tweaking is feasible now!
Many thanks, Hazen!!
Cheers,
Kaj
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl