How to use the spectral.io.envi.open function in spectral

To help you get started, we’ve selected a few spectral examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dm6718 / RITSAR / ritsar / phsRead.py View on Github external
def DIRSIG(directory):
    from spectral.io import envi
    
    #get phase history
    phs_fname = getWildcard(directory, '*.hdr')
    phs = envi.open(phs_fname).load(dtype = np.complex128)
    phs = np.squeeze(phs)
    
    #get platform geometry
    ppd_fname = getWildcard(directory, '*.ppd')
    tree = ET.parse(ppd_fname)
    root = tree.getroot()
    
    pos_dirs = []
    for children in root.iter('point'):
        pos_dirs.append(float(children[0].text))
        pos_dirs.append(float(children[1].text))
        pos_dirs.append(float(children[2].text))
    pos_dirs = np.asarray(pos_dirs).reshape([len(pos_dirs)/3,3])
    
    t_dirs=[]
    for children in root.iter('datetime'):
github dsmbgu8 / image_annotate.py / image_annotate.py View on Github external
dfile,dext = os.path.splitext(datf)
        normf = '%s_normed.mat'%dfile
        
        if norm and pathexists(normf):
            print "Loading precomputed normalized data file %s"%normf
            dat = load_matlab(normf,'normed')
            print "Finished loading normalized data"
                   
        if dext == '.mat':
            dat = load_matlab(datf,datkey)
            if len(dat)==0:
                return -1
        elif dext in ('.img','.hdr'):
            import spectral.io.envi as envi
            dinfo = envi.open(datf)
            dat = dinfo.read_bands(range(dinfo.shape[2])).squeeze()
        else:
            dat = pl.imread(datf)

        x,y,z = np.atleast_3d(dat).shape

        if verbose:
            print "Loaded %d x %d x %d image data from file %s"%(x,y,z,datf)

        if norm and not pathexists(normf):
            from scipy.io import savemat 
            print "Saving normalized data to file %s"%normf  
            dat = dat.reshape([x*y,z])   
            normv = np.apply_along_axis(np.linalg.norm,1,dat)
            normv[normv==0] = 1.0
            dat = (dat.T / normv.T).T