def read_band(fileObj,key,b,d):
'''reads MODIS data,scale them with the Solar Zenith and returns one band'''
print 'read image '+str(b)+' from dataset '+str(key) +'... '
dsObj=fileObj.select(key)
B=sp.array(dsObj.get(),sp.float32) # float32
attr=dsObj.attributes()
scale=attr['reflectance_scales'][b]
offset=attr['reflectance_offsets'][b]
dn=B[b,:,:]
bad_ind=(dn>=32767).nonzero() # Bit16 zeigt fehlerhafte Messungen an
band=(scale*(dn-offset))/sp.cos(d['SolarZenith'])
band[bad_ind]=0
print ' done'
return band
评论列表
文章目录