Runoff coefficient error ROCE

@param obs
@param sim
@param precip
@return
160040
public static double runoffCoefficientError(double[] obs, double[] sim, double[] precip) {
        sameArrayLen(sim, obs, precip);

        double mean_pred = Stats.mean(sim);
        double mean_val = Stats.mean(obs);
        double mean_ppt = Stats.mean(precip);
        double error = Math.abs((mean_pred / mean_ppt) - (mean_val / mean_ppt));
        return Math.sqrt(error);
    }
809905
def simxClearFloatSignal(clientID, signalName, operationMode):
    '''
    
    '''

    if (sys.version_info[0] == 3) and (type(signalName) is str):
        signalName=signalName.encode('utf-8')
    return c_ClearFloatSignal(clientID, signalName, operationMode)
1268201
def _F(self, X, b, c = 0.001):
        

        if b == 1:
            b = 1 + c

        prefac = (b - 1) ** -2

        if isinstance(X, np.ndarray):

            X[np.where(X == 1)] = 1 - c

            output = np.empty_like(X)

            inds1 = np.where(np.absolute(X - b)<c)
            output[inds1] = prefac*(-2 - b + (1 + b + b ** 2) * self._nfw_func(b)) * (1 + b) ** -1

            inds2 = np.where(np.absolute(X - b)>=c)

            output[inds2] = prefac * ((X[inds2] ** 2 - 1) ** -1 * (1 - b -
                                    (1 - b * X[inds2] ** 2) * self._nfw_func(X[inds2])) - \
                                        self._nfw_func(X[inds2] * b ** -1))

        else:

            if X == 1:
                X = 1-c

            if np.absolute(X - b)<c:
                output = prefac * (-2 - b + (1 + b + b ** 2) * self._nfw_func(b)) * (1 + b) ** -1

            else:
                output = prefac * ((X ** 2 - 1) ** -1 * (1 - b -
                                    (1 - b * X ** 2) * self._nfw_func(X)) - \
                                        self._nfw_func(X * b ** -1))

        return output
586217
public void requestFlushAtSource(boolean indoubtDiscard) throws SIMPRuntimeOperationFailedException, SIMPControllableNotFoundException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "requestFlushAtSource", new Boolean(indoubtDiscard));

    assertValidControllable();

    SIBUuid8 source = streamSet.getRemoteMEUuid();
    SIBUuid12 destID = streamSet.getDestUuid();
    SIBUuid8 busID = streamSet.getBusUuid();
    try
    {
      //TODO pass through the indoubtDiscard flag      
      tsm.requestFlushAtSource(source, destID, busID, streamID, indoubtDiscard);
    }
    catch (SIException e)
    {
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.runtime.TargetStreamSetControl.requestFlushAtSource",
        "1:152:1.16",
        this);
      
      SIMPRuntimeOperationFailedException finalE =
        new SIMPRuntimeOperationFailedException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0003",
            new Object[] {"TargetStreamSetControl.requestFlushAtSource",
                "1:160:1.16",
                          e,
                          streamID},
            null), e);

      SibTr.exception(tc, finalE);
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "requestFlushAtSource", finalE);
      throw finalE;             
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "requestFlushAtSource");
  }
755064
def spa_tmplt_precondition(length, delta_f, kmin=0):
    
    global _prec
    if _prec is None or _prec.delta_f != delta_f or len(_prec) < length:
        v = numpy.arange(0, (kmin+length*2), 1.0) * delta_f
        v = numpy.power(v[1:len(v)], -7.0/6.0)
        _prec = FrequencySeries(v, delta_f=delta_f, dtype=float32)
    return _prec[kmin:kmin + length]
613992
function obsFws() {
        return opts.strict ? null : wrap('obs-FWS', star(
            and(invis(opt(crlf)), wsp),
            1
        )());
    }
708570
def simxGetLastErrors(clientID, operationMode):
    '''
    
    '''
    errors =[]
    errorCnt = ct.c_int()
    errorStrings = ct.POINTER(ct.c_char)()
    ret = c_GetLastErrors(clientID, ct.byref(errorCnt), ct.byref(errorStrings), operationMode)
    if ret == 0:
        s = 0
        for i in range(errorCnt.value):
            a = bytearray()
            while errorStrings[s] != b'\0':
                if sys.version_info[0] == 3:
                    a.append(int.from_bytes(errorStrings[s],'big'))
                else:
                    a.append(errorStrings[s])
                s += 1
            s += 1 #skip null
            if sys.version_info[0] == 3:
                errors.append(str(a,'utf-8'))
            else:
                errors.append(str(a))

    return ret, errors
509896
public static int cs_fkeep(Dcs A, Dcs_ifkeep fkeep, Object other) {
        int j, p, nz = 0, n, Ap[], Ai[];
        double Ax[];
        if (!Dcs_util.CS_CSC(A))
            return (-1); /* check inputs */
        n = A.n;
        Ap = A.p;
        Ai = A.i;
        Ax = A.x;
        for (j = 0; j < n; j++) {
            p = Ap[j]; /* get current location of col j */
            Ap[j] = nz; /* record new location of col j */
            for (; p < Ap[j + 1]; p++) {
                if (fkeep.fkeep(Ai[p], j, Ax != null ? Ax[p] : 1, other)) {
                    if (Ax != null)
                        Ax[nz] = Ax[p]; /* keep A(i,j) */
                    Ai[nz++] = Ai[p];
                }
            }
        }
        Ap[n] = nz; /* finalize A */
        Dcs_util.cs_sprealloc(A, 0); /* remove extra space from A */
        return (nz);
    }
35767
static double computeDynamicTimeWarpingDistance(
    	DoubleTuple u, DoubleTuple v)
    {
        int m = u.getSize();
        int n = v.getSize();
        double matrix[][] = threadLocalMatrix.get();
        if (matrix.length < m || matrix[0].length < n)
        {
        	matrix = new double[m][n];
        	threadLocalMatrix.set(matrix);
        }
        double u0 = u.get(0);
        double v0 = v.get(0);
        matrix[0][0] = Math.abs(u0-v0);
        for (int j=1; j<n; j++)
        {
            matrix[0][j] = Math.abs(u0-v.get(j)) + matrix[0][j-1];
        }
        for (int i=1; i<m; i++)
        {
           matrix[i][0] = Math.abs(u.get(i)-v0) + matrix[i-1][0];
        }
        for (int i = 1; i < m; i++)
        {
            double ui = u.get(i);
            for (int j = 1; j < n; j++)
            {
                double vj = v.get(j);
                double min = matrix[i - 1][j - 1];
                min = min(min, matrix[i][j - 1]);
                min = min(min, matrix[i - 1][j]);
                double d = ui - vj;
                matrix[i][j] = min + (d < 0 ? -d : d);
            }
        }
        return matrix[m-1][n-1];
    }
159233
public static void go_upstream_a( int[] p, RandomIter flowRandomIter, RandomIter tcaRandomIter, RandomIter lRandomIter,
            int[] param ) {
        double area = 0, lenght = 0;
        int[] point = new int[2];
        int kk = 0, count = 0;

        point[0] = p[0];
        point[1] = p[1];
        // check how many pixels are draining in the considered pixel and select
        // the pixel with maximun tca
        for( int k = 1; k <= 8; k++ ) {
            if (flowRandomIter.getSampleDouble(p[0] + dirIn[k][1], p[1] + dirIn[k][0], 0) == dirIn[k][2]) {
                // counts how many pixels are draining in the considere
                count++;
                if (tcaRandomIter.getSampleDouble(p[0] + dirIn[k][1], p[1] + dirIn[k][0], 0) >= area) {
                    // if two pixels has the same tca select the pixel with the
                    // maximum vale of hacklength
                    if (tcaRandomIter.getSampleDouble(p[0] + dirIn[k][1], p[1] + dirIn[k][0], 0) == area) {
                        if (lRandomIter.getSampleDouble(p[0] + dirIn[k][1], p[1] + dirIn[k][0], 0) > lenght) {
                            kk = k;
                            area = tcaRandomIter.getSampleDouble(p[0] + dirIn[k][1], p[1] + dirIn[k][0], 0);
                            lenght = lRandomIter.getSampleDouble(p[0] + dirIn[k][1], p[1] + dirIn[k][0], 0);
                            point[0] = p[0] + dirIn[k][1];
                            point[1] = p[1] + dirIn[k][0];
                        }
                    } else {
                        kk = k;
                        area = tcaRandomIter.getSampleDouble(p[0] + dirIn[k][1], p[1] + dirIn[k][0], 0);
                        lenght = lRandomIter.getSampleDouble(p[0] + dirIn[k][1], p[1] + dirIn[k][0], 0);
                        point[0] = p[0] + dirIn[k][1];
                        point[1] = p[1] + dirIn[k][0];
                    }
                }
            }

        }
        p[0] = point[0];
        p[1] = point[1];
        param[0] = kk;
        param[1] = count;
    }
