How to use the wradlib.util._idvalid function in wradlib

To help you get started, we’ve selected a few wradlib 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 wradlib / wradlib / wradlib / adjust.py View on Github external
def _get_valid_pairs(self, obs, raw):
        """INTERNAL: Helper method to identify valid obs-raw pairs
        """
        # checking input shape consistency
        self._check_shape(obs, raw)
        # radar values at gage locations
        rawatobs = self.get_raw_at_obs(raw, obs)
        # check where both gage and radar observations are valid
        ix = np.intersect1d(util._idvalid(obs, minval=self.minval),
                            util._idvalid(rawatobs, minval=self.minval))
        return rawatobs, ix
github wradlib / wradlib / wradlib / adjust.py View on Github external
def _get_valid_pairs(self, obs, raw):
        """INTERNAL: Helper method to identify valid obs-raw pairs
        """
        # checking input shape consistency
        self._check_shape(obs, raw)
        # radar values at gage locations
        rawatobs = self.get_raw_at_obs(raw, obs)
        # check where both gage and radar observations are valid
        ix = np.intersect1d(util._idvalid(obs, minval=self.minval),
                            util._idvalid(rawatobs, minval=self.minval))
        return rawatobs, ix
github wradlib / wradlib / wradlib / verify.py View on Github external
def __init__(self, obs, est, minval=None):
        # Check input
        if len(obs) != len(est):
            raise ValueError("WRADLIB: obs and est need to have the "
                             "same length. len(obs)={}, "
                             "len(est)={}".format(len(obs), len(est)))
        self.est = est
        self.obs = obs
        # remember those pairs which both have valid obs and est
        self.ix = np.intersect1d(util._idvalid(obs, minval=minval),
                                 util._idvalid(est, minval=minval))
        self.n = len(self.ix)
        if self.n == 0:
            warnings.warn("WRADLIB: No valid pairs of observed and "
                          "estimated available for ErrorMetrics!")
        self.resids = self.est[self.ix] - self.obs[self.ix]
github wradlib / wradlib / wradlib / verify.py View on Github external
def __init__(self, obs, est, minval=None):
        # Check input
        if len(obs) != len(est):
            raise ValueError("WRADLIB: obs and est need to have the "
                             "same length. len(obs)={}, "
                             "len(est)={}".format(len(obs), len(est)))
        self.est = est
        self.obs = obs
        # remember those pairs which both have valid obs and est
        self.ix = np.intersect1d(util._idvalid(obs, minval=minval),
                                 util._idvalid(est, minval=minval))
        self.n = len(self.ix)
        if self.n == 0:
            warnings.warn("WRADLIB: No valid pairs of observed and "
                          "estimated available for ErrorMetrics!")
        self.resids = self.est[self.ix] - self.obs[self.ix]
github wradlib / wradlib / wradlib / adjust.py View on Github external
raw : array of floats

        Returns
        -------
        obs : array of floats
            valid observations at those locations which have a valid radar
            observation
        estatobs : array of floats
            estimated values at the valid observation locations

        """
        rawatobs, ix = self._get_valid_pairs(obs, raw)
        self.get_raws_directly_at_obs = RawAtObs(self.obs_coords,
                                                 self.raw_coords, nnear=1)
        raws_directly_at_obs = self.get_raws_directly_at_obs(raw)
        ix = np.intersect1d(ix, util._idvalid(raws_directly_at_obs,
                                              minval=self.minval))
        # Container for estimation results at the observation location
        estatobs = np.zeros(obs.shape) * np.nan
        # check whether enough gages remain for adjustment
        if len(ix) <= (self.mingages - 1):
            # not enough gages for cross validation: return empty arrays
            return obs, estatobs
        # Now iterate over valid pairs
        for i in ix:
            # Pass all valid pairs except ONE which you pass as target
            ix_adjust = np.setdiff1d(ix, [i])
            estatobs[i] = self.__call__(obs, raws_directly_at_obs[i],
                                        self.obs_coords[i].reshape((1, -1)),
                                        rawatobs, ix_adjust)
        return obs, estatobs