Beispiel #1
0
    def __init__(self, parent=None, dir=None):
        super(FsarImportWidget, self).__init__(parent)
        self.setWindowTitle("FSAR import")
        mainlayout = QtWidgets.QVBoxLayout(self)

        self.dirwidget = FileselWidget(title='FSAR product dir',
                                       type='opendir')
        self.dirwidget.setvalue(dir)
        mainlayout.addWidget(self.dirwidget)
        mainlayout.addWidget(HLine())
        self.productwidget = ProductContentWidget(
            products=["RGI-SLC", "RGI-AMP", "INF-SLC"])
        mainlayout.addWidget(self.productwidget)
        mainlayout.addWidget(HLine())
        self.cropwidget = CropBoxWidget(title='Select crop (0=maximum)')
        mainlayout.addWidget(self.cropwidget)
        mainlayout.addWidget(HLine())
        self.symwidget = BoolWidget(text="Cross-polar symmetrisation")
        mainlayout.addWidget(self.symwidget)

        self.buttons = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal, self)
        mainlayout.addWidget(self.buttons)
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        self.dirwidget.text.textChanged.connect(
            lambda: self.update(mode=0))  # update all

        self.bandupdate = lambda: self.update(mode=2)  # update band
        self.productwidget.product.currentIndexChanged.connect(
            lambda: self.update(mode=1))  # update product
        self.productwidget.band.currentIndexChanged.connect(self.bandupdate)
Beispiel #2
0
    def __init__(self, parent=None, dir=None):
        super(EsarImportWidget, self).__init__(parent)
        self.setWindowTitle("ESAR import")
        mainlayout = QtWidgets.QVBoxLayout(self)

        self.dirwidget = FileselWidget(title='ESAR product directory (RGI-SR)', type='opendir')
        self.dirwidget.setvalue(dir)
        mainlayout.addWidget(self.dirwidget)
        mainlayout.addWidget(HLine())
        self.productwidget = ProductContentWidget(products=["SLC", "DCSLC"])
        mainlayout.addWidget(self.productwidget)
        mainlayout.addWidget(HLine())
        self.cropwidget = CropBoxWidget(title='Select crop (0=maximum)')
        mainlayout.addWidget(self.cropwidget)

        self.buttons = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
                                              QtCore.Qt.Horizontal, self)
        mainlayout.addWidget(self.buttons)
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        self.dirwidget.text.textChanged.connect(lambda: self.update(mode=0))  # update all

        self.bandupdate = lambda: self.update(mode=2)  # update band
        self.productupdate = lambda: self.update(mode=1)
        self.productwidget.product.currentIndexChanged.connect(self.productupdate)  # update product
        self.productwidget.band.currentIndexChanged.connect(self.bandupdate)
