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


Python Dataset.variables[key][:]方法代码示例

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


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

示例1: _write_nc

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import variables[key][:] [as 别名]
 def _write_nc(self, FN, data):
   """
   Writes a grid in netcdf format
   """
   n_points = data['counts'][0]*data['counts'][1]*data['counts'][2]
   from netCDF4 import Dataset
   grid_nc = Dataset(FN,'w',format='NETCDF4')
   grid_nc.createDimension('one', 1)
   grid_nc.createDimension('n_cartesian', 3)
   grid_nc.createDimension('n_points', n_points)
   grid_nc.createVariable('origin','f8',('one','n_cartesian'))
   grid_nc.createVariable('counts','i8',('one','n_cartesian'))
   grid_nc.createVariable('spacing','f8',('one','n_cartesian'))
   grid_nc.createVariable('vals','f8',('one','n_points'), zlib=True)
   for key in data.keys():
     grid_nc.variables[key][:] = data[key]
   grid_nc.close()
开发者ID:Mamie,项目名称:AlGDock,代码行数:19,代码来源:IO.py

示例2: _write_nc

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import variables[key][:] [as 别名]
    def _write_nc(self, FN, data):
        """
    Writes a grid in netcdf format
    """
        n_points = data["counts"][0] * data["counts"][1] * data["counts"][2]
        from netCDF4 import Dataset

        grid_nc = Dataset(FN, "w", format="NETCDF4")
        grid_nc.createDimension("one", 1)
        grid_nc.createDimension("n_cartesian", 3)
        grid_nc.createDimension("n_points", n_points)
        grid_nc.createVariable("origin", "f8", ("one", "n_cartesian"))
        grid_nc.createVariable("counts", "i8", ("one", "n_cartesian"))
        grid_nc.createVariable("spacing", "f8", ("one", "n_cartesian"))
        grid_nc.createVariable("vals", "f8", ("one", "n_points"), zlib=True)
        for key in data.keys():
            grid_nc.variables[key][:] = data[key]
        grid_nc.close()
开发者ID:homsun,项目名称:AlGDock,代码行数:20,代码来源:IO.py

示例3: replicate

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import variables[key][:] [as 别名]
def replicate(OldFileName,NewFileName):
    # Creates a new NetCDF file with the same dimensions and variables as
    # the old file but no content
    OldFile = NetCDFFile(OldFileName,'r')
    NewFile = NetCDFFile(NewFileName,'w',format='NETCDF3_CLASSIC')

    Dims = OldFile.dimensions

    for key in Dims:
        NewFile.createDimension(key,len(Dims[key]))

    Vars = OldFile.variables
    for key in Vars:
        NewFile.createVariable(key,Vars[key].typecode(),Vars[key].dimensions)
        for key1 in OldFile.variables[key].__dict__:
            exec('NewFile.variables[key].%s = OldFile.variables[key].%s'%(key1,key1))
        if key in Dims and Dims[key] is not None:
            NewFile.variables[key][:] = OldFile.variables[key][:]
    return NewFile
开发者ID:rodrigo-caballero,项目名称:my_python,代码行数:21,代码来源:ReplicateNcFile.py

示例4: open

# 需要导入模块: from netCDF4 import Dataset [as 别名]
# 或者: from netCDF4.Dataset import variables[key][:] [as 别名]
import AlGDock.IO
IO_dock6_mol2 = AlGDock.IO.dock6_mol2()
(confs, Es) = IO_dock6_mol2.read(inFN)

if confs==[]:
  F = open(inFN,'w')
  F.close()
  sys.exit()

import numpy as np
confs = np.array(confs)
confs = np.array(confs)/10. # Convert Angstroms to nanometers

from netCDF4 import Dataset
dock6_nc = Dataset(outFN,'w',format='NETCDF4')
dock6_nc.createDimension('n_poses', confs.shape[0])
dock6_nc.createDimension('n_atoms', confs.shape[1])
dock6_nc.createDimension('n_cartesian', confs.shape[2])
dock6_nc.createDimension('one',1)
dock6_nc.createVariable('confs','f4',('n_poses','n_atoms','n_cartesian'), \
  zlib=True, complevel=9, shuffle=True)
dock6_nc.variables['confs'][:,:,:] = confs
for key in Es.keys():
  datatype = 'i2' if key=='Cluster Size' else 'f4'
  dock6_nc.createVariable(key, datatype,('n_poses'), \
    zlib=True, complevel=9, shuffle=True)
  dock6_nc.variables[key][:] = np.array(Es[key])
dock6_nc.close()

os.remove(inFN)
开发者ID:CCBatIIT,项目名称:AlGDock,代码行数:32,代码来源:dock6_to_nc.py


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