Example #1
0
    def __init__(self, dialog, parent):

        Ui_CaliperImport.__init__(self)
        self.setupUi(dialog)
        self.dialog = dialog
        self.parent = parent

        self.ciLASData_fields = mdl.get_ciLASData_fields()
        self.ciOpenFile_pushButton.clicked.connect(self.open_file)
        self.ciValueDecimalPoint_radioButton.clicked.connect(
            self.setup_valueDecimalPoint)
        self.ciValueDecimalComma_radioButton.clicked.connect(
            self.setup_valueDecimalComma)

        self.unitRepresentations = mdl.get_lengthUnits()

        self.ciMDvalueUnit_comboBox.addItems(self.unitRepresentations)
        i = self.unitRepresentations.index(self.ciLASData_fields.MD.unit)
        self.ciMDvalueUnit_comboBox.setCurrentIndex(i)

        self.ciIDvalueUnit_comboBox.addItems(self.unitRepresentations)
        i = self.unitRepresentations.index(self.ciLASData_fields.CD.unit)
        self.ciIDvalueUnit_comboBox.setCurrentIndex(i)

        self.ciApplyAndDraw_pushButton.clicked.connect(
            self.applyAndDraw_caliperData)
        self.ciCommaDelimiter_checkBox.stateChanged.connect(
            self.setNumberPattern)
        self.ciHoleIDsmoothing_slider.valueChanged.connect(
            self.update_ciHoleIDsmoothing_label)
        self.ciHoleIDsmoothing_slider.sliderReleased.connect(
            self.draw_caliperData)
        #self.ciHoleIDsmoothing_slider.actionTriggered.connect( self.update_sliderValue )
        self.ciAccept_pushButton.clicked.connect(self.makeResults_and_done)

        self.ciHoleIDsmoothing_graphicsView.axes.set_position(
            [0.23, 0.1, 0.7, 0.85])
        self.ciHoleIDsmoothing_graphicsView_ylimits = [None, None]
        self.ciHoleIDsmoothing_graphicsView_yselection = []
        zp = pu.ZoomPan()
        zp.zoomYD_factory(self.ciHoleIDsmoothing_graphicsView.axes,
                          self.ciHoleIDsmoothing_graphicsView_ylimits)
        zp.panYD_factory(self.ciHoleIDsmoothing_graphicsView.axes,
                         self.ciHoleIDsmoothing_graphicsView_ylimits)
        #ypressfunction3=self.snapshot )

        self.setup_valueDecimalPoint()

        dialog.setAttribute(Qt.WA_DeleteOnClose)
        dialog.exec_()
	def __init__(self, dialog, parent):
		
		Ui_SpacingSetup.__init__(self)
		zp = pu.ZoomPan()
		self.setupUi(dialog)
		self.dialog = dialog
		self.parent = parent
		self.centralizerCount = 0

		self.ssAccept_pushButton.clicked.connect( self.makeResults_and_done )

		self.ssNextSpacing_fields = mdl.get_ssNextSpacing_fields()
		self.ssCentralizerLocations_fields = mdl.get_ssCentralizerLocations_fields()
		#mdl.calculate_axialForce_field(self)	

		self.__init__ssCentralizerLocations_tableWidget()
		self.__init__ssNextSpacing_tableWidget()

		self.stage = parent.currentWellboreInnerStageDataItem

		self.max_MD = self.stage['MD']
		self.min_MD = self.max_MD-self.stage['Length']
		self.IPOD = self.stage['PipeProps'].OD[0]

		self.centralizers = copy.deepcopy(self.stage['Centralization'])
		del self.centralizers['Mode']
		del self.centralizers['Fields']

		MD, ID, mean_ID, lim_ID = mdl.get_LASMDandCALID_intoInterval(self)
		self.MD = MD
		self.ID = ID
		self.mean_ID = mean_ID

		#-------------------------------------------------

		self.ssCaliperMap_graphicsView.axes.set_position([0.2,0.15,0.75,0.8])
		self.ssCaliperMap_graphicsView_ylimits    = [None,None]
		self.ssCaliperMap_graphicsView_yselection = []

		self.ssSOVisualization_graphicsView.axes.set_position([0.2,0.15,0.75,0.8])
		self.ssSOVisualization_graphicsView_ylimits    = [None,None]
		self.ssSOVisualization_graphicsView_yselection = []
		
		zp.zoomYD_factory(	(self.ssCaliperMap_graphicsView.axes, self.ssSOVisualization_graphicsView.axes),
							(self.ssCaliperMap_graphicsView_ylimits, self.ssSOVisualization_graphicsView_ylimits)  )
		zp.panYD_factory(	(self.ssCaliperMap_graphicsView.axes, self.ssSOVisualization_graphicsView.axes), 
							(self.ssCaliperMap_graphicsView_ylimits, self.ssSOVisualization_graphicsView_ylimits), 
							(self.ssCaliperMap_graphicsView_yselection, self.ssSOVisualization_graphicsView_yselection),
							ypressfunction1=self.highlight_MDlocation,
							ypressfunction3=self.choose_MDlocation )

		self.ssCaliperMap_graphicsView.axes.clear()
		self.ssSOVisualization_graphicsView.axes.clear()

		#-------------------------------------------------

		self.ssCaliperMap_graphicsView.axes.fill_betweenx( MD, -ID, +ID, alpha=0.5, color='C0')
		factors = mu.np.linspace(1,2,11)
		for factor in factors[1:]:
			IPOD = self.IPOD*factor
			self.ssCaliperMap_graphicsView.axes.fill_betweenx( MD, +IPOD, +ID, where=IPOD<ID, alpha=0.05, color='C3')
			self.ssCaliperMap_graphicsView.axes.fill_betweenx( MD, -IPOD, -ID, where=IPOD<ID, alpha=0.05, color='C3')

		self.ssCaliperMap_graphicsView.axes.plot( [ -self.IPOD, -self.IPOD], [MD[0],MD[-1]], 'C1', lw=2 )
		self.ssCaliperMap_graphicsView.axes.plot( [ +self.IPOD, +self.IPOD], [MD[0],MD[-1]], 'C1', lw=2 )

		MDHeaderName = self.ssCentralizerLocations_fields.MD.headerName
		IDHeaderName = self.ssCentralizerLocations_fields.ID.headerName

		self.ssCaliperMap_graphicsView.axes.set_xlabel( IDHeaderName )
		self.ssCaliperMap_graphicsView.axes.set_ylabel( MDHeaderName )
		self.ssCaliperMap_graphicsView.axes.set_xlim( -lim_ID, lim_ID )
		self.ssCaliperMap_graphicsView.axes.set_ylim( self.max_MD, self.min_MD ) 
		self.ssCaliperMap_graphicsView.draw()

		#-------------------------------------------------

		SOHeaderName = self.ssCentralizerLocations_fields.SOatC.headerName +'  &  '+ self.ssCentralizerLocations_fields.SOatM.headerName
		if self.ssCentralizerLocations_fields.SOatC.unit=='%':
			self.max_SO = 100
			self.min_SO = 67
			self.ΔSO = 10
		elif self.ssCentralizerLocations_fields.SOatC.unit=='1':
			self.max_SO = 1
			self.min_SO = 0.67
			self.ΔSO = 0.1

		self.ssSOVisualization_graphicsView.axes.set_xlabel( SOHeaderName )
		self.ssSOVisualization_graphicsView.axes.set_ylabel( MDHeaderName )
		self.ssSOVisualization_graphicsView.axes.set_xlim( -self.ΔSO, self.max_SO+self.ΔSO )
		self.ssSOVisualization_graphicsView.axes.set_ylim( self.max_MD, self.min_MD )
		#self.ssSOVisualization_graphicsView.axes.grid()
		self.ssSOVisualization_graphicsView.axes.plot( [self.min_SO, self.min_SO], [self.max_MD, self.min_MD], 'C3--', lw=2 )
		self.ssSOVisualization_graphicsView.axes.plot( [0, 0], [self.max_MD, self.min_MD], 'k-', lw=1, alpha=0.3 )
		self.ssSOVisualization_graphicsView.axes.plot( [self.max_SO, self.max_SO], [self.max_MD, self.min_MD], 'k-', lw=1, alpha=0.3 )
		self.ssSOVisualization_graphicsView.draw()

		#-------------------------------------------------

		min_EW,min_NS,min_VD,min_index = mdl2.get_ASCCoordinates_from_MD(parent, self.min_MD, unit=parent.s2DataSurvey_fields.MD.unit)
		max_EW,max_NS,max_VD,max_index = mdl2.get_ASCCoordinates_from_MD(parent, self.max_MD, unit=parent.s2DataSurvey_fields.MD.unit)
		EW = parent.s2DataSurvey_fields.EW[min_index:max_index+1]
		NS = parent.s2DataSurvey_fields.NS[min_index:max_index+1]
		VD = parent.s2DataSurvey_fields.TVD[min_index:max_index+1]
		
		EW[0] = min_EW
		NS[0] = min_NS
		VD[0] = min_VD
		EW[-1] = max_EW
		NS[-1] = max_NS
		VD[-1] = max_VD

		curve, = self.ssWellbore3D_graphicsView.axes.plot( EW, NS, VD )

		self.ssWellbore3D_graphicsView.axes.set_xlabel( parent.s2DataSurvey_fields.EW.headerName )
		self.ssWellbore3D_graphicsView.axes.set_ylabel( parent.s2DataSurvey_fields.NS.headerName )
		self.ssWellbore3D_graphicsView.axes.set_zlabel( parent.s2DataSurvey_fields.TVD.headerName )

		max_EW = max(parent.s2DataSurvey_fields.EW)
		min_EW = min(parent.s2DataSurvey_fields.EW)
		max_NS = max(parent.s2DataSurvey_fields.NS)
		min_NS = min(parent.s2DataSurvey_fields.NS)
		ΔEW = max_EW - min_EW
		ΔNS = max_NS - min_NS

		if ΔEW>ΔNS:
			self.ssWellbore3D_graphicsView.axes.set_xlim( min_EW, max_EW )
			Δ = (ΔEW-ΔNS)/2
			self.ssWellbore3D_graphicsView.axes.set_ylim( min_NS-Δ, max_NS+Δ )
		elif ΔNS>ΔEW:
			self.ssWellbore3D_graphicsView.axes.set_ylim( min_NS, max_NS )
			Δ = (ΔNS-ΔEW)/2
			self.ssWellbore3D_graphicsView.axes.set_xlim( min_EW-Δ, max_EW+Δ )
		else:
			self.ssWellbore3D_graphicsView.axes.set_xlim( min_EW, max_EW )
			self.ssWellbore3D_graphicsView.axes.set_ylim( min_NS, max_NS )


		self.ssWellbore3D_graphicsView.axes.set_zlim( max(VD), min(VD) )
		self.ssWellbore3D_graphicsView.axes.mouse_init()
		#zp.point3D_factory(self.s2TriDView_graphicsView.axes, dot, curve)
		zp.zoom3D_factory( self.ssWellbore3D_graphicsView.axes, curve )
		self.ssWellbore3D_graphicsView.draw()

		dialog.setAttribute(Qt.WA_DeleteOnClose)
		dialog.exec_()
	def __init__(self, dialog, parent):

		Ui_DiagramWindow.__init__(self)
		#zp = pu.ZoomPan()
		self.setupUi(dialog)
		self.dialog = dialog
		self.parent = parent

		self.dwWellboreSchematic_graphicsView

		self.dwWellboreSchematic_graphicsView.axes.set_position([0.2,0.15,0.75,0.8])
		zp = pu.ZoomPan()
		zp.zoom2D_factory( self.dwWellboreSchematic_graphicsView.axes )
		zp.pan2D_factory( self.dwWellboreSchematic_graphicsView.axes )
		self.dwWellboreSchematic_graphicsView.axes.clear()

		MDs = self.parent.v3Forces_fields.MD[:]

		for stage in self.parent.v3WellboreInnerStageData.values():
			MDbot = stage['MDbot']
			MDs.append(MDbot)

		for stage in self.parent.v3WellboreOuterStageData.values():
			MDbot = stage['WellboreProps'].MDbot[0]
			MDs.append(MDbot)

		MDs.sort()
		MDunit = MDbot.unit
		factor = max(self.parent.v3Forces_fields.HD)/mdl.get_outerStage_at_MD( self.parent, 0.0, MDunit )['WellboreProps'].ID[0]*0.2

		HDu_i = []
		VDu_i = []
		HDd_i = []
		VDd_i = []
		HDu_o = []
		VDu_o = []
		HDd_o = []
		VDd_o = []

		for MD in MDs:
			ew,ns,VD,HD,i = mdl.get_ASCCoordinates_from_MD(self.parent, MD, MDunit)

			T = mdl.get_ASCT_from_MD(self.parent, MD, MDunit)
			t = mu.np.array([ T[3], T[2], 0 ])
			t = t.reshape(1,-1)
			normt = mu.np.linalg.norm(t)
			if normt!=0.0:
				t /=normt
			u = mu.np.array([ 0, 0, 1 ])
			u = u.reshape(1,-1)
			nu = mu.np_cross(t,u)

			d = mu.np.array([ 0, 0, -1 ])
			d = d.reshape(1,-1)
			nd = mu.np_cross(t,d)

			innerStage = mdl.get_innerStage_at_MD(self.parent, MD, MDunit)
			factor_i = factor*innerStage['PipeProps'].OD[0]

			outerStage = mdl.get_outerStage_at_MD(self.parent, MD, MDunit)
			if outerStage['PipeBase']==None:
				noise = 0.1*(mu.np.random.rand()-0.5)+1
			else:
				noise = 1
			factor_o = factor*outerStage['WellboreProps'].ID[0]*noise

			HDu_i.append( HD+nu[0][0]*factor_i )
			VDu_i.append( VD+nu[0][1]*factor_i )
			HDd_i.append( HD+nd[0][0]*factor_i )
			VDd_i.append( VD+nd[0][1]*factor_i )
			HDu_o.append( HD+nu[0][0]*factor_o )
			VDu_o.append( VD+nu[0][1]*factor_o )
			HDd_o.append( HD+nd[0][0]*factor_o )
			VDd_o.append( VD+nd[0][1]*factor_o )

		max_VD = max( self.parent.v3Forces_fields.TVD )
		min_VD = min( self.parent.v3Forces_fields.TVD )
		delta = (max_VD-min_VD)*0.55

		self.dwWellboreSchematic_graphicsView.axes.axis('equal')
		self.dwWellboreSchematic_graphicsView.axes.set_ylim( max_VD+delta, min_VD-delta )
		self.dwWellboreSchematic_graphicsView.axes.set_xlabel( self.parent.v3Forces_fields.HD.headerName )
		self.dwWellboreSchematic_graphicsView.axes.set_ylabel( self.parent.v3Forces_fields.TVD.headerName )
		
		self.dwWellboreSchematic_graphicsView.axes.plot( self.parent.v3Forces_fields.HD, self.parent.v3Forces_fields.TVD, 'k--', lw=1 )
		self.dwWellboreSchematic_graphicsView.axes.plot( HDu_i, VDu_i, 'C1', lw=3 )
		self.dwWellboreSchematic_graphicsView.axes.plot( HDd_i, VDd_i, 'C1', lw=3 )
		self.dwWellboreSchematic_graphicsView.axes.plot( HDu_o, VDu_o, 'C0', lw=3 )
		self.dwWellboreSchematic_graphicsView.axes.plot( HDd_o, VDd_o, 'C0', lw=3 )

		for stage in self.parent.v3WellboreInnerStageData.values():
			MDbot = stage['MDbot']

			EW,NS,VD,HD,i = mdl.get_ASCCoordinates_from_MD(self.parent, MDbot)

			T = mdl.get_ASCT_from_MD(self.parent, MDbot, MDbot.unit)
			t = mu.np.array([ T[3], T[2], 0 ])
			t = t.reshape(1,-1)
			normt = mu.np.linalg.norm(t)
			if normt!=0.0:
				t /=normt
			u = mu.np.array([ 0, 0, 1 ])
			u = u.reshape(1,-1)
			nu = mu.np_cross(t,u)
			nu *= 0.3*max_VD

			d = mu.np.array([ 0, 0, -1 ])
			d = d.reshape(1,-1)
			nd = mu.np_cross(t,d)
			nd *= 0.3*max_VD

			self.dwWellboreSchematic_graphicsView.axes.arrow(HD, VD, nu[0][0], nu[0][1], head_width=0, head_length=0, fc='k', ec='k', lw=0.5, alpha=0.5)
			self.dwWellboreSchematic_graphicsView.axes.arrow(HD, VD, nd[0][0], nd[0][1], head_width=0, head_length=0, fc='k', ec='k', lw=0.5, alpha=0.5)
			

		dialog.setAttribute(Qt.WA_DeleteOnClose)
		dialog.exec_()
