Quick and dirty list of data associated with nodes, cells, links, and faces

Jan 2016

Raster grid example


In [2]:
from landlab import RasterModelGrid
rg = RasterModelGrid(3, 4)

Data associated with nodes:


In [3]:
rg.number_of_nodes


Out[3]:
12

In [4]:
rg.number_of_node_rows


Out[4]:
3

In [5]:
rg.number_of_node_columns


Out[5]:
4

In [6]:
rg.node_x  # x coord


Out[6]:
array([ 0.,  1.,  2.,  3.,  0.,  1.,  2.,  3.,  0.,  1.,  2.,  3.])

In [7]:
rg.node_y  # y coord


Out[7]:
array([ 0.,  0.,  0.,  0.,  1.,  1.,  1.,  1.,  2.,  2.,  2.,  2.])

In [8]:
rg.status_at_node  # core/boundary status (0=core, 1=FIXED_VALUE_BOUNDARY, 4=CLOSED_BOUNDARY)


Out[8]:
array([1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1], dtype=int8)

In [9]:
rg.cell_at_node  # ID of cell surrounding node, or BAD_INDEX_VALUE if none


Out[9]:
array([2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
                0,          1, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647])

In [10]:
rg.links_at_node  # IDs of links at each node, or -1 if none (ENWS order for raster)


Out[10]:
array([[ 0,  3, -1, -1],
       [ 1,  4,  0, -1],
       [ 2,  5,  1, -1],
       [-1,  6,  2, -1],
       [ 7, 10, -1,  3],
       [ 8, 11,  7,  4],
       [ 9, 12,  8,  5],
       [-1, 13,  9,  6],
       [14, -1, -1, 10],
       [15, -1, 14, 11],
       [16, -1, 15, 12],
       [-1, -1, 16, 13]])

In [11]:
rg.link_dirs_at_node


Out[11]:
array([[-1, -1,  0,  0],
       [-1, -1,  1,  0],
       [-1, -1,  1,  0],
       [ 0, -1,  1,  0],
       [-1, -1,  0,  1],
       [-1, -1,  1,  1],
       [-1, -1,  1,  1],
       [ 0, -1,  1,  1],
       [-1,  0,  0,  1],
       [-1,  0,  1,  1],
       [-1,  0,  1,  1],
       [ 0,  0,  1,  1]], dtype=int8)

Data associated with cells:


In [12]:
rg.number_of_cells


Out[12]:
2

In [13]:
rg.area_of_cell


Out[13]:
array([ 1.,  1.])

In [14]:
rg.node_at_cell


Out[14]:
array([5, 6])

In [15]:
rg.faces_at_cell()   # should be made into a property (Eric is working on this)


Out[15]:
array([[0, 2, 5, 3],
       [1, 3, 6, 4]])

Data associated with links:


In [16]:
rg.number_of_links


Out[16]:
17

In [17]:
rg.link_length  # naming: <element>_<attribute> vs <attribute>_of_<element> (disc. in prog)


Out[17]:
array([ 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,
        1.,  1.,  1.,  1.])

In [18]:
rg.node_at_link_tail


Out[18]:
array([ 0,  1,  2,  0,  1,  2,  3,  4,  5,  6,  4,  5,  6,  7,  8,  9, 10])

In [19]:
rg.node_at_link_head


Out[19]:
array([ 1,  2,  3,  4,  5,  6,  7,  5,  6,  7,  8,  9, 10, 11,  9, 10, 11])

In [20]:
rg.face_at_link  # ID of face at each link, or BAD_INDEX_VALUE if none


Out[20]:
array([2147483647, 2147483647, 2147483647, 2147483647,          0,
                1, 2147483647,          2,          3,          4,
       2147483647,          5,          6, 2147483647, 2147483647,
       2147483647, 2147483647])

Data associated with faces


In [21]:
rg.number_of_faces


Out[21]:
7

In [22]:
rg.face_width


Out[22]:
array([ 1.,  1.,  1.,  1.,  1.,  1.,  1.])

In [23]:
rg.link_at_face  # ID of link that crosses each face


Out[23]:
array([ 4,  5,  7,  8,  9, 11, 12])

Hex grid (Voronoi subclass) example


