Exemple #1
0
    def LoadHoles(self, holeList):
        # pre stuff
        self.parent.INIT_CHANGES()
        self.parent.OnNewData(None)  # brgtodo

        self.parent.Window.range = []
        self.parent.Window.AltSpliceData = []
        self.parent.Window.selectedType = ""
        self.parent.TimeChange = False
        self.parent.Window.timeseries_flag = False

        site = holeList[
            0].holeSet.site  # shorten some otherwise long statements
        sitePath = self.parent.DBPath + 'db/' + site.GetDir()

        # load holes (independent of enabled status, client can pass whatever list of holes they like)
        for hole in holeList:
            self.parent.CurrentDir = sitePath
            holefile = sitePath + hole.file
            self.parent.LOCK = 0
            type = hole.holeSet.type  #GRA
            intType, annot = self.parent.TypeStrToInt(type)
            decimate = hole.holeSet.decimate
            #self.parent.filterPanel.decimate.SetValue(str(decimate))
            ret = py_correlator.openHoleFile(holefile, -1, intType, decimate,
                                             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                             1, annot)
            if ret == 1:
                self.parent.LOCK = 1

            # set range
            holeRange = MakeRangeList(hole, type)
            self.parent.Window.range.append(holeRange)

        # load cull tables
        culledTypes = []
        for hole in holeList:
            if hole.holeSet.type not in culledTypes and hole.holeSet.IsCullEnabled(
            ):
                print "loading cull"
                coretype, annot = self.parent.TypeStrToInt(hole.holeSet.type)
                print "coretype = " + str(coretype) + ", annot = " + annot
                py_correlator.openCullTable(
                    sitePath + hole.holeSet.cullTable.file, coretype, annot)
                culledTypes.append(hole.holeSet.type)

        # load log
        logLoaded = False
        for log in site.logTables:
            if log.enable:
                py_correlator.openLogFile(sitePath + log.file,
                                          int(log.dataIndex))
                # decimate
                # smooth
                ret = py_correlator.getData(5)
                if ret != "":
                    if py_correlator.getMudline() != 0.0:
                        self.parent.Window.isLogShifted = True
                    self.parent.filterPanel.OnLock()
                    self.parent.ParseData(ret, self.parent.Window.LogData)

                    # set range
                    logRange = MakeRangeList(log, 'log')
                    self.parent.Window.range.append(logRange)

                    self.parent.UpdateSMOOTH_LogData()

                    self.parent.filterPanel.OnRelease()
                    self.parent.Window.isLogMode = 1
                    self.parent.Window.SpliceTieData = []
                    self.parent.Window.CurrentSpliceCore = -1
                    self.parent.autoPanel.OnButtonEnable(0, True)
                    logLoaded = True
                    break

        # load saved tables (OnLOAD_TABLE())
        tableLoaded = [False, False, False]
        for at in site.affineTables:
            if at.enable:
                py_correlator.openAttributeFile(sitePath + at.file, 0)
                tableLoaded[0] = True
                break
        for st in site.spliceTables:
            if st.enable:
                ret = py_correlator.openSpliceFile(sitePath + st.file)
                if ret == 'error':
                    self.parent.OnShowMessage(
                        "Error", "Couldn't create splice record(s)", 1)
                else:
                    tableLoaded[1] = True
                break
        for et in site.eldTables:
            if et.enable:
                py_correlator.openAttributeFile(sitePath + et.file, 1)
                tableLoaded[2] = True
                if self.parent.Window.LogData != []:
                    self.parent.eldPanel.SetFlag(True)
                    if py_correlator.getMudline() != 0.0:
                        self.parent.OnUpdateLogData(True)
                    retdata = py_correlator.getData(13)
                    if retdata != "":
                        self.parent.ParseSaganData(retdata)
                        self.parent.autoPanel.OnButtonEnable(0, False)
                    retdata = ""
                break

        # 1/21/2014 brgtodo: Try to consolidate all the parent.Window changes, GUI changes
        # and such into their own routines.
        self.parent.Window.LogselectedTie = -1
        self.parent.Window.activeSATie = -1
        self.parent.LOCK = 0

        if tableLoaded[1] == True:
            self.parent.OnInitDataUpdate()
            self.parent.InitSPLICE()
            self.parent.UpdateSPLICE(False)
            self.parent.autoPanel.SetCoreList(1, [])
            self.parent.filterPanel.OnRegisterHole("Spliced Records")

            holeSet = holeList[0].holeSet
            hsMin = float(holeSet.min)
            hsMax = float(holeSet.max)
            newrange = 'splice', hsMin, hsMax, hsMax - hsMin, 0, holeSet.continuous
            self.parent.Window.range.append(newrange)
            self.parent.Window.selectedType = holeSet.type

        if tableLoaded[2] == True:
            self.parent.UpdateELD(True)

        if not tableLoaded[1] and not tableLoaded[2]:
            self.parent.UpdateCORE()
            self.parent.UpdateSMOOTH_CORE()
            self.parent.autoPanel.SetCoreList(0, self.parent.Window.HoleData)

        self.parent.Window.ShowLog = False
        if logLoaded:
            self.parent.Window.ShowLog = True
            self.parent.filterPanel.OnRegisterHole("Log")

        self.parent.OnDisableMenu(1, True)
        self.parent.LOCK = 1

        if self.parent.showReportPanel == 1:
            self.parent.OnUpdateReport()

        self.parent.ShowDisplay()
        self.parent.SetLoadedSite(site)

        # LOAD SECTION
        self.parent.OnUpdateDepthStep()

        self.parent.NewDATA_SEND()
        self.parent.Window.UpdateScroll(1)
        self.parent.Window.UpdateScroll(2)
        self.parent.Window.SetFocusFromKbd()
        self.parent.Window.UpdateDrawing()
        self.parent.compositePanel.OnUpdate(
        )  # make sure growth rate is updated