def calculateAndDraw_torque_drag_sideforce(self):

    for field in self.v4TorqueDragForces_fields:
        print(field.headerName, len(field), field)

    calculate_TorqueAndDrag(self)

    for field in self.v4TorqueDragForces_fields:
        print(field.headerName, len(field), field)

    TDS_fields = self.v4TorqueDragForces_fields

    for field in self.v4TorqueDragForces_fields[:7]:
        for row, value in enumerate(field):
            item = self.s4TorqueDragSideforce_tableWidget.item(row, field.pos)
            item.set_text(value, value.unit)

    max_MD = max(TDS_fields.MD)

    self.s4Drag_graphicsView.axes.clear()
    self.s4Drag_graphicsView.axes.set_xlabel(TDS_fields.Drag_s.headerName)
    self.s4Drag_graphicsView.axes.set_ylabel(TDS_fields.MD.headerName)
    #self.s4Drag_graphicsView.axes.set_xlim( 0, self.max_SO )
    self.s4Drag_graphicsView.axes.set_ylim(max_MD * 1.2, 0)
    self.s4Drag_graphicsView.axes.grid()
    self.s4Drag_graphicsView.axes.plot(TDS_fields.Drag_u,
                                       TDS_fields.MD,
                                       'C0',
                                       lw=2)
    self.s4Drag_graphicsView.axes.plot(TDS_fields.Drag_s,
                                       TDS_fields.MD,
                                       'C1',
                                       lw=2)
    self.s4Drag_graphicsView.axes.plot(TDS_fields.Drag_d,
                                       TDS_fields.MD,
                                       'C2',
                                       lw=2)
    self.s4Drag_graphicsView.axes.plot(TDS_fields.uncDrag_u,
                                       TDS_fields.MD,
                                       'C0--',
                                       lw=2)
    self.s4Drag_graphicsView.axes.plot(TDS_fields.uncDrag_s,
                                       TDS_fields.MD,
                                       'C1--',
                                       lw=2)
    self.s4Drag_graphicsView.axes.plot(TDS_fields.uncDrag_d,
                                       TDS_fields.MD,
                                       'C2--',
                                       lw=2)
    self.s4Drag_graphicsView.draw()

    #---------------------------------------------
    self.s4Torque_graphicsView.axes.clear()
    self.s4Torque_graphicsView.axes.set_xlabel(TDS_fields.Torque.headerName)
    self.s4Torque_graphicsView.axes.set_ylabel(TDS_fields.MD.headerName)
    #self.s4Torque_graphicsView.axes.set_xlim( 0, self.max_SO )
    self.s4Torque_graphicsView.axes.set_ylim(max_MD * 1.2, 0)
    self.s4Torque_graphicsView.axes.grid()
    self.s4Torque_graphicsView.axes.plot(TDS_fields.Torque,
                                         TDS_fields.MD,
                                         'C0',
                                         lw=2)
    self.s4Torque_graphicsView.axes.plot(TDS_fields.uncTorque,
                                         TDS_fields.MD,
                                         'C0--',
                                         lw=2)
    self.s4Torque_graphicsView.draw()

    #---------------------------------------------

    self.s4Sideforce_graphicsView.axes.set_position([0.2, 0.15, 0.75, 0.8])
    zp = pu.ZoomPan()
    zp.zoom2D_factory(self.s4Sideforce_graphicsView.axes)
    zp.pan2D_factory(self.s4Sideforce_graphicsView.axes)
    self.s4Sideforce_graphicsView.axes.clear()

    max_VD = max(self.v3Forces_fields.TVD)
    min_VD = min(self.v3Forces_fields.TVD)
    max_SF = max(self.v3Forces_fields.SideF)

    self.s4Sideforce_graphicsView.axes.axis('equal')
    self.s4Sideforce_graphicsView.axes.set_ylim(max_VD, min_VD)
    self.s4Sideforce_graphicsView.axes.set_xlabel(
        self.v3Forces_fields.HD.headerName)
    self.s4Sideforce_graphicsView.axes.set_ylabel(
        self.v3Forces_fields.TVD.headerName)

    self.s4Sideforce_graphicsView.axes.plot(self.v3Forces_fields.HD,
                                            self.v3Forces_fields.TVD,
                                            'C0',
                                            lw=3)
    factor = max(self.v3Forces_fields.HD) / max(
        self.v3Forces_fields.SideF) * 0.5
    for i, MDi in enumerate(self.v3Forces_fields.MD):
        HDi = self.v3Forces_fields.HD[i]
        VDi = self.v3Forces_fields.TVD[i]
        DFi = self.v3Forces_fields.DLplaneF[i]
        SFi = self.v3Forces_fields.SideF[i]

        T = mdl.get_ASCT_from_MD(self, MDi, MDi.unit)
        t = mu.np.array([T[3], T[2], 0])
        t = t.reshape(1, -1)
        normt = mu.np.linalg.norm(t)
        if normt != 0.0:
            t /= normt
        u = mu.np.array([0, 0, -DFi])
        u = u.reshape(1, -1)
        normu = mu.np.linalg.norm(u)
        if normu != 0.0:
            u /= normu

        if normt == 0 or normu == 0:
            n = mu.np.array([0, 0, 0])
            n = n.reshape(1, -1)
        else:
            n = mu.np_cross(t, u)
            n *= SFi * factor

        self.s4Sideforce_graphicsView.axes.arrow(HDi,
                                                 VDi,
                                                 n[0][0],
                                                 n[0][1],
                                                 head_width=factor * 0.1,
                                                 head_length=factor * 0.2,
                                                 fc='C1',
                                                 ec='C1')
        #self.s4Sideforce_graphicsView.axes.arrow(HDi, VDi, t[0][0], t[0][1], head_width=factor*0.1, head_length=factor*0.2, fc='C1', ec='C1')

    for stage in self.v3WellboreInnerStageData.values():
        MDbot = stage['MDbot']
        EW, NS, VD, HD, i = mdl.get_ASCCoordinates_from_MD(self, MDbot)

        T = mdl.get_ASCT_from_MD(self, MDbot, MDbot.unit)
        t = mu.np.array([T[3], T[2], 0])
        t = t.reshape(1, -1)
        normt = mu.np.linalg.norm(t)
        if normt != 0.0:
            t /= normt
        u = mu.np.array([0, 0, 1])
        u = u.reshape(1, -1)
        nu = mu.np_cross(t, u)
        nu *= 1.2 * max_SF * factor

        d = mu.np.array([0, 0, -1])
        d = d.reshape(1, -1)
        nd = mu.np_cross(t, d)
        nd *= 1.2 * max_SF * factor

        self.s4Sideforce_graphicsView.axes.arrow(HD,
                                                 VD,
                                                 nu[0][0],
                                                 nu[0][1],
                                                 head_width=0,
                                                 head_length=0,
                                                 fc='k',
                                                 ec='k',
                                                 lw=0.5,
                                                 alpha=0.5)
        self.s4Sideforce_graphicsView.axes.arrow(HD,
                                                 VD,
                                                 nd[0][0],
                                                 nd[0][1],
                                                 head_width=0,
                                                 head_length=0,
                                                 fc='k',
                                                 ec='k',
                                                 lw=0.5,
                                                 alpha=0.5)

    #-------------------------------------------------

    self.s4HookLoad_graphicsView.axes.clear()
    self.s4HookLoad_graphicsView.axes.set_xlabel(TDS_fields.Drag_s.headerName)
    self.s4HookLoad_graphicsView.axes.set_ylabel(TDS_fields.MD.headerName)
    self.s4HookLoad_graphicsView.axes.set_ylim(max_MD * 1.2, 0)
    self.s4HookLoad_graphicsView.axes.grid()
    max_Drag_u = max(TDS_fields.Drag_u)
    max_Drag_s = max(TDS_fields.Drag_s)
    max_Drag_d = max(TDS_fields.Drag_d)
    max_uncDrag_u = max(TDS_fields.uncDrag_u)
    max_uncDrag_s = max(TDS_fields.uncDrag_s)
    max_uncDrag_d = max(TDS_fields.uncDrag_d)
    self.s4HookLoad_graphicsView.axes.plot(max_Drag_u -
                                           mu.array(TDS_fields.Drag_u),
                                           TDS_fields.MD,
                                           'C0',
                                           lw=2)
    self.s4HookLoad_graphicsView.axes.plot(max_Drag_s -
                                           mu.array(TDS_fields.Drag_s),
                                           TDS_fields.MD,
                                           'C1',
                                           lw=2)
    self.s4HookLoad_graphicsView.axes.plot(max_Drag_d -
                                           mu.array(TDS_fields.Drag_d),
                                           TDS_fields.MD,
                                           'C2',
                                           lw=2)
    self.s4HookLoad_graphicsView.axes.plot(max_uncDrag_u -
                                           mu.array(TDS_fields.uncDrag_u),
                                           TDS_fields.MD,
                                           'C0--',
                                           lw=2)
    self.s4HookLoad_graphicsView.axes.plot(max_uncDrag_s -
                                           mu.array(TDS_fields.uncDrag_s),
                                           TDS_fields.MD,
                                           'C1--',
                                           lw=2)
    self.s4HookLoad_graphicsView.axes.plot(max_uncDrag_d -
                                           mu.array(TDS_fields.uncDrag_d),
                                           TDS_fields.MD,
                                           'C2--',
                                           lw=2)
    self.s4HookLoad_graphicsView.draw()
