コード例 #1
0
    def lasLoad(self):
        las_name = self.lastree.tree.selectedItems()[0].text(
            0)  #self.logFileList.selectedItems()[0].text()
        if las_name in ['TVD', 'MD', 'LWD', 'WireLine']:
            return

        findex = np.where(self.files == las_name)[0][0]
        # print(findex)
        Loaded = False
        while (not Loaded):
            if (findex < len(self.lasLoadThread.Lases)):
                self.las = self.lasLoadThread.Lases[findex]
                Loaded = True
            else:
                self.logtree.clear()
                # self.logtree.addItems(['Loading....'])
                time.sleep(1)

        if len(self.logtree.selectedItems()) > 0:
            item = self.logtree.selectedItems()[0]
            # print(dir(item))
            item.setSelected = False
        # self.logList.clear()
        # self.logList.addItems(self.las.keys() )
        if not (len(self.las.keys()) < 1):
            self.logtree = LasTree(self.las.keys())
            self.logtree.buildTreeWidget()
            # self.logtree.tree.itemSelectionChanged.connect(self.logPlot)

            dcol = self.las.keys()[find_depth_indx(self.las)]
            self.depth_col = str_array2floats(self.las[dcol])
コード例 #2
0
 def buildLogTree(self):
     self.lastree = LasTree()
     self.lastree.tree.headerItem().setText(0, "Categories")
     for lb in self.log_bundle:
         # logkeys=np.append(['GR'],lb['keys'])
         # print(logkeys)
         self.lastree.set_files(lb['keys'], make_tree_dict=False)
         mind, maxd = min(lb['DEPTH']), max(lb['DEPTH'])
         self.lastree.tree = treeWidgetFrmArray(
             self.lastree.tree, '({0:4.1f} to {1:4.1f})'.format(mind, maxd),
             lb['keys'])
     self.lastree.tree.itemSelectionChanged.connect(self.logPlotPanel)
     self.dock.setWidget(self.lastree.tree)
コード例 #3
0
    def wellLoad(self):
        self.wellFolder = r'E:\Data\W1\LAS\\'

        self.files = np.array(os.listdir(self.wellFolder)[:])
        files_w_path = [self.wellFolder + f for f in self.files]
        # print(files_w_path)
        # self.logFileList.addItems(self.files)

        # folder=r'D:\Ameyem Office\Projects\Cairn\W1\LAS\\'
        cols = []
        # las=[]
        # log.df().sort_values([log.keys()[dindx]])
        # log.keys()
        self.files = np.array(os.listdir(self.wellFolder)[:])
        self.lastree = LasTree(self.files)
        self.lastree.buildTreeWidget()
        self.lastree.tree.itemSelectionChanged.connect(self.lasLoad)

        self.lasLoadThread = LasLoadThread(files=files_w_path)
コード例 #4
0
ファイル: Loggy-v2.py プロジェクト: narunbabu/Loggy
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setGeometry(100, 100, 600, 900)

        self.centralWidget = QWidget()
        # GrphicsWidget()
        layout = QHBoxLayout(self.centralWidget)
        self.scrollArea = QScrollArea(self)

        # gwidget=GrphicsWidget()

        self.mw = MatplotlibWidget(size=(3.0, 40.0), dpi=100)
        lplot = self.mw.getFigure().add_subplot(121)
        # print(dir(self.mw.getFigure()))

        # self.mw.getFigure().set_axes([0.85, 0.1, 0.075, 0.8])
        self.ax = self.mw.getFigure().gca()
        self.ax.set_position([0.1, 0.05, 0.8, 0.94])
        self.ax.invert_yaxis()
        # l, b, w, h = self.ax.get_position().bounds
        # print(l, b, w, h)
        self.mw.draw()
        # self.plotlayout.addWidget(self.mw)

        self.scrollArea.setWidget(self.mw)

        layout.addWidget(self.scrollArea)

        self.setCentralWidget(self.centralWidget)
        self.lastree = LasTree()
        self.logtree = LasTree()
        self.wellLoad()
        self.logtree.set_files(['GR', 'BS'])
        self.logtree.buildTreeWidget()
        self.logtree.tree.itemSelectionChanged.connect(self.logPlot)

        self.createDockWindows()

        # self.logFileList.itemSelectionChanged.connect(self.lasLoad)
        # if not self.las_just_selected:
        # self.logList.itemSelectionChanged.connect(self.logPlot)

        self.setWindowTitle("Loggy")
コード例 #5
0
    def buildLogTree(self,files_w_path):
        w = LasTree()
        self.lasLoadThread = LasLoadThread(files=files_w_path)
        # print(self.lasLoadThread.Lases)
        notloaded=True
        

        while notloaded:
            if (len(self.lasLoadThread.Lases)>0):
                if (len(self.lasLoadThread.Lases[0].keys())>0):
                    self.las=self.lasLoadThread.Lases[0]      
                    # print(self.logs) 
                    w.set_files(self.las.keys())
                    del w.treeview_dict['Log']['NA']
                    self.treeview_dict=w.treeview_dict
                    
                    w.buildTreeWidget()  
                    # print(self.interestedLognames)              
                    # w.tree.clear()
                    # w.buildTreeWidget()
                    notloaded=False
            time.sleep(1)
        # print(w.treeview_dict)
        

        self.dock.setWidget(w.tree) 
コード例 #6
0
ファイル: LateralCorr_v2.py プロジェクト: narunbabu/Loggy
    def buildLogTree(self,lases):
        w = LasTree()
        # self.lasLoadThread = LasLoadThread(files=files_w_path)

        self.lases=lases
        if (len(self.lases)>0):
            if (len(self.lases[0].keys())>0):
                self.las=self.lases[0]      
                w.set_files(self.las.keys())
                del w.treeview_dict['Log']['NA']
                self.treeview_dict=w.treeview_dict
                
                w.buildTreeWidget()          

        self.dock.setWidget(w.tree)         
コード例 #7
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setGeometry(100, 100, 600, 900)

        self.centralWidget = QWidget()
        # GrphicsWidget()
        layout = QHBoxLayout(self.centralWidget)
        self.scrollArea = QScrollArea(self)

        # gwidget=GrphicsWidget()

        self.mw = MatplotlibWidget(size=(3.0, 40.0), dpi=100)
        lplot = self.mw.getFigure().add_subplot(121)
        # print(dir(self.mw.getFigure()))

        # self.mw.getFigure().set_axes([0.85, 0.1, 0.075, 0.8])
        self.ax = self.mw.getFigure().gca()
        self.ax.set_position([0.1, 0.05, 0.8, 0.94])
        self.ax.invert_yaxis()
        # l, b, w, h = self.ax.get_position().bounds
        # print(l, b, w, h)
        self.mw.draw()
        # self.plotlayout.addWidget(self.mw)

        self.scrollArea.setWidget(self.mw)

        layout.addWidget(self.scrollArea)

        self.setCentralWidget(self.centralWidget)
        self.wellLoad()
        self.logtree = LasTree(['GR', 'NPHI'])
        self.logtree.buildTreeWidget()
        self.logtree.tree.itemSelectionChanged.connect(self.logPlot)

        self.createDockWindows()

        # self.logFileList.itemSelectionChanged.connect(self.lasLoad)
        # if not self.las_just_selected:
        # self.logList.itemSelectionChanged.connect(self.logPlot)

        self.setWindowTitle("Loggy")

        # self.newLetter()
    def wellLoad(self):
        self.wellFolder = r'E:\Data\W1\LAS\\'

        self.files = np.array(os.listdir(self.wellFolder)[:])
        files_w_path = [self.wellFolder + f for f in self.files]
        # print(files_w_path)
        # self.logFileList.addItems(self.files)

        # folder=r'D:\Ameyem Office\Projects\Cairn\W1\LAS\\'
        cols = []
        # las=[]
        # log.df().sort_values([log.keys()[dindx]])
        # log.keys()
        self.files = np.array(os.listdir(self.wellFolder)[:])
        self.lastree = LasTree(self.files)
        self.lastree.buildTreeWidget()
        self.lastree.tree.itemSelectionChanged.connect(self.lasLoad)

        self.lasLoadThread = LasLoadThread(files=files_w_path)

    # def lasBackgroundLoad():

    def lasLoad(self):
        las_name = self.lastree.tree.selectedItems()[0].text(
            0)  #self.logFileList.selectedItems()[0].text()
        if las_name in ['TVD', 'MD', 'LWD', 'WireLine']:
            return

        findex = np.where(self.files == las_name)[0][0]
        # print(findex)
        Loaded = False
        while (not Loaded):
            if (findex < len(self.lasLoadThread.Lases)):
                self.las = self.lasLoadThread.Lases[findex]
                Loaded = True
            else:
                self.logtree.clear()
                # self.logtree.addItems(['Loading....'])
                time.sleep(1)

        if len(self.logtree.selectedItems()) > 0:
            item = self.logtree.selectedItems()[0]
            # print(dir(item))
            item.setSelected = False
        # self.logList.clear()
        # self.logList.addItems(self.las.keys() )
        if not (len(self.las.keys()) < 1):
            self.logtree = LasTree(self.las.keys())
            self.logtree.buildTreeWidget()
            # self.logtree.tree.itemSelectionChanged.connect(self.logPlot)

            dcol = self.las.keys()[find_depth_indx(self.las)]
            self.depth_col = str_array2floats(self.las[dcol])
        # else:

        # self.las_just_selected = True

    def logPlot(self):

        # print(self.mw.getFigure().)
        # pass
        # if not self.las_just_selected:
        if len(self.logtree.selectedItems()) > 0:
            keycol = self.logtree.selectedItems()[0].text(0)
            try:
                self.log_col = str_array2floats(self.las[keycol])
                self.ax = LogPlot.basicPlot(self.ax,
                                            self.depth_col,
                                            self.log_col,
                                            lcolor='#800000')
            except:
                print('Unable to convert log to floats')
        # else:
        #     self.las_just_selected=False

        # fig.subplots_adjust(top=0.75,wspace=0.1)

        # ax.invert_yaxis()
        # ax.plot([1,2,3],[2,1,4],'*')
        self.mw.draw()
        # self.subplot1 = self.mw.getFigure().add_subplot(121)

    def createDockWindows(self):

        dock = QDockWidget("Log Files", self)
        dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)

        # self.logFileList = self.lastree.tree #QListWidget(dock)
        # self.customerList.addItems(('Hello','How are you'))
        dock.setWidget(self.lastree.tree)
        #
        self.addDockWidget(Qt.LeftDockWidgetArea, dock)
        # self.viewMenu.addAction(dock.toggleViewAction())

        dock = QDockWidget("Logs", self)

        # self.logList = QListWidget(dock)
        # self.logList.addItems(('Good morning','Hope you are doing well'))

        dock.setWidget(self.logtree.tree)

        # self.logList = QListWidget(dock)
        # self.logList.addItems(('Good morning','Hope you are doing well'))
        # dock.setWidget(self.logList)

        self.addDockWidget(Qt.LeftDockWidgetArea, dock)
コード例 #8
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.createActions()
        self.createMenus()
        self.setGeometry(100, 100, 600, 900)

        self.centralWidget = QWidget()
        # GrphicsWidget()
        layout = QHBoxLayout(self.centralWidget)
        self.scrollArea = QScrollArea(self)
        self.mw = MatplotlibWidget(size=(3.0, 40.0), dpi=100)
        lplot = self.mw.getFigure().add_subplot(121)
        self.ax = self.mw.getFigure().gca()
        l, b, w, h = self.ax.get_position().bounds
        # print(l, b, w, h)
        # self.ax.invert_yaxis()
        self.ax.set_position([0.125, 0.05, 0.5, 0.94])

        # l, b, w, h = self.ax.get_position().bounds
        # print(l, b, w, h)
        self.mw.draw()
        # self.plotlayout.addWidget(self.mw)

        self.scrollArea.setWidget(self.mw)

        layout.addWidget(self.scrollArea)

        self.setCentralWidget(self.centralWidget)
        self.lastree = LasTree()
        self.logtree = LasTree()
        self.wellLoad()
        self.logtree.set_files(['GR', 'BS'])
        self.logtree.buildTreeWidget()
        self.logtree.tree.itemSelectionChanged.connect(self.logPlot)

        self.createDockWindows()

        # self.logFileList.itemSelectionChanged.connect(self.lasLoad)
        # if not self.las_just_selected:
        # self.logList.itemSelectionChanged.connect(self.logPlot)

        self.setWindowTitle("Loggy")

        # self.newLetter()
    def wellLoad(self):
        self.wellFolder = well_folder

        self.files = []
        for f in np.array(os.listdir(self.wellFolder)[:]):
            if f[-4:].lower() in ['.las', 'dlis']:
                self.files.append(f)
        self.files = np.array(self.files)
        files_w_path = [self.wellFolder + f for f in self.files]

        cols = []

        # self.files=np.array(os.listdir(self.wellFolder)[:])

        self.lastree.set_files(self.files)
        self.lastree.buildTreeWidget()
        self.lasfiletree = self.lastree.treeview_dict.copy()
        self.lastree.tree.itemSelectionChanged.connect(self.lasLoad)

        self.lasLoadThread = LasLoadThread(files=files_w_path)

    # def lasBackgroundLoad():

    def lasLoad(self):
        las_name = self.lastree.tree.selectedItems()[0].text(
            0)  #self.logFileList.selectedItems()[0].text()
        if las_name in ['TVD', 'MD', 'LWD', 'WireLine']:
            return

        findex = np.where(self.files == las_name)[0][0]
        # print(findex)
        Loaded = False
        while (not Loaded):
            if (findex < len(self.lasLoadThread.Lases)):
                self.las = self.lasLoadThread.Lases[findex]
                Loaded = True
                self.logtree.tree.clear()
                # print('hi')
            else:
                # print('hello')

                # self.logtree.addItems(['Loading....'])
                time.sleep(1)

        if len(self.logtree.tree.selectedItems()) > 0:
            item = self.logtree.tree.selectedItems()[0]
            # print(dir(item))
            item.setSelected = False
        if not (len(self.las.keys()) < 1):
            # self.logtree = LasTree(self.las.keys())
            self.logtree.set_files(self.las.keys())
            self.logtree.buildTreeWidget()

            dcol = self.las.keys()[find_depth_indx(self.las)]
            self.depth_col = str_array2floats(self.las[dcol])
        # else:

        # self.las_just_selected = True

    def logPlot(self):

        # print(self.mw.getFigure().)
        # pass
        # if not self.las_just_selected:
        if len(self.logtree.tree.selectedItems()) > 0:
            keycol = self.logtree.tree.selectedItems()[0].text(0)
            try:
                self.log_col = str_array2floats(self.las[keycol])
                self.ax = LogPlot.basicPlot(self.ax,
                                            self.depth_col,
                                            self.log_col,
                                            lcolor='#800000')
                self.ax.set_ylim(500, 3000)
                self.ax.invert_yaxis()
            except:
                print('Unable to convert log to floats')
        self.mw.draw()

    def set_category(self):
        # qt_app = QApplication(sys.argv)
        # mnomonicsfile=mnomonicsfile
        # print(self.logtree.treeview_dict)
        # set_category_app = Categorize(self.logtree.treeview_dict,mnomonicsfile)
        print('*************************************************')
        print(self.logtree.treeview_dict)
        category_window = Categorize(self)
        category_window.set_params(self.logtree, mnomonicsfile)
        category_window.show()

        # self.logtree.tree.clear()
        # self.logtree.buildTreeWidget()
        # set_category_app.run()
        # self.logtree.buildTreeWidget()

    def createDockWindows(self):

        dock = QDockWidget("Log Files", self)
        dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        dock.setWidget(self.lastree.tree)
        #
        self.addDockWidget(Qt.LeftDockWidgetArea, dock)
        self.set_category_button = QPushButton('Set Category', self)
        self.slect_files_button = QPushButton(
            'Select files for further process', self)

        # self.layout.addWidget(self.logtree.tree)
        dock = QDockWidget("Set", self)
        btn_w = QWidget()
        self.btn_layout = QVBoxLayout()
        btn_w.setLayout(self.btn_layout)
        dock.setWidget(btn_w)

        self.btn_layout.addWidget(self.set_category_button)
        self.btn_layout.addWidget(self.slect_files_button)

        self.addDockWidget(Qt.LeftDockWidgetArea, dock)
        dock = QDockWidget("Logs", self)

        dock.setWidget(self.logtree.tree)
        self.addDockWidget(Qt.LeftDockWidgetArea, dock)

        self.set_category_button.clicked.connect(self.set_category)
        self.slect_files_button.clicked.connect(self.retain4FurtherAnalysis)

    def createActions(self):
        self.exitAct = QAction("E&xit",
                               self,
                               shortcut="Ctrl+Q",
                               triggered=self.close)
        self.openFileAct = QAction("&Open",
                                   self,
                                   shortcut="Ctrl+O",
                                   triggered=self.file_open)
        self.aboutAct = QAction("&About", self, triggered=self.about)

    def retain4FurtherAnalysis(self):
        # print(self.lastree.treeview_dict)

        print(self.lasfiletree)
        lasfilemodtree = {}
        lc = LogCategorize(mnomonicsfile)
        self.files_4_further_analysis = []
        self.allfiles = {'fname': [], 'drange': [], 'curve_names': []}
        if len(self.lasLoadThread.Lases) == len(self.files):
            print('Loaded all files...')
            for las, lf in zip(self.lasLoadThread.Lases, self.files):
                lc.set_las(las)
                lc.lasCategorize()
                # print(lc.treeview_dict)
                # print(lc.get_catePresent())
                # print( lc.get_lasdepthrange())
                # print( lc.get_curverange('CAL'))
                lcates = lc.get_catePresent()
                # if len(lcates)>3:
                self.allfiles['fname'].append(lf)
                self.allfiles['drange'].append(lc.get_lasdepthrange())
                self.allfiles['curve_names'].append(lc.get_catePresent())
            # print(self.allfiles)
            topdepts = np.array(
                [np.float(d[0]) for d in self.allfiles['drange']])
            ncurves = np.array([len(d) for d in self.allfiles['curve_names']])

            self.allfiles['topdepts'] = topdepts
            self.allfiles['ncurves'] = ncurves
            self.allfiles['fname'] = np.array(self.allfiles['fname'])
            print(np.column_stack((topdepts, ncurves)))
            for k in self.lasfiletree:
                lasfilemodtree[k] = {}
                for l in self.lasfiletree[k]:
                    lasfilemodtree[k][l] = {}
                    if (len(self.lasfiletree[k][l]) > 0):
                        branch_files = np.array(self.lasfiletree[k][l])
                        print('*****************************************')
                        print(branch_files)
                        branch_files = self.sort_per_depthNcurves(branch_files)
                        print(branch_files)
                        for m in branch_files:
                            indx = np.where(self.allfiles['fname'] == m)[0][0]
                            print(m, self.allfiles['fname'], indx)
                            lasfilemodtree[k][l][m] = [
                                '{} - {}'.format(
                                    *self.allfiles['drange'][indx]),
                                str(len(self.allfiles['curve_names'][indx])),
                                ','.join(self.allfiles['curve_names'][indx])
                            ]
        else:
            print('Not loaded all files...')
        print(lasfilemodtree)
        self.retain_tree = Pytree(self)
        self.retain_tree.set_tree(lasfilemodtree)
        self.retain_tree.select_btn.clicked.connect(self.return_selected_items)
        self.retain_tree.buildTree()
        self.retain_tree.show()

        # sys.exit(app.exec_())
    def return_selected_items(self):
        iterator = QTreeWidgetItemIterator(self.retain_tree.tree)
        value = iterator.value()
        self.retain_files = []
        self.retain_files_ranges = []
        while value:
            if value.checkState(0) == Qt.Checked:
                # print('yes')
                print(value.text(0))
                self.retain_files.append(value.text(0))
                self.retain_files_ranges.append(value.text(1))
            # if hasattr(value, 'saveValue'):
            #     value.saveValue()
            iterator += 1
            value = iterator.value()
        # print(self.retain_files)
        # print(self.retain_files_ranges)
        self.retain_tree.close()
        self.show_lateralCorrections()

    def show_lateralCorrections(self):

        self.lateralCorr_buttons = []
        for i, rf in enumerate(zip(self.retain_files,
                                   self.retain_files_ranges)):
            lcw = QWidget()
            self.harlayout = QHBoxLayout()
            self.lateralCorr_buttons.append(
                QPushButton('Do Lateral Depth Match-' + str(i), self))
            self.harlayout.addWidget(QLabel(rf[1]))
            self.harlayout.addWidget(self.lateralCorr_buttons[-1])
            print(rf[0])
            self.lateralCorr_buttons[-1].clicked.connect(
                lambda state, x=rf[0]: self.doLateralCorr(x))
            lcw.setLayout(self.harlayout)
            self.btn_layout.addWidget(lcw)

    def doLateralCorr(self, lfilename):
        self.selected_lases = []
        findex = np.where(self.files == lfilename)[0][0]
        print(lfilename, findex)
        self.selected_lases.append(self.lasLoadThread.Lases[findex])
        lateralWin = LateralCorr(self)
        lateralWin.buildLogTree(self.selected_lases)
        lateralWin.logCorrelations()
        lateralWin.show()

    def sort_per_depthNcurves(self, branch_files):
        indxs = []

        for m in branch_files:
            indxs.append(np.where(self.allfiles['fname'] == m)[0][0])
        ncurves = self.allfiles['ncurves'][indxs]

        sort_dpt_indx = np.argsort(self.allfiles['topdepts'][indxs])

        ncurves_rule = ncurves[sort_dpt_indx] > 2
        branch_files = branch_files[sort_dpt_indx]

        # sort_dpt_indx=sort_dpt_indx[::-1]

        return np.append(branch_files[ncurves_rule],
                         branch_files[~ncurves_rule])

    def createMenus(self):
        self.fileMenu = QMenu("&File", self)
        # self.fileMenu.addAction(self.openAct)
        # self.fileMenu.addAction(self.printAct)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.openFileAct)
        self.fileMenu.addAction(self.exitAct)

        self.helpMenu = QMenu("&Help", self)
        self.helpMenu.addAction(self.aboutAct)
        # self.helpMenu.addAction(self.aboutQtAct)

        self.menuBar().addMenu(self.fileMenu)
        # self.menuBar().addMenu(self.viewMenu)
        # self.menuBar().addMenu(self.digitizeMenu)
        self.menuBar().addMenu(self.helpMenu)

        self.file_toolbar = QToolBar("File")
        self.file_toolbar.setIconSize(QSize(24, 24))
        self.addToolBar(self.file_toolbar)

    def about(self):
        QMessageBox.about(
            self, "About Log splicer",
            "<p>The <b>Image Viewer</b> example shows how to combine "
            "(QScrollArea.widgetResizable), can be used to implement "
            "zooming and scaling features.</p>"
            "<p>In addition the example shows how to use QPainter to "
            "print an image.</p>")

    def file_open(self):
        print('Not yet set')
コード例 #9
0
class VerticalCorr(QMainWindow):
    def __init__(self, parent=None):
        super(VerticalCorr, self).__init__(parent)
        from loggy_settings import well_folder, lwdVSwirelineFile, mnomonicsfile
        # projectFolder=r'D:\Ameyem Office\Projects\Cairn\W1\\'

        self.log_bundle = np.load(well_folder + '..\proc_logs_bundle.npy')
        self.flt_logs = {}

        for logname in self.log_bundle[0]['keys']:
            print(logname)
            self.flt_logs[logname] = [[] for i in range(len(self.log_bundle))]

        print('Starting main window...')

        self.centralWidget = QWidget()
        self.setCentralWidget(self.centralWidget)
        self.setWindowTitle('Vertical Correlations')
        self.setGeometry(100, 100, 900, 400)
        layout = QVBoxLayout(self.centralWidget)

        self.logscrollArea = QScrollArea(self)
        layout.addWidget(self.logscrollArea)

        fw = QWidget()
        # fw.setMaximumWidth(120)
        # self.formLayout=QFormLayout()
        self.formLayout = QHBoxLayout()
        fw.setLayout(self.formLayout)
        layout.addWidget(fw)

        self.filtscrollArea = QScrollArea(self)
        layout.addWidget(self.filtscrollArea)
        self.getFormLayerFilled()

        self.setCentralWidget(self.centralWidget)

        self.createDockWindows()

        self.run_mass_filter()

    def getFormLayerFilled(self):
        self.learray = []
        # self.formLayout.addRow(QLabel(' '))
        # self.formLayout.addRow(QLabel('Calculated delays'))
        # self.formLayout.addRow(QLabel(' '))
        # for i,l in enumerate(self.delays.keys()):
        #     self.learray.append( QLineEdit('%.2f'%self.delays[l])) #
        #     self.formLayout.addRow(QLabel(l),self.learray[-1])
        self.n_patches2retain_le = QLineEdit('1')
        self.n_hist_segments_le = QLineEdit('100')
        self.histFilter_btn = QPushButton("Remove Spikes")
        self.histForm = QFormLayout()

        self.histForm.addRow(QLabel('Retainpatches: '),
                             self.n_patches2retain_le)
        self.histForm.addRow(QLabel('HistSegments: '), self.n_hist_segments_le)

        hfw = QWidget()
        hfw.setMaximumWidth(200)
        hfw.setLayout(self.histForm)
        # hfw.setMinimumWidth(120)

        self.formLayout.addWidget(hfw)
        self.formLayout.addWidget(self.histFilter_btn)
        self.histFilter_btn.clicked.connect(self.histFilter)
        # self.formLayout.addRow(QLabel('   '))

        # self.recal_btn = QPushButton("Recalculate")
        # self.formLayout.addRow(self.recal_btn)
        # self.recal_btn.clicked.connect(self.recalculateDelay)

    #     self.formLayout.addRow(QLabel(' '))
    #     self.save_btn = QPushButton("Save Curves")
    #     self.formLayout.addRow(self.save_btn)
    #     self.save_btn.clicked.connect(self.saveCorrCurves)

    # def applyDelayChange(self):
    #     for le,key in zip(self.learray,self.delays.keys()):
    #         self.delays[key]=np.float(le.text())
    #         print(le.text())
    #     self.log_correlations_plot()
    # def recalculateDelay(self):

    #     self.logCorrelations()

    # def saveCorrCurves(self):
    #     print('Saving logs...')
    #     proc_logs={}
    #     for logname in self.delays.keys():
    #         if self.delays[logname] !=0:
    #             shift_depth=self.depth_col+self.delays[logname]
    #             shift_depth.shape=len(shift_depth),1
    #             # np.save('now.npy',(shift_depth,self.las[logname]))
    #             # print(shift_depth,self.las[logname])
    #             XY=np.append(shift_depth,self.las[logname].reshape(len(shift_depth),1),axis=1)
    #             XY.shape=len(shift_depth),2
    #             # print(XY)
    #             flexlog=FlexLog(XY)
    #             resamLog=flexlog.resampleY(self.depth_col)
    #         else:
    #             resamLog=self.las[logname]
    #         key=self.interestedKeynames[self.interestedLognames==logname][0]
    #         proc_logs[key]=resamLog
    #     proc_logs['GR']=self.las[self.grlogname]
    #     proc_logs['DEPTH']=self.depth_col
    #     proc_logs['vlues_size']=np.size(self.las.values())
    #     proc_logs['keys']=self.interestedKeynames
    #     # proc_logs['test']='yes'
    #     bundle_file=self.wellFolder+'../proc_logs_bundle.npy'
    #     repeated=False
    #     if os.path.isfile(bundle_file):
    #         logbundle=np.load(bundle_file)
    #         for i,lb in enumerate(logbundle):
    #             if lb['vlues_size']==proc_logs['vlues_size']:
    #                 repeated=True
    #                 print('It is repeated so updated but not created...')
    #                 logbundle[i]=proc_logs
    #     else:
    #         logbundle=[]
    #     if not repeated:
    #         logbundle=np.append(logbundle,proc_logs)
    #     np.save(bundle_file,logbundle)
    #     print('Processed logs saved.. you can move on to next set...')
    #     time.sleep(2)
    #     self.close()
    def histFilter(self):
        depthcol_name = 'DEPTH'
        self.filtw = MatplotlibWidget(size=(22.0, 4), dpi=100)
        self.filtscrollArea.setWidget(self.filtw)
        ax = self.filtw.getFigure().add_subplot(1, 1, 1)

        hist_bins = np.int(self.n_hist_segments_le.text())
        n_big_patches = np.int(self.n_patches2retain_le.text())
        self.flt_logs[self.logname] = []
        for i, lb in enumerate(self.log_bundle):
            self.flt_logs[self.logname][i] = hist_filter(
                lb[self.logname].copy(),
                n_big_patches=n_big_patches,
                hist_bins=hist_bins)
            ax.plot(lb[depthcol_name], self.flt_logs[self.logname][i])
        # print(flt_arrs)

    def run_mass_filter(self):
        hist_bins = np.int(self.n_hist_segments_le.text())
        n_big_patches = np.int(self.n_patches2retain_le.text())

        for i, lb in enumerate(self.log_bundle):
            for logname in lb['keys']:
                self.flt_logs[logname][i] = hist_filter(
                    lb[logname].copy(),
                    n_big_patches=n_big_patches,
                    hist_bins=hist_bins)

    def logPlotPanel(self):
        print('Initiating plot widget...')
        self.logname = self.lastree.tree.selectedItems()[0].text(0)

        depthcol_name = 'DEPTH'
        # firstlog
        logdata = []
        depthdata = []
        self.mw = MatplotlibWidget(size=(22.0, 4), dpi=100)
        self.logscrollArea.setWidget(self.mw)
        self.ax = self.mw.getFigure().add_subplot(1, 1, 1)

        self.filtw = MatplotlibWidget(size=(22.0, 4), dpi=100)
        self.filtscrollArea.setWidget(self.filtw)
        ax2 = self.filtw.getFigure().add_subplot(1, 1, 1)

        for i, lb in enumerate(self.log_bundle):
            # print(lb[self.logname],lb[depthcol_name])
            self.ax.plot(lb[depthcol_name], lb[self.logname])
            ax2.plot(lb[depthcol_name], self.flt_logs[self.logname][i])

            # logdata=np.append([logdata],[lb[logname]],axis=0  )
            # depthdata=np.append([depthdata],[lb[depthcol_name] ],axis=0  )
        # print(logdata)
        # self.depth_col=self.las[dcol]
        # dt=self.depth_col[1]-self.depth_col[0]
        # print('Spacing = ',dt)
        # gammacol=self.las[self.grlogname]
        # gammacol[np.isnan(gammacol)]=0
        # self.norm_gamma=mean_norm(gammacol)#[0:800]

        # l, b, w, h = self.ax.get_position().bounds
        # self.ax.set_position([0.27,b+0.1,0.7,h])

        # self.lag_corrs={}
        # self.delays={}
        # self.normlogs={}
        # print('Calculating correlations...')
        # for logname in self.interestedLognames:
        #     if logname != self.grlogname:
        #         self.log_col=self.las[logname]
        #         self.log_col[np.isnan(self.log_col)]=0
        #         norm_blog=mean_norm(self.log_col)#[0:800]
        #         self.normlogs[logname]=norm_blog
        #         dist2look=100
        #         delay_estimation,lag_corr= get_delay(self.norm_gamma,norm_blog,dt,corrtype='abs',dist2look=dist2look)
        #         self.delays[logname]=-delay_estimation
        #         lagcor_range=np.arange(round(len(lag_corr[0])/2)-4*dist2look,round(len(lag_corr[0])/2)+4*dist2look)
        #         self.lag_corrs[logname]=(lag_corr[0][lagcor_range],lag_corr[1][lagcor_range])
        # self.log_correlations_plot()
        # self.getFormLayerFilled()
    def log_correlations_plot(self):
        self.mw = MatplotlibWidget(size=(22.0,
                                         len(self.interestedLognames) * 1.6),
                                   dpi=100)
        self.logscrollArea.setWidget(self.mw)
        print('Plotting...')
        self.ax = []
        for i, logname in enumerate(self.normlogs.keys()):
            self.ax.append(self.mw.getFigure().add_subplot(
                len(self.normlogs), 1, i + 1))
            l, b, w, h = self.ax[-1].get_position().bounds
            self.ax[-1].set_position([0.27, b + 0.1, 0.7, h])
            # self.log_col=self.las[logname]
            # self.log_col[np.isnan(self.log_col)]=0
            # norm_blog=mean_norm(self.log_col)#[0:800]
            depthb_shift = self.depth_col + self.delays[logname]
            self.ax[-1].plot(self.depth_col, self.normlogs[logname], 'b')
            self.ax[-1].plot(self.depth_col, self.norm_gamma, 'r')
            self.ax[-1].plot(depthb_shift, self.normlogs[logname], 'magenta')
            self.ax[-1].text(self.depth_col[0] - 50, 0.02, logname)

        lenax = len(self.ax)
        for i, logname in enumerate(self.lag_corrs.keys()):
            self.ax.append(self.mw.getFigure().add_subplot(
                len(self.normlogs), 2, lenax + i + 1))
            l, b, w, h = self.ax[i].get_position().bounds
            self.ax[-1].set_position([0.03, b, 0.21, h])
            self.ax[-1].plot(self.lag_corrs[logname][0],
                             self.lag_corrs[logname][1], 'b')
            self.ax[-1].text(self.delays[logname],
                             min(self.lag_corrs[logname][1]),
                             'Delay = %.2f' % self.delays[logname])
            line = self.ax[-1].axvline(x=self.delays[logname],
                                       ymin=-1,
                                       ymax=+1,
                                       linewidth=1.5,
                                       color='c')
            self.ax[-1].text(self.lag_corrs[logname][0][0], 0.4, logname)

        self.mw.draw()
        print('Complete...')

    def buildLogTree(self):
        self.lastree = LasTree()
        self.lastree.tree.headerItem().setText(0, "Categories")
        for lb in self.log_bundle:
            # logkeys=np.append(['GR'],lb['keys'])
            # print(logkeys)
            self.lastree.set_files(lb['keys'], make_tree_dict=False)
            mind, maxd = min(lb['DEPTH']), max(lb['DEPTH'])
            self.lastree.tree = treeWidgetFrmArray(
                self.lastree.tree, '({0:4.1f} to {1:4.1f})'.format(mind, maxd),
                lb['keys'])
        self.lastree.tree.itemSelectionChanged.connect(self.logPlotPanel)
        self.dock.setWidget(self.lastree.tree)
        print(dir(self.lastree.tree))
        print(help(self.lastree.tree.itemAt))
        print(self.lastree.tree.itemAt(1, 0).text(0))

    def createDockWindows(self):
        self.dock = QDockWidget("Log Files", self)
        self.dock.setAllowedAreas(Qt.LeftDockWidgetArea
                                  | Qt.RightDockWidgetArea)
        # dock.setWidget(self.lastree.tree)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.dock)
コード例 #10
0
ファイル: Loggy-v2.py プロジェクト: narunbabu/Loggy
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setGeometry(100, 100, 600, 900)

        self.centralWidget = QWidget()
        # GrphicsWidget()
        layout = QHBoxLayout(self.centralWidget)
        self.scrollArea = QScrollArea(self)

        # gwidget=GrphicsWidget()

        self.mw = MatplotlibWidget(size=(3.0, 40.0), dpi=100)
        lplot = self.mw.getFigure().add_subplot(121)
        # print(dir(self.mw.getFigure()))

        # self.mw.getFigure().set_axes([0.85, 0.1, 0.075, 0.8])
        self.ax = self.mw.getFigure().gca()
        self.ax.set_position([0.1, 0.05, 0.8, 0.94])
        self.ax.invert_yaxis()
        # l, b, w, h = self.ax.get_position().bounds
        # print(l, b, w, h)
        self.mw.draw()
        # self.plotlayout.addWidget(self.mw)

        self.scrollArea.setWidget(self.mw)

        layout.addWidget(self.scrollArea)

        self.setCentralWidget(self.centralWidget)
        self.lastree = LasTree()
        self.logtree = LasTree()
        self.wellLoad()
        self.logtree.set_files(['GR', 'BS'])
        self.logtree.buildTreeWidget()
        self.logtree.tree.itemSelectionChanged.connect(self.logPlot)

        self.createDockWindows()

        # self.logFileList.itemSelectionChanged.connect(self.lasLoad)
        # if not self.las_just_selected:
        # self.logList.itemSelectionChanged.connect(self.logPlot)

        self.setWindowTitle("Loggy")

        # self.newLetter()
    def wellLoad(self):
        self.wellFolder = r'D:\Ameyem Office\Projects\Cairn\W1\LAS\\'

        self.files = np.array(os.listdir(self.wellFolder)[:])
        files_w_path = [self.wellFolder + f for f in self.files]

        cols = []

        self.files = np.array(os.listdir(self.wellFolder)[:])

        self.lastree.set_files(self.files)
        self.lastree.buildTreeWidget()
        self.lastree.tree.itemSelectionChanged.connect(self.lasLoad)

        self.lasLoadThread = LasLoadThread(files=files_w_path)

    # def lasBackgroundLoad():

    def lasLoad(self):
        las_name = self.lastree.tree.selectedItems()[0].text(
            0)  #self.logFileList.selectedItems()[0].text()
        if las_name in ['TVD', 'MD', 'LWD', 'WireLine']:
            return

        findex = np.where(self.files == las_name)[0][0]
        # print(findex)
        Loaded = False
        while (not Loaded):
            if (findex < len(self.lasLoadThread.Lases)):
                self.las = self.lasLoadThread.Lases[findex]
                Loaded = True
                self.logtree.tree.clear()
                # print('hi')
            else:
                # print('hello')

                # self.logtree.addItems(['Loading....'])
                time.sleep(1)

        if len(self.logtree.tree.selectedItems()) > 0:
            item = self.logtree.tree.selectedItems()[0]
            # print(dir(item))
            item.setSelected = False
        if not (len(self.las.keys()) < 1):
            # self.logtree = LasTree(self.las.keys())
            self.logtree.set_files(self.las.keys())
            self.logtree.buildTreeWidget()

            dcol = self.las.keys()[find_depth_indx(self.las)]
            self.depth_col = str_array2floats(self.las[dcol])
        # else:

        # self.las_just_selected = True

    def logPlot(self):

        # print(self.mw.getFigure().)
        # pass
        # if not self.las_just_selected:
        if len(self.logtree.tree.selectedItems()) > 0:
            keycol = self.logtree.tree.selectedItems()[0].text(0)
            try:
                self.log_col = str_array2floats(self.las[keycol])
                self.ax = LogPlot.basicPlot(self.ax,
                                            self.depth_col,
                                            self.log_col,
                                            lcolor='#800000')
            except:
                print('Unable to convert log to floats')
        self.mw.draw()

    def set_category(self):
        # qt_app = QApplication(sys.argv)
        mnomonicsfile = self.wellFolder + '../../mnemonics.txt'
        # print(self.logtree.treeview_dict)
        # set_category_app = Categorize(self.logtree.treeview_dict,mnomonicsfile)
        print('*************************************************')
        print(self.logtree.treeview_dict)
        category_window = Categorize(self)
        category_window.set_params(self.logtree, mnomonicsfile)
        category_window.show()

        # self.logtree.tree.clear()
        # self.logtree.buildTreeWidget()
        # set_category_app.run()
        # self.logtree.buildTreeWidget()

    def createDockWindows(self):

        dock = QDockWidget("Log Files", self)
        dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        dock.setWidget(self.lastree.tree)
        #
        self.addDockWidget(Qt.LeftDockWidgetArea, dock)
        self.set_category_button = QPushButton('Set Category', self)

        # self.layout.addWidget(self.logtree.tree)
        dock = QDockWidget("Set", self)
        dock.setWidget(self.set_category_button)
        self.addDockWidget(Qt.LeftDockWidgetArea, dock)
        dock = QDockWidget("Logs", self)

        dock.setWidget(self.logtree.tree)
        self.addDockWidget(Qt.LeftDockWidgetArea, dock)

        self.set_category_button.clicked.connect(self.set_category)
コード例 #11
0
ファイル: Loggy-v2.1.py プロジェクト: narunbabu/Loggy
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.createActions()
        self.createMenus()
        self.setGeometry(100, 100, 600, 900)

        self.centralWidget = QWidget()
        # GrphicsWidget()
        layout = QHBoxLayout(self.centralWidget)
        self.scrollArea = QScrollArea(self)
        self.mw = MatplotlibWidget(size=(3.0, 40.0), dpi=100)
        lplot = self.mw.getFigure().add_subplot(121)
        self.ax = self.mw.getFigure().gca()
        l, b, w, h = self.ax.get_position().bounds
        # print(l, b, w, h)
        # self.ax.invert_yaxis()
        self.ax.set_position([0.125, 0.05, 0.5, 0.94])

        # l, b, w, h = self.ax.get_position().bounds
        # print(l, b, w, h)
        self.mw.draw()
        # self.plotlayout.addWidget(self.mw)

        self.scrollArea.setWidget(self.mw)

        layout.addWidget(self.scrollArea)

        self.setCentralWidget(self.centralWidget)
        self.lastree = LasTree()
        self.logtree = LasTree()
        self.wellLoad()
        self.logtree.set_files(['GR', 'BS'])
        self.logtree.buildTreeWidget()
        self.logtree.tree.itemSelectionChanged.connect(self.logPlot)

        self.createDockWindows()

        # self.logFileList.itemSelectionChanged.connect(self.lasLoad)
        # if not self.las_just_selected:
        # self.logList.itemSelectionChanged.connect(self.logPlot)

        self.setWindowTitle("Loggy")

        # self.newLetter()
    def wellLoad(self):
        self.wellFolder = well_folder

        self.files = []
        for f in np.array(os.listdir(self.wellFolder)[:]):
            if f[-4:].lower() in ['.las', 'dlis']:
                self.files.append(f)
        self.files = np.array(self.files)
        files_w_path = [self.wellFolder + f for f in self.files]

        cols = []

        # self.files=np.array(os.listdir(self.wellFolder)[:])

        self.lastree.set_files(self.files)
        self.lastree.buildTreeWidget()
        self.lastree.tree.itemSelectionChanged.connect(self.lasLoad)

        self.lasLoadThread = LasLoadThread(files=files_w_path)

    # def lasBackgroundLoad():

    def lasLoad(self):
        las_name = self.lastree.tree.selectedItems()[0].text(
            0)  #self.logFileList.selectedItems()[0].text()
        if las_name in ['TVD', 'MD', 'LWD', 'WireLine']:
            return

        findex = np.where(self.files == las_name)[0][0]
        # print(findex)
        Loaded = False
        while (not Loaded):
            if (findex < len(self.lasLoadThread.Lases)):
                self.las = self.lasLoadThread.Lases[findex]
                Loaded = True
                self.logtree.tree.clear()
                # print('hi')
            else:
                # print('hello')

                # self.logtree.addItems(['Loading....'])
                time.sleep(1)

        if len(self.logtree.tree.selectedItems()) > 0:
            item = self.logtree.tree.selectedItems()[0]
            # print(dir(item))
            item.setSelected = False
        if not (len(self.las.keys()) < 1):
            # self.logtree = LasTree(self.las.keys())
            self.logtree.set_files(self.las.keys())
            self.logtree.buildTreeWidget()

            dcol = self.las.keys()[find_depth_indx(self.las)]
            self.depth_col = str_array2floats(self.las[dcol])
        # else:

        # self.las_just_selected = True

    def logPlot(self):

        # print(self.mw.getFigure().)
        # pass
        # if not self.las_just_selected:
        if len(self.logtree.tree.selectedItems()) > 0:
            keycol = self.logtree.tree.selectedItems()[0].text(0)
            try:
                self.log_col = str_array2floats(self.las[keycol])
                self.ax = LogPlot.basicPlot(self.ax,
                                            self.depth_col,
                                            self.log_col,
                                            lcolor='#800000')
                self.ax.set_ylim(500, 3000)
                self.ax.invert_yaxis()
            except:
                print('Unable to convert log to floats')
        self.mw.draw()

    def set_category(self):
        # qt_app = QApplication(sys.argv)
        # mnomonicsfile=mnomonicsfile
        # print(self.logtree.treeview_dict)
        # set_category_app = Categorize(self.logtree.treeview_dict,mnomonicsfile)
        print('*************************************************')
        print(self.logtree.treeview_dict)
        category_window = Categorize(self)
        category_window.set_params(self.logtree, mnomonicsfile)
        category_window.show()

        # self.logtree.tree.clear()
        # self.logtree.buildTreeWidget()
        # set_category_app.run()
        # self.logtree.buildTreeWidget()

    def createDockWindows(self):

        dock = QDockWidget("Log Files", self)
        dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        dock.setWidget(self.lastree.tree)
        #
        self.addDockWidget(Qt.LeftDockWidgetArea, dock)
        self.set_category_button = QPushButton('Set Category', self)

        # self.layout.addWidget(self.logtree.tree)
        dock = QDockWidget("Set", self)
        dock.setWidget(self.set_category_button)
        self.addDockWidget(Qt.LeftDockWidgetArea, dock)
        dock = QDockWidget("Logs", self)

        dock.setWidget(self.logtree.tree)
        self.addDockWidget(Qt.LeftDockWidgetArea, dock)

        self.set_category_button.clicked.connect(self.set_category)

    def createActions(self):
        self.exitAct = QAction("E&xit",
                               self,
                               shortcut="Ctrl+Q",
                               triggered=self.close)
        self.openFileAct = QAction("&Open",
                                   self,
                                   shortcut="Ctrl+O",
                                   triggered=self.file_open)
        self.aboutAct = QAction("&About", self, triggered=self.about)

    def createMenus(self):
        self.fileMenu = QMenu("&File", self)
        # self.fileMenu.addAction(self.openAct)
        # self.fileMenu.addAction(self.printAct)
        self.fileMenu.addSeparator()
        self.fileMenu.addAction(self.openFileAct)
        self.fileMenu.addAction(self.exitAct)

        self.helpMenu = QMenu("&Help", self)
        self.helpMenu.addAction(self.aboutAct)
        # self.helpMenu.addAction(self.aboutQtAct)

        self.menuBar().addMenu(self.fileMenu)
        # self.menuBar().addMenu(self.viewMenu)
        # self.menuBar().addMenu(self.digitizeMenu)
        self.menuBar().addMenu(self.helpMenu)

        self.file_toolbar = QToolBar("File")
        self.file_toolbar.setIconSize(QSize(24, 24))
        self.addToolBar(self.file_toolbar)

    def about(self):
        QMessageBox.about(
            self, "About Log splicer",
            "<p>The <b>Image Viewer</b> example shows how to combine "
            "(QScrollArea.widgetResizable), can be used to implement "
            "zooming and scaling features.</p>"
            "<p>In addition the example shows how to use QPainter to "
            "print an image.</p>")

    def file_open(self):
        print('Not yet set')