[PYTHON MATRIX-SIG] Creating grid object
janko hauser
jhauser@ifm.uni-kiel.de
Tue, 8 Oct 1996 14:06:10 +0200
Hello, I want to use Numpy (is this name "official"?) to build an
analysis package for a numerical model. At the moment I implement some
simple functions, which are working on array-arguments. Now I get the
idea, that it would nice to have an array-object of a variable say
salinity, with an attribut about the edges of the grid the variable is
defined on, so that I can work on arbitray blocks and can get the
information where this block is later.
I want to define the hole grid as a global variable and let the edges
in the new object point at a subregion of the grid. I'm new to python
and object-oriented programming, but I think that I must define my own
class. My problem now is, that I want to do normal math directly with
this object, like
sal_anomaly_on_grid = sal_on_grid - mean_sal_in_depth_on_this_grid
^new object ^new object ^normal 1d array
At the moment I know only to do something like
sal_anomaly_on_grid = sal_on_grid.data - mean_sal_in_depth_on_this_grid
^normal array ^new object ^normal array
My grid is defined in two 2d-arrays x_loc,y_loc and one 3d-array z with
depth of x,y in n layers. My first idea is to have an attribut in the new
object, wich is a list of 16 points
x_loc(index_of_x_starting_location)
x_loc(index_of_y_starting_location)
x_loc(index_of_x_stop_location)
x_loc(index_of_y_stop_location)
4 y_loc(...)
8 z
But it would be better, to have references to each gridpoint, to allow
more flexibel grids, but this is perhaps memory-consuming. Is it
possible to build something like this? Is the definition of such
classes covered in one of the new python-books? Or must I program
something in C (I hope not).
Last but not least, is this group the right place to ask? I think I
will have more questions in the future.
TIA
Janko Hauser
=================
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================