Ejemplo n.º 1
0
def main():
    #need actual or soft link to alos.int and dem.la
    referenceOrbit = sys.argv[1]  #look for reference_orbit.txt
    fin1 = open(referenceOrbit)
    allLines = fin1.readlines()
    s_mocomp = []
    for line in allLines:
        lineS = line.split()
        s_mocomp.append(float(lineS[2]))
    fin1.close()
    from isceobj import Image as IF

    demNameXml = 'la.dem.xml'
    from iscesys.Parsers.FileParserFactory import createFileParser
    parser = createFileParser('xml')
    #get the properties from the file init file
    prop = parser.parse(demNameXml)[0]
    objDem = IF.createDemImage()
    objDem.initProperties(prop)
    objDem.createImage()
    obj = Topo()
    obj.setReferenceOrbit(s_mocomp)
    intImage = IF.createIntImage()
    width = 1328
    filename = 'alos.int'
    intImage.initImage(filename, 'read', width)
    intImage.createImage()
    obj.wireInputPort(name='interferogram', object=intImage)
    obj.wireInputPort(name='dem', object=objDem)
    obj.pegLatitude = 0.58936848339144254
    obj.pegLongitude = -2.1172133973559606
    obj.pegHeading = -0.22703294510994310
    obj.planetLocalRadius = 6356638.1714100000
    # Frame information
    obj.slantRangePixelSpacing = 9.3685142500000005
    obj.prf = 1930.502000000000
    obj.radarWavelength = 0.23605699999999999
    obj.rangeFirstSample = 750933.00000000000
    # Doppler information
    # Make_raw information
    obj.spacecraftHeight = 698594.96239000000
    obj.bodyFixedVelocity = 7595.2060428100003
    obj.isMocomp = 3072
    obj.numberRangeLooks = 1
    obj.numberAzimuthLooks = 4
    obj.dopplerCentroidConstantTerm = .0690595
    obj.topo()
    minLat = obj.getMinimumLatitude()
    maxLat = obj.getMaximumLatitude()
    minLon = obj.getMinimumLongitude()
    maxLon = obj.getMaximumLongitude()
    azspace = obj.getAzimuthSpacing()
    s0 = obj.getSCoordinateFirstLine()
    print(minLat, maxLat, minLon, maxLon, azspace, s0)
    #squintShift = obj.getSquintShift()
    #for el in squintShift:
    #print(el)
    intImage.finalizeImage()
    objDem.finalizeImage()
Ejemplo n.º 2
0
    def createImages(self):
       
        #assume that even if an image is passed, the createImage and finalizeImage are called here
        if self.demImage is None and not self.demFilename == '':
            self.demImage = IF.createDemImage()
            demAccessMode = 'read'
            demWidth = self.demWidth
            self.demImage.initImage(self.demFilename,demAccessMode,demWidth)
        elif self.demImage is None:#this should never happen, atleast when using the  correct method. same for other images

            self.logger.error('Must either pass the demImage in the call or set self.demFilename.')
            raise Exception
        
        if(self.latImage == None and not self.latFilename == ''):
            self.latImage = IF.createImage()
            accessMode = 'write'
            dataType = 'DOUBLE'
            width = self.width
            self.latImage.initImage(self.latFilename,accessMode,width,dataType)
        elif(self.latImage == None):
            self.logger.error('Must either pass the latImage in the call or set self.latFilename.')
            raise Exception
        
        if(self.lonImage == None and not self.lonFilename == ''):
            self.lonImage = IF.createImage()
            accessMode = 'write'
            dataType = 'DOUBLE'
            width = self.width
            self.lonImage.initImage(self.lonFilename,accessMode,width,dataType)
        elif(self.lonImage == None):
            self.logger.error('Must either pass the lonImage in the call or set self.lonFilename.')
            raise Exception

        if(self.heightImage == None and not self.heightFilename == ''):
            self.heightImage = IF.createImage()
            accessMode = 'write'
            dataType = 'DOUBLE'
            width = self.width
            self.heightImage.initImage(self.heightFilename,accessMode,width,dataType)
        elif(self.heightImage == None):
            self.logger.error('Must either pass the heightImage in the call or set self.heightFilename.')
            raise Exception

        ####User provided an input file name for slant range to work with
        if(self.slantRangeImage == None and not self.slantRangeFilename == ''):

            if self.rangeFirstSample:
                raise Exception('Cannot provide both slant range image and range first sample as input')

            if self.slantRangePixelSpacing:
                raise Exception('Cannot provide both slant range image and slant range pixel spacing as input')

            self.slantRangeImage = IF.createImage()
            self.slantRangeImage.load(self.slantRangeFilename + '.xml')
            self.slantRangeImage.setAccessMode = 'READ'

            if self.slantRangeImage.width != self.width:
                raise Exception('Slant Range Image width {0} does not match input width {1}'.format(self.slantRangeImage.width, self.width))

            if self.slantRangeImage.length != self.length:
                raise Exception('Slant Range Image length {0} does not match input length {1}'.format(self.slantRangeImage.length, self.length))

            self.slantRangeImage.createImage()
            ###Set these to zero since not used but bindings need it - PSA
            self.rangeFirstSample = 0.0
            self.slantRangePixelSpacing = 0.0

        ####User provided an image like object (maybe polynomial)
        elif self.slantRangeImage is not None:
            if self.slantRangeImage.width != self.width:
                raise Exception('Slant Range Image width {0} does not match input width {1}'.format(self.slantRangeImage.width, self.width))

            if self.slantRangeImage.length != self.length:
                raise Exception('Slant Range Image length {0} does not match input length {1}'.format(self.slantRangeImage.length, self.length))

        #####Standard operation
        else:
            r0 = self.rangeFirstSample
            dr = self.slantRangePixelSpacing*self.numberRangeLooks
            self.slantRangeImage = Poly2D.Poly2D()
            self.slantRangeImage.setWidth(self.width)
            self.slantRangeImage.setLength(self.length)
            self.slantRangeImage.setNormRange(1.0)
            self.slantRangeImage.setNormAzimuth(1.0)
            self.slantRangeImage.setMeanRange(0.0)
            self.slantRangeImage.setMeanAzimuth(0.0)
            self.slantRangeImage.initPoly(rangeOrder=1, azimuthOrder=0, coeffs=[[r0,dr]])



        if(self.losImage == None and not self.losFilename == ''):
            self.losImage = IF.createImage()
            accessMode = 'write'
            dataType ='FLOAT'
            bands = 2
            scheme = 'BIL'
            width = self.width
            self.losImage.initImage(self.losFilename,accessMode,width,dataType,bands=bands,scheme=scheme)

        if (self.incImage == None and not self.incFilename == ''):
            self.incImage = IF.createImage()
            accessMode = 'write'
            dataType = 'FLOAT'
            bands = 2
            scheme = 'BIL'
            width = self.width
            self.incImage.initImage(self.incFilename, accessMode, width, dataType, bands=bands, scheme=scheme)

        if (self.maskImage == None and not self.maskFilename == ''):
            self.maskImage = IF.createImage()
            accessMode = 'write'
            dataType = 'BYTE'
            bands = 1
            scheme = 'BIL'
            width = self.width
            self.maskImage.initImage(self.maskFilename, accessMode, width, dataType, bands=bands, scheme=scheme)

        #the dem image could have different datatype so create a caster here
        #the short is the data type used in the fortran. 
        self.demImage.setCaster('read','FLOAT')
        self.demImage.createImage()
        self.latImage.createImage()
        self.lonImage.createImage()
        self.heightImage.createImage()
        self.losImage.createImage()

        if self.incImage:
            self.incImage.createImage()

        if self.maskImage:
            self.maskImage.createImage()

        return
