def test_obslist_s2n_zeroweight(): rng = np.random.RandomState(seed=11) obslist = ObsList() for _ in range(3): obs = Observation( image=rng.normal(size=(13, 15)), weight=np.zeros((13, 15)), store_pixels=False, ) obslist.append(obs) assert np.allclose(obslist.get_s2n(), -9999)
def test_obslist_s2n(): rng = np.random.RandomState(seed=11) obslist = ObsList() numer = 0 denom = 0 for _ in range(3): obs = Observation(image=rng.normal(size=(13, 15))) numer += np.sum(obs.image) denom += np.sum(1.0 / obs.weight) obslist.append(obs) s2n = obslist.get_s2n() assert s2n == numer / np.sqrt(denom)