# [Numpy-discussion] Specially Constructed Arrays

Ian Mallett geometrian@gmail....
Wed Apr 8 20:39:14 CDT 2009

```Hello,

I want to make an array of size sqrt(n) by sqrt(n) by 3, filled with special
values.

The values range from 0.0 to 3.0, starting with 0.0 at one corner and ending
at 3.0 in the opposite, increasing going row by row.  The value is to be
encoded in each color.  Because this is somewhat abstract, here's a small
example (n=25), generated using the attached code (it also multiplies the
number by 255 to obtain a RGB color and not messy floats) to show the
concept.  The real version should be done by NumPy.  This is where I need
help; I have no idea how to even approach the problem.

[[  0,  0,  0],[ 32,  0,  0],[ 64,  0,  0],[ 96,  0,  0],[128,  0,  0],
[159,  0,  0],[191,  0,  0],[223,  0,  0],[255,  0,  0],[255, 32,  0],
[255, 64,  0],[255, 96,  0],[255,128,  0],[255,159,  0],[255,191,  0],
[255,223,  0],[255,255,  0],[255,255, 32],[255,255, 64],[255,255, 96],
[255,255,128],[255,255,159],[255,255,191],[255,255,223],[255,255,255]]

Arrays like this need to be generated quite quickly, so the per-pixel method
I presented will not work.  How should I do it with NumPy?

Thanks,
Ian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090408/b893c033/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: particlesurfgen.py
Type: text/x-python
Size: 869 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090408/b893c033/attachment.py
```