Exemple #2
0
	def ExportHoles(self, holeList):
		exportDlg = dialog.ExportCoreDialog(self.dataFrame)
		exportDlg.Centre()
		if exportDlg.ShowModal() == wx.ID_OK:
			fileDlg = wx.FileDialog(self.dataFrame, "Select Directory for Export", self.parent.Directory, style=wx.SAVE)
			if fileDlg.ShowModal() == wx.ID_OK:
				self.parent.OnNewData(None)

				siteDir = holeList[0].holeSet.site.GetDir()
				path = self.parent.DBPath + 'db/' + siteDir

				# load holes (ignoring enabled state)
				for hole in holeList:
					intType, annot = self.parent.TypeStrToInt(hole.holeSet.type)
					holefile = path + hole.file
					ret = py_correlator.openHoleFile(holefile, -1, intType, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, annot)

				# apply cull, affine, splice
				applied = ""
# 				if exportDlg.cull.GetValue() == True and cull_item != None:
# 					py_correlator.openCullTable(path + self.tree.GetItemText(cull_item, 8), type, annot)
# 					applied = "cull"

				affine_item = holeList[0].holeSet.site.GetAffine()
 				if exportDlg.affine.GetValue() == True and affine_item != None:
 					py_correlator.openAttributeFile(path + affine_item.file, 0)
 					applied = "affine"

				splice_item = holeList[0].holeSet.site.GetSplice()
 				if exportDlg.splice.GetValue() == True and splice_item != None :
 					ret_splice = py_correlator.openSpliceFile(path + splice_item.file)
 					if ret_splice == "error" : 
 						self.parent.OnShowMessage("Error", "Could not Make Splice Records", 1)
					applied = "splice"
				elif exportDlg.splice.GetValue() == True and splice_item == None :
 					self.parent.OnShowMessage("Error", "Can't export, active splice table required.", 1)
 					self.parent.OnNewData(None)
 					exportDlg.Destroy()
 					return

				# apply eld, age model
# 				if exportDlg.eld.GetValue() == True and eld_item != None :
# 					if log_item != None :
# 						py_correlator.openLogFile(path+ self.tree.GetItemText(log_item, 8), int(self.tree.GetItemText(log_item, 11)))
# 						py_correlator.openAttributeFile(path + self.tree.GetItemText(eld_item, 8), 1)
# 						applied = "eld"
# 					else :
# 						self.parent.OnShowMessage("Error", "Need Log to Export ELD", 1)
# 						self.parent.OnNewData(None)
# 						dlg.Destroy()
# 						return
# 				if exportDlg.age.GetValue() == True and age_item != None :
# 					applied += "-age"
# 					agefilename = path+ self.tree.GetItemText(age_item, 8)
# 					if exportDlg.eld.GetValue() == True :
# 						if exportDlg.splice.GetValue() == True :
# 							count = py_correlator.saveAgeCoreData(agefilename, path + ".export.tmp", 2)
# 						else :
# 							count = py_correlator.saveAgeCoreData(agefilename, path + ".export.tmp", 0)
# 					else :
# 						if exportDlg.splice.GetValue() == True :
# 							count = py_correlator.saveAgeCoreData(agefilename, path + ".export.tmp", 1)
# 						else :
# 							count = py_correlator.saveAgeCoreData(agefilename, path + ".export.tmp", 0)
# 				elif exportDlg.eld.GetValue() == True :
# 					if exportDlg.splice.GetValue() == True :
# 						count = py_correlator.saveCoreData(path + ".export.tmp", 2)
# 					else :
# 						count = py_correlator.saveCoreData(path + ".export.tmp", 0)
# 				elif exportDlg.splice.GetValue() == True :
# 					count = py_correlator.saveCoreData(path + ".export.tmp", 1)
# 				else :
# 					count = py_correlator.saveCoreData(path + ".export.tmp", 0)
#
# 				self.parent.OnNewData(None)

				# just using splice/affine for now
				saveType = 1 if (exportDlg.splice.GetValue() == True) else 0
				savedCoreCount = py_correlator.saveCoreData(path + ".export.tmp", saveType)

 				self.parent.OnNewData(None)

				# 1/20/2014 brgtodo: I was initially horrified by the idea of assembling shell
				# commands to copy files, but it seems to be an accepted practice in the Python
				# world. Further, using a library (shlib is the most likely candidate) will lose
				# file metadata on POSIX systems like OS X, i.e. we'll lose group, owner and
				# resource forks (though, God willing, we don't have anything with a fork!).
				if exportDlg.format.GetValue() == True: # export non-XML
					outdir = fileDlg.GetDirectory()
					filename = fileDlg.GetFilename()
					#multiple = len(holeList) > 0
					count = 0
					for hole in holeList:
						filePrefix = filename + '-' + hole.holeSet.site.name + '-' + applied
						countStr = ""
						#if multiple:
						if savedCoreCount > 1:
							filePrefix = filePrefix + hole.name
							countStr = str(count)
							count = count + 1
							
						typeStr = self.parent.TypeStrToFileSuffix(hole.holeSet.type, True)
						fileSuffix = '.' + typeStr + '.dat'
						outfile = filePrefix + fileSuffix
						if sys.platform == 'win32':
							workingdir = os.getcwd()
							os.chdir(path)
							cmd = 'copy ' + '.export.tmp' + countStr + ' \"' + outdir + '/' + outfile + '\"'
							os.system(cmd)
							os.chdir(workingdir)
						else:
							cmd = 'cp \"' + path + '.export.tmp' + countStr + '\" \"' + outdir + '/' + outfile + '\"'
							os.system(cmd)
				else: # export as XML - 1/17/2014 brgtodo
					pass
				
				if savedCoreCount > 0:
					self.parent.OnShowMessage("Information", "Export successful", 1)
				else:
					self.parent.OnShowMessage("Error", "Export failed", 1)

			fileDlg.Destroy()
		exportDlg.Destroy()
Exemple #3
0
    def ExportHoles(self, holeList):
        exportDlg = dialog.ExportCoreDialog(self.dataFrame)
        exportDlg.Centre()
        if exportDlg.ShowModal() == wx.ID_OK:
            fileDlg = wx.FileDialog(self.dataFrame,
                                    "Select Directory for Export",
                                    self.parent.Directory,
                                    style=wx.SAVE)
            if fileDlg.ShowModal() == wx.ID_OK:
                self.parent.OnNewData(None)

                siteDir = holeList[0].holeSet.site.GetDir()
                path = self.parent.DBPath + 'db/' + siteDir

                # load holes (ignoring enabled state)
                for hole in holeList:
                    intType, annot = self.parent.TypeStrToInt(
                        hole.holeSet.type)
                    holefile = path + hole.file
                    ret = py_correlator.openHoleFile(holefile, -1, intType, 1,
                                                     0, 0, 0, 0, 0, 0, 0, 0, 0,
                                                     0, 0, 1, annot)

                # apply cull, affine, splice
                applied = ""
                # 				if exportDlg.cull.GetValue() == True and cull_item != None:
                # 					py_correlator.openCullTable(path + self.tree.GetItemText(cull_item, 8), type, annot)
                # 					applied = "cull"

                affine_item = holeList[0].holeSet.site.GetAffine()
                if exportDlg.affine.GetValue() == True and affine_item != None:
                    py_correlator.openAttributeFile(path + affine_item.file, 0)
                    applied = "affine"

                splice_item = holeList[0].holeSet.site.GetSplice()
                if exportDlg.splice.GetValue() == True and splice_item != None:
                    ret_splice = py_correlator.openSpliceFile(path +
                                                              splice_item.file)
                    if ret_splice == "error":
                        self.parent.OnShowMessage(
                            "Error", "Could not Make Splice Records", 1)
                    applied = "splice"
                elif exportDlg.splice.GetValue(
                ) == True and splice_item == None:
                    self.parent.OnShowMessage(
                        "Error", "Can't export, active splice table required.",
                        1)
                    self.parent.OnNewData(None)
                    exportDlg.Destroy()
                    return

                # apply eld, age model


# 				if exportDlg.eld.GetValue() == True and eld_item != None :
# 					if log_item != None :
# 						py_correlator.openLogFile(path+ self.tree.GetItemText(log_item, 8), int(self.tree.GetItemText(log_item, 11)))
# 						py_correlator.openAttributeFile(path + self.tree.GetItemText(eld_item, 8), 1)
# 						applied = "eld"
# 					else :
# 						self.parent.OnShowMessage("Error", "Need Log to Export ELD", 1)
# 						self.parent.OnNewData(None)
# 						dlg.Destroy()
# 						return
# 				if exportDlg.age.GetValue() == True and age_item != None :
# 					applied += "-age"
# 					agefilename = path+ self.tree.GetItemText(age_item, 8)
# 					if exportDlg.eld.GetValue() == True :
# 						if exportDlg.splice.GetValue() == True :
# 							count = py_correlator.saveAgeCoreData(agefilename, path + ".export.tmp", 2)
# 						else :
# 							count = py_correlator.saveAgeCoreData(agefilename, path + ".export.tmp", 0)
# 					else :
# 						if exportDlg.splice.GetValue() == True :
# 							count = py_correlator.saveAgeCoreData(agefilename, path + ".export.tmp", 1)
# 						else :
# 							count = py_correlator.saveAgeCoreData(agefilename, path + ".export.tmp", 0)
# 				elif exportDlg.eld.GetValue() == True :
# 					if exportDlg.splice.GetValue() == True :
# 						count = py_correlator.saveCoreData(path + ".export.tmp", 2)
# 					else :
# 						count = py_correlator.saveCoreData(path + ".export.tmp", 0)
# 				elif exportDlg.splice.GetValue() == True :
# 					count = py_correlator.saveCoreData(path + ".export.tmp", 1)
# 				else :
# 					count = py_correlator.saveCoreData(path + ".export.tmp", 0)
#
# 				self.parent.OnNewData(None)

# just using splice/affine for now
                saveType = 1 if (exportDlg.splice.GetValue() == True) else 0
                savedCoreCount = py_correlator.saveCoreData(
                    path + ".export.tmp", saveType)

                self.parent.OnNewData(None)

                # 1/20/2014 brgtodo: I was initially horrified by the idea of assembling shell
                # commands to copy files, but it seems to be an accepted practice in the Python
                # world. Further, using a library (shlib is the most likely candidate) will lose
                # file metadata on POSIX systems like OS X, i.e. we'll lose group, owner and
                # resource forks (though, God willing, we don't have anything with a fork!).
                if exportDlg.format.GetValue() == True:  # export non-XML
                    outdir = fileDlg.GetDirectory()
                    filename = fileDlg.GetFilename()
                    #multiple = len(holeList) > 0
                    count = 0
                    for hole in holeList:
                        filePrefix = filename + '-' + hole.holeSet.site.name + '-' + applied
                        countStr = ""
                        #if multiple:
                        if savedCoreCount > 1:
                            filePrefix = filePrefix + hole.name
                            countStr = str(count)
                            count = count + 1

                        typeStr = self.parent.TypeStrToFileSuffix(
                            hole.holeSet.type, True)
                        fileSuffix = '.' + typeStr + '.dat'
                        outfile = filePrefix + fileSuffix
                        if sys.platform == 'win32':
                            workingdir = os.getcwd()
                            os.chdir(path)
                            cmd = 'copy ' + '.export.tmp' + countStr + ' \"' + outdir + '/' + outfile + '\"'
                            os.system(cmd)
                            os.chdir(workingdir)
                        else:
                            cmd = 'cp \"' + path + '.export.tmp' + countStr + '\" \"' + outdir + '/' + outfile + '\"'
                            os.system(cmd)
                else:  # export as XML - 1/17/2014 brgtodo
                    pass

                if savedCoreCount > 0:
                    self.parent.OnShowMessage("Information",
                                              "Export successful", 1)
                else:
                    self.parent.OnShowMessage("Error", "Export failed", 1)

            fileDlg.Destroy()
        exportDlg.Destroy()
Exemple #4
0
	def LoadHoles(self, holeList):
		# pre stuff
		self.parent.INIT_CHANGES()
		self.parent.OnNewData(None) # brgtodo

		self.parent.Window.range = []
		self.parent.Window.AltSpliceData = []
		self.parent.Window.selectedType = ""
		self.parent.TimeChange = False
		self.parent.Window.timeseries_flag = False

		site = holeList[0].holeSet.site # shorten some otherwise long statements
		sitePath = self.parent.DBPath + 'db/' + site.GetDir()

		# load holes (independent of enabled status, client can pass whatever list of holes they like)
		for hole in holeList:
			self.parent.CurrentDir = sitePath
			holefile = sitePath + hole.file
			self.parent.LOCK = 0
			type = hole.holeSet.type #GRA
			intType, annot = self.parent.TypeStrToInt(type)
			decimate = hole.holeSet.decimate
			#self.parent.filterPanel.decimate.SetValue(str(decimate))
			ret = py_correlator.openHoleFile(holefile, -1, intType, decimate, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, annot)
			if ret == 1:
				self.parent.LOCK = 1

			# set range
			holeRange = MakeRangeList(hole, type)
			self.parent.Window.range.append(holeRange)

		# load cull tables
		culledTypes = []
		for hole in holeList:
			if hole.holeSet.type not in culledTypes and hole.holeSet.IsCullEnabled():
				print "loading cull"
				coretype, annot = self.parent.TypeStrToInt(hole.holeSet.type)
				print "coretype = " + str(coretype) + ", annot = " + annot
				py_correlator.openCullTable(sitePath + hole.holeSet.cullTable.file, coretype, annot)
				culledTypes.append(hole.holeSet.type)

		# load log
		logLoaded = False
		for log in site.logTables:
			if log.enable:
				py_correlator.openLogFile(sitePath + log.file, int(log.dataIndex))
				# decimate
				# smooth
				ret = py_correlator.getData(5)
				if ret != "":
					if py_correlator.getMudline() != 0.0:
						self.parent.Window.isLogShifted = True
					self.parent.filterPanel.OnLock()
					self.parent.ParseData(ret, self.parent.Window.LogData)

					# set range
					logRange = MakeRangeList(log, 'log')
					self.parent.Window.range.append(logRange)

					self.parent.UpdateSMOOTH_LogData()

					self.parent.filterPanel.OnRelease()
					self.parent.Window.isLogMode = 1
					self.parent.Window.SpliceTieData = []
					self.parent.Window.CurrentSpliceCore = -1
					self.parent.autoPanel.OnButtonEnable(0, True)
					logLoaded = True
					break

		# load saved tables (OnLOAD_TABLE())
		tableLoaded = [False, False, False]
		for at in site.affineTables:
			if at.enable:
				py_correlator.openAttributeFile(sitePath + at.file, 0)
				tableLoaded[0] = True
				break
		for st in site.spliceTables:
			if st.enable:
				ret = py_correlator.openSpliceFile(sitePath + st.file)
				if ret == 'error':
					self.parent.OnShowMessage("Error", "Couldn't create splice record(s)", 1)
				else:
					tableLoaded[1] = True
				break
		for et in site.eldTables:
			if et.enable:
				py_correlator.openAttributeFile(sitePath + et.file, 1)
				tableLoaded[2] = True
				if self.parent.Window.LogData != [] :
					self.parent.eldPanel.SetFlag(True)
					if py_correlator.getMudline() != 0.0 :
						self.parent.OnUpdateLogData(True)
					retdata = py_correlator.getData(13)
					if retdata != "" :
						self.parent.ParseSaganData(retdata)
						self.parent.autoPanel.OnButtonEnable(0, False)
					retdata = "" 
				break

		# 1/21/2014 brgtodo: Try to consolidate all the parent.Window changes, GUI changes
		# and such into their own routines.
		self.parent.Window.LogselectedTie = -1
		self.parent.Window.activeSATie = -1
		self.parent.LOCK = 0

		if tableLoaded[1] == True :
			self.parent.OnInitDataUpdate()
			self.parent.InitSPLICE()
			self.parent.UpdateSPLICE(False)
			self.parent.autoPanel.SetCoreList(1, [])
			self.parent.filterPanel.OnRegisterHole("Spliced Records")

			holeSet = holeList[0].holeSet
			hsMin = float(holeSet.min)
			hsMax = float(holeSet.max)
			newrange = 'splice', hsMin, hsMax, hsMax - hsMin, 0, holeSet.continuous
			self.parent.Window.range.append(newrange)
			self.parent.Window.selectedType = holeSet.type

		if tableLoaded[2] == True :
			self.parent.UpdateELD(True)

		if not tableLoaded[1] and not tableLoaded[2]:
			self.parent.UpdateCORE()
			self.parent.UpdateSMOOTH_CORE()
			self.parent.autoPanel.SetCoreList(0, self.parent.Window.HoleData)

		self.parent.Window.ShowLog = False
		if logLoaded:
			self.parent.Window.ShowLog = True
			self.parent.filterPanel.OnRegisterHole("Log")

		self.parent.OnDisableMenu(1, True)
 		self.parent.LOCK = 1

		if self.parent.showReportPanel == 1:
			self.parent.OnUpdateReport()

		self.parent.ShowDisplay()
		self.parent.SetLoadedSite(site)

		# LOAD SECTION
		self.parent.OnUpdateDepthStep()

		self.parent.NewDATA_SEND()
		self.parent.Window.UpdateScroll(1)
		self.parent.Window.UpdateScroll(2)
		self.parent.Window.SetFocusFromKbd()
		self.parent.Window.UpdateDrawing()
		self.parent.compositePanel.OnUpdate() # make sure growth rate is updated