pyrw documentation¶
API:¶
pyrw.RWdomain module¶
-
class
pyrw.RWdomain.
domain
(RW, typ='poly')¶ Domain class for defining random walk domain.
Parameters: - RW (pyrw.RWRW) – A pyrw RW.
- typ (str) – Type of domain
-
addArc
(vstart, vcenter=None, vend=None, angle=None)¶ Adds arc from vstart to vend around vcenter to domain.
Parameters: - vstart (pyrw.geometry.vertex) – Vertex object.
- vcenter (pyrw.geometry.vertex) – Vertex object.
- vend (pyrw.geometry.vertex) – Vertex object.
- angle (float) – Angle.
Returns: pyrw.geometry.arc – arc object
-
addCircle
(vcenter, radius, BC='')¶ Adds circle around vcenter with r=radius to domain.
Parameters: - vcenter (pyrw.geometry.vertex) – Vertex object.
- radius (float) – Radius of circle.
Returns: pyrw.geometry.circle – circle object
-
addLine
(v1, v2)¶ Adds line from v1 to v2 to domain.
Parameters: - v1 (pyrw.geometry.vertex) – Vertex object.
- v2 (pyrw.geometry.vertex) – Vertex object.
Returns: pyrw.geometry.line – line object
-
addRectangle
(voffset, lenx, leny)¶ Adds rectangle with offset voffset and sidelengths lenx,leny to domain.
Parameters: - voffset (pyrw.geometry.vertex) – Vertex object.
- lenx (float) – Sidelength in x direction.
- leny (float) – Sidelength in y direction.
Returns: pyrw.geometry.rectangle – rectangle object
-
addVertex
(x)¶ Adds vertex to domain.
Parameters: x (pyrw.RWRW) – 2D coordinate. Returns: pyrw.geometry.vertex – vertex object
-
draw
(r=None, color=None, ann=False)¶ Draw all geometrical elements associated with domain.
Parameters: - r (pyrw.RWrun) – pyrw run, if None, picks last run of main pyrw.RWRW object.
- color (matplotlib color) – color of elements in matplotlib syntax, e.g. ‘r’ or (0.1,1,0.5)
- ann (bool) – Annotation Flag
-
edgeByID
(ID)¶ Returns edge given its ID
Parameters: ID (int) – ID of edge. Returns: pyrw.geometry.edge – edge object
-
genRandomPoint
()¶ Returns random coordinate inside domain.
Returns: array – coordinate
-
getExtend
()¶ Returns x-y-extend of domain.
Returns: (float,float,float,float) – (minX,maxX,minY,maxY)
-
setRW
(rw)¶
-
verticesCoordsToList
()¶ Returns list with coordinates of all vertices of domain.
Returns: list – list with coordinates
pyrw.RWHC module¶
-
class
pyrw.RWHC.
none
(RW, w, Id, suc=1.0)¶ Bases:
pyrw.RWHC.HC
-
hit
()¶
-
-
class
pyrw.RWHC.
stop
(RW, w, Id, suc=1.0)¶ Bases:
pyrw.RWHC.HC
-
hit
(suc=1.0, debug=False)¶
-
pyrw.RWrun module¶
-
class
pyrw.RWrun.
run
(RW)¶ -
checkFig
()¶
-
computeEndStastics
()¶
-
doStep
(debug=False)¶
-
getGroupOfInterest
()¶
-
getRuntime
()¶
-
getWalkerOfInterest
()¶
-
plotStep
(color=None)¶
-
plotTraj
(color=None)¶
-
scalePlot
()¶
-
setGroupOfInterest
(group)¶
-
setWalkerOfInterest
(w)¶
-
start
(plotStep=False, printProcess=False)¶
-
stop
(stopped)¶
-
pyrw.RWstep module¶
-
class
pyrw.RWstep.
CCRWstep
(w, r1, r2, gamma, kappa)¶ Bases:
pyrw.RWstep.step
-
scaleR
(rScale)¶
-
setGamma
(gamma)¶
-
setKappa
(kappa)¶
-
setParms
(parms)¶
-
setR1
(r)¶
-
setR2
(r)¶
-
-
class
pyrw.RWstep.
CRWstep
(w, r1, r2, gamma)¶ Bases:
pyrw.RWstep.step
-
class
pyrw.RWstep.
CorRWstep
(w, r, kappa)¶ Bases:
pyrw.RWstep.step
-
class
pyrw.RWstep.
MRWstep
(w, r)¶ Bases:
pyrw.RWstep.step
pyrw.RWessentials module¶
-
pyrw.RWessentials.
angle_from_vertices
(vcenter, vstart, vend, samedist=False)¶ Returns angle between two vertices around vcenter.
Parameters: - vcenter (pyrw.geometry.vertex) – Vertex object.
- vstart (pyrw.geometry.vertex) – Vertex object.
- vend (pyrw.geometry.vertex) – Vertex object.
- samedist (bool) – Flag if vectors need to have same length.
Returns: float – angle
-
pyrw.RWessentials.
checkInsideCircle
(x, center, radius, tol=1e-30, debug=False)¶ Returns True if x is inside circle.
Parameters: - x (array) – Coordinate.
- center (float) – Coordinate of center.
- radius (float) – Radius of circle.
- center – Tolerance added to check to avoid rounding errors.
- debug (bool) – Debugging flag.
Returns: bool – True if inside
-
pyrw.RWessentials.
checkInsidePoly
(coord, poly)¶ Returns True if coord is inside poly.
Taken from http://www.ariel.com.au/a/python-point-int-poly.html
Parameters: - coord (array) – Coordinate.
- poly (list) – Polygon corners.
Returns: bool – True if inside
-
pyrw.RWessentials.
combinations
(arrays, out=None)¶ Returns cartesian product of arrays.
Parameters: - arrays (list) – List of arrays.
- out (array) – Result vector.
Returns: array – Cartesian product
-
pyrw.RWessentials.
compute_angle
(vec1, vec2)¶ Returns angle between two vectors.
Parameters: - vec1 (array) – Vector.
- vec2 (array) – Vector.
Returns: float – angle
-
pyrw.RWessentials.
create_arc_curve
(vcenter, angle, angle_offset, radius, steps=100)¶ Creates array with points describing the curve of an arc.
Parameters: - vcenter (pyrw.geometry.vertex) – Vertex object.
- angle (float) – Angle of arc.
- angle_offset (float) – Offset angle of arc.
- radius (float) – radius of arc.
- steps (int) – number of steps for arc.
Returns: (array,array) – vectors describing x/y-coordinates
-
pyrw.RWessentials.
cross2d
(x1, x2)¶ Returns reduced 2D cross product.
Parameters: - x1 (array) – Coordinate 1.
- x2 (array) – Coordinate 2.
Returns: float – cross product
-
pyrw.RWessentials.
direc_angle
(v1, v2)¶ Returns directional angle.
Parameters: - v1 (array) – Vector.
- v2 (array) – Vector.
Returns: array – directional angle
-
pyrw.RWessentials.
dist
(p1, p2)¶ Returns euclidean distance between two points.
Parameters: - p1 (array) – Point 1.
- p2 (array) – Point 2.
Returns: float – distance
-
pyrw.RWessentials.
norm
(vec)¶ Returns L2-norm of vector.
Parameters: vec (array) – Vector. Returns: float – length of vector
-
pyrw.RWessentials.
outwPerp
(x, c)¶ Returns outward perpendicular vector.
Parameters: - x (array) – Vector.
- c (array) – Center coordinate.
Returns: array – perpendicular vector
-
pyrw.RWessentials.
perp
(x)¶ Returns perpendicular vector.
Parameters: x (array) – Vector. Returns: array – perpendicular vector
-
pyrw.RWessentials.
unit_vector
(vector)¶ Returns unit vector.
Parameters: vector (array) – Vector. Returns: array – unit vector
pyrw.RWmisc module¶
-
pyrw.RWmisc.
listToCSV
(l, fn=None)¶
-
pyrw.RWmisc.
loadFromPickle
(fn)¶
-
pyrw.RWmisc.
printVariable
(var, obj)¶
-
pyrw.RWmisc.
saveToPickle
(obj, fn=None)¶
-
pyrw.RWmisc.
setVariable
(var, obj, val)¶
pyrw.RWRW module¶
-
class
pyrw.RWRW.
RW
(tstart=0.0, tend=1000.0, deltat=1.0, N=5, P=1, name='RW')¶ -
addNRuns
(N)¶
-
addRun
()¶
-
addWalker
(x0=<Mock name='mock.array()' id='140217938245264'>, RWtyp='MRW', color='b', BCtyp='sticky', HCtyp=None, hitGroup=[], typ='typ0', hitTypes=None, detectRadius=1.0, successRate=1.0)¶
-
computeStatistics
()¶
-
getDomain
()¶
-
getMeanRuntime
()¶
-
getTotalRuntime
()¶
-
getWalkerById
(Id)¶
-
printStatistics
()¶
-
printVariable
(var)¶
-
runAll
(printProcess=True, printRunProcess=False, plotStep=False)¶
-
saveToFile
(fn=None)¶
-
setDomain
(d)¶
-
setVarForAllRuns
(var, val)¶
-
statsToCSV
(fn=None)¶
-
pyrw.RWsuperposition module¶
pyrw.RWBC module¶
-
class
pyrw.RWBC.
BC
(w, typ, Id, edge, direcBehaviour)¶ Bases:
object
-
arcIntersect
(x1, x2, arc, tol=1e-30, spacer=1e-05, breakAtProblem=False, debug=False)¶
-
arcPreChecks
(x1, x2, arc, tol=1e-30, breakAtProblem=False, debug=False)¶
-
checkArcIntersect
(x1, x2, arc, tol=1e-30, spacer=1e-05, breakAtProblem=False, preCheck=True, debug=False)¶
-
circCheck
(x, center, radius, tol=1e-30, debug=False)¶
-
computeArcIntersect
(x1, x2, arc, a, b, discriminant, spacer=1e-05, debug=False)¶
-
cross2d
(x1, x2)¶
-
findIntersectPoly
(xold, xnew, poly)¶
-
perp
(x)¶
-
segIntersect
(x1, x2, y1, y2, debug=False)¶
-
-
class
pyrw.RWBC.
setBack
(w, Id, edge, direcBehaviour=1)¶ Bases:
pyrw.RWBC.BC
-
circleHit
(xold, xnew, breakAtProblem=False, debug=False)¶
-
hit
(xold, xnew, breakAtProblem=False, debug=False)¶
-
-
class
pyrw.RWBC.
sticky
(w, Id, edge, direcBehaviour=1)¶ Bases:
pyrw.RWBC.BC
-
hit
(xold, xnew, debug=False)¶
-
pyrw.RWgeometry module¶
-
class
pyrw.RWgeometry.
arc
(domain, vstart, vcenter, Id, vend=None, angle=None)¶ Bases:
pyrw.RWgeometry.edge
Arc class for defining domain geometry.
Parameters: - domain (pyrw.RWdomain) – A pyrw domain.
- vstart (pyrw.RWgeometry.vertex) – Start vertex of the arc.
- vcenter (pyrw.RWgeometry.vertex) – Center vertex of the arc.
- Id (int) – ID of arc.
- vend (pyrw.RWgeometry.vertex) – Second vertex of the arc.
- angle (float) – Angle of arc.
-
computeAngle
(debug=False)¶ Computes both angle and angle_offset of arc
Parameters: debug (bool) – Debugging flag. Returns: (float,float) – angle, angle_offset
-
computePoint
(angle, radius)¶ Computes point on arc
Parameters: - angle (float) – Point’s angle.
- radius (float) – Point’s radius.
-
computeRadius
()¶
-
computeVend
()¶
-
computeVstart
()¶
-
draw
(r=None, color=None, ann=False)¶ Draw arc
Parameters: - r (pyrw.RWrun) – pyrw run, if None, picks last run of main pyrw.RWRW object.
- color (matplotlib color) – color of arc in matplotlib syntax, e.g. ‘r’ or (0.1,1,0.5)
- ann (bool) – Annotation Flag
-
genFromAngle
(vcenter, vstart, angle)¶ Initializes arc if angle was given at initialization
Parameters: - vstart (pyrw.RWgeometry.vertex) – Start vertex of the arc.
- vcenter (pyrw.RWgeometry.vertex) – Center vertex of the arc.
- angle (float) – Angle of arc.
-
genFromPoints
(vcenter, vstart, vend)¶ Initializes arc if vend was given at initialization
Parameters: - vstart (pyrw.RWgeometry.vertex) – Start vertex of the arc.
- vcenter (pyrw.RWgeometry.vertex) – Center vertex of the arc.
- vend (pyrw.RWgeometry.vertex) – Second vertex of the arc.
-
getAngle
()¶
-
getAngleOffset
()¶
-
getRadius
()¶
-
getVcenter
()¶
-
getVend
()¶
-
getVstart
()¶
-
getXcenter
()¶
-
getXend
()¶
-
getXstart
()¶
-
inArc
(x, debug=False)¶ Checks if points x lies on arc
Parameters: - x (array) – coordinate.
- debug (bool) – Debugging flag.
-
setAngle
(angle)¶
-
setRadius
(radius)¶
-
class
pyrw.RWgeometry.
circle
(domain, vcenter, radius)¶ Circle class for defining domain geometry.
Parameters: - domain (pyrw.RWdomain) – A pyrw domain.
- vcenter (pyrw.RWgeometry.vertex) – Center vertex of the arc.
- radius (float) – Radius.
-
draw
()¶
-
getArcs
()¶
-
getDomain
()¶
-
getRadius
()¶
-
getVcenter
()¶
-
getVertices
()¶
-
getXcenter
()¶
-
setRadius
(radius)¶
-
setVcenter
(v)¶
-
setXcenter
(x)¶
-
class
pyrw.RWgeometry.
edge
(domain, Id, typ)¶ Edge class for defining domain geometry.
Parameters: - domain (pyrw.RWdomain) – A pyrw domain.
- Id (int) – ID of edge.
- typ (int) – Edge type
-
decodeTyp
()¶ Returns type of edge in words.
Returns: str – type of the edge
-
getDomain
()¶
-
getId
()¶
-
getTyp
()¶
-
class
pyrw.RWgeometry.
line
(domain, v1, v2, Id)¶ Bases:
pyrw.RWgeometry.edge
Line class for defining domain geometry.
Parameters: - domain (pyrw.RWdomain) – A pyrw domain.
- Id (int) – ID of line.
- v1 (pyrw.RWgeometry.vertex) – Start vertex of the line.
- v2 (pyrw.RWgeometry.vertex) – Second vertex of the line.
-
draw
(r=None, color=None, ann=False)¶ Draw line
Parameters: - r (pyrw.RWrun) – pyrw run, if None, picks last run of main pyrw.RWRW object.
- color (matplotlib color) – color of line in matplotlib syntax, e.g. ‘r’ or (0.1,1,0.5)
- ann (bool) – Annotation Flag
-
class
pyrw.RWgeometry.
rectangle
(domain, voffset, lenx, leny)¶ Rectangle class for defining domain geometry.
Parameters: - domain (pyrw.RWdomain) – A pyrw domain.
- voffset (pyrw.RWgeometry.vertex) – Offset vertex of the arc.
- lenx (float) – Sidelength in x direction.
- leny (float) – Sidelength in y direction.
-
draw
(r=None, color=None, ann=None)¶
-
getDomain
()¶
-
getEdges
()¶
-
getLenx
()¶
-
getLeny
()¶
-
getVertices
()¶
-
getVoffset
()¶
-
getXoffset
()¶
-
setLenx
(lenx)¶
-
setLeny
(leny)¶
-
setXoffset
(xoffset)¶
-
class
pyrw.RWgeometry.
vertex
(domain, x, Id)¶ Vertex class for defining domain geometry.
Parameters: - domain (pyrw.RWdomain) – A pyrw domain.
- x (array) – A coordinate, e.g. [0,1].
- Id (int) – ID of vertex.
-
draw
(r=None, color=None, ann=False)¶ Draw vertex
Parameters: - r (pyrw.RWrun object) – pyrw run, if None, picks last run of main pyrw.RWRW object.
- color (matplotlib color) – color of vertex in matplotlib syntax, e.g. ‘r’ or (0.1,1,0.5)
- ann (bool) – Annotation Flag
-
setX
(x)¶ Define vertex location
Parameters: x (array) – A coordinate, e.g. [0,1]
pyrw.RWwalker module¶
-
class
pyrw.RWwalker.
walker
(RW, x0=<Mock name='mock.array()' id='140217938245264'>, RWtyp='MRW', color='r', wid=None, BCs=[], BCtyp='sticky', HCtyp=None, hitGroup=[], typ='typ0', hitTypes=None, detectRadius=1.0, successRate=1.0)¶ -
allBCsSame
()¶
-
checkBC
()¶
-
checkHC
()¶
-
computeSquaredDisplacement
()¶
-
computeStatistics
()¶
-
computeTrajLength
()¶
-
genBC
(typ, edge)¶
-
genHC
(typ, hitGroup)¶
-
genHitGroup
()¶
-
genRandomX0
()¶
-
genStep
(typ, rs=[1.0, 3.0], gammas=[0.5, 0.5], kappas=[0.0, 3.0], gammaSup=1, gammaStep=0.1, gammaMin=0.2)¶
-
getBCIds
()¶
-
getDetectRadius
()¶
-
getHitGroupLoc
()¶
-
getSquaredDisplacement
()¶
-
getTrajLength
()¶
-
getX0
()¶
-
plotTraj
(draw=True, color=None)¶
-
setAllBCs
(typ)¶
-
setBC
(typ, ID)¶
-
setCurrRun
(r)¶
-
setDetectRadius
(radius)¶
-
setToStart
()¶
-
setX0
(x0)¶
-
toTraj
()¶
-
updateBCIds
()¶
-
updateBCTyp
()¶
-