Hi Chris: Thanks. I'm looking forward to these improved messages.
Regards,
Doug
[email protected]
Software Engineer
UCAR - COSMIC, Tel. (303) 497-2611
On Tue, 10 Dec 2013, Chris Marshall wrote:
Doug-
One step in the right direction is that Craig has improved the completeness
and clarity of the threading error messages. Once we get an official release
out with those, it should be easier to figure out working threading constructs.
--Chris
On Mon, Dec 9, 2013 at 3:27 PM, Doug Hunt <[email protected]> wrote:
Thanks, Craig: That worked magically!
--Doug
[email protected]
Software Engineer
UCAR - COSMIC, Tel. (303) 497-2611
On Mon, 9 Dec 2013, Craig DeForest wrote:
(As always, I hit "send" a moment too soon...)
That problem is a good example of the maxim that "when in doubt, add more
dimensions"... :-) Interpolators are particularly confusing because they
have to have a different number of active dims in different parameters/terms
-- hence Chris's recent example, and the I-hope-now-well-known wart with
index() threading...
On Dec 9, 2013, at 9:44 AM, Craig DeForest <[email protected]>
wrote:
Hmmmm..
If I understand right, you've enumerated the altitudes in lgrid and
hgrid. Since you're interpolating over altitude, you want that moved to the
pole position in the dim list in your $x and $y for your dplinear call.
Everything else can be left alone. You want:
* active dim: lgrid-altitude
* thread dims: lat, lon, and hgrid-altitude
After that, it's easy:
$hg= Dutil::dplinear( $lgrid->mv(2,0), # (n: lo-alt, t0: lat, t1: lon)
$t->mv(2,0), # (n: lo-alt, t0: lat, t1: lon)
$hg # (t0: lat, t1: lon, t2: hi-alt)
);
I named the dimensions of each term, for clarity: 'n' is the active dim
in the signature, the 't' dimensions are the thread dimensions. Note that
$hg (the 'in()' term) is missing the active dim 'n', as the signature
requires.
On Dec 9, 2013, at 8:56 AM, Doug Hunt <[email protected]> wrote:
Hi PDL folks: I just wrote a function that I think should be
thread-able, but I can't think how. Any ideas welcome.
This function is used to up-sample a weather model grid via linear
interpolation. I use the local PP function Dutil::dplinear to do this. It
may be better to use other PDL interpolation functions, but I've been using
this for years and I know just what it does. Here is its signature:
dplinear (x(n); y(n); in(); [o]out())
It is just a simple interpolation routine which takes $x and $y vectors
as input, along with one value in $x-space to interpolate into $y space.
The tricky bit here is that two sorts of threading are necessary:
1) Interpolating a column of input temperatures via the $x and $y input
to dplinear.
2) Threading over all the lat/lon columns in the input temperature grid
$t. The tricky bit is that the pressure values are different for each
column--this model does not use standard pressure levels, but the pressure
levels at each grid point depend upon the surface pressure.
Any ideas? Please let me know if this is not clear...
Regards,
Doug Hunt
--------------------------------------------------------------------------------------
sub upsampleGrid {
my $lgrid = shift; # low resolution (half) pressure grid: lat x lon x
92 levels
my $hgrid = shift; # high resolution (half) pressure grid: lat x lon x
138 levels
my $t = shift; # temperature grid to upsample: lat x lon x level
my ($nlat, $nlon, $llvl) = $t->dims; # llvl = 92
my $hlvl = ($hgrid->dims)[2]; # 138
my $ht = zeroes($nlat, $nlon, $hlvl); # high resolution output grid
# This could be sped up with threading, I feel sure...
for (my $lati=0;$lati<$nlat;$lati++) {
for (my $loni=0;$loni<$nlon;$loni++) {
my $x = $lgrid->(($lati),($loni),:);
my $y = $t->(($lati),($loni),:);
my $in = $hgrid->(($lati),($loni),:);
$hg(($lati),($loni),:) .= Dutil::dplinear($x, $y, $in);
}
}
return $hg;
}
--------------------------------------------------------------------------------------
[email protected]
Software Engineer
UCAR - COSMIC, Tel. (303) 497-2611
_______________________________________________
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
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl