How to use the ert.util.Matrix function in ert

To help you get started, we’ve selected a few ert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Ensembles / ert / devel / python / python / ert / util / stat.py View on Github external
def polyfit(n, x, y, s=None):
    """
    @type n: int
    @type x: Matrix or Sequence
    @type y: Matrix or Sequence
    @type s: Matrix or Sequence or None
    @return: tuple
    """
    if _polyfit is None:
        raise NotImplementedError("Sorry - your ert distribution has been built without lapack support")

    if isinstance(x, Matrix):
        xm = x
    else:
        xm = Matrix(len(x), 1)
        for i in range(len(x)):
            xm[i, 0] = x[i]

    if isinstance(y, Matrix):
        ym = y
    else:
        ym = Matrix(len(y), 1)
        for i in range(len(y)):
            ym[i, 0] = y[i]

    if s:
        if isinstance(s, Matrix):
            sm = s
github Ensembles / ert / devel / python / python / ert / util / stat.py View on Github external
def polyfit(n, x, y, s=None):
    """
    @type n: int
    @type x: Matrix or Sequence
    @type y: Matrix or Sequence
    @type s: Matrix or Sequence or None
    @return: tuple
    """
    if _polyfit is None:
        raise NotImplementedError("Sorry - your ert distribution has been built without lapack support")

    if isinstance(x, Matrix):
        xm = x
    else:
        xm = Matrix(len(x), 1)
        for i in range(len(x)):
            xm[i, 0] = x[i]

    if isinstance(y, Matrix):
        ym = y
    else:
        ym = Matrix(len(y), 1)
        for i in range(len(y)):
            ym[i, 0] = y[i]

    if s:
        if isinstance(s, Matrix):
            sm = s
        else:
            sm = Matrix(len(s), 1)
            for i in range(len(s)):
github OPM / ResInsight / ThirdParty / Ert / devel / python / python / ert / ecl / faults / fault.py View on Github external
def __sortFaultLines(self):
        N = len(self.__fault_lines)
        x = Matrix(N , 1)
        y = Matrix(N , 1)

        for index,line in enumerate(self.__fault_lines):
            xc,yc = line.center()
            
            x[index,0] = xc
            y[index,0] = yc

        # y = beta[0] + beta[1] * x
        #   = a       + b * x
        beta = stat.polyfit(2 , x , y)
        a = beta[0]
        b = beta[1]

        perm_list = []
        for index,line in enumerate(self.__fault_lines):
github Ensembles / ert / devel / python / python / ert / util / stat.py View on Github external
xm = Matrix(len(x), 1)
        for i in range(len(x)):
            xm[i, 0] = x[i]

    if isinstance(y, Matrix):
        ym = y
    else:
        ym = Matrix(len(y), 1)
        for i in range(len(y)):
            ym[i, 0] = y[i]

    if s:
        if isinstance(s, Matrix):
            sm = s
        else:
            sm = Matrix(len(s), 1)
            for i in range(len(s)):
                sm[i, 0] = s[i]
    else:
        sm = s

    beta = Matrix(n, 1)
    res = _polyfit(beta, xm, ym, sm)

    if not res == LLSQResultEnum.LLSQ_SUCCESS:
        raise Exception("Linear Least Squares Estimator failed?")

    l = []
    for i in range(n):
        l.append(beta[i, 0])

    return tuple(l)
github Ensembles / ert / python / python / ert / enkf / obs_data.py View on Github external
def scale(self, S, E=None, D=None, R=None, D_obs=None):
        assert isinstance(S, Matrix)
        for X in (E,D,R,D_obs):
            if X is not None:
                assert isinstance(X, Matrix)
        self._scale(S, E, D, R, D_obs)
github Ensembles / ert / python / python / ert / enkf / enkf_linalg.py View on Github external
def calculatePrincipalComponents(cls, S0, D_obs, truncation, ncomp, PC, PC_obs, singular_values):
        assert isinstance(S0, Matrix)
        assert isinstance(D_obs, Matrix)
        assert isinstance(truncation, (float, int))
        assert isinstance(ncomp, int)
        assert isinstance(PC, Matrix)
        assert isinstance(PC_obs, Matrix)
        assert isinstance(singular_values , DoubleVector)

        cls._get_PC(S0, D_obs, truncation, ncomp, PC, PC_obs , singular_values)
github Ensembles / ert / python / python / ert / enkf / plot_data / pca_plot_data.py View on Github external
def __init__(self, name, principal_component_matrix, observation_principal_component_matrix, singular_values):
        assert isinstance(name, str)
        assert isinstance(principal_component_matrix, Matrix)
        assert isinstance(observation_principal_component_matrix, Matrix)

        c_pointer = self._alloc(name, principal_component_matrix, observation_principal_component_matrix , singular_values)
        super(PcaPlotData, self).__init__(c_pointer)
github Ensembles / ert / devel / python / python / ert / enkf / plot_data / pca_plot_data.py View on Github external
def __init__(self, name, principal_component_matrix, observation_principal_component_matrix):
        assert isinstance(name, str)
        assert isinstance(principal_component_matrix, Matrix)
        assert isinstance(observation_principal_component_matrix, Matrix)

        c_pointer = PcaPlotData.cNamespace().alloc(name, principal_component_matrix, observation_principal_component_matrix)
        super(PcaPlotData, self).__init__(c_pointer)
github Ensembles / ert / devel / python / python / ert / enkf / plot_data / pca_plot_vector.py View on Github external
def __init__(self, component, principal_component_matrix, observation_principal_component_matrix):
        assert isinstance(component, int)
        assert isinstance(principal_component_matrix, Matrix)
        assert isinstance(observation_principal_component_matrix, Matrix)

        c_pointer = PcaPlotVector.cNamespace().alloc(component, principal_component_matrix, observation_principal_component_matrix)
        super(PcaPlotVector, self).__init__(c_pointer)
github Ensembles / ert / python / python / ert / enkf / obs_data.py View on Github external
def scale(self, S, E=None, D=None, R=None, D_obs=None):
        assert isinstance(S, Matrix)
        for X in (E,D,R,D_obs):
            if X is not None:
                assert isinstance(X, Matrix)
        self._scale(S, E, D, R, D_obs)