本文整理汇总了Python中pyhdf.SD.SD.get方法的典型用法代码示例。如果您正苦于以下问题:Python SD.get方法的具体用法?Python SD.get怎么用?Python SD.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyhdf.SD.SD
的用法示例。
在下文中一共展示了SD.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_interpolated
# 需要导入模块: from pyhdf.SD import SD [as 别名]
# 或者: from pyhdf.SD.SD import get [as 别名]
def write_interpolated(filename, f0, f1, fact, datasetNames):
'''
interpolate two hdf files f0 and f1 using factor fact, and
write the result to filename
'''
hdf = SD(filename, SDC.WRITE|SDC.CREATE)
for datasetName in datasetNames:
try:
info = SD(f0).select(datasetName).info()
except:
print >> stderr, 'Error loading %s in %s' % (datasetName, f0)
raise
typ = info[3]
shp = info[2]
sds_in1 = SD(f0).select(datasetName)
met0 = sds_in1.get()
met1 = SD(f1).select(datasetName).get()
interp = (1-fact)*met0 + fact*met1
interp = interp.astype({
SDC.INT16: 'int16',
SDC.FLOAT32: 'float32',
SDC.FLOAT64: 'float64',
}[typ])
# write
sds = hdf.create(datasetName, typ, shp)
sds[:] = interp[:]
# copy attributes
attr = sds_in1.attributes()
if len(attr) > 0:
for name in attr.keys():
setattr(sds, name, attr[name])
sds.endaccess()
hdf.end()