Exemplo n.º 1
0
    def fit_unloading(self):
        well_names = []
        for idx in range(self.well_listWidget.count()):
            item = self.well_listWidget.item(idx)
            if item.checkState() == Qt.Checked:
                well_names.append(str(item.text()))

        vel_name = str(self.velocity_comboBox.currentText())
        obp_name = str(self.obp_comboBox.currentText())

        vel = list()
        obp = list()
        pres = list()
        for well_name in well_names:
            well = ppp.Well(str(CONF.well_dir / ".{}".format(well_name)))
            obp_log = well.get_log(obp_name)
            vel_log = well.get_log(vel_name)
            # get data
            for pres_name in ["unloading"]:
                if pres_name not in well.params.keys():
                    continue
                if pres_name == "MP":
                    pres_log = well.get_pressure_normal()
                else:
                    pres_log = well._get_pressure(pres_name)
                depth = np.array(vel_log.depth)
                for dp, val in zip(pres_log.depth, pres_log.data):
                    idx = np.searchsorted(depth, dp)
                    vel.append(vel_log.data[idx])
                    obp.append(obp_log.data[idx])
                    pres.append(val)
        vel, obp, pres = \
            np.array(vel), np.array(obp), np.array(pres)
        es = obp - pres
        # fit
        v_max = float(self.vmax_lineEdit.text())
        A = float(self.a_lineEdit.text())
        B = float(self.b_lineEdit.text())

        sigma_max = ((v_max - 1524)/A)**(1/B)
        temp_dict = {"A": A, "B": B, "sigma_max": sigma_max}
        def unloading_curve(sigma, u):
            independent = temp_dict["sigma_max"]*(sigma/temp_dict["sigma_max"])**(1/u)
            return 1524 + temp_dict['A'] * independent**temp_dict['B']

        popt, pcov = curve_fit(unloading_curve, es, vel)
        U, = popt
        self.u_lineEdit.setText("{}".format(U))

        RRMSE = ppp.rmse(vel, ppp.unloading_curve(es, A, B, U, v_max))
        R_squared = r2_score(vel, ppp.unloading_curve(es, A, B, U, v_max))
        string_output = 'RRMSE={}\n'.format(RRMSE) + \
            "R-squared={}".format(R_squared)
        self.unloading_textEdit.setText(string_output)

        self.draw_unloading_line()
Exemplo n.º 2
0
    def draw_unloading_line(self):
        A = float(self.a_lineEdit.text())
        B = float(self.b_lineEdit.text())
        v_max = float(self.vmax_lineEdit.text())
        U = float(self.u_lineEdit.text())

        new_es = np.arange(0, 70, 0.001)
        new_vel = ppp.unloading_curve(new_es, A, B, U, v_max)
        # --------------------------------------------
        self.clear_unloading_line()
        line = self.ax.plot(new_es, new_vel, color='gray', zorder=0)[0]

        self.line_unloading.append(line)
        self.matplotlib_widget.fig.canvas.draw()
def test__unloading_curve():
    assert ppp.unloading_curve(36, 98, 0.5, 1, 4000) == 2112
    assert ppp.invert_unloading(2112, 98, 0.5, 1, 4000) == 36
def test__unloading_curve():
    assert ppp.unloading_curve(36, 98, 0.5, 1, 4000) == 2112
    assert ppp.invert_unloading(2112, 98, 0.5, 1, 4000) == 36