Thanks Craig,
That is exactly what I wanted to do. I had used which originally, but
then switched to where so that I could see what I was selecting. With
one column it seemed to work the way I wanted, but when I tried to
select multiples I ended up with the results shown. I forgot that what I
really wanted was the indexes for the slice. It does take a bit of
wrapping yourself in a new way of looking at things.
After reviewing what I thought I could do, it seems that I will have at
least one more question.....
How does one put an entire time stamp - YMDHMS.S in to a single column?
When I bring in the time stamp (from the time precise module- seems that
it represents the data as an array) I end up with each element Y M D H M
S .S each going to its own column index, even if I use the:
$time=PDL->new($time_s);
$tmp=pdl($mySector,$carrNum,$time,$1,$2);
if (!nelem($rx)) {
$rx=transpose($tmp);
}else {
$rx=transpose($tmp)->glue(1,$rx);
}
I still end up with a piddle that looks like:
[
[ 1 1 2009 114 134]
[ 0 0 4 0 0]
[ 0 0 14 0 0]
[ 0 0 7 0 0]
[ 0 0 15 0 0]
[ 0 0 8 0 0]
[ 0 0 0.364995 0 0]
]
Where the Timestamp takes up 7 elements.
Any ideas?
Cliff Sobchuk esn 758-2063, (403)769-2063. fax 769-8854
Nortel Core RF Field Support: All information is Nortel confidential.
________________________________
From: Craig DeForest [mailto:[email protected]]
Sent: April 13, 2009 10:42 PM
To: Sobchuk, Cliff (WIC:W788)
Cc: Craig DeForest; [email protected]
Subject: Re: [Perldl] Help with slices?
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