Ejemplo n.º 1
0
 def findLongestGRLog(self, well):
     '''Input parameter Well object
     Returns None no GR found'''
     assert isinstance(well, Well)
     grTypeName = LogType.GAMMA.name
     grLogs = LogDao.getLogTypeLogs(well.id, grTypeName)
     log = Log()
     longestLog = None
     if grLogs is not None:
         longestLog = log.findLogWithLargestDepthRange(grLogs)
     else:
         logger.info("No GR log found in well: {1}".format(well.name))
     return longestLog
Ejemplo n.º 2
0
    def test_findLogWithLargestDepthRange(self):
        #QWidget: Must construct a QApplication before a QPaintDevice
        app = QApplication(sys.argv)

        self.dummyDbSetup = DummyDbSetup()
        self.dummyDbSetup.setupDatabase()

        session = DM.getSession()
        well = self.dummyDbSetup.createWell()
        logs = self.dummyDbSetup.create3VariableDepthLogs(well.id)
        log = Log()
        longestLog = log.findLogWithLargestDepthRange(logs)
        self.assertEqual("3SP", longestLog.name)
Ejemplo n.º 3
0
    def findLongestLog(self, well):
        '''Input parameter Well object
        Returns longest log in well'''
        assert isinstance(well, Well)

        log = Log()
        longestLog = None

        allLogs = LogDao.getWellLogs(well.id)
        longestLog = log.findLogWithLargestDepthRange(allLogs)
        if longestLog == None:
            logger.warn("No log found in well: {1}".format(well.name))

        return longestLog
Ejemplo n.º 4
0
 def populateDataCombo(self):
     log = Log()
     if log.qr_classname == self.dataClassComboBox.currentText():
         logTypeName = self.typeComboBox.currentText()
         logs = LogDao.getLogTypeLogs(self._wellPlotData.well.id, logTypeName)
         self.dataComboBox.clear()
         #add id as data
         for log in logs:
             self.dataComboBox.addItem(log.name, userData = log.id)
     else:
         self.dataComboBox.clear()
Ejemplo n.º 5
0
    def setGenericDefaults(self, wellPlotData):
        #hack compromise with having preferences in a data table
        wellPlotData.well_id = 0

        wellPlotData.title = ''

        wellPlotData.widget_width = None
        wellPlotData.widget_height = 6
        wellPlotData.y_label = WellPlotConstants.WELL_PLOT_DEFAULT_Z_MEASURE_TYPE_UID
        wellPlotData.y_limit = None

        wellPlotData.y_scale = 'linear'

        wellPlotData.y_data_string = ""
        wellPlotData.y_data = []

        #store plots in a list
        wellPlotData._z_axis_track_ids = ""
        #wellPlotData.z_axis_track_datas = []

        wellPlotData._log_track_ids = ""
        #wellPlotData.log_track_datas = []

        domainPriority = WellPlotConstants.WELL_PLOT_DOMAIN_PRIORITY
        domainTrackPriority = BaseDao.convertDataToJSON(domainPriority)
        wellPlotData.z_axis_priority_str = domainTrackPriority

        wellPlotData.display_depth_axes = False

        wellPlotData.title_on = False

        #wellPlotData.start_plots_group = PlotStartDefaults.template.name
        #ivory
        wellPlotData.plot_background_rgb = "255, 255, 240"
        wellPlotData.plot_background_alpha = "255"
        wellPlotData.label_background_rgb = "255, 255, 240"
        wellPlotData.label_background_alpha = "255"
        wellPlotData.label_foreground_rgb = "0,0,0"
        wellPlotData.label_foreground_alpha = "255"
        #wellPlotData.track_header_titles= "General Logs, Lithology, MRI, Porosity, Pore Volume, Resistivity, Saturation, Wellbore"

        wellPlotData.single_row_header_labels = False

        wellPlotData.track_header_titles_on = False
        wellPlotData.overview_range_type = WellPlotRangeType.DATASTARTSTOP.name
        wellPlotData.overview_layout_selection = WellPlotConstants.OVERVIEW_LONGEST_GR_LOG
        wellPlotData.overview_layout_data_class = str(type(Log()))
        #the following need to be set on populating widget
        #wellPlotData.overview_layout_data_type
        #wellPlotData.overview_layout_data
        wellPlotData.tracks_range_type = WellPlotRangeType.DATASTARTSTOP.name
        #5cm per 100m
        wellPlotData.tracks_vertical_spacing = 5
        wellPlotData.tracks_vertical_spacing_display_units = ScreenUnitsType.CMpHM.name
Ejemplo n.º 6
0
 def logRadioButtonClicked(self, setUp = None):
     logger.debug(">>logRadioButtonClicked")
     overviewLayoutHandler = OverviewLayoutHandler()
     self.dataToPlot = overviewLayoutHandler.findLongestLog(self._wellPlotData.well)
     if self.dataToPlot is not None:
         self.selectDataWidget.setEnabled(False)
         self.lineEditLongestLog.setText(self.dataToPlot.name)
         self.lineEditLongestGRLog.setText('')
         log = Log()
         self.dataTypeToPlot = log.qr_classname
         if setUp is None:
             self.isDirty = True
Ejemplo n.º 7
0
 def populateDataTypeCombo(self):
     log = Log()
     typeList = []
     if log.qr_classname == self.dataClassComboBox.currentText():
         logTypeList = LogDao.getLogTypeNamesInWell(self._wellPlotData.well.id)
         self.typeComboBox.clear()
         self.typeComboBox.addItems(logTypeList)
     else:
         self.typeComboBox.clear()
         logger.error("Error in text value")
         if AppSettings.isDebugMode:
             raise ValueError
Ejemplo n.º 8
0
    def generateQuickPlotPrimaryZAxis(self, wellPlotData,
                                      logsFilteredOnZMeasure,
                                      zMeasureReferenceStr, zMeasureTypeStr):
        '''Generates ZAxisData'''
        assert wellPlotData is not None
        assert logsFilteredOnZMeasure is not None
        assert zMeasureReferenceStr is not None
        assert zMeasureTypeStr is not None

        logDataLogic = Log()
        zAxisData = ZAxisDataUtility.createNewZAxis()
        #assign a uid that can be used on object before is persisted
        zAxisData.uid = id(zAxisData)

        #use primary ZMeasureType for min/max
        yMin, yMax = logDataLogic.getDepthRange(logsFilteredOnZMeasure)
        zAxisData.allLogDepthMin = yMin
        zAxisData.allLogDepthMax = yMax
        plotYmin, plotYmax = logDataLogic.getDepthPlotRange(yMin, yMax)
        zAxisData.plotMin = plotYmin
        zAxisData.plotMax = plotYmax
        zAxisData.z_axis_type = zMeasureTypeStr
        #zAxisData.z_axis_display_units = zDisplayUnitStr
        zAxisData.z_axis_reference_level = zMeasureReferenceStr
        zAxisData.is_primary = True

        #ensure we don't use same plot indexes if already allocated
        plotDict = WellPlotUtils.createPlotDict(wellPlotData)
        if plotDict is not None:
            #as are creating quickplot from nothing should be no zaxis already, if exists ensure only 1 primary axis
            for item in plotDict.values():
                if isinstance(item, ZAxisData):
                    logger.error(
                        "Existing ZAxis found during quickplot set-up")
                    item.is_primary = False
            zAxisData.plot_index = len(plotDict)
        else:
            zAxisData.plot_index = 0
        return zAxisData
Ejemplo n.º 9
0
    def parseUnitRecord(self, record):
        data = self.splitHeaderRecord(record)
        mnem = NamingUtils.createUniqueMnemonic(data[self.MNEM].strip(),
                                                self._unitMap)

        logItem = Log()
        logItem.fileMnemonic = mnem
        logItem.name = mnem
        logItem.type = self.convertType(mnem)
        logItem.fileUnit = data[self.UNIT].strip()
        logItem.unit = self.convertUnit(data[self.UNIT].strip())
        logItem.fileDescription = data[self.DESC].strip()

        self._unitMap[mnem] = data[self.UNIT].strip()
        #logger.debug("--parseUnitRecord() mnem: "+str(mnem)+" _unitMap[mnem]: "+str(self._unitMap[mnem]))
        self._commentsMap[mnem] = data[self.DESC].strip()
        self.logList.append(logItem)
Ejemplo n.º 10
0
 def populateClassCombo(self):
     '''At moment only log classes are allowed, later add Wavelet, Seismic trace, Seismic stack'''
     log = Log()
     self.dataClassComboBox.addItem(log.qr_classname)
     #reset data types
     self.populateDataTypeCombo()
Ejemplo n.º 11
0
    def create3Logs(self, wellId, session=None):
        logger.debug(">>create3Logs() well id: " + str(wellId))
        localSession = False
        if session == None:
            session = DM.getSession()
            localSession = True

        logDomain = LogDomain()
        logDomain.z_measure_type_name = "MD"

        logDomain.log_start = 0.0
        logDomain.log_step = 0.1524
        logDomain.log_stop = 1000.0

        session.add(logDomain)
        session.flush()
        logDomainId = logDomain.id

        log1 = Log()
        log1.name = "LWD_GR"
        log1.log_type_name = LogType.GAMMA.name
        log1.z_measure_type_name = "MD"
        log1.z_measure_min = 0.0
        log1.z_measure_max = 1000.0
        log1.z_measure_step = 0.1524
        log1.log_data_str = BaseDao.convertDataToJSON(
            [0.378425, 0.381605, 0.397528])
        log1.z_measure_data_str = BaseDao.convertDataToJSON([102, 103, 104])
        #log1.rgb="100,100,100"
        #log1.alpha="255"
        #log1.log_plot_points_on = False
        log1.well_id = wellId
        log1.log_domain_id = logDomainId

        log2 = Log()
        log2.name = "2DT"
        log2.log_type_name = LogType.DT.name
        log2.z_measure_type_name = "MD"
        log2.z_measure_min = 0.0
        log2.z_measure_max = 1000.0
        log2.z_measure_step = 0.1524
        log2.log_data_str = BaseDao.convertDataToJSON(
            [0.378425, 0.381605, 0.397528])
        log2.z_measure_data_str = BaseDao.convertDataToJSON([102, 103, 104])
        #log2.rgb="100,100,100"
        #log2.alpha="255"
        #log2.log_plot_points_on = False
        log2.well_id = wellId
        log2.log_domain_id = logDomainId

        log3 = Log()
        log3.name = "3SP"
        log3.log_type_name = LogType.SP.name
        log3.z_measure_type_name = "MD"
        log3.z_measure_min = 0.0
        log3.z_measure_max = 1000.0
        log3.z_measure_step = 0.1524
        log3.log_data_str = BaseDao.convertDataToJSON(
            [0.378425, 0.381605, 0.397528])
        log3.z_measure_data_str = BaseDao.convertDataToJSON([102, 103, 104])
        #log3.rgb="100,100,100"
        #log3.alpha="255"
        #log3.log_plot_points_on = False
        log3.well_id = wellId
        log3.log_domain_id = logDomainId

        self.setPreferences(log1, session)
        self.setPreferences(log2, session)
        self.setPreferences(log3, session)

        session.add(log1)
        session.add(log2)
        session.add(log3)
        session.commit()
        dummyLog = session.query(Log).filter(Log.name == 'LWD_GR').one()
        assert "LWD_GR" == dummyLog.name
        assert wellId == dummyLog.well_id
        allLogs = session.query(Log).all()
        if localSession:
            session.close()
        return allLogs
Ejemplo n.º 12
0
    def create1Log(self, wellId, session=None):
        logger.debug(">>create3Logs() well id: " + str(wellId))
        localSession = False
        if session == None:
            session = DM.getSession()
            localSession = True

        log1 = Log()
        log1.name = "SWIRR"
        log1.log_type_name = LogType.SATURATION.name
        log1.z_measure_type_name = "MD"
        log1.z_measure_min = 0.0
        log1.z_measure_max = 2000.0
        log1.z_measure_step = 0.1524
        log1.log_data_str = BaseDao.convertDataToJSON(
            [0.378425, 0.381605, 0.397528])
        log1.z_measure_data_str = BaseDao.convertDataToJSON([102, 103, 104])
        log1.well_id = wellId

        self.setPreferences(log1, session)
        session.add(log1)
        session.commit()
        dummyLog = session.query(Log).filter(Log.name == 'SWIRR').one()
        assert "SWIRR" == dummyLog.name
        assert wellId == dummyLog.well_id
        allLogs = session.query(Log).all()
        if localSession:
            session.close()
        return allLogs
Ejemplo n.º 13
0
    def handleActiveOrAllTemplate(self, well, wellPlotData, logList, template,
                                  logSet):
        assert well is not None
        assert wellPlotData is not None
        assert logList is not None
        assert template is not None

        logDataLogic = Log()

        zAxis = ZAxisDataUtility.createNewZAxis()
        #assign a uid that can be used on object before is persisted
        zAxis.uid = id(zAxis)
        domainTrackPriority = wellPlotData.getZAxisPriority()
        #use for iterating through ZMeasureType list and get list of logs with matching zAxisType
        logsFilteredOnZAxis = []
        #just want to find first domainTrackPriority
        matched = False
        zAxisReferenceStr = ""
        zAxisTypeStr = ""
        for zAxisReference in domainTrackPriority:
            zAxisType, zReference = zAxisReference.split()
            for log in logList:
                if (log.z_measure_type_name
                        == zAxisType) and (log.z_measure_reference
                                           == zReference):
                    matched = True
                    logsFilteredOnZAxis.append(log)
            if matched:
                zAxisReferenceStr = zReference
                zAxisTypeStr = zAxisType
                break

        if len(logsFilteredOnZAxis) > 0:

            #use primary ZMeasureType for min/max
            yMin, yMax = logDataLogic.getDepthRange(logsFilteredOnZAxis)
            zAxis.allLogDepthMin = yMin
            zAxis.allLogDepthMax = yMax
            plotYmin, plotYmax = logDataLogic.getDepthPlotRange(yMin, yMax)
            zAxis.plotMin = plotYmin
            zAxis.plotMax = plotYmax
            zAxis.z_axis_type = zAxisTypeStr
            zAxis.is_primary = True
            zAxis.z_axis_reference_level = zAxisReferenceStr
            #ensure we don't use same plot indexes if already allocated
            plotDict = WellPlotUtils.createPlotDict(wellPlotData)
            if plotDict is not None:
                zAxis.plot_index = len(plotDict)
            else:
                zAxis.plot_index = 0

            wellPlotData._z_axis_track_datas.append(zAxis)

            wellPlotData._log_track_datas = self.generateActiveAllEmptyLogTracks(
                wellPlotData, logsFilteredOnZAxis, paramTemplate=template)

        else:
            self.generateLoggerMessageNoLogsOfZAxisType(
                well, logSet, domainTrackPriority)

        if len(wellPlotData.getLogTrackDatas()) == 0:
            self.noLogTrackDataMessages(template, logSet, well)