コード例 #1
0
ファイル: CellRefImageSelect.py プロジェクト: xia2/trashcan
def write_dot_reciprocal_axes(phi_start, phi_end, phi_width,
                              wavelength, lattice, matrix):

    a, b, c = get_reciprocal_space_primitive_matrix(lattice, matrix)

    # calculate the cross terms
    ab = (0.5 * (a[0] + b[0]),
          0.5 * (a[1] + b[1]),
          0.5 * (a[2] + b[2]))

    bc = (0.5 * (b[0] + c[0]),
          0.5 * (b[1] + c[1]),
          0.5 * (b[2] + c[2]))

    ca = (0.5 * (c[0] + a[0]),
          0.5 * (c[1] + a[1]),
          0.5 * (c[2] + a[2]))

    phi = phi_start + 0.5 * phi_width
    i = 0

    dot_a = 0.0
    dot_b = 0.0
    doc_c = 0.0

    dot_ab = 0.0
    dot_bc = 0.0
    doc_ca = 0.0

    fout = open('dot_recl.txt', 'w')

    while phi < phi_end:

        i += 1

        RX = rot_x(phi)

        RXa = matvecmul(RX, a)
        RXb = matvecmul(RX, b)
        RXc = matvecmul(RX, c)

        dot_a = math.fabs(RXa[2])
        dot_b = math.fabs(RXb[2])
        dot_c = math.fabs(RXc[2])

        RXab = matvecmul(RX, ab)
        RXbc = matvecmul(RX, bc)
        RXca = matvecmul(RX, ca)

        dot_ab = math.fabs(RXab[2])
        dot_bc = math.fabs(RXbc[2])
        dot_ca = math.fabs(RXca[2])

        fout.write('%d %.2f %.4f %.4f %.4f %.4f %.4f %.4f\n' %
                   (i, phi, dot_a, dot_b, dot_c, dot_ab, dot_bc, dot_ca))

        phi += phi_width

    fout.close()

    return
コード例 #2
0
ファイル: CellRefImageSelect.py プロジェクト: xia2/trashcan
def identify_parallel_reciprocal_axes(phi_start, phi_end, phi_width,
                                      wavelength, lattice, matrix):
    '''Find phi values which present the primitive reciprocal unit cell axes as
    near as possible to being perpendicular to the beam vector.'''

    # FIXME should add a test in here that the mosflm orientation matrix
    # corresponds to the asserted lattice...

    # find thee P1 reciprocal-space cell axes

    a, b, c = get_reciprocal_space_primitive_matrix(lattice, matrix)

    # compute rotations of these and find minimum for axis.Z - that is the
    # Z component of the rotated axis... check workings and definitions!

    phi = phi_start + 0.5 * phi_width

    # initialize search variables

    phi_a = phi_start
    phi_b = phi_start
    phi_c = phi_start

    dot_a = 0.0
    dot_b = 0.0
    dot_c = 0.0

    ia = 0
    ib = 0
    ic = 0

    i = 0

    # only consider the first 180 degrees of data...

    if phi_end - phi_start > 180:
        phi_end = phi_start + 180

    while phi < phi_end:
        RX = rot_x(phi)

        RXa = matvecmul(RX, a)
        RXb = matvecmul(RX, b)
        RXc = matvecmul(RX, c)

        if math.fabs(RXa[2]) > dot_a:
            dot_a = math.fabs(RXa[2])
            phi_a = phi
            ia = i

        if math.fabs(RXb[2]) > dot_b:
            dot_b = math.fabs(RXb[2])
            phi_b = phi
            ib = i

        if math.fabs(RXc[2]) > dot_c:
            dot_c = math.fabs(RXc[2])
            phi_c = phi
            ic = i

        phi += phi_width
        i += 1

    length_a = math.sqrt(dot(a, a))
    length_b = math.sqrt(dot(b, b))
    length_c = math.sqrt(dot(c, c))

    rtod = 180.0 / math.pi

    angle_a = math.fabs(rtod * math.acos(dot_a / length_a))
    angle_b = math.fabs(rtod * math.acos(dot_b / length_b))
    angle_c = math.fabs(rtod * math.acos(dot_c / length_c))

    # return the closest positions and the angular offset from
    # perpendicularity...

    return phi_a, phi_b, phi_c, angle_a, angle_b, angle_c, ia, ib, ic