Beispiel #3
0
class FsarImportWidget(QtWidgets.QDialog):
    def __init__(self, parent=None, dir=None):
        super(FsarImportWidget, self).__init__(parent)
        self.setWindowTitle("FSAR import")
        mainlayout = QtWidgets.QVBoxLayout(self)

        self.dirwidget = FileselWidget(title='FSAR product dir',
                                       type='opendir')
        self.dirwidget.setvalue(dir)
        mainlayout.addWidget(self.dirwidget)
        mainlayout.addWidget(HLine())
        self.productwidget = ProductContentWidget(
            products=["RGI-SLC", "RGI-AMP", "INF-SLC"])
        mainlayout.addWidget(self.productwidget)
        mainlayout.addWidget(HLine())
        self.cropwidget = CropBoxWidget(title='Select crop (0=maximum)')
        mainlayout.addWidget(self.cropwidget)
        mainlayout.addWidget(HLine())
        self.symwidget = BoolWidget(text="Cross-polar symmetrisation")
        mainlayout.addWidget(self.symwidget)

        self.buttons = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal, self)
        mainlayout.addWidget(self.buttons)
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        self.dirwidget.text.textChanged.connect(
            lambda: self.update(mode=0))  # update all

        self.bandupdate = lambda: self.update(mode=2)  # update band
        self.productwidget.product.currentIndexChanged.connect(
            lambda: self.update(mode=1))  # update product
        self.productwidget.band.currentIndexChanged.connect(self.bandupdate)

    def update(self, mode=0):
        self.dir = str(self.dirwidget.getvalue())
        self.product = self.productwidget.getvalue(0)
        self.bands = self.productwidget.getvalue(1)
        self.polar = self.productwidget.getvalue(2)

        if self.product == 'RGI-SLC':
            head = 'slc'
            src = ('RGI', 'RGI-SR')
            code_pos = 2
        if self.product == 'RGI-AMP':
            head = 'amp'
            src = ('RGI', 'RGI-SR')
            code_pos = 2
        if self.product == 'INF-SLC':
            head = 'slc_coreg'
            src = ('INF', 'INF-SR')
            code_pos = 4

        files = glob.glob(
            os.path.join(
                self.dir, src[0], src[1], head + '*' + self.bands.upper() +
                self.polar.lower() + '*.rat'))

        if mode == 0:
            allfiles = glob.glob(
                os.path.join(self.dir, src[0], src[1], head + '*.rat'))
            self.bands = '*'
            self.polar = '*'
        if mode == 1:
            allfiles = glob.glob(
                os.path.join(self.dir, src[0], src[1], head + '*.rat'))
        if mode == 2:
            allfiles = glob.glob(
                os.path.join(self.dir, src[0], src[1],
                             head + '*' + self.bands.upper() + '*.rat'))

        # allfiles = glob.glob(os.path.join(self.dir,'RGI','RGI-SR',head+'*.rat'))
        allbands = list(
            set([
                os.path.basename(slc).split('_')[code_pos][0]
                for slc in allfiles
            ]))
        allpols = list(
            set([
                os.path.basename(slc).split('_')[code_pos][1:3].upper()
                for slc in allfiles
            ]))

        nrg = 0
        naz = 0
        for filename in files:
            lun = RatFile(filename)
            nrg = max(nrg, lun.dim[0])
            naz = max(naz, lun.dim[1])
        self.cropwidget.setrange([[0, naz], [0, naz], [0, nrg], [0, nrg]])
        self.cropwidget.setvalues([0, naz, 0, nrg])

        if mode == 0 or mode == 1:
            self.productwidget.band.currentIndexChanged.disconnect(
                self.bandupdate)
            self.productwidget.updatepolar(allpols)
            self.productwidget.updatebands(allbands)
            self.productwidget.setvalue(1, self.bands)
            self.productwidget.setvalue(2, self.polar)
            self.productwidget.band.currentIndexChanged.connect(
                self.bandupdate)

        elif mode == 2:
            self.productwidget.updatepolar(allpols)
            self.productwidget.setvalue(2, self.polar)

    def accept(self):
        self.product = self.productwidget.getvalue(0)
        self.bands = self.productwidget.getvalue(1)
        self.polar = self.productwidget.getvalue(2)
        self.crop = self.cropwidget.getvalues()
        self.sym = self.symwidget.getvalue()
        super(FsarImportWidget, self).accept()
Beispiel #4
0
class EsarImportWidget(QtWidgets.QDialog):
    def __init__(self, parent=None, dir=None):
        super(EsarImportWidget, self).__init__(parent)
        self.setWindowTitle("ESAR import")
        mainlayout = QtWidgets.QVBoxLayout(self)

        self.dirwidget = FileselWidget(title='ESAR product directory (RGI-SR)',
                                       type='opendir')
        self.dirwidget.setvalue(dir)
        mainlayout.addWidget(self.dirwidget)
        mainlayout.addWidget(HLine())
        self.productwidget = ProductContentWidget(products=["SLC", "DCSLC"])
        mainlayout.addWidget(self.productwidget)
        mainlayout.addWidget(HLine())
        self.cropwidget = CropBoxWidget(title='Select crop (0=maximum)')
        mainlayout.addWidget(self.cropwidget)

        self.buttons = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal, self)
        mainlayout.addWidget(self.buttons)
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        self.dirwidget.text.textChanged.connect(
            lambda: self.update(mode=0))  # update all

        self.bandupdate = lambda: self.update(mode=2)  # update band
        self.productupdate = lambda: self.update(mode=1)
        self.productwidget.product.currentIndexChanged.connect(
            self.productupdate)  # update product
        self.productwidget.band.currentIndexChanged.connect(self.bandupdate)

    def update(self, mode=0):
        self.dir = str(self.dirwidget.getvalue())
        ESAR.file = self.dir
        self.product = self.productwidget.getvalue(0)
        self.polar = self.productwidget.getvalue(2)

        if os.path.isdir(self.dir):  # read from several files
            allfiles = glob.glob(os.path.join(self.dir, '*slc*' + '*.dat'))
        elif os.path.isfile(self.dir):  # read from a single file
            allfiles = [self.dir]
        else:  # nothing selected
            allfiles = []

        # allpols = list(set([os.path.basename(slc).split('_')[1][2:].upper() for slc in allfiles]))
        allpols = list(
            set([
                crawlMetaForInfo(slc, 'init.polarization') for slc in allfiles
            ]))
        allbands = list(
            set([crawlMetaForInfo(slc, 'init.freq_band') for slc in allfiles]))
        allproducts = list(
            set(['SLC' if 'slc' in slc else 'DCSLC' for slc in allfiles]))

        # the range settings for the crop widget are missing (the max value is 99999...)
        # take a look on F-SAR; where are the dimensions of an image (.dat) from E-SAR?
        # self.cropwidget.setrange([[0, naz], [0, naz], [0, nrg], [0, nrg]])
        # self.cropwidget.setvalues([0, naz, 0, nrg])

        if mode == 0 or mode == 1:
            self.productwidget.band.currentIndexChanged.disconnect(
                self.bandupdate)
            self.productwidget.product.currentIndexChanged.disconnect(
                self.productupdate)
            self.productwidget.updatebands(allbands)
            self.productwidget.updatepolar(allpols)
            self.productwidget.updateproducts(allproducts)
            self.productwidget.setvalue(2, self.polar)
            self.productwidget.band.currentIndexChanged.connect(
                self.bandupdate)
            self.productwidget.product.currentIndexChanged.connect(
                self.productupdate)

        elif mode == 2:
            self.productwidget.updatepolar(allpols)
            self.productwidget.setvalue(2, self.polar)

    def accept(self):
        self.product = self.productwidget.getvalue(0)
        self.polar = self.productwidget.getvalue(2)
        self.crop = self.cropwidget.getvalues()
        self.band = self.productwidget.getvalue(1)
        super(EsarImportWidget, self).accept()
