def populateComboBoxes(self): resistivityUnits = LogType.getLogUnitsForType(LogType.RESIS) for item in resistivityUnits: self.defaultRwUnitComboBox.addItem(str(item)) self.defaultRwtComboBox.addItem(str(item)) #eg m, ft etc depthUnits = LogType.getLogUnitsForType(LogType.DEPTH) for item in depthUnits: self.logStartUnitComboBox.addItem(str(item)) self.logStopUnitComboBox.addItem(str(item)) self.logStepUnitComboBox.addItem(str(item)) self.tdLoggerUnitComboBox.addItem(str(item))
def populateComboBoxes(self): #depth types eg MB, TVDSS etc depthTypes = ZAxis.getExtendedDataTypeUids() for item in depthTypes: self.depthTypeComboBox.addItem(str(item)) #reference level eg DF, GL etc referenceLevelType = ReferenceLevelType.CBF refTypes = referenceLevelType.getAllTypeUids() for item in refTypes: self.depthReferenceComboBox.addItem(str(item)) self.drillingReferenceComboBox.addItem(str(item)) #eg m, ft etc depthUnits = LogType.getLogUnitsForType(LogType.DEPTH) for item in depthUnits: self.depthTypeUnitComboBox.addItem(str(item)) self.depthReferenceUnitComboBox.addItem(str(item)) self.elevationOfDepthReferenceUnitComboBox.addItem(str(item)) self.tdDrillerUnitComboBox.addItem(str(item)) self.waterDepthUnitComboBox.addItem(str(item)) self.dfElevationUnitComboBox.addItem(str(item)) self.kbElevationUnitComboBox.addItem(str(item)) self.glElevationComboBox.addItem(str(item)) self.permDatumElevUnitComboBox.addItem(str(item)) self.elevationAbovePDComboBox.addItem(str(item))
def populateUnitsListForType(self, logType): unitTypes = LogType.getLogUnitsForType(logType) unitsList = [] for item in unitTypes: #logger.debug("--populateUnitsListForType() log type: "+str(logType)+" unit type: "+str(item)) unitsList.append(item.name) return unitsList
def getLogTypeNamesPreferences(self): logPlotPreferences = WellPlotDataDao.getWellPlotPreferences() logTypeNamesPreferences = [] if logPlotPreferences != None: logUids = logPlotPreferences.default_log_plots logger.debug("--getWellPlotPreferences() logUids: " + logUids) defaultList = logUids.split() for uid in defaultList: logger.debug("--getWellPlotPreferences() uid: " + str(uid) + " type: " + LogType.getLogTypeFromUid(uid).getName()) logTypeNamesPreferences.append( LogType.getLogTypeFromUid(uid).getName()) else: logger.error("No log plot defaults exist in the database") return logTypeNamesPreferences
def getUnits(cls, log): units = "" logType = LogType.getLogType(log.log_type_name) if logType != None: units = logType.getStdUnits().name else: logType = LogType.UNKNOWN units = logType.getStdUnits().name logger.error("--getUnits() " + str(log.name) + " is of an unknown type returning unknown units: " + str(units)) if AppSettings.isDebugMode: raise AttributeError return units
def setPreferences(self, log, session=None): localSession = False if session == None: session = DM.getSession() localSession = True logType = LogType.getLogType(log.log_type_name) log_type_uid = logType.getUid() logCurveDefaults = LogCurvePreferencesDao.getLogCurvePreferences( log_type_uid, session) if logCurveDefaults == None: #no preferences set yet, use defaults logCurveDefaults = LogCurvePreferencesDao.getLogCurveDefaults( log_type_uid, session) assert logCurveDefaults is not None 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 logCurveDefaults.is_logarithmic: log.log_plot_log_cycles = logCurveDefaults.log_plot_log_cycles log.z_measure_type_name = "MD" #duplication - but makes simpler if want to change log down track log.z_measure_reference = "KB" if localSession: session.close()
def findDepthUnitsMatch(self, depthUnits, logType): assert isinstance(depthUnits, str), "depthUnits is not a string: %r" % depthUnits assert isinstance(logType, LogType), "logType is not a LogType: %r" % logType match = "" if (depthUnits.strip()): depthUnitTypes = LogType.getLogUnitsForType(logType) for type_ in depthUnitTypes: types = type_.uid splitArr = types.split() for item in splitArr: if (depthUnits.lower() == item.lower()): # have a match match = depthUnits break return match
def populateTableWidget(self, selectedLog=None): logger.debug(">>populateTableWidget()") selected = None self.logsTableWidget.clear() self.logsTableWidget.setSortingEnabled(False) self.logsTableWidget.setRowCount(len(self._logTableModel.logs)) self.logsTableWidget.setColumnCount(len(self._logTableModel.HEADERS)) self.logsTableWidget.setHorizontalHeaderLabels( self._logTableModel.HEADERS) for row, log in enumerate(self._logTableModel.logs): item = QTableWidgetItem(log.name) item.setData(Qt.UserRole, str(id(log))) localLogType = LogType.findLogTypeFromMnemonic(log.fileMnemonic) if selectedLog is not None and selectedLog == id(log): selected = item chkBoxItem = QtGui.QTableWidgetItem() chkBoxItem.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) chkBoxItem.setCheckState(QtCore.Qt.Unchecked) #is this needed? chkBoxItem.setData(Qt.UserRole, str(id(log))) self.logsTableWidget.setItem(row, logtablemodel.IMPORT, chkBoxItem) self.logsTableWidget.setItem(row, logtablemodel.NAME, item) self.logsTableWidget.setCellWidget( row, logtablemodel.TYPE, self.getPreparedTypesCombo(log.fileMnemonic)) self.logsTableWidget.setCellWidget( row, logtablemodel.UNIT, self.populateUnitsCombo(localLogType, log.fileUnit)) self.logsTableWidget.setItem(row, logtablemodel.FILE_MNEMONIC, QTableWidgetItem(log.fileMnemonic)) self.logsTableWidget.setItem(row, logtablemodel.FILE_UNIT, QTableWidgetItem(log.fileUnit)) self.logsTableWidget.setItem(row, logtablemodel.FILE_DESCRIPTION, QTableWidgetItem(log.fileDescription)) self.logsTableWidget.setSortingEnabled(True) self.logsTableWidget.resizeColumnsToContents() if selected is not None: selected.setSelected(True) self.logsTableWidget.setCurrentItem(selected)
def getPreparedTypesCombo(self, logMnemonic): typesComboBox = self.generateTypesCombo() localLogType = LogType.findLogTypeFromMnemonic(logMnemonic) if typesComboBox.findData(localLogType.name): index = typesComboBox.findText(localLogType.name) logger.debug( "--getPreparedTypesCombo() matched name in combo - index: " + str(index) + " name: " + str(localLogType.name) + " mnem: " + str(logMnemonic)) typesComboBox.setCurrentIndex(index) else: type = LogType logType = type.UNKNOWN index = typesComboBox.findText(logType.name) logger.debug("--getPreparedTypesCombo() not matched - index: " + str(index) + " name: " + str(logType.name) + " mnem: " + str(logMnemonic)) typesComboBox.setCurrentIndex(index) return typesComboBox
def test_getIndex(self): logger.debug(">>test_getIndex") logType = LogType.findLogTypeFromMnemonic("Time") index = logType.getIndex() self.assertTrue(5 == index)
def test_findFromMnemonic1(self): logger.debug(">>test_findFromMnemonic1") logType = LogType.findLogTypeFromMnemonic("VQtz") self.assertTrue("Volume fraction" == logType.name)
def test_findFromMnemonic0(self): """ generated source for method getLogTypeFromString0_Test """ log = "RHOB" logType = LogType.findLogTypeFromMnemonic(log) self.assertTrue( logType.RHO.__str__().lower() == logType.__str__().lower())
def populateCurveTable(self): logger.debug(">>populateCurveTable()") try: self.curveTableWidget.itemChanged.disconnect(self.styleChanged) except TypeError as ex: logger.debug(str(ex)) headers = LogPlotConstants.LOG_PLOT_CURVE_STYLE_HEADERS numberOfColumns = len(headers) self.curveTableWidget.clear() self.curveTableWidget.setSortingEnabled(False) logCount = 0 countIds = [] for plot in self._wellPlotData.getLogTrackDatas(): for log in plot.getLogs(): #only want unique curve attributes if log.id not in countIds: logCount += 1 countIds.append(log.id) self.curveTableWidget.setRowCount(logCount) self.curveTableWidget.setColumnCount(numberOfColumns) self.curveTableWidget.setHorizontalHeaderLabels(headers) #only want unique curve attributes ids = [] for i, plot in enumerate(self._wellPlotData.getLogTrackDatas()): j = 0 for log in plot.getLogs(): if log.id not in ids: #add one so starts at 1 not zero? nameLineEdit = QtGui.QLineEdit(log.name) typeLineEdit = QtGui.QLineEdit(log.log_type_name) logType = LogType.getLogType(log.log_type_name) unit = logType.getUnit() unitsLineEdit = QtGui.QLineEdit(unit.getName()) trackLineEdit = QtGui.QLineEdit(str(plot.plot_index)) leftScaleLineEdit = QtGui.QLineEdit(str(log.log_plot_left)) rightScaleLineEdit = QtGui.QLineEdit( str(log.log_plot_right)) logarithmicCheckBox = QtGui.QTableWidgetItem() logarithmicCheckBox.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) logarithmicCheckBox.setCheckState(log.is_logarithmic) logarithmicCheckBox.setData(Qt.UserRole, str(log.id)) buttonQColor = ImageUtils.rbgToQColor(log.rgb) #logger.debug("--populateCurveTable() "+log.rgb+" converted rgb: "+str(buttonQColor.getRgb())) qColorButton = QColorButton() qColorButton.setColor(buttonQColor) qColorButton.setData(Qt.UserRole, str(log.id)) opacityLineEdit = QtGui.QLineEdit(log.alpha) widthLineEdit = QtGui.QLineEdit(str(log.line_width)) styleLineEdit = QtGui.QLineEdit(log.line_style) pointSizeLineEdit = QtGui.QLineEdit(str(log.point_size)) pointStyleLineEdit = QtGui.QLineEdit(log.point_style) pointsOn = QtGui.QTableWidgetItem() pointsOn.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) pointsOn.setCheckState(log.log_plot_points_on) pointsOn.setData(Qt.UserRole, str(log.id)) twItem0 = QtGui.QTableWidgetItem(nameLineEdit.text()) twItem0.setData(Qt.UserRole, str(log.id)) twItem1 = QtGui.QTableWidgetItem(typeLineEdit.text()) twItem1.setData(Qt.UserRole, str(log.id)) twItem2 = QtGui.QTableWidgetItem(unitsLineEdit.text()) twItem2.setData(Qt.UserRole, str(log.id)) twItem3 = QtGui.QTableWidgetItem(trackLineEdit.text()) twItem3.setData(Qt.UserRole, str(log.id)) twItem4 = QtGui.QTableWidgetItem(leftScaleLineEdit.text()) twItem4.setData(Qt.UserRole, str(log.id)) twItem5 = QtGui.QTableWidgetItem(rightScaleLineEdit.text()) twItem5.setData(Qt.UserRole, str(log.id)) twItem8 = QtGui.QTableWidgetItem(opacityLineEdit.text()) twItem8.setData(Qt.UserRole, str(log.id)) twItem9 = QtGui.QTableWidgetItem(widthLineEdit.text()) twItem9.setData(Qt.UserRole, str(log.id)) twItem10 = QtGui.QTableWidgetItem(styleLineEdit.text()) twItem10.setData(Qt.UserRole, str(log.id)) twItem11 = QtGui.QTableWidgetItem(pointSizeLineEdit.text()) twItem11.setData(Qt.UserRole, str(log.id)) twItem12 = QtGui.QTableWidgetItem( pointStyleLineEdit.text()) twItem12.setData(Qt.UserRole, str(log.id)) #row, column self.curveTableWidget.setItem(j + i, 0, twItem0) self.curveTableWidget.setItem(j + i, 1, twItem1) self.curveTableWidget.setItem(j + i, 2, twItem2) self.curveTableWidget.setItem(j + i, 3, twItem3) self.curveTableWidget.setItem(j + i, 4, twItem4) self.curveTableWidget.setItem(j + i, 5, twItem5) self.curveTableWidget.setItem(j + i, 6, logarithmicCheckBox) self.curveTableWidget.setCellWidget(j + i, 7, qColorButton) self.curveTableWidget.setItem(j + i, 8, twItem8) self.curveTableWidget.setItem(j + i, 9, twItem9) self.curveTableWidget.setItem(j + i, 10, twItem10) self.curveTableWidget.setItem(j + i, 11, twItem11) self.curveTableWidget.setItem(j + i, 12, twItem12) self.curveTableWidget.setItem(j + i, 13, pointsOn) #logger.debug("--populateCurveTable() j: "+str(j)+" i: "+str(i)) ids.append(log.id) j += 1 self.curveTableWidget.itemChanged.connect(self.curveStyleChanged)
def convertType(self, fileMnemonic): type_ = LogType.findLogTypeFromMnemonic(fileMnemonic).__str__() return type_
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))
def generateTypesCombo(self): typesComboBox = QtGui.QComboBox() logTypes = LogType.getAllLogTypesStringList() typesComboBox.addItems(sorted(logTypes)) typesComboBox.setEditable(False) return typesComboBox