def test_reglmr(self): nsite = 10 L1 = dist.gamma.rvs(4, size=nsite) L2 = dist.gamma.rvs(2., size=nsite) R3 = dist.beta.rvs(3., 5., size=nsite) R4 = dist.beta.rvs(4., 5., size=nsite) W = dist.poisson.rvs(4, loc=10, size=nsite) xmom = np.vstack([L1, L2, R3, R4]) rmom = reglmr(xmom, W) assert_equal(len(xmom), 4) assert_equal(rmom[2], np.average(R3, weights=W))
def test_reglmr_maxwind(self): """Compare results with those in MAXWIND.OUT obtained by processing the MAXWIND.DAT input file.""" import maxwind lmom = {} L = {} # Compute sample L-moments for name, d in maxwind.data.items(): lmom[name] = lmoments(d, nmom=5, a=-0.35, b=0, mode='stats') L[name] = len(d) assert_almost_equal(lmom[name], maxwind.lmr[name],2) # Compute regionalized value. xmom = np.array(lmom.values()).T w = np.array(L.values()) assert_almost_equal(np.around(reglmr(xmom, w, 5), 4), maxwind.reglmr,6)
def test_reglmr_simple(self): rmom = reglmr(np.array([[2., 1., .5]]).T, weight=[1], nmom=3) assert_equal(rmom, [1., .5, .5])