Wanted: nifty one-liners for PDL demo this aft. Could be any field, but
more fun if they are spatial data/remote sensing related. But really,
niftiness trumps field. Please share your craft. In return, I will put
all of these up in the cookbook.
For now, besides the intro to PDL, and basic manipulation of piddles
(cribbed from Chapter 2 of the book), I have the following that I use
myself --
#### !Up sample a piddle
have: $in = [
[1 0 8]
[6 3 5]
[3 0 5]
]
want: $out = [
[1 1 1 0 0 0 8 8 8]
[1 1 1 0 0 0 8 8 8]
[1 1 1 0 0 0 8 8 8]
[6 6 6 3 3 3 5 5 5]
[6 6 6 3 3 3 5 5 5]
[6 6 6 3 3 3 5 5 5]
[3 3 3 0 0 0 5 5 5]
[3 3 3 0 0 0 5 5 5]
[3 3 3 0 0 0 5 5 5]
]
pdl> use PDL::NiceSlice
pdl> $out = $in(*$n,:,*$n,:)->clump(0,1)->clump(1,2)
#### !Piddle of n dims with elements MIN < random int < MAX
pdl> $a = (random(5,5,3)*(1000-500+1)+500)->floor
#### !Flip vertical (tv scan problem)
have: [
[1 0 8]
[6 3 5]
[3 0 5]
]
want: [
[3 0 5]
[6 3 5]
[1 0 8]
]
pdl> $in = pdl [[1, 0, 8],[6, 3, 5],[3, 0, 5],[2, 4, 2]]
pdl> p $in->slice(':,-1:0:-1')
#### !Extract rectangle
pdl> $a = (random(5,5)*(1000-500+1)+500)->floor
pdl> p $a(1:3,2:4)
pdl> p $a->range([1,2],[3,3])
#### !Karl's point-in-poly
#### !Game of life
#### !Create images from 3D output from IDL
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl