Skip to content

Commit f709e10

Browse files
committed
simplify $data in Cyl::transform
1 parent 5fe04cc commit f709e10

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

lib/PDL/Graphics/TriD/Graph.pm

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,16 @@ sub transform {
317317
barf "Wrong number of arguments to transform $this\n" if @$inds != 3;
318318
my ($longrange, $latrange) = map $this->{Scale}[$_][1] - $this->{Scale}[$_][0], 0,1;
319319
my $pressure_max = $this->{Scale}[2][1];
320+
$data = $data->dice_axis(0, $inds);
320321
$point->slice("(0)") +=
321-
0.5+($data->slice("($inds->[0])")-$this->{Center}[0]) /
322+
0.5+($data->slice("(0)")-$this->{Center}[0]) /
322323
$longrange
323-
*cos($data->slice("($inds->[1])")*DEG2RAD);
324+
*cos($data->slice("(1)")*DEG2RAD);
324325
$point->slice("(1)") +=
325-
0.5+($data->slice("($inds->[1])")-$this->{Center}[1]) /
326+
0.5+($data->slice("(1)")-$this->{Center}[1]) /
326327
$latrange;
327328
$point->slice("(2)") .=
328-
log($data->slice("($inds->[2])")/1012.5)/log($pressure_max/1012.5);
329+
log($data->slice("(2)")/1012.5)/log($pressure_max/1012.5);
329330
$point;
330331
}
331332

@@ -417,14 +418,15 @@ sub transform {
417418
PDL::barf "no \$inds given" if !defined $inds;
418419
my $i = 0;
419420
barf "Wrong number of arguments to transform $this\n" if @$inds != 3;
421+
$data = $data->dice_axis(0, $inds);
420422
$point->slice("(0)") +=
421-
0.5+($data->slice("($inds->[0])")-$this->{Center}[0]) /
423+
0.5+($data->slice("(0)")-$this->{Center}[0]) /
422424
($this->{Scale}[0][1] - $this->{Scale}[0][0])
423-
*cos($data->slice("($inds->[1])")*DEG2RAD);
425+
*cos($data->slice("(1)")*DEG2RAD);
424426
$point->slice("(1)") +=
425-
0.5+($data->slice("($inds->[1])")-$this->{Center}[1]) /
427+
0.5+($data->slice("(1)")-$this->{Center}[1]) /
426428
($this->{Scale}[1][1] - $this->{Scale}[1][0])
427-
*cos($data->slice("($inds->[1])")*DEG2RAD);
429+
*cos($data->slice("(1)")*DEG2RAD);
428430
# Longitude transformation
429431
# $point->slice("(0)") =
430432
# ($this->{Center}[0]-$point->slice("(0)"))*cos($data->slice("(1)"));
@@ -434,7 +436,7 @@ sub transform {
434436
# Vertical transformation
435437
# -7.2*log($data->slice("(2)")/1012.5
436438
$point->slice("(2)") .=
437-
log($data->slice("($inds->[2])")/1012.5)/log($this->{Scale}[2][1]/1012.5);
439+
log($data->slice("(2)")/1012.5)/log($this->{Scale}[2][1]/1012.5);
438440
$point;
439441
}
440442

0 commit comments

Comments
 (0)