vcor_dual_prf/vcor_dual_prf.py
def _dualprf_error_unwrap(data_ma, ref_ma, err_mask, pvel_arr, prf_arr):
    """
    Finds the correction factor that minimises the difference between
    the gate velocity and the reference velocity

    Parameters
    ----------
    data_ma : masked array
        Data
    ref_ma : masked array
        Reference data
    err_mask : bool array
        Mask for the identified outliers
    pvel_arr : array
        Primary (high/low PRF) velocity for each gate
    prf_arr : array
        PRF (high/low) of each gate

     Returns
     -------
     nuw : int array
         Unwrap number (correction factor) for each gate
     """

    # Convert non-outliers to zero
    ma_out = data_ma * err_mask.astype(int)
    th_arr_out = pvel_arr * err_mask.astype(int)
    ref_out = ref_ma * err_mask.astype(int)

    # Primary velocity and prf factor of low PRF gates
    prf_factor = np.unique(np.min(prf_arr))[0]
    th_l = th_arr_out.copy()
    th_l[prf_arr == prf_factor] = 0

    dev = np.ma.abs(ma_out - ref_out)
    nuw = np.zeros(ma_out.shape)

    # Loop for possible correction factors
    for ni in range(-prf_factor, (prf_factor + 1)):

        # New velocity values for identified outliers
        if abs(ni) == prf_factor:
            v_corr_tmp = ma_out + 2 * ni * th_l
        else:
            v_corr_tmp = ma_out + 2 * ni * th_arr_out

        # New deviation for new velocity values
        dev_tmp = np.ma.abs(v_corr_tmp - ref_out)
        # Compare with previous deviation
        delta = dev - dev_tmp

        # Update unwrap number when deviation has decreased
        nuw[delta > 0] = ni
        # Update corrected velocity and deviation
        v_corr = ma_out + 2 * nuw * th_arr_out
        dev = np.ma.abs(v_corr - ref_out)

    return nuw.astype(int)

    Finds the correction factor that minimises the difference between
    the gate velocity and the reference velocity

    Parameters
    ----------
    data_ma : masked array
        Data
    ref_ma : masked array
        Reference data
    err_mask : bool array
        Mask for the identified outliers
    pvel_arr : array
        Primary (high/low PRF) velocity for each gate
    prf_arr : array
        PRF (high/low) of each gate

     Returns
     -------
     nuw : int array
         Unwrap number (correction factor) for each gate
     
Finds the correction factor that minimises the difference between
the gate velocity and the reference velocity

Parameters



Returns

nuw : int array
Unwrap number (correction factor) for each gate
Finds the correction factor that minimises the difference between the gate velocity and the reference velocity Parameters Returns nuw : int array Unwrap number ( correction factor ) for each gate
def _dualprf_error_unwrap(data_ma, ref_ma, err_mask, pvel_arr, prf_arr):
    ma_out = data_ma * err_mask.astype(int)
    th_arr_out = pvel_arr * err_mask.astype(int)
    ref_out = ref_ma * err_mask.astype(int)
    prf_factor = np.unique(np.min(prf_arr))[0]
    th_l = th_arr_out.copy()
    th_l[prf_arr == prf_factor] = 0
    dev = np.ma.abs(ma_out - ref_out)
    nuw = np.zeros(ma_out.shape)
    for ni in range(-prf_factor, (prf_factor + 1)):
        if abs(ni) == prf_factor:
            v_corr_tmp = ma_out + 2 * ni * th_l
        else:
            v_corr_tmp = ma_out + 2 * ni * th_arr_out
        dev_tmp = np.ma.abs(v_corr_tmp - ref_out)
        delta = dev - dev_tmp
        nuw[delta > 0] = ni
        v_corr = ma_out + 2 * nuw * th_arr_out
        dev = np.ma.abs(v_corr - ref_out)
    return nuw.astype(int)
def _dualprf_error_unwrap ( data_ma , ref_ma , err_mask , pvel_arr , prf_arr ) : ma_out = data_ma * err_mask . astype ( int ) th_arr_out = pvel_arr * err_mask . astype ( int ) ref_out = ref_ma * err_mask . astype ( int ) prf_factor = np . unique ( np . min ( prf_arr ) ) [ 0 ] th_l = th_arr_out . copy ( ) th_l [ prf_arr == prf_factor ] = 0 dev = np . ma . abs ( ma_out - ref_out ) nuw = np . zeros ( ma_out . shape ) for ni in range ( - prf_factor , ( prf_factor + 1 ) ) : if abs ( ni ) == prf_factor : v_corr_tmp = ma_out + 2 * ni * th_l else : v_corr_tmp = ma_out + 2 * ni * th_arr_out dev_tmp = np . ma . abs ( v_corr_tmp - ref_out ) delta = dev - dev_tmp nuw [ delta > 0 ] = ni v_corr = ma_out + 2 * nuw * th_arr_out dev = np . ma . abs ( v_corr - ref_out ) return nuw . astype ( int )
Finds the correction factor that minimises the difference between
the gate velocity and the reference velocity
Finds the correction factor that minimises the difference between the gate velocity and the reference velocity
"""
    Finds the correction factor that minimises the difference between
    the gate velocity and the reference velocity

    Parameters
    ----------
    data_ma : masked array
        Data
    ref_ma : masked array
        Reference data
    err_mask : bool array
        Mask for the identified outliers
    pvel_arr : array
        Primary (high/low PRF) velocity for each gate
    prf_arr : array
        PRF (high/low) of each gate

     Returns
     -------
     nuw : int array
         Unwrap number (correction factor) for each gate
     """ # Convert non-outliers to zero # Primary velocity and prf factor of low PRF gates # Loop for possible correction factors # New velocity values for identified outliers # New deviation for new velocity values # Compare with previous deviation # Update unwrap number when deviation has decreased # Update corrected velocity and deviation
data_ma
ref_ma
err_mask
pvel_arr
prf_arr