Beispiel #5
0
class EsarImportWidget(QtWidgets.QDialog):
    def __init__(self, parent=None, dir=None):
        super(EsarImportWidget, self).__init__(parent)
        self.setWindowTitle("ESAR import")
        mainlayout = QtWidgets.QVBoxLayout(self)

        self.dirwidget = FileselWidget(title='ESAR product directory (RGI-SR)', type='opendir')
        self.dirwidget.setvalue(dir)
        mainlayout.addWidget(self.dirwidget)
        mainlayout.addWidget(HLine())
        self.productwidget = ProductContentWidget(products=["SLC", "DCSLC"])
        mainlayout.addWidget(self.productwidget)
        mainlayout.addWidget(HLine())
        self.cropwidget = CropBoxWidget(title='Select crop (0=maximum)')
        mainlayout.addWidget(self.cropwidget)

        self.buttons = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
                                              QtCore.Qt.Horizontal, self)
        mainlayout.addWidget(self.buttons)
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        self.dirwidget.text.textChanged.connect(lambda: self.update(mode=0))  # update all

        self.bandupdate = lambda: self.update(mode=2)  # update band
        self.productupdate = lambda: self.update(mode=1)
        self.productwidget.product.currentIndexChanged.connect(self.productupdate)  # update product
        self.productwidget.band.currentIndexChanged.connect(self.bandupdate)

    def update(self, mode=0):
        self.dir = str(self.dirwidget.getvalue())
        self.product = self.productwidget.getvalue(0)
        self.polar = self.productwidget.getvalue(2)

        if os.path.isdir(self.dir):  # read from several files
            allfiles = glob.glob(os.path.join(self.dir, '*slc*' + '*.dat'))
        elif os.path.isfile(self.dir):  # read from a single file
            allfiles = [self.dir]
        else:  # nothing selected
            allfiles = []

        # allpols = list(set([os.path.basename(slc).split('_')[1][2:].upper() for slc in allfiles]))
        allpols = list(set([crawlMetaForInfo(slc, 'init.polarization') for slc in allfiles]))
        allbands = list(set([crawlMetaForInfo(slc, 'init.freq_band') for slc in allfiles]))
        allproducts = list(set(['SLC' if 'slc' in slc else 'DCSLC' for slc in allfiles]))

        # the range settings for the crop widget are missing (the max value is 99999...)
        # take a look on F-SAR; where are the dimensions of an image (.dat) from E-SAR?
        # self.cropwidget.setrange([[0, naz], [0, naz], [0, nrg], [0, nrg]])
        # self.cropwidget.setvalues([0, naz, 0, nrg])

        if mode == 0 or mode == 1:
            self.productwidget.band.currentIndexChanged.disconnect(self.bandupdate)
            self.productwidget.product.currentIndexChanged.disconnect(self.productupdate)
            self.productwidget.updatebands(allbands)
            self.productwidget.updatepolar(allpols)
            self.productwidget.updateproducts(allproducts)
            self.productwidget.setvalue(2, self.polar)
            self.productwidget.band.currentIndexChanged.connect(self.bandupdate)
            self.productwidget.product.currentIndexChanged.connect(self.productupdate)

        elif mode == 2:
            self.productwidget.updatepolar(allpols)
            self.productwidget.setvalue(2, self.polar)

    def accept(self):
        self.product = self.productwidget.getvalue(0)
        self.polar = self.productwidget.getvalue(2)
        self.crop = self.cropwidget.getvalues()
        self.band = self.productwidget.getvalue(1)
        super(EsarImportWidget, self).accept()
Beispiel #6
0
class FsarImportWidget(QtGui.QDialog):
    def __init__(self, parent=None, dir=None):
        super(FsarImportWidget, self).__init__(parent)
        self.setWindowTitle("FSAR import")
        mainlayout = QtGui.QVBoxLayout(self)

        self.dirwidget = FileselWidget(title='FSAR product dir', type='opendir')
        self.dirwidget.setvalue(dir)
        mainlayout.addWidget(self.dirwidget)
        mainlayout.addWidget(HLine())
        self.productwidget = ProductContentWidget(products=["RGI-SLC", "RGI-AMP", "INF-SLC"])
        mainlayout.addWidget(self.productwidget)
        mainlayout.addWidget(HLine())
        self.cropwidget = CropBoxWidget(title='Select crop (0=maximum)')
        mainlayout.addWidget(self.cropwidget)

        self.buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel,
                                              QtCore.Qt.Horizontal, self)
        mainlayout.addWidget(self.buttons)
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        self.dirwidget.text.textChanged.connect(lambda: self.update(mode=0))   # update all

        self.bandupdate = lambda: self.update(mode=2)                          # update band
        self.productwidget.product.currentIndexChanged.connect(lambda: self.update(mode=1))# update product
        self.productwidget.band.currentIndexChanged.connect(self.bandupdate)

    def update(self, mode=0):
        self.dir = str(self.dirwidget.getvalue())
        self.product = self.productwidget.getvalue(0)
        self.bands = self.productwidget.getvalue(1)
        self.polar = self.productwidget.getvalue(2)

        if self.product == 'RGI-SLC':
            head = 'slc'
            src = ('RGI','RGI-SR')
            code_pos = 2
        if self.product == 'RGI-AMP':
            head = 'amp'
            src = ('RGI','RGI-SR')
            code_pos = 2
        if self.product == 'INF-SLC':
            head = 'slc_coreg'
            src = ('INF','INF-SR')
            code_pos = 4

        files = glob.glob(os.path.join(self.dir, src[0], src[1], head+'*'+self.bands.upper()+self.polar.lower()+'*.rat'))

        if mode == 0:
            allfiles = glob.glob(os.path.join(self.dir,src[0],src[1],head+'*.rat'))
            self.bands = '*'
            self.polar = '*'
        if mode == 1:
            allfiles = glob.glob(os.path.join(self.dir,src[0],src[1],head+'*.rat'))
        if mode == 2:
            allfiles = glob.glob(os.path.join(self.dir,src[0],src[1],head+'*'+self.bands.upper()+'*.rat'))

        # allfiles = glob.glob(os.path.join(self.dir,'RGI','RGI-SR',head+'*.rat'))
        allbands = list(set([os.path.basename(slc).split('_')[code_pos][0] for slc in allfiles]))
        allpols = list(set([os.path.basename(slc).split('_')[code_pos][1:3].upper() for slc in allfiles]))

        nrg = 0
        naz = 0
        for filename in files:
            lun = RatFile(filename)
            nrg = max(nrg, lun.dim[0])
            naz = max(naz, lun.dim[1])
        self.cropwidget.setrange([[0, naz], [0, naz], [0, nrg], [0, nrg]])
        self.cropwidget.setvalues([0, naz, 0, nrg])

        if mode == 0 or mode == 1:
            self.productwidget.band.currentIndexChanged.disconnect(self.bandupdate)
            self.productwidget.updatepolar(allpols)
            self.productwidget.updatebands(allbands)
            self.productwidget.setvalue(1, self.bands)
            self.productwidget.setvalue(2, self.polar)
            self.productwidget.band.currentIndexChanged.connect(self.bandupdate)

        elif mode == 2:
            self.productwidget.updatepolar(allpols)
            self.productwidget.setvalue(2, self.polar)

    def accept(self):
        self.product = self.productwidget.getvalue(0)
        self.bands = self.productwidget.getvalue(1)
        self.polar = self.productwidget.getvalue(2)
        self.crop = self.cropwidget.getvalues()
        super(FsarImportWidget, self).accept()