Hi, Cliff,
One problem is that you're using where(), when you want which(). The
former returns the actual elements that match the mask criterion, in
this case the elements of $a that correspond to the places where your
mask "$a(0)==1" is true. This is doubly wrong, because the thing
you're asking where() to index is $a itself, which is treated as
flat. You'll note that the first three values of $a(0) are all 1, so
where() is returning the first three values of $a itself: (1,1,2).
Thus your slice is returning columns 3 and 4 (which you want) from
rows 1, 1, and 2 in order.
You almost certainly want the expression "$a->(3:4, which($a((0))==1)"
instead. (The double parens aren't strictly necessary but are cleaner
-- you want to obliterate the 0 dimension, not just reduce it to size
1...)
On Apr 13, 2009, at 5:05 PM, Cliff Sobchuk wrote:
Hi folks, This is my first real foray in to using PDL for an entire
program. The basis of the program is to use Perl to parse values
from a text file that indicate specifics of
[place1 place2 time measurement1 measurement2]
I am using glue to build up the piddle for each col, row index. To
analyze the data though I need to perform stats and histogram
profiles for each place1,place2 of measurement1, measurement2. I
thought that I could simply slice out the data using nslice and
where. However, I don't get what I expect out when I try it on
sample data. I have gone through the documentation, but have not
found any examples to do what I am trying to do.
My example data is :
perldl> p $a
[
[ 1 1 2 3 4]
[ 1 1 7 8 9]
[ 1 1 12 13 14]
[ 2 1 17 18 19]
[ 2 1 22 23 24]
[ 2 1 27 28 29]
[ 3 1 32 33 34]
[ 3 1 37 38 39]
[ 3 1 42 43 44]
]
To get the data for columns 3 & 4 (the measure columns) I used :
p $a->nslice([3,4],$a->where($a(0)==1))
which provided me with :
[
[ 8 9]
[ 8 9]
[13 14]
]
What I expected to get was column 3 & 4 for the mask defined by :
perldl> p ($a(0)==1)->(3,4)
[
[1]
[1]
[1]
[0]
[0]
[0]
[0]
[0]
[0]
]
Can't call method "nslice" without a package or object reference
I don't know why I get the warning/error - but the correct rows were
selected.
What am I doing wrong and how do I get:
[
[ 3 4]
[ 8 9]
[13 14]
]
Thanks,
Cliff Sobchuk
Core RF Field Support Engineer
Phone: (403) 769 2063 / ESN 758
<emailsig_static_orange.gif>
Confidentiality Notice:This message and any attachments may contain
information that is privileged and confidential. If you have reason
to believe that you are not the intended recipient or a person
responsible for delivering this message to an intended recipient,
you are hereby notified that any review, dissemination,
distribution, or copying of this message is strictly prohibited. If
you have reason to believe that you are not the intended recipient
or a person responsible for delivering this message to an intended
recipient, please contact the sender immediately by reply email and
destroy all copies of the original message.
_______________________________________________
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