[GRASS-dev] matplotlib example script

Yann Chemin yann.chemin at gmail.com
Fri Jul 25 19:09:23 EDT 2008


Hi,

after chmod +x, it created a nice histogram of elevation.10m.
So I tried on floating point image created by some process.

here is the problem:
Traceback (most recent call last):
  File "/home/yann/histogram_mpldemo.py", line 173, in <module>
    main()
  File "/home/yann/histogram_mpldemo.py", line 159, in main
    alpha=0.75)
  File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 6035, in hist
    normed=bool(normed), new=True)
  File "/usr/lib/python2.5/site-packages/numpy/lib/function_base.py",
line 236, in histogram
    range = (a.min(), a.max())
ValueError: zero-size array to ufunc.reduce without identity


this happens because the data has NAN (see r.info output):
 Range of data:    min = nan  max = nan

Is there a way to discard NAN in a.min() and a.max() calculations?
Or is there a NAN-resistant mode in matplotlib?

Yann


More information about the grass-dev mailing list