A way to compute a 2d histogram
Nicolas Champavert
nicolas.champavert at obs.univ-lyon1.fr
Wed Oct 25 06:56:04 CDT 2006
Hi,
there is a problem when using this patch of numpy.histogram2d.
I've tried:
a=pylab.rand(10)
numpy.histogram2d(a,a)
and there is an exception (exceptions.AttributeError) in
numpy.histogramdd function called by numpy.histogram2d.
But numpy.histogram2d(a,a,bins=[10,10]) works.
So I've tried to use directly numpy.histogramdd function:
numpy.histogramdd([a,a])
and it works.
I've looked at the histogram2d code:
try:
N = len(bins)
except TypeError:
N = 1
bins = [bins]
I think the last line (bins = [bins]) have to be deleted because if you
do so, numpy.histogram2d(a,a) works.
Or maybe the good think to do is:
try:
N = len(bins)
except TypeError:
N = 1
bins = 2*[bins]
Nicolas
David Huard a écrit :
> Xavier,
> Here is the patch against svn. Please report any bug. I haven't had
> the time to test it extensively, something that should be done before
> commiting the patch to the repo. I'd appreciate your feedback.
>
> David
>
> 2006/10/24, David Huard <david.huard at gmail.com
> <mailto:david.huard at gmail.com>>:
>
> Hi Xavier,
>
> You could tweak histogram2d to do what you want, or you could give
> me a couple of days and I'll do it and let you know. If you want
> to help, you could write a test using your particular application
> and data.
>
> David
>
>
>
>
>
>
>
>
>
>
>
> 2006/10/24, Xavier Gnata < gnata at obs.univ-lyon1.fr
> <mailto:gnata at obs.univ-lyon1.fr>>:
>
> Hi,
>
> I have a set of 3 1D large arrays.
> The first 2 one stand for the coordinates of particules and
> the last one
> for their masses.
> I would like to be able to plot this data ie to compute a 2D
> histogram
> summing the masses in each bin.
> I cannot find a way to do that without any loop on the indices
> resulting
> too a very slow function.
>
> I'm looking for an elegant way to do that with numpy (or
> scipy??) function.
>
> For instance, scipy.histogram2d cannot do the job because it
> only counts
> the number of samples in each bin.
> There is no way to deal with weights.
>
> Xavier.
>
>
> --
> ############################################
> Xavier Gnata
> CRAL - Observatoire de Lyon
> 9, avenue Charles André
> 69561 Saint Genis Laval cedex
> Phone: +33 4 78 86 85 28
> Fax: +33 4 78 86 83 86
> E-mail: gnata at obs.univ-lyon1.fr <mailto:gnata at obs.univ-lyon1.fr>
> ############################################
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web
> services, security?
> Get stuff done quickly with pre-integrated technology to make
> your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on
> Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> <http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> <mailto:Numpy-discussion at lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>
>
> ------------------------------------------------------------------------
>
>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
More information about the Numpy-discussion
mailing list