本文整理汇总了Python中Scientific.IO.NetCDF.NetCDFFile.NsnapsDone方法的典型用法代码示例。如果您正苦于以下问题:Python NetCDFFile.NsnapsDone方法的具体用法?Python NetCDFFile.NsnapsDone怎么用?Python NetCDFFile.NsnapsDone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scientific.IO.NetCDF.NetCDFFile
的用法示例。
在下文中一共展示了NetCDFFile.NsnapsDone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: openOutputFile
# 需要导入模块: from Scientific.IO.NetCDF import NetCDFFile [as 别名]
# 或者: from Scientific.IO.NetCDF.NetCDFFile import NsnapsDone [as 别名]
def openOutputFile(self):
# Create file
os.system('mkdir -p results/%s-%s' % (self.Case1,self.Case2))
FileName = 'results/%s-%s/Cam3Feedbacks.%s-%s.%03i.nc' % \
(self.Case1,self.Case2,self.Case1,self.Case2,self.FileNumber)
if not os.path.exists(FileName):
print 'creating %s ...' % FileName
File = NetCDFFile(FileName,'w')
File.createDimension('lat',len(self.data.lat))
var = File.createVariable('lat','f',('lat',))
var.long_name = 'latitude'
var.units = 'degrees_north'
var[:] = self.data.lat.astype('f')
File.createDimension('lon',len(self.data.lon))
var = File.createVariable('lon','f',('lon',))
var.long_name = 'longitude'
var.units = 'degrees_east'
var[:] = self.data.lon.astype('f')
# create variables
for Field in ['dR_Ts','dR_lapse','dR_q','dR_cld_sw','dR_cld_lw','dR_alb','dR_co2']:
var = File.createVariable(Field,'f',('lat','lon'))
var.long_name = 'TOA radiative perturbation'
var.units = 'W m-2'
var[:,:] = 0.
File.NsnapsDone = 0
return 0, File
else:
File = NetCDFFile(FileName,'a')
NsnapsDone = int(File.NsnapsDone[0])
if NsnapsDone < len(self.data.time):
return NsnapsDone, File
else:
print 'No more snaps to be done'
sys.exit(0)