Module: gridutil

7 Functions

hexrd.gridutil.cellIndices(edges, points_1d)[source]

get indices in a 1-d regular grid.

edges are just that:

point: x (2.5)

edges: |1 |2 |3 |4 |5
indices: | 0 | 1 | 2 | 3 |

above the deltas are + and the index for the point is 1

point: x (2.5)

edges: |5 |4 |3 |2 |1
indices: | 0 | 1 | 2 | 3 |

here the deltas are - and the index for the point is 2

  • can handle grids with +/- deltas
  • be careful when using with a cyclical angular array! edges and points must be mapped to the same branch cut, and abs(edges[0] - edges[-1]) = 2*pi
hexrd.gridutil.cellConnectivity(m, n, p=1, origin='ul')[source]

p x m x n (layers x rows x cols)

origin can be upper left – ‘ul’ <default> or lower left – ‘ll’

choice will affect handedness (cw or ccw)

hexrd.gridutil.cellCentroids(crd, con)[source]

con.shape = (nele, 4) crd.shape = (ncrd, 2)

con.shape = (nele, 8) crd.shape = (ncrd, 3)

hexrd.gridutil.computeArea(polygon)[source]

must be ORDERED and CONVEX!

hexrd.gridutil.computeIntersection(line1, line2)[source]

compute intersection of two-dimensional line intersection

this is an implementation of two lines:

line1 = [ [x0, y0], [x1, y1] ] line1 = [ [x3, y3], [x4, y4] ]

hexrd.gridutil.isinside(point, boundary, ccw=True)[source]

Assumes CCW boundary ordering

hexrd.gridutil.sutherlandHodgman(subjectPolygon, clipPolygon)[source]