def __init__(self, filename): hdfFile = SD(filename) bo = re.compile('.*?=\s+([-]*\d*\.\d+).*',re.DOTALL) coord_string = hdfFile.__getattr__('ArchiveMetadata.0')[hdfFile.__getattr__('ArchiveMetadata.0').find('NORTHBOUNDINGCOORDINATE')] self.west = float(bo.match(coord_string.split('WESTBOUNDINGCOORDINATE')[1]).group(1)) self.east = float(bo.match(coord_string.split('EASTBOUNDINGCOORDINATE')[1]).group(1)) self.south = float(bo.match(coord_string.split('SOUTHBOUNDINGCOORDINATE')[1]).group(1)) self.north = float(bo.match(coord_string.split('NORTHBOUNDINGCOORDINATE')[1]).group(1)) tmp = np.array (hdfFile.select(1)[:], dtype = np.int16) emp = hdfFile.getfillvalue() tmp[tmp == emp] = 0 min = tmp.min() rng = tmp.max() - min self.image = np.array(float(tmp-min)/rng*255, dtype=np.uint8) hdfFile.end()
def __init__(self, filename): hdfFile = SD(filename) bo = re.compile('.*?=\s+([-]*\d*\.\d+).*', re.DOTALL) coord_string = hdfFile.__getattr__('ArchiveMetadata.0')[ hdfFile.__getattr__('ArchiveMetadata.0').find( 'NORTHBOUNDINGCOORDINATE')] self.west = float( bo.match(coord_string.split('WESTBOUNDINGCOORDINATE')[1]).group(1)) self.east = float( bo.match(coord_string.split('EASTBOUNDINGCOORDINATE')[1]).group(1)) self.south = float( bo.match( coord_string.split('SOUTHBOUNDINGCOORDINATE')[1]).group(1)) self.north = float( bo.match( coord_string.split('NORTHBOUNDINGCOORDINATE')[1]).group(1)) tmp = np.array(hdfFile.select(1)[:], dtype=np.int16) emp = hdfFile.getfillvalue() tmp[tmp == emp] = 0 min = tmp.min() rng = tmp.max() - min self.image = np.array(float(tmp - min) / rng * 255, dtype=np.uint8) hdfFile.end()