in reply to Re: Grouping one piddle based on ranges of another
in thread Grouping one piddle based on ranges of another
My apologies; I had modified the appearance to try to make it more clear what I was attempting. I've fixed it now and the code runs as written.
Yes, you are correct about the intermediate piddles (the ones of which I am finding the median) being different lengths. I was thinking perhaps there's some way to expand into extra dimensions, where each dimension would contain the values in a given $b range, and then take medover the entire array to condense it into the form of $d. Is this possible?
Like this, only without having to manually type all of the $mask(..) .= 1 lines:
pdl> $e = $a(,,*3)->copy pdl> p $e [ [ [ 0 6 18 7 19 3 10 2 12 4 8 9 1 15 11 11 19 17 0 9] ] [ [ 0 6 18 7 19 3 10 2 12 4 8 9 1 15 11 11 19 17 0 9] ] [ [ 0 6 18 7 19 3 10 2 12 4 8 9 1 15 11 11 19 17 0 9] ] ] pdl> $mask = $e->zeroes pdl> $mask(,,0)->where(($b>0)*($b<=5)) .= 1 pdl> $mask(,,1)->where(($b>5)*($b<=10)) .= 1 pdl> $mask(,,2)->where(($b>10)*($b<=15)) .= 1 pdl> p $mask [ [ [0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0] ] [ [0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0] ] [ [0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1] ] ] pdl> $mask = $mask->setbadif($mask==0) pdl> p $mask [ [ [BAD 1 1 1 1 1 BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD + BAD BAD BAD] ] [ [BAD BAD BAD BAD BAD BAD 1 1 1 1 1 BAD BAD BAD BAD BAD BAD + BAD BAD BAD] ] [ [BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD 1 1 1 1 1 1 + 1 1 1] ] ] pdl> $f = $e*$mask pdl> p $f [ [ [BAD 6 18 7 19 3 BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD + BAD BAD BAD] ] [ [BAD BAD BAD BAD BAD BAD 10 2 12 4 8 BAD BAD BAD BAD BAD BAD + BAD BAD BAD] ] [ [BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD 9 1 15 11 11 19 + 17 0 9] ] ] pdl> $g = $f->medover pdl> p $g [ [ 7] [ 8] [11] ]
Thank you very much for your help!
|
|---|