@@ -230,7 +230,7 @@ package # hide from PAUSE
230230 PDL::Graphics::TriD::CylindricalEquidistantAxes;
231231use base qw( PDL::Graphics::TriD::LatticeAxes) ;
232232use fields qw( Names Scale Center) ;
233- use PDL::Core ' ' ;
233+ use PDL::Core qw( barf float ) ;
234234use PDL::Constants qw( DEGRAD) ;
235235use constant DEG2RAD => 1/DEGRAD;
236236
@@ -248,7 +248,7 @@ sub init_scale {
248248
249249sub add_scale {
250250 my ($this ,$data ,$inds ) = @_ ;
251- PDL:: barf " no \$ inds given" if !defined $inds ;
251+ barf " no \$ inds given" if !defined $inds ;
252252 $data = $data -> dice_axis(0, $inds );
253253 my $to_minmax = $data -> clump(1..$data -> ndims-1); # xyz,...
254254 $to_minmax = $to_minmax -> glue(1, $this -> {Scale }); # include old min/max
@@ -258,8 +258,7 @@ sub add_scale {
258258 }
259259 $this -> {Scale } = PDL-> pdl($mins , $maxes ); # xyz,minmax
260260# Should make the projection center an option
261- $this -> {Center } = [(($maxes -> slice(0) + $mins -> slice(0))/2)-> sclr,
262- 0];
261+ $this -> {Center } = float([($maxes + $mins )-> slice(" (0)" )/2, 0]);
263262}
264263
265264sub finish_scale {
@@ -296,17 +295,18 @@ sub finish_scale {
296295
297296sub transform {
298297 my ($this ,$point ,$data ,$inds ) = @_ ;
299- PDL:: barf " no \$ inds given" if !defined $inds ;
298+ barf " no \$ inds given" if !defined $inds ;
300299 barf " Wrong number of arguments to transform $this \n " if @$inds != 3;
301300 my ($longrange , $latrange ) = $this -> {Scale }-> slice(' 0:1' )-> t-> diff2-> dog;
302301 my $pressure_max = $this -> {Scale }-> slice(' 2,1' );
303302 $data = $data -> dice_axis(0, $inds );
303+ my $data01_ctr = $data -> slice(" 0:1" )-$this -> {Center };
304304 $point -> slice(" (0)" ) +=
305- 0.5+( $data -> slice(" (0)" )- $this -> { Center }[0] ) /
305+ 0.5+$data01_ctr -> slice(" (0)" ) /
306306 $longrange
307307 *cos ($data -> slice(" (1)" )*DEG2RAD);
308308 $point -> slice(" (1)" ) +=
309- 0.5+( $data -> slice(" (1)" )- $this -> { Center }[1] ) /
309+ 0.5+$data01_ctr -> slice(" (1)" ) /
310310 $latrange ;
311311 $point -> slice(" (2)" ) .=
312312 log ($data -> slice(" (2)" )/1012.5)/log ($pressure_max /1012.5);
@@ -320,7 +320,7 @@ package # hide from PAUSE
320320 PDL::Graphics::TriD::PolarStereoAxes;
321321use base qw( PDL::Graphics::TriD::LatticeAxes) ;
322322use fields qw( Names Scale Center) ;
323- use PDL::Core ' ' ;
323+ use PDL::Core qw( barf float ) ;
324324use PDL::Constants qw( DEGRAD) ;
325325use constant DEG2RAD => 1/DEGRAD;
326326
@@ -338,7 +338,7 @@ sub init_scale {
338338
339339sub add_scale {
340340 my ($this ,$data ,$inds ) = @_ ;
341- PDL:: barf " no \$ inds given" if !defined $inds ;
341+ barf " no \$ inds given" if !defined $inds ;
342342 $data = $data -> dice_axis(0, $inds );
343343 my $to_minmax = $data -> clump(1..$data -> ndims-1); # xyz,...
344344 $to_minmax = $to_minmax -> glue(1, $this -> {Scale }); # include old min/max
@@ -347,8 +347,7 @@ sub add_scale {
347347 barf " Error in Latitude " , $maxes -> slice(1), " " , $mins -> slice(1);
348348 }
349349 $this -> {Scale } = PDL-> pdl($mins , $maxes ); # xyz,minmax
350- $this -> {Center } = [(($maxes -> slice(0) + $mins -> slice(0))/2)-> sclr,
351- (($maxes -> slice(1) + $mins -> slice(1))/2)-> sclr];
350+ $this -> {Center } = (($maxes + $mins )/2)-> slice(" 0:1" );
352351}
353352
354353sub finish_scale {
@@ -385,18 +384,19 @@ sub finish_scale {
385384
386385sub transform {
387386 my ($this ,$point ,$data ,$inds ) = @_ ;
388- PDL:: barf " no \$ inds given" if !defined $inds ;
387+ barf " no \$ inds given" if !defined $inds ;
389388 my $i = 0;
390389 barf " Wrong number of arguments to transform $this \n " if @$inds != 3;
391390 $data = $data -> dice_axis(0, $inds );
392391 my ($longrange , $latrange ) = $this -> {Scale }-> slice(' 0:1' )-> t-> diff2-> dog;
393392 my $pressure_max = $this -> {Scale }-> slice(' 2,1' );
393+ my $data01_ctr = $data -> slice(" 0:1" )-$this -> {Center };
394394 $point -> slice(" (0)" ) +=
395- 0.5+( $data -> slice(" (0)" )- $this -> { Center }[0] ) /
395+ 0.5+$data01_ctr -> slice(" (0)" ) /
396396 $longrange
397397 *cos ($data -> slice(" (1)" )*DEG2RAD);
398398 $point -> slice(" (1)" ) +=
399- 0.5+( $data -> slice(" (1)" )- $this -> { Center }[1] ) /
399+ 0.5+$data01_ctr -> slice(" (1)" ) /
400400 $latrange
401401 *cos ($data -> slice(" (1)" )*DEG2RAD);
402402# Longitude transformation
0 commit comments