Example #5
0
def draw_survey_plots( self ):

	self.s2SectionView_graphicsView.axes.clear()
	self.s2PlanView_graphicsView.axes.clear()
	self.s2TriDView_graphicsView.axes.clear()
	self.s2Dogleg_graphicsView.axes.clear()

	color='C1' if self.s2SurveyTortuosity_checkBox.isChecked() else 'C0'
	self.s2SectionView_graphicsView.axes.plot( 	self.v2ASCComplements_fields.HD, 
												self.v2ASCComplements_fields.TVD, color=color )
	self.s2SectionView_graphicsView.axes.set_xlabel( self.v2ASCComplements_fields.HD.headerName )
	self.s2SectionView_graphicsView.axes.set_ylabel( self.v2ASCComplements_fields.TVD.headerName )
	self.s2SectionView_graphicsView.axes.set_ylim(	max(self.v2ASCComplements_fields.TVD), 
													min(self.v2ASCComplements_fields.TVD) )
	self.s2SectionView_graphicsView.axes.grid()
	self.s2SectionView_graphicsView.draw()
	
	self.s2PlanView_graphicsView.axes.plot( self.v2ASCComplements_fields.EW, 
											self.v2ASCComplements_fields.NS, color=color )
	self.s2PlanView_graphicsView.axes.set_xlabel( self.v2ASCComplements_fields.EW.headerName )
	self.s2PlanView_graphicsView.axes.set_ylabel( self.v2ASCComplements_fields.NS.headerName )
	self.s2PlanView_graphicsView.axes.grid()
	self.s2PlanView_graphicsView.draw()
	
	"""
	X,Y,Z,C = mu.render_wellbore( self.v2ASCComplements_fields, 100, 20 )
	lis = pu.LightSource(270, 45)
	rgb = lis.shade(mu.np.cos(C/500), cmap=pu.cm.RdYlBu, vert_exag=1, blend_mode='soft')
	self.s2TriDView_graphicsView.axes.plot_surface(X,Y,Z, linewidth=0, facecolors=rgb, antialiased=False)
	"""
	
	curve, = self.s2TriDView_graphicsView.axes.plot(self.v2ASCComplements_fields.EW, 
													self.v2ASCComplements_fields.NS, 
													self.v2ASCComplements_fields.TVD, color=color, lw=3 )
	self.s2TriDView_graphicsView.axes.plot( [0,0], [0,0], 
											[self.v2ASCComplements_fields.TVD[0], 
											self.v2ASCComplements_fields.TVD[-1]],'r--', lw=1 )
	self.s2TriDView_graphicsView.axes.plot( [0,self.v2ASCComplements_fields.EW[-1]],
											[0,self.v2ASCComplements_fields.NS[-1]], 
											[self.v2ASCComplements_fields.TVD[-1], 
											self.v2ASCComplements_fields.TVD[-1]],'g--', lw=1 )
	#dot,   = self.s2TriDView_graphicsView.axes.plot( [0],[0],[0],'bo' )
	self.s2TriDView_graphicsView.axes.set_xlabel( self.v2ASCComplements_fields.EW.headerName )
	self.s2TriDView_graphicsView.axes.set_ylabel( self.v2ASCComplements_fields.NS.headerName )
	self.s2TriDView_graphicsView.axes.set_zlabel( self.v2ASCComplements_fields.TVD.headerName )

	
	max_VD = max(self.v2ASCComplements_fields.TVD)
	min_VD = min(self.v2ASCComplements_fields.TVD)
	max_EW = max(self.v2ASCComplements_fields.EW)
	min_EW = min(self.v2ASCComplements_fields.EW)
	max_NS = max(self.v2ASCComplements_fields.NS)
	min_NS = min(self.v2ASCComplements_fields.NS)
	
	ΔVD = max_VD - min_VD
	ΔEW = max_EW - min_EW
	ΔNS = max_NS - min_NS

	Δ = max( [ΔVD, ΔEW, ΔNS] )

	ar = self.s2AspectRatio_verticalSlider.sliderPosition()

	if ΔVD==Δ:
		self.s2TriDView_graphicsView.axes.set_xlim( min_EW-(Δ/ar-ΔEW)/2, max_EW+(Δ/ar-ΔEW)/2 )
		self.s2TriDView_graphicsView.axes.set_ylim( min_NS-(Δ/ar-ΔNS)/2, max_NS+(Δ/ar-ΔNS)/2 )
		self.s2TriDView_graphicsView.axes.set_zlim( max_VD, min_VD )
	elif ΔNS==Δ:
		self.s2TriDView_graphicsView.axes.set_xlim( min_EW-(Δ-ΔEW)/2, max_EW+(Δ-ΔEW)/2 )
		self.s2TriDView_graphicsView.axes.set_ylim( min_NS, max_NS )
		self.s2TriDView_graphicsView.axes.set_zlim( max_VD+(Δ-ΔVD)/2, min_VD-(Δ-ΔVD)/2 )
	elif ΔEW==Δ:
		self.s2TriDView_graphicsView.axes.set_xlim( min_EW, max_EW )
		self.s2TriDView_graphicsView.axes.set_ylim( min_NS-(Δ-ΔNS)/2, max_NS+(Δ-ΔNS)/2 )
		self.s2TriDView_graphicsView.axes.set_zlim( max_VD+(Δ-ΔVD)/2, min_VD-(Δ-ΔVD)/2 )


	self.s2TriDView_graphicsView.axes.mouse_init()
	zp = pu.ZoomPan()
	#zp.point3D_factory(self.s2TriDView_graphicsView.axes, dot, curve)
	#zp.zoom3D_factory( self.s2TriDView_graphicsView.axes, curve )
	self.s2TriDView_graphicsView.draw()
	
	zp.zoom2D_factory( self.s2Dogleg_graphicsView.axes )
	zp.pan2D_factory( self.s2Dogleg_graphicsView.axes )

	self.s2Dogleg_graphicsView.axes.plot(	self.v2ASCComplements_fields.DL, 
											self.v2ASCComplements_fields.MD, color=color )
	self.s2Dogleg_graphicsView.axes.set_xlabel( self.v2ASCComplements_fields.DL.headerName )
	self.s2Dogleg_graphicsView.axes.set_ylabel( self.v2ASCComplements_fields.MD.headerName )
	self.s2Dogleg_graphicsView.axes.set_ylim(	max(self.v2ASCComplements_fields.MD), 
												min(self.v2ASCComplements_fields.MD) )
	self.s2Dogleg_graphicsView.axes.grid()
	self.s2Dogleg_graphicsView.draw()
    def __init__(self, dialog, parent):

        Ui_GraphWindow.__init__(self)
        zp = pu.ZoomPan()
        self.setupUi(dialog)
        self.dialog = dialog
        self.parent = parent

        #self.lsAccept_pushButton.clicked.connect( self.makeResults_and_done )

        #-------------------------------------------------

        #self.lsCaliperMap_graphicsView.axes.set_position([0.2,0.15,0.75,0.8])

        #-------------------------------------------------

        EW = parent.v2ASCComplements_fields.EW
        NS = parent.v2ASCComplements_fields.NS
        VD = parent.v2ASCComplements_fields.TVD

        max_VD = max(VD)
        min_VD = min(VD)
        max_EW = max(EW)
        min_EW = min(EW)
        max_NS = max(NS)
        min_NS = min(NS)

        ΔVD = max_VD - min_VD
        ΔEW = max_EW - min_EW
        ΔNS = max_NS - min_NS

        Δ = max([ΔVD, ΔEW, ΔNS])

        if ΔVD == Δ:
            self.gwColoredWellbore_graphicsView.axes.set_xlim(
                min_EW - (Δ - ΔEW) / 2, max_EW + (Δ - ΔEW) / 2)
            self.gwColoredWellbore_graphicsView.axes.set_ylim(
                min_NS - (Δ - ΔNS) / 2, max_NS + (Δ - ΔNS) / 2)
            self.gwColoredWellbore_graphicsView.axes.set_zlim(max_VD, min_VD)
        elif ΔNS == Δ:
            self.gwColoredWellbore_graphicsView.axes.set_xlim(
                min_EW - (Δ - ΔEW) / 2, max_EW + (Δ - ΔEW) / 2)
            self.gwColoredWellbore_graphicsView.axes.set_ylim(min_NS, max_NS)
            self.gwColoredWellbore_graphicsView.axes.set_zlim(
                max_VD + (Δ - ΔVD) / 2, min_VD - (Δ - ΔVD) / 2)
        elif ΔEW == Δ:
            self.gwColoredWellbore_graphicsView.axes.set_xlim(min_EW, max_EW)
            self.gwColoredWellbore_graphicsView.axes.set_ylim(
                min_NS - (Δ - ΔNS) / 2, max_NS + (Δ - ΔNS) / 2)
            self.gwColoredWellbore_graphicsView.axes.set_zlim(
                max_VD + (Δ - ΔVD) / 2, min_VD - (Δ - ΔVD) / 2)

        X, Y, Z, C = mu.render_wellbore(parent.v2ASCComplements_fields, 50, 15)
        SO = mu.np.interp(parent.v2ASCComplements_fields.MD, parent.v3SOs_MD,
                          parent.v3SOs_SO)
        C = SO * C

        print(C.min(), C.max())

        lis = pu.LightSource(270, 45)
        rgb = lis.shade(C,
                        cmap=pu.cm.coolwarm,
                        vert_exag=1,
                        blend_mode='soft',
                        vmin=0,
                        vmax=100)
        surface = self.gwColoredWellbore_graphicsView.axes.plot_surface(
            X,
            Y,
            Z,
            facecolors=rgb,
            linewidth=0,
            antialiased=False,
            vmin=0,
            vmax=100)

        #mappable = pu.plt.cm.ScalarMappable(cmap=pu.cm.bwr)
        #mappable.set_array(C)
        #surface = self.gwColoredWellbore_graphicsView.axes.plot_surface(X,Y,Z, cmap=mappable.cmap, linewidth=0, antialiased=False)
        #fig = self.gwColoredWellbore_graphicsView.axes.get_figure()
        #fig.colorbar(mappable, shrink=0.2, aspect=5, orientation='horizontal', location='bottom')

        self.gwColoredWellbore_graphicsView.axes.set_xlabel(EW.headerName)
        self.gwColoredWellbore_graphicsView.axes.set_ylabel(NS.headerName)
        self.gwColoredWellbore_graphicsView.axes.set_zlabel(VD.headerName)

        self.gwColoredWellbore_graphicsView.axes.mouse_init()

        #curve, = self.gwColoredWellbore_graphicsView.axes.plot( EW, NS, VD, lw=2 )
        #zp.point3D_factory(self.s2TriDView_graphicsView.axes, dot, curve)
        #zp.zoom3D_factory( self.gwColoredWellbore_graphicsView.axes, curve )
        #self.gwColoredWellbore_graphicsView.draw()

        #dialog.setAttribute(Qt.WA_DeleteOnClose)
        dialog.exec_()
Example #7
0
    def __init__(self, dialog, parent):

        Ui_LocationSetup.__init__(self)
        zp = pu.ZoomPan()
        self.setupUi(dialog)
        self.dialog = dialog
        self.parent = parent

        self.lsAspectRatio_verticalSlider.setValue(1)
        self.lsAspectRatio_verticalSlider.valueChanged.connect(
            self.redraw_with_aspectratio)

        self.lsAccept_pushButton.clicked.connect(self.makeResults_and_done)
        self.lsCentralization_fields = mdl.get_lsCentralization_fields()
        self.__init__lsCentralizerLocations_tableWidget()

        self.MD = self.parent.v3WorkWellboreMD
        self.ID = self.parent.v3WorkWellboreID
        self.max_MD = mu.np.max(self.MD)
        self.min_MD = mu.np.min(self.MD)
        self.lim_ID = mu.np.max(self.ID) * 1.2

        self.numofStages = mdl.cat_locations(self)
        self.centralizerCount = len(self.lsCentralization_fields.MD)
        self.update_calculations()

        #-------------------------------------------------

        self.lsCaliperMap_graphicsView.axes.set_position([0.3, 0.15, 0.6, 0.8])
        self.lsCaliperMap_graphicsView_ylimits = [None, None]
        self.lsCaliperMap_graphicsView_yselection = []

        self.lsSOVisualization_graphicsView.axes.set_position(
            [0.2, 0.15, 0.7, 0.8])
        self.lsSOVisualization_graphicsView_ylimits = [None, None]
        self.lsSOVisualization_graphicsView_yselection = []

        self.lsSideForces_graphicsView.axes.set_position([0.2, 0.15, 0.7, 0.8])
        #self.lsSideForces_graphicsView_ylimits    = [None,None]
        #self.lsSideForces_graphicsView_yselection = []

        zp.zoomYD_factory((self.lsCaliperMap_graphicsView.axes,
                           self.lsSOVisualization_graphicsView.axes),
                          (self.lsCaliperMap_graphicsView_ylimits,
                           self.lsSOVisualization_graphicsView_ylimits))
        zp.panYD_factory((self.lsCaliperMap_graphicsView.axes,
                          self.lsSOVisualization_graphicsView.axes),
                         (self.lsCaliperMap_graphicsView_ylimits,
                          self.lsSOVisualization_graphicsView_ylimits),
                         (self.lsCaliperMap_graphicsView_yselection,
                          self.lsSOVisualization_graphicsView_yselection),
                         ypressfunction1=self.highlight_MDlocation,
                         ypressfunction3=self.choose_MDlocation)
        zp.zoom2D_factory(self.lsSideForces_graphicsView.axes)
        zp.pan2D_factory(self.lsSideForces_graphicsView.axes)

        self.lsCaliperMap_graphicsView.axes.clear()
        self.lsSOVisualization_graphicsView.axes.clear()
        self.lsSideForces_graphicsView.axes.clear()

        #-------------------------------------------------

        self.lsCaliperMap_graphicsView.axes.fill_betweenx(self.MD,
                                                          -self.ID,
                                                          +self.ID,
                                                          alpha=0.5,
                                                          color='C0')
        factors = mu.np.linspace(1.2, 1.6, 8)

        for stage in self.parent.v3WellboreInnerStageData.values():

            MDstage, IDstage = mdl.get_LASMDandCALID_intoStage(self, stage)
            IPODstage = stage['PipeProps'].OD[0]
            """
			for factor in factors[1:]:
				IPOD = IPODstage*factor
				self.lsCaliperMap_graphicsView.axes.fill_betweenx( MDstage, +IPOD, +IDstage, where=IPOD<IDstage, alpha=0.15, color='C3')
				self.lsCaliperMap_graphicsView.axes.fill_betweenx( MDstage, -IPOD, -IDstage, where=IPOD<IDstage, alpha=0.15, color='C3')
			"""

            if stage['Centralization']['Mode'] == False:
                self.lsCaliperMap_graphicsView.axes.fill_betweenx(
                    MDstage, -IDstage, +IDstage, alpha=0.5, color='white')

            self.lsCaliperMap_graphicsView.axes.plot(
                [-self.lim_ID, self.lim_ID], [stage['MDbot'], stage['MDbot']],
                'k-',
                lw=0.5,
                alpha=0.5)
            self.lsCaliperMap_graphicsView.axes.plot([-IPODstage, -IPODstage],
                                                     [MDstage[0], MDstage[-1]],
                                                     'C1',
                                                     lw=2)
            self.lsCaliperMap_graphicsView.axes.plot([+IPODstage, +IPODstage],
                                                     [MDstage[0], MDstage[-1]],
                                                     'C1',
                                                     lw=2)

        MDHeaderName = self.lsCentralization_fields.MD.headerName
        IDHeaderName = self.lsCentralization_fields.ID.headerName

        self.lsCaliperMap_graphicsView.axes.set_xlabel(IDHeaderName)
        self.lsCaliperMap_graphicsView.axes.set_ylabel(MDHeaderName)
        self.lsCaliperMap_graphicsView.axes.set_xlim(-self.lim_ID, self.lim_ID)
        self.lsCaliperMap_graphicsView.axes.set_ylim(self.max_MD, self.min_MD)
        #self.lsCaliperMap_graphicsView.draw()

        #-------------------------------------------------

        max_VD = max(self.parent.v3Forces_fields.TVD)
        min_VD = min(self.parent.v3Forces_fields.TVD)
        max_SF = max(self.parent.v3Forces_fields.SideF)

        self.lsSideForces_graphicsView.axes.axis('equal')
        self.lsSideForces_graphicsView.axes.set_ylim(max_VD, min_VD)
        self.lsSideForces_graphicsView.axes.set_xlabel(
            self.parent.v3Forces_fields.HD.headerName)
        self.lsSideForces_graphicsView.axes.set_ylabel(
            self.parent.v3Forces_fields.TVD.headerName)

        self.lsSideForces_graphicsView.axes.plot(
            self.parent.v3Forces_fields.HD,
            self.parent.v3Forces_fields.TVD,
            'C0',
            lw=3)
        factor = max(self.parent.v3Forces_fields.HD) / max(
            self.parent.v3Forces_fields.SideF) * 0.5
        for i, MDi in enumerate(self.parent.v3Forces_fields.MD):
            HDi = self.parent.v3Forces_fields.HD[i]
            VDi = self.parent.v3Forces_fields.TVD[i]
            DFi = self.parent.v3Forces_fields.DLplaneF[i]
            SFi = self.parent.v3Forces_fields.SideF[i]

            T = mdl.mdl.get_ASCT_from_MD(self.parent, MDi, MDi.unit)
            t = mu.np.array([T[3], T[2], 0])
            t = t.reshape(1, -1)
            normt = mu.np.linalg.norm(t)
            if normt != 0.0:
                t /= normt
            u = mu.np.array([0, 0, -DFi])
            u = u.reshape(1, -1)
            normu = mu.np.linalg.norm(u)
            if normu != 0.0:
                u /= normu

            if normt == 0 or normu == 0:
                n = mu.np.array([0, 0, 0])
                n = n.reshape(1, -1)
            else:
                n = mu.np_cross(t, u)
                n *= SFi * factor

            self.lsSideForces_graphicsView.axes.arrow(HDi,
                                                      VDi,
                                                      n[0][0],
                                                      n[0][1],
                                                      head_width=factor * 0.1,
                                                      head_length=factor * 0.2,
                                                      fc='C1',
                                                      ec='C1')
            #self.lsSideForces_graphicsView.axes.arrow(HDi, VDi, t[0][0], t[0][1], head_width=factor*0.1, head_length=factor*0.2, fc='C1', ec='C1')

        for stage in self.parent.v3WellboreInnerStageData.values():
            MDbot = stage['MDbot']
            EW, NS, VD, HD, i = mdl.mdl.get_ASCCoordinates_from_MD(
                self.parent, MDbot)

            T = mdl.mdl.get_ASCT_from_MD(self.parent, MDbot, MDbot.unit)
            t = mu.np.array([T[3], T[2], 0])
            t = t.reshape(1, -1)
            normt = mu.np.linalg.norm(t)
            if normt != 0.0:
                t /= normt
            u = mu.np.array([0, 0, 1])
            u = u.reshape(1, -1)
            nu = mu.np_cross(t, u)
            nu *= 1.2 * max_SF * factor

            d = mu.np.array([0, 0, -1])
            d = d.reshape(1, -1)
            nd = mu.np_cross(t, d)
            nd *= 1.2 * max_SF * factor

            self.lsSideForces_graphicsView.axes.arrow(HD,
                                                      VD,
                                                      nu[0][0],
                                                      nu[0][1],
                                                      head_width=0,
                                                      head_length=0,
                                                      fc='k',
                                                      ec='k',
                                                      lw=0.5,
                                                      alpha=0.5)
            self.lsSideForces_graphicsView.axes.arrow(HD,
                                                      VD,
                                                      nd[0][0],
                                                      nd[0][1],
                                                      head_width=0,
                                                      head_length=0,
                                                      fc='k',
                                                      ec='k',
                                                      lw=0.5,
                                                      alpha=0.5)

        #-------------------------------------------------

        SOHeaderName = self.lsCentralization_fields.SOatC.headerName + '  &  ' + self.lsCentralization_fields.SOatM.headerName
        if self.lsCentralization_fields.SOatC.unit == '%':
            self.max_SO = 100
            self.min_SO = 67
            self.ΔSO = 10
        elif self.lsCentralization_fields.SOatC.unit == '1':
            self.max_SO = 1
            self.min_SO = 0.67
            self.ΔSO = 0.1

        self.lsSOVisualization_graphicsView.axes.set_xlabel(SOHeaderName)
        self.lsSOVisualization_graphicsView.axes.set_ylabel(MDHeaderName)
        self.lsSOVisualization_graphicsView.axes.set_xlim(
            -self.ΔSO, self.max_SO + self.ΔSO)
        self.lsSOVisualization_graphicsView.axes.set_ylim(
            self.max_MD, self.min_MD)
        #self.lsSOVisualization_graphicsView.axes.grid()
        self.lsSOVisualization_graphicsView.axes.plot(
            [self.min_SO, self.min_SO], [self.max_MD, self.min_MD],
            'C3--',
            lw=2)
        self.lsSOVisualization_graphicsView.axes.plot(
            [0, 0], [self.max_MD, self.min_MD], 'k-', lw=1, alpha=0.3)
        self.lsSOVisualization_graphicsView.axes.plot(
            [self.max_SO, self.max_SO], [self.max_MD, self.min_MD],
            'k-',
            lw=1,
            alpha=0.3)
        for stage in self.parent.v3WellboreInnerStageData.values():
            self.lsSOVisualization_graphicsView.axes.plot(
                [0, self.max_SO], [stage['MDbot'], stage['MDbot']],
                'k-',
                lw=0.5,
                alpha=0.5)

        #self.lsSOVisualization_graphicsView.draw()

        #-------------------------------------------------

        EW = parent.v2ASCComplements_fields.EW
        NS = parent.v2ASCComplements_fields.NS
        VD = parent.v2ASCComplements_fields.TVD

        self.max_VD = max(VD)
        self.min_VD = min(VD)
        self.max_EW = max(EW)
        self.min_EW = min(EW)
        self.max_NS = max(NS)
        self.min_NS = min(NS)

        self.ΔVD = self.max_VD - self.min_VD
        self.ΔEW = self.max_EW - self.min_EW
        self.ΔNS = self.max_NS - self.min_NS

        self.Δ = max([self.ΔVD, self.ΔEW, self.ΔNS])

        ar = self.lsAspectRatio_verticalSlider.sliderPosition()
        self.set_3DGraph_limits(ar)

        curve, = self.lsWellbore3D_graphicsView.axes.plot(EW, NS, VD, lw=3)

        self.lsWellbore3D_graphicsView.axes.plot([0, 0], [0, 0],
                                                 [VD[0], VD[-1]],
                                                 'g--',
                                                 lw=1)
        self.lsWellbore3D_graphicsView.axes.plot([0, EW[-1]], [0, NS[-1]],
                                                 [VD[-1], VD[-1]],
                                                 'g--',
                                                 lw=1)

        self.lsWellbore3D_graphicsView.axes.set_xlabel(EW.headerName)
        self.lsWellbore3D_graphicsView.axes.set_ylabel(NS.headerName)
        self.lsWellbore3D_graphicsView.axes.set_zlabel(VD.headerName)

        self.lsWellbore3D_graphicsView.axes.mouse_init()
        #zp.point3D_factory(self.s2TriDView_graphicsView.axes, dot, curve)
        zp.zoom3D_factory(self.lsWellbore3D_graphicsView.axes, curve)
        #self.lsWellbore3D_graphicsView.draw()

        #-------------------------------------------------

        self.draw_MDlocations(initial=True)
        self.parent.v3CentralizationProcessed_flag = True

        dialog.setAttribute(Qt.WA_DeleteOnClose)
        dialog.exec_()