647205
def cal_model_performance(obsl, siml):
    """"""
    nse = MathClass.nashcoef(obsl, siml)
    r2 = MathClass.rsquare(obsl, siml)
    rmse = MathClass.rmse(obsl, siml)
    pbias = MathClass.pbias(obsl, siml)
    rsr = MathClass.rsr(obsl, siml)
    print('NSE: %.2f, R-square: %.2f, PBIAS: %.2f%%, RMSE: %.2f, RSR: %.2f' %
          (nse, r2, pbias, rmse, rsr))
124165
def score_events(self, obs, pstates):
        
        pstates_idx = np.array([self.e[p] for p in pstates])

        framelogprob = self._compute_log_likelihood(obs, pstates_idx)
        _, fwdlattice = self._do_forward_pass(framelogprob, pstates_idx)
        L = logsumexp(fwdlattice, axis=1)
        return np.concatenate([L[[0]], np.diff(L)])
1042358
private int pool( int row, int col, int prevNPool ) {
        int in;
        int jn;
        int npool = prevNPool;
        if (apool[col][row] <= 0) { /* not already part of a pool */
            if (dir[col][row] != -1) {/* check only dir since dir was initialized */
                /* not on boundary */
                apool[col][row] = pooln;/* apool assigned pool number */
                npool = npool + 1;// the number of pixel in the pool
                if (npool >= pstack) {
                    if (pstack < nCols * nRows) {
                        pstack = (int) (pstack + nCols * nRows * .1);
                        if (pstack > nCols * nRows) {
                            /* Pool stack too large */
                        }

                        ipool = realloc(ipool, pstack);
                        jpool = realloc(jpool, pstack);
                    }

                }

                ipool[npool] = row;
                jpool[npool] = col;

                for( int k = 1; k <= 8; k++ ) {
                    in = row + DIR_WITHFLOW_EXITING_INVERTED[k][1];
                    jn = col + DIR_WITHFLOW_EXITING_INVERTED[k][0];
                    /* test if neighbor drains towards cell excluding boundaries */
                    if (((dir[jn][in] > 0) && ((dir[jn][in] - k == 4) || (dir[jn][in] - k == -4))) || ((dir[jn][in] == 0)
                            && (pitIter.getSampleDouble(jn, in, 0) >= pitIter.getSampleDouble(col, row, 0)))) {
                        /* so that adjacent flats get included */
                        npool = pool(in, jn, npool);
                    }
                }

            }
        }
        return npool;
    }
1173531
def simxSetArrayParameter(clientID, paramIdentifier, paramValues, operationMode):
    '''
    
    '''

    c_paramValues = (ct.c_float*3)(*paramValues)
    return c_SetArrayParameter(clientID, paramIdentifier, c_paramValues, operationMode)
208889
def simxReadDistance(clientID, distanceObjectHandle, operationMode):
    '''
    
    '''

    minimumDistance = ct.c_float()
    return c_ReadDistance(clientID, distanceObjectHandle, ct.byref(minimumDistance), operationMode), minimumDistance.value
209523
def simxReadVisionSensor(clientID, sensorHandle, operationMode):
    '''
    
    '''

    detectionState = ct.c_ubyte()
    auxValues      = ct.POINTER(ct.c_float)()
    auxValuesCount = ct.POINTER(ct.c_int)()
    ret = c_ReadVisionSensor(clientID, sensorHandle, ct.byref(detectionState), ct.byref(auxValues), ct.byref(auxValuesCount), operationMode)
    
    auxValues2 = []
    if ret == 0:
        s = 0
        for i in range(auxValuesCount[0]):
            auxValues2.append(auxValues[s:s+auxValuesCount[i+1]])
            s += auxValuesCount[i+1]

        #free C buffers
        c_ReleaseBuffer(auxValues)
        c_ReleaseBuffer(auxValuesCount)

    return ret, bool(detectionState.value!=0), auxValues2
887777
def simxSetObjectFloatParameter(clientID, objectHandle, parameterID, parameterValue, operationMode):
    '''
    
    '''

    return c_SetObjectFloatParameter(clientID, objectHandle, parameterID, parameterValue, operationMode)