In [24]:
from landlab import HexModelGrid
hg = HexModelGrid(3, 3)

Data associated with nodes


In [25]:
hg.number_of_nodes


Out[25]:
10

In [26]:
hg.node_x


Out[26]:
array([ 0. ,  1. ,  2. , -0.5,  0.5,  1.5,  2.5,  0. ,  1. ,  2. ])

In [27]:
hg.node_y


Out[27]:
array([ 0.        ,  0.        ,  0.        ,  0.8660254 ,  0.8660254 ,
        0.8660254 ,  0.8660254 ,  1.73205081,  1.73205081,  1.73205081])

In [28]:
hg.status_at_node


Out[28]:
array([1, 1, 1, 1, 0, 0, 1, 1, 1, 1], dtype=int8)

In [29]:
hg.cell_at_node


Out[29]:
array([2147483647, 2147483647, 2147483647, 2147483647,          0,
                1, 2147483647, 2147483647, 2147483647, 2147483647])

In [30]:
hg.links_at_node  # Note that these are sorted by angle, CCW from +x


Out[30]:
array([[ 0,  3,  2, -1, -1, -1],
       [ 1,  5,  4,  0, -1, -1],
       [ 7,  6,  1, -1, -1, -1],
       [ 8, 11,  2, -1, -1, -1],
       [ 9, 13, 12,  8,  3,  4],
       [10, 15, 14,  9,  5,  6],
       [16, 10,  7, -1, -1, -1],
       [17, 11, 12, -1, -1, -1],
       [18, 17, 13, 14, -1, -1],
       [18, 15, 16, -1, -1, -1]], dtype=int32)

In [31]:
hg.link_dirs_at_node  # link direction relative to node: +1 incoming, -1 outgoing, 0 none


Out[31]:
array([[-1, -1, -1,  0,  0,  0],
       [-1, -1, -1,  1,  0,  0],
       [-1, -1,  1,  0,  0,  0],
       [-1, -1,  1,  0,  0,  0],
       [-1, -1, -1,  1,  1,  1],
       [-1, -1, -1,  1,  1,  1],
       [-1,  1,  1,  0,  0,  0],
       [-1,  1,  1,  0,  0,  0],
       [-1,  1,  1,  1,  0,  0],
       [ 1,  1,  1,  0,  0,  0]], dtype=int8)

Data associated with cells


In [32]:
hg.number_of_cells


Out[32]:
2

In [33]:
hg.area_of_cell


Out[33]:
array([ 0.8660254,  0.8660254])

In [34]:
hg.node_at_cell


Out[34]:
array([4, 5])

In [35]:
hg.faces_at_cell


Out[35]:
array([[ 5,  8,  7,  4,  0,  1],
       [ 6, 10,  9,  5,  2,  3]])

In [36]:
hg.number_of_links


Out[36]:
19

In [37]:
hg.link_length


Out[37]:
array([ 1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,  1.,
        1.,  1.,  1.,  1.,  1.,  1.])

In [38]:
hg.node_at_link_tail


Out[38]:
array([0, 1, 0, 0, 1, 1, 2, 2, 3, 4, 5, 3, 4, 4, 5, 5, 6, 7, 8])

In [39]:
hg.node_at_link_head


Out[39]:
array([1, 2, 3, 4, 4, 5, 5, 6, 4, 5, 6, 7, 7, 8, 8, 9, 9, 8, 9])

In [40]:
hg.face_at_link


Out[40]:
array([2147483647, 2147483647, 2147483647,          0,          1,
                2,          3, 2147483647,          4,          5,
                6, 2147483647,          7,          8,          9,
               10, 2147483647, 2147483647, 2147483647])

Data associated with faces


In [41]:
hg.number_of_faces


Out[41]:
11

In [42]:
hg.face_width


Out[42]:
array([ 0.57735027,  0.57735027,  0.57735027,  0.57735027,  0.57735027,
        0.57735027,  0.57735027,  0.57735027,  0.57735027,  0.57735027,
        0.57735027])

In [43]:
hg.link_at_face


Out[43]:
array([ 3,  4,  5,  6,  8,  9, 10, 12, 13, 14, 15])

In [ ]:


In [ ]: