Beispiel #1
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
Beispiel #2
0
 def populateWellsCombo(self):
     session = BaseDao.getSession()
     wells = WellDao.getAllWells(session)
     for well in wells:
         self.wellsComboBox.addItem(well.name, well)
     if len(wells) > 0:
         self.wellsComboBox.setCurrentIndex(0)
Beispiel #3
0
 def getZAxisDatas(self):
     ''' Retrieves lit of _z_axis_track_datas from db on first call and stores them here '''
     if (len(self._z_axis_track_datas) == 0) and (self._z_axis_track_ids != ""):
         session = DM.getSession()
         domainDataIdList = BaseDao.convertJSONtoData(self._z_axis_track_ids)
         domainTrackData = ZAxisDataDao()
         self._z_axis_track_datas = domainTrackData.getDomainTrackDatasFromIds(domainDataIdList, session)   
     return self._z_axis_track_datas
Beispiel #4
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
Beispiel #5
0
    def test_updateWellStartStop(self, mock_class):
        logger.debug(">>test_updateWellStartStop()")
        #self.dummyDbSetup = DummyDbSetup()
        self.dummyDbSetup.setupDatabase()
        
        session = DM.getSession()
        well = self.dummyDbSetup.createWell(session)
        logs = self.dummyDbSetup.create3Logs(well.id, session)
        data = BaseDao.convertJSONtoData(logs[0].log_data_str)
        logData = np.empty((len(logs), len(data)))
        domainId = 0
        for i, log in enumerate(logs):
            if i == 0:
                domainId = log.log_domain_id
            data = BaseDao.convertJSONtoData(log.log_data_str)
            for j, sample in enumerate(data):
                logData[i][j] = sample
            log.importLog = True
        dataTest = logData[1,:]

        lasPersister = LasPersister(session)
        lasReader = LasReader()
        lasReader.logList = logs
        lasReader._logs = logData
        
        lasPersister._logSetId = 1
        lasPersister._logServiceId = 1
        #TODO log domain needs to be created with dumy DB
        logDomain = LogDomainDao.getLogDomain( domainId, session)
        self.assertNotEqual(None, logDomain, "Sould not be None")
        lasPersister._logDomainId = logDomain.id
        lasReader.logDomain = logDomain
        logger.debug("well.mdstart:{0}, well.mdstop:{1}, logDomain.log_start:{2}, logDomain.log_stop:{3}".format(well.mdstart, well.mdstop, logDomain.log_start, logDomain.log_stop))
        
        lasPersister._lasReader = lasReader
        lasPersister._wellId = well.id
        lasPersister.writeLogData()
        allLogs = session.query(Log).all()
        for log in allLogs:
            logger.debug("--test_updateWellStartStop() post write log data id:{0}, name:{1}".format(log.id, log.name))
        session.close()
Beispiel #6
0
    def test_writeLogData(self, mock_class):
        logger.debug(">>test_writeLogData()")
        #self.dummyDbSetup = DummyDbSetup()
        self.dummyDbSetup.setupDatabase()
        
        session = DM.getSession()
        well = self.dummyDbSetup.createWell(session)
        logs = self.dummyDbSetup.create3Logs(well.id, session)
        data = BaseDao.convertJSONtoData(logs[0].log_data_str)
        logData = np.empty((len(logs), len(data)))
        for i, log in enumerate(logs):
            data = BaseDao.convertJSONtoData(log.log_data_str)
            for j, sample in enumerate(data):
                logData[i][j] = sample
            log.importLog = True
        dataTest = logData[1,:]

        lasPersister = LasPersister(session)
        lasReader = LasReader()
        lasReader.logList = logs
        lasReader._logs = logData
        
        lasPersister._logSetId = 1
        lasPersister._logServiceId = 1
        #TODO log domain needs to be created with dumy DB
        logDomain = LogDomainDao.getLogDomain(log.log_domain_id, session)
        lasPersister._logDomainId = logDomain.id
        lasReader.logDomain = logDomain
        
        lasPersister._lasReader = lasReader
        lasPersister._wellId = well.id
        lasPersister._lasModel = lasReader.lasModel
        lasRounding = 4
        lasPersister._lasImportLogicModel = LasImportLogicModel()
        lasPersister.writeLogData(lasPersister._lasModel, lasPersister._lasImportLogicModel, lasRounding)
        allLogs = session.query(Log).all()
        for log in allLogs:
            logger.debug("--test_writeLogData() post write log data id:{0}, name:{1}".format(log.id, log.name))
        session.close()
Beispiel #7
0
 def writeDepthData(self):
     logger.debug(">>writeDepthData() ")
     if ImportExportPreferences.HONOUR_LAS_DEPTH_VALUES:
         depthList = self._lasReader._depthData
     else:
         depthList = self.calcSteppedDepth(self._lasReader.logDomain,
                                           self._las_rounding,
                                           self._lasReader._logs[0, :])
     jsonStr = BaseDao.convertDataToJSON(depthList)
     depth = DepthData()
     depth.data = jsonStr
     depth.log_domain_id = self._logDomainId
     self._session.add(depth)
     self._session.flush()
     logger.debug("--writeDepthData() ")
Beispiel #8
0
    def _initialiseWellTemplateDefaults(self):
        logger.debug(">>_initialiseWellTemplateDefaults()")
        #subPlotId = self._initialiseLogTrackDefaults()
        tempTemplate = WellPlotType.TRIPLECOMBO
        for key, value in tempTemplate.templateTypes.items():
            assert isinstance(value, WellPlotType)
            wellPlotTemplate = WellPlotTemplate()
            wellPlotTemplate.uid = value.uid
            wellPlotTemplate.name = value.name
            #wellPlotTemplate.typeName = value.typeName
            wellPlotTemplate.track_data_str = BaseDao.convertDataToJSON(
                value.trackDataList)
            wellPlotTemplate.is_preferences = True

            if (value.uid == WellPlotType.ALLLOGS.uid) or (
                    value.uid == WellPlotType.ACTIVELOGS.uid) or (
                        value.uid == WellPlotType.EMPTY.uid) or (
                            value.uid == WellPlotType.QUICKPLOT.uid):
                wellPlotTemplate.is_modifiable = False
            else:
                wellPlotTemplate.is_modifiable = True

            self._session.add(wellPlotTemplate)
        self._session.flush()
Beispiel #9
0
    def writeLogData(self):
        logger.debug(">>writeLogData()")
        logList = self._lasReader.logList
        assert len(self._lasReader.logList) == len(self._lasReader._logs)
        depthType = self._lasReader.well.z_measure_type_name
        for i, log in enumerate(logList):
            logger.debug("--writeLogData() log: " + str(log.name) +
                         " import: " + str(log.importLog))
            if log.importLog:
                log.log_set_id = self._logSetId
                log.log_service_id = self._logServiceId
                log.log_domain_id = self._logDomainId
                log.well_id = self._wellId

                if ImportExportPreferences.HONOUR_LAS_DEPTH_VALUES:
                    depthList = self._lasReader._depthData
                    honour_las_depth_values = True
                else:
                    depthList = self.calcSteppedDepth(
                        self._lasReader.logDomain, self._las_rounding,
                        self._lasReader._logs[0, :])
                    honour_las_depth_values = False
                jsonStr = BaseDao.convertDataToJSON(depthList)
                log.z_measure_data_str = jsonStr
                logDomain = self._lasReader.logDomain
                log.z_measure_min = logDomain.log_start
                log.z_measure_max = logDomain.log_stop
                log.consistent_step = self._consistentStep
                #store the mean step anyway
                log.z_measure_step = self._meanStepValue

                log.null = self._lasReader.null_value

                logTypeUid = LogType.getUidFromName(log.log_type_name)
                logCurveDefaults = LogCurvePreferencesDao.getLogCurvePreferences(
                    logTypeUid, self._session)
                if logCurveDefaults == None:
                    #no preferences set yet, use defaults
                    logCurveDefaults = LogCurvePreferencesDao.getLogCurveDefaults(
                        logTypeUid, self._session)

                log.log_plot_left = logCurveDefaults.log_plot_left
                log.log_plot_right = logCurveDefaults.log_plot_right
                log.log_plot_default = logCurveDefaults.log_plot_default
                log.log_plot_points_on = logCurveDefaults.log_plot_points_on

                log.histogram_left = logCurveDefaults.histogram_left
                log.histogram_right = logCurveDefaults.histogram_right
                log.histogram_default = logCurveDefaults.histogram_default

                log.cross_plot_left = logCurveDefaults.cross_plot_left
                log.cross_plot_right = logCurveDefaults.cross_plot_right
                log.cross_plot_default = logCurveDefaults.cross_plot_default

                log.line_width = logCurveDefaults.line_width
                log.line_style = logCurveDefaults.line_style

                log.point_size = logCurveDefaults.point_size
                log.point_style = logCurveDefaults.point_style

                log.rgb = logCurveDefaults.rgb
                log.alpha = logCurveDefaults.alpha

                log.is_logarithmic = logCurveDefaults.is_logarithmic
                if log.is_logarithmic:
                    log.log_plot_log_cycles = logCurveDefaults.log_plot_log_cycles

                log.z_measure_type_name = depthType
                #duplication - but makes simpler if want to change log down track
                log.z_measure_reference = self._lasReader.logService.z_measure_reference
                try:
                    #see http://stackoverflow.com/questions/4455076/numpy-access-an-array-by-column
                    data = self._lasReader._logs[i, :]
                    log.honour_las_depth_values = honour_las_depth_values
                    log.value_min = NumberUtils.minimumExcludingNulls(
                        data, log.null)
                    log.value_max = NumberUtils.maximumExcludingNulls(
                        data, log.null)
                    jsonStr = BaseDao.convertDataToJSON(data.tolist())
                    log.log_data_str = jsonStr
                    #statistics
                    log.mean = statistics.mean(data)
                    log.median = statistics.median(data)
                    #standard deviation
                    log.stdev = statistics.pstdev(data)

                except IndexError as ie:
                    logger.error("Error saving log data " + str(ie))
                    return
                if self._allDataFlag:
                    log.parameter_set_id = self._parameterSetId

                log.source = self._lasReader.fullFilePathName
                logger.debug("--writeLogData() pre flush log.id: " +
                             str(log.id) + " log_set_id " +
                             str(log.log_set_id) + " log_service_id " +
                             str(log.log_service_id) + " log_domain_id " +
                             str(log.log_domain_id) +
                             " log.parameter_set_id " +
                             str(log.parameter_set_id))
                logger.debug(
                    "--writeLogData() name: " + str(log.name) + " type: " +
                    str(log.log_type_name))  #+" datas: "+str(log.log_datas))

                log.history_set_id = self._historySetId

                self._session.add(log)
                self._session.flush()
                logger.debug("--writeLogData() post flush log.id: " +
                             str(log.id))
Beispiel #10
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
Beispiel #11
0
 def getYData(self):
     ''' Retrieves lit of yData from db on first call and stores it here '''
     if (len(self.y_data) == 0) and (self.y_data_string != ""):
         session = DM.getSession()
         self.y_data = BaseDao.convertJSONtoData(self.y_data_string)
     return self.y_data