Giter Site home page Giter Site logo

Comments (5)

RubenImhoff avatar RubenImhoff commented on August 26, 2024 1

With no rain in the precip radar fields, the noise cannot be initialized. The proposed change is to initialize the noise in step 3 instead of step 2 (hence, after the cascade decompositions). This allows for a check if there is no rain in both the radar field and NWP fields. If that is the case, the resulting forecast will directly consist of only zeroes and thus the noise initialization and all subsequent steps will be bypassed. Otherwise, if the radar field is zero and the NWP field is not, the initialization of noise will take place with the NWP field at timestep zero (which is at that time step zero in 'Lagrangian coordinates').

from pysteps.

mpvginde avatar mpvginde commented on August 26, 2024

Link with issue #6

from pysteps.

RubenImhoff avatar RubenImhoff commented on August 26, 2024

Changed the auto-correlation derivation function to make sure it gives the climatological auto-correlation values when the radar rainfall fields are zero:

def _estimate_ar_parameters_radar(
    R_c, ar_order, n_cascade_levels, MASK_thr, zero_precip_radar
):
    """Estimate AR parameters for the radar rainfall field."""
    # If there are values in the radar fields, compute the autocorrelations
    GAMMA = np.empty((n_cascade_levels, ar_order))
    if not zero_precip_radar:
        # compute lag-l temporal autocorrelation coefficients for each cascade level
        for i in range(n_cascade_levels):
            GAMMA[i, :] = correlation.temporal_autocorrelation(R_c[i], mask=MASK_thr)

    # Else, use standard values for the autocorrelations
    else:
        # Get the climatological lag-1 and lag-2 autocorrelation values from Table 2
        # in `BPS2004`.
        # Hard coded, change to own (climatological) values when present.
        GAMMA = np.array(
            [
                [0.99805, 0.9925, 0.9776, 0.9297, 0.796, 0.482, 0.079, 0.0006],
                [0.9933, 0.9752, 0.923, 0.750, 0.367, 0.069, 0.0018, 0.0014],
            ]
        )

        # Check whether the number of cascade_levels is correct
        if GAMMA.shape[1] > n_cascade_levels:
            GAMMA = GAMMA[:, 0:n_cascade_levels]
        elif GAMMA.shape[1] < n_cascade_levels:
            # Get the number of cascade levels that is missing
            n_extra_lev = n_cascade_levels - GAMMA.shape[1]
            # Append the array with correlation values of 10e-4
            GAMMA = np.append(
                GAMMA,
                [np.repeat(0.0006, n_extra_lev), np.repeat(0.0014, n_extra_lev)],
                axis=1,
            )

        # Finally base GAMMA.shape[0] on the AR-level
        if ar_order == 1:
            GAMMA = GAMMA[0, :]
        if ar_order > 2:
            for repeat_index in range(ar_order - 2):
                GAMMA = np.vstack((GAMMA, GAMMA[1, :]))

        # Finally, transpose GAMMA to ensure that the shape is the same as np.empty((n_cascade_levels, ar_order))
        GAMMA = GAMMA.transpose()
        assert GAMMA.shape == (n_cascade_levels, ar_order)

    # Print the GAMMA value
    nowcast_utils.print_corrcoefs(GAMMA)

    if ar_order == 2:
        # adjust the lag-2 correlation coefficient to ensure that the AR(p)
        # process is stationary
        for i in range(n_cascade_levels):
            GAMMA[i, 1] = autoregression.adjust_lag2_corrcoef2(GAMMA[i, 0], GAMMA[i, 1])

    # estimate the parameters of the AR(p) model from the autocorrelation
    # coefficients
    PHI = np.empty((n_cascade_levels, ar_order + 1))
    for i in range(n_cascade_levels):
        PHI[i, :] = autoregression.estimate_ar_params_yw(GAMMA[i, :])

    nowcast_utils.print_ar_params(PHI)
    return PHI

from pysteps.

RubenImhoff avatar RubenImhoff commented on August 26, 2024

Fixed with commit b375e69

from pysteps.

ladc avatar ladc commented on August 26, 2024

A possible improvement here is to replace the climatological values from the paper by the ones calculated for our domain.

from pysteps.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.