当前位置: 首页>>代码示例>>Python>>正文


Python Matrix.rotation_axis_angle方法代码示例

本文整理汇总了Python中Matrix.rotation_axis_angle方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.rotation_axis_angle方法的具体用法?Python Matrix.rotation_axis_angle怎么用?Python Matrix.rotation_axis_angle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix的用法示例。


在下文中一共展示了Matrix.rotation_axis_angle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write_grid_as_netcdf

# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import rotation_axis_angle [as 别名]
def write_grid_as_netcdf(grid_data, outpath, options = {}, progress = None):

  from Scientific.IO import NetCDF
  f = NetCDF.NetCDFFile(outpath, 'w')
  if progress:
    progress.close_on_cancel(f)

  # createDimension() cannot handle long integer size values
  xsize, ysize, zsize = map(int, grid_data.size)
  f.createDimension('x', xsize)
  f.createDimension('y', ysize)
  f.createDimension('z', zsize)

  f.xyz_origin = grid_data.origin
  f.xyz_step = grid_data.step
  if grid_data.cell_angles != (90,90,90):
    f.cell_angles = grid_data.cell_angles
  if grid_data.rotation != ((1,0,0),(0,1,0),(0,0,1)):
    import Matrix
    axis, angle = Matrix.rotation_axis_angle(grid_data.rotation)
    f.rotation_axis = axis
    f.rotation_angle = angle

  name = 'data'
  typecode = grid_data.value_type.char
  v = f.createVariable(name, typecode, ('z','y','x'))
  v.rgba = grid_data.rgba
  v.component_number = 1
  save_unsigned_typecode(v, typecode)
  sarrays = subsample_arrays(grid_data, name, f)
  for k in range(zsize):
    if progress:
      progress.plane(k)
    values = grid_data.matrix((0,0,k), (xsize,ysize,1))
    v[k,:,:] = values.view(v.typecode())[0,:,:]
    for cell_size, ssv in sarrays:
      kstep = cell_size[2]
      if k % kstep == 0:
        ssd = grid_data.available_subsamplings[cell_size]
        xs,ys,zs = ssd.size
        ssk = k/kstep
        if ssk < zs:
          values = ssd.matrix((0,0,ssk), (xs,ys,1))
          ssv[ssk,:,:] = values.view(ssv.typecode())[0,:,:]

  # Subsample arrays may have an extra plane.
  for cell_size, ssv in sarrays:
    ssd = grid_data.available_subsamplings[cell_size]
    xs,ys,zs = ssd.size
    for ssk in range(zsize/cell_size[2], zs):
      values = ssd.matrix((0,0,ssk), (xs,ys,1))
      ssv[ssk,:,:] = values.view(ssv.typecode())[0,:,:]
    
  f.close()
开发者ID:davem22101,项目名称:semanticscience,代码行数:56,代码来源:netcdf_format.py

示例2: write_grid_data

# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import rotation_axis_angle [as 别名]
def write_grid_data(h5file, grid_data, g, settings, progress):

    if progress:
        from os.path import basename
        wpath = basename(h5file.filename)
        progress.operation = 'Writing %s to %s' % (grid_data.name, wpath)
        progress.array_size(grid_data.size, grid_data.value_type.itemsize)

    g._v_attrs.chimera_map_version = 1

    from chimera.version import release
    g._v_attrs.chimera_version = release        # string

    if grid_data.name:
        g._v_attrs.name = data_name(grid_data)

    # Need to use numpy arrays for attributes otherwise pytables 2.0 uses
    # python pickle strings in the hdf file.  Want hdf file to be readable
    # by other software without Python.
    from numpy import array, float32
    g._v_attrs.origin = array(grid_data.origin, float32)
    g._v_attrs.step = array(grid_data.step, float32)
    if grid_data.cell_angles != (90,90,90):
        g._v_attrs.cell_angles = array(grid_data.cell_angles, float32)
    if grid_data.rotation != ((1,0,0),(0,1,0),(0,0,1)):
        import Matrix
        axis, angle = Matrix.rotation_axis_angle(grid_data.rotation)
        g._v_attrs.rotation_axis = array(axis, float32)
        g._v_attrs.rotation_angle = array(angle, float32)
    if len(grid_data.symmetries) > 0:
        g._v_attrs.symmetries = array(grid_data.symmetries, float32)

    # Determine data type.
    import tables
    atom = tables.Atom.from_dtype(grid_data.value_type)

    # Create data array, subsample arrays, and alternate chunk shape arrays.
    arrays = make_arrays(h5file, g, grid_data.size, atom, settings)

    # Write values to primary and subsample arrays.
    isz,jsz,ksz = grid_data.size
    for k in range(ksz):
        if progress:
            progress.plane(k)
        # Read a single plane at a time to handle data sets that do not
        # fit in memory.
        m = grid_data.matrix((0,0,k), (isz,jsz,1))
        for step, a in arrays:
            if step == 1 or k % step == 0:
                a[k/step,:,:] = m[0,::step,::step]
开发者ID:davem22101,项目名称:semanticscience,代码行数:52,代码来源:write_cmap.py

示例3: mrc2000_header

# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import rotation_axis_angle [as 别名]
def mrc2000_header(grid_data, value_type, stats = None):

    size = grid_data.size

    from numpy import float32, int16, int8, int32
    if value_type == float32:         mode = 2
    elif value_type == int16:         mode = 1
    elif value_type == int8:          mode = 0

    cell_size = map(lambda a,b: a*b, grid_data.step, size)

    if stats:
        dmin, dmax = stats.min, stats.max
        dmean, rms = stats.mean_and_rms(size)
    else:
        dmin = dmax = dmean = rms = 0

    from numpy import little_endian
    if little_endian:
        machst = 0x44440000
    else:
        machst = 0x00001111

    from chimera.version import release
    from time import asctime
    ver_stamp = 'Chimera %s %s' % (release, asctime())
    labels = [ver_stamp[:80]]

    if grid_data.rotation != ((1,0,0),(0,1,0),(0,0,1)):
        import Matrix
        axis, angle = Matrix.rotation_axis_angle(grid_data.rotation)
        r = 'Chimera rotation: %12.8f %12.8f %12.8f %12.8f' % (axis + (angle,))
        labels.append(r)

    nlabl = len(labels)
    # Make ten 80 character labels.
    labels.extend(['']*(10-len(labels)))
    labels = [l + (80-len(l))*'\0' for l in labels]
    labelstr = ''.join(labels)

    strings = [
        binary_string(size, int32),  # nx, ny, nz
        binary_string(mode, int32),  # mode
        binary_string((0,0,0), int32), # nxstart, nystart, nzstart
        binary_string(size, int32),  # mx, my, mz
        binary_string(cell_size, float32), # cella
        binary_string(grid_data.cell_angles, float32), # cellb
        binary_string((1,2,3), int32), # mapc, mapr, maps
        binary_string((dmin, dmax, dmean), float32), # dmin, dmax, dmean
        binary_string(0, int32), # ispg
        binary_string(0, int32), # nsymbt
        binary_string([0]*25, int32), # extra
        binary_string(grid_data.origin, float32), # origin
        'MAP ', # map
        binary_string(machst, int32), # machst
        binary_string(rms, float32), # rms
        binary_string(nlabl, int32), # nlabl
        labelstr,
        ]

    header = ''.join(strings)
    return header
开发者ID:davem22101,项目名称:semanticscience,代码行数:64,代码来源:writemrc.py


注:本文中的Matrix.rotation_axis_angle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。