Ejemplo n.º 1
0
def drawLines(pw, pointLists=[],
              netStyle = None, netNDiv = 12, netAlpha = 0.5, rMat=None,
              southern=False, invertFromSouthern=True,
              origin=(0.,0.), r=1.0):

    x0, y0 = origin

    lines = pw.a.get_lines()
    for line in lines:
        line.remove()

    ringAngs = num.linspace(0,num.pi*2.,181)
    if netStyle:
        arcAngsM  = num.linspace(-num.pi/2.,num.pi/2.,91)
        arcAngsL  = num.linspace(0, num.pi, 181)
        rMat_yDiv = ors.RotInv(-num.pi/netNDiv, [0,1,0]).toMatrix()
    pw(r*num.cos(ringAngs)+x0,r*num.sin(ringAngs)+y0,style='k-')

    if netStyle:
        nVMerid = num.vstack( ( num.cos(arcAngsM), num.sin(arcAngsM), num.zeros(len(arcAngsM)) ) )
        for iDiv in range(netNDiv-1):
            nVMerid = num.dot(rMat_yDiv, nVMerid)
            eaProj = n2eap(nVMerid, flip=False)
            pw(r*eaProj[0,:]+x0, r*eaProj[1,:]+y0, alpha=netAlpha, style=netStyle)
        for latAng in num.pi/netNDiv*num.arange(1,netNDiv):
            polZ = num.cos(latAng)
            polR = num.sin(latAng)
            nVLat = num.vstack( ( polR*num.cos(arcAngsL), polZ*num.ones(len(arcAngsL)), polR*num.sin(arcAngsL)) )
            eaProj = n2eap(nVLat, flip=False)
            pw(r*eaProj[0,:]+x0, r*eaProj[1,:]+y0, alpha=netAlpha, style=netStyle)
    'done with drawing net'

    for points, pwKWArgs in pointLists:
        nVecs  = matrixutil.unitVector(points)
        if rMat is not None:
            'rotate as did elsewhere'
            nVecs = num.dot(rMat, nVecs)
        bNVecsS = nVecs[2,:] < 0
        if southern:
            nVecsS = nVecs[:,bNVecsS]
            nVecsS = fromSouthern(nVecsS, invertFromSouthern)
            eaProj = n2eap(nVecsS, flip=False)
            pw(r*eaProj[0,:]+x0, r*eaProj[1,:]+y0, **pwKWArgs)
        else:
            nVecsN = nVecs[:,num.logical_not(bNVecsS)]
            eaProj = n2eap(nVecsN, flip=False)
            pw(r*eaProj[0,:]+x0, r*eaProj[1,:]+x0, **pwKWArgs)
    'done with pointLists'

    return
Ejemplo n.º 2
0
def sph2n(coords_sph):
    '''convert from chi/eta spherical coordinates to normal vectors;
    can use with coords from femODF.FemHemisphere
    '''

    assert coords_sph.shape[0] == 2, 'shape[0] not 2'

    z = num.cos(coords_sph[0, :])
    rho = num.sin(coords_sph[0, :])
    x = rho * num.cos(coords_sph[1, :])
    y = rho * num.sin(coords_sph[1, :])

    # nVectors = arrayutil.toArray(num.vstack((x,y,z)))
    nVectors = getMem((3, coords_sph.shape[1]))
    nVectors[0, :] = x
    nVectors[1, :] = y
    nVectors[2, :] = z

    return nVectors
Ejemplo n.º 3
0
def sph2n(coords_sph):
    '''convert from chi/eta spherical coordinates to normal vectors;
    can use with coords from femODF.FemHemisphere
    '''

    assert coords_sph.shape[0] == 2, 'shape[0] not 2'

    z   = num.cos(coords_sph[0,:])
    rho = num.sin(coords_sph[0,:])
    x = rho * num.cos(coords_sph[1,:])
    y = rho * num.sin(coords_sph[1,:])

    # nVectors = arrayutil.toArray(num.vstack((x,y,z)))
    nVectors = getMem((3,coords_sph.shape[1]))
    nVectors[0,:] = x
    nVectors[1,:] = y
    nVectors[2,:] = z

    return nVectors
Ejemplo n.º 4
0
def drawLines(pw,
              pointLists=[],
              netStyle=None,
              netNDiv=12,
              netAlpha=0.5,
              rMat=None,
              southern=False,
              invertFromSouthern=True,
              origin=(0., 0.),
              r=1.0):

    x0, y0 = origin

    lines = pw.a.get_lines()
    for line in lines:
        line.remove()

    ringAngs = num.linspace(0, num.pi * 2., 181)
    if netStyle:
        arcAngsM = num.linspace(-num.pi / 2., num.pi / 2., 91)
        arcAngsL = num.linspace(0, num.pi, 181)
        rMat_yDiv = ors.RotInv(-num.pi / netNDiv, [0, 1, 0]).toMatrix()
    pw(r * num.cos(ringAngs) + x0, r * num.sin(ringAngs) + y0, style='k-')

    if netStyle:
        nVMerid = num.vstack(
            (num.cos(arcAngsM), num.sin(arcAngsM), num.zeros(len(arcAngsM))))
        for iDiv in range(netNDiv - 1):
            nVMerid = num.dot(rMat_yDiv, nVMerid)
            eaProj = n2eap(nVMerid, flip=False)
            pw(r * eaProj[0, :] + x0,
               r * eaProj[1, :] + y0,
               alpha=netAlpha,
               style=netStyle)
        for latAng in num.pi / netNDiv * num.arange(1, netNDiv):
            polZ = num.cos(latAng)
            polR = num.sin(latAng)
            nVLat = num.vstack(
                (polR * num.cos(arcAngsL), polZ * num.ones(len(arcAngsL)),
                 polR * num.sin(arcAngsL)))
            eaProj = n2eap(nVLat, flip=False)
            pw(r * eaProj[0, :] + x0,
               r * eaProj[1, :] + y0,
               alpha=netAlpha,
               style=netStyle)
    'done with drawing net'

    for points, pwKWArgs in pointLists:
        nVecs = matrixutil.unitVector(points)
        if rMat is not None:
            'rotate as did elsewhere'
            nVecs = num.dot(rMat, nVecs)
        bNVecsS = nVecs[2, :] < 0
        if southern:
            nVecsS = nVecs[:, bNVecsS]
            nVecsS = fromSouthern(nVecsS, invertFromSouthern)
            eaProj = n2eap(nVecsS, flip=False)
            pw(r * eaProj[0, :] + x0, r * eaProj[1, :] + y0, **pwKWArgs)
        else:
            nVecsN = nVecs[:, num.logical_not(bNVecsS)]
            eaProj = n2eap(nVecsN, flip=False)
            pw(r * eaProj[0, :] + x0, r * eaProj[1, :] + x0, **pwKWArgs)
    'done with pointLists'

    return