Diab Jerius wrote:
> I'm trying to simulate the effects of spectral pileup in a detector.
> Incoming event are transformed into a pseudo-Gaussian shaped signal
> (f(t)). If two or more events occur too close together their signals
> overlap.
>
> As a prototype I thought I could use the range operator to construct
> views onto a piddle that would allow me to easily add overlapping
> signals.
>
> For example, given
>
> $ph : the signal function with dimension [$nsample]
> $t: the arrival time of events with dimension [$nevents]
> $buffer: the coadded signals
>
> Then
>
> $bp = $buffer->range($t->transpose,$nsample)->transpose;
>
> is a set of $nsample windows onto $buffer, some of which may overlap.
> Theoretically I could then perform
>
> $bp += $ph
>
> and $buffer would contain the coadded signals. Alas, this doesn't seem
> to work. Here's an abstracted example
>
> $z = xvals(20);
> $v = $z->range( pdl( 1,8 )->transpose, 9 )->transpose;
>
> p $z
> [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
>
> p $v
>
> [
> [ 1 2 3 4 5 6 7 8 9]
> [ 8 9 10 11 12 13 14 15 16]
> ]
>
> So, $v is a set of two overlapping windows onto $z. But,
>
> $v += 1;
>
> p $v
>
> [
> [ 2 3 4 5 6 7 8 9 10]
> [ 9 10 11 12 13 14 15 16 17]
> ]
>
> p $z
> [0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 17 18 19]
>
> The addition is only done once per element in $z, not once per element
> in $v. I expected $v to look like this:
>
> [
> [ 2 3 4 5 6 7 8 10 11]
> [10 11 11 12 13 14 15 16 17]
> ]
>
> and thus for $z to look like this
>
> [0 2 3 4 5 6 7 8 10 11 11 12 13 14 15 16 17 17 18 19]
>
>
> Bug or feature?
>
> Thanks,
>
> Diab
Probably you should call it a known limitation. From the docs for range:
CAVEAT: It's quite possible to select multiple ranges that intersect. In
that case, modifying the ranges doesn't have a guaranteed result in the
original PDL -- the result is an arbitrary choice among the valid
values. For some things that's OK; but for others it's not. In
particular, this doesn't work:
perldl> $photon_list = new PDL::RandVar->sample(500)->reshape(2,250)*10
perldl> histogram = zeroes(10,10)
perldl> histogram->range($photon_list,1)++; #not what you wanted
The reason is that if two photons land in the same bin, then that bin
doesn't get incremented twice. (That may get fixed in a later
version...)
Derek
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl