Пример #1
0
def fakeCube(interleave,default=None, file=fakeNmFile):
    file=StringIO(file)
    h=ENVI.Header()
    h.read(file)
    h['interleave']=interleave
    other = HSI.newCube(interleave)
    h.setCubeAttributes(other)
    
    if default is None:
        data = numpy.array(numpy.arange(other.samples*other.lines*other.bands),dtype=other.data_type)
    else:
        data = numpy.zeros((other.samples*other.lines*other.bands),dtype=other.data_type)
        data += default
    
    cube = HSI.createCubeLike(other, data=data.tostring())
    h.setCubeAttributes(cube)
    return cube
Пример #2
0
 def getCube(self, filename=None, index=0, progress=None, options=None):
     if filename is None:
         filename = self.url
     hdu = None
     i = 0
     for h in self.hdus:
         if h.image_size > 0:
             if index == i:
                 hdu = h
                 break
             i += 1
     if not hdu:
         raise IndexError("HDU index out of range")
     cube = HSI.newCube(hdu.getInterleave(), progress=progress)
     self.setCubeAttributes(cube, hdu)
     cube.verifyAttributes()
     if filename:
         try:
             cube.open(filename)
         except:
             dprint("Failed opening cube %s" % cube)
             raise
     return cube
Пример #3
0
 def getCube(self, filename=None, index=0, progress=None, options=None):
     if filename is None:
         filename = self.url
     hdu = None
     i = 0
     for h in self.hdus:
         if h.image_size > 0:
             if index == i:
                 hdu = h
                 break
             i += 1
     if not hdu:
         raise IndexError("HDU index out of range")
     cube = HSI.newCube(hdu.getInterleave(), progress=progress)
     self.setCubeAttributes(cube, hdu)
     cube.verifyAttributes()
     if filename:
         try:
             cube.open(filename)
         except:
             dprint("Failed opening cube %s" % cube)
             raise
     return cube
Пример #4
0
 def setup(self):
     self.cube = HSI.newCube("bsq")