Ejemplo n.º 3
0
    def createImages(self):

        #assume that even if an image is passed, the createImage and finalizeImage are called here
        if self.demImage is None and not self.demFilename == '':
            self.demImage = IF.createDemImage()
            demAccessMode = 'read'
            demWidth = self.demWidth
            self.demImage.initImage(self.demFilename, demAccessMode, demWidth)
        elif self.demImage is None:  #this should never happen, atleast when using the  correct method. same for other images

            self.logger.error(
                'Must either pass the demImage in the call or set self.demFilename.'
            )
            raise Exception

        if (self.latImage == None and not self.latFilename == ''):
            self.latImage = IF.createImage()
            accessMode = 'write'
            dataType = 'DOUBLE'
            width = self.width
            self.latImage.initImage(self.latFilename, accessMode, width,
                                    dataType)
        elif (self.latImage == None):
            self.logger.error(
                'Must either pass the latImage in the call or set self.latFilename.'
            )
            raise Exception

        if (self.lonImage == None and not self.lonFilename == ''):
            self.lonImage = IF.createImage()
            accessMode = 'write'
            dataType = 'DOUBLE'
            width = self.width
            self.lonImage.initImage(self.lonFilename, accessMode, width,
                                    dataType)
        elif (self.lonImage == None):
            self.logger.error(
                'Must either pass the lonImage in the call or set self.lonFilename.'
            )
            raise Exception

        if (self.heightRImage == None and not self.heightRFilename == ''):
            self.heightRImage = IF.createImage()
            accessMode = 'write'
            dataType = 'FLOAT'
            width = self.width
            self.heightRImage.initImage(self.heightRFilename, accessMode,
                                        width, dataType)
        elif (self.heightRImage == None):
            self.logger.error(
                'Must either pass the heightRImage in the call or set self.heightRFilename.'
            )
            raise Exception

        if (self.heightSchImage == None and not self.heightSchFilename == ''):
            self.heightSchImage = IF.createImage()
            accessMode = 'write'
            dataType = 'FLOAT'
            width = self.width
            self.heightSchImage.initImage(self.heightSchFilename, accessMode,
                                          width, dataType)
        elif (self.heightSchImage == None):
            self.logger.error(
                'Must either pass the heightSchImage in the call or set self.heightSchFilename.'
            )
            raise Exception

        if (self.losImage == None and not self.losFilename == ''):
            self.losImage = IF.createImage()
            accessMode = 'write'
            dataType = 'FLOAT'
            bands = 2
            scheme = 'BIL'
            width = self.width
            self.losImage.initImage(self.losFilename,
                                    accessMode,
                                    width,
                                    dataType,
                                    bands=bands,
                                    scheme=scheme)

        if (self.incImage == None and not self.incFilename == ''):
            self.incImage = IF.createImage()
            accessMode = 'write'
            dataType = 'FLOAT'
            bands = 1
            scheme = 'BIL'
            width = self.width
            self.incImage.initImage(self.incFilename,
                                    accessMode,
                                    width,
                                    dataType,
                                    bands=bands,
                                    scheme=scheme)

        #self.intImage.createImage()
        #the dem image could have different datatype so create a caster here
        #the short is the data type used in the fortran.
        self.demImage.setCaster('read', 'FLOAT')
        self.demImage.createImage()
        self.latImage.createImage()
        self.lonImage.createImage()
        self.heightRImage.createImage()
        self.heightSchImage.createImage()
        self.losImage.createImage()

        if self.incImage:
            self.incImage.createImage()