本文整理汇总了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()
示例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()
示例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
示例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)