Beispiel #1
0
def test_observation_pixels_update_image(image_data):
    rng = np.random.RandomState(seed=11)
    obs = Observation(image=image_data['image'],
                      weight=image_data['weight'],
                      jacobian=image_data['jacobian'])

    new_arr = rng.normal(size=obs.image.shape)
    my_pixels = make_pixels(new_arr, image_data['weight'],
                            image_data['jacobian'])

    assert np.all(obs.pixels != my_pixels)
    obs.image = new_arr
    assert np.all(obs.pixels == my_pixels)
Beispiel #2
0
def test_observation_set(image_data):
    obs = Observation(image=image_data['image'],
                      weight=image_data['weight'],
                      bmask=image_data['bmask'],
                      ormask=image_data['ormask'],
                      noise=image_data['noise'],
                      jacobian=image_data['jacobian'],
                      gmix=image_data['gmix'],
                      psf=image_data['psf'],
                      meta=image_data['meta'])

    rng = np.random.RandomState(seed=11)

    new_arr = rng.normal(size=image_data['image'].shape)
    assert np.all(obs.image != new_arr)
    obs.image = new_arr
    assert np.all(obs.image == new_arr)

    new_arr = np.exp(rng.normal(size=image_data['image'].shape))
    assert np.all(obs.weight != new_arr)
    obs.weight = new_arr
    assert np.all(obs.weight == new_arr)

    new_arr = (np.exp(rng.normal(size=image_data['image'].shape)) *
               100).astype(np.int32)
    assert np.all(obs.bmask != new_arr)
    obs.bmask = new_arr
    assert np.all(obs.bmask == new_arr)

    new_arr = (np.exp(rng.normal(size=image_data['image'].shape)) *
               100).astype(np.int32)
    assert np.all(obs.ormask != new_arr)
    obs.ormask = new_arr
    assert np.all(obs.ormask == new_arr)

    new_arr = rng.normal(size=image_data['image'].shape)
    assert np.all(obs.noise != new_arr)
    obs.noise = new_arr
    assert np.all(obs.noise == new_arr)

    new_jac = DiagonalJacobian(x=8, y=13, scale=1.2)
    assert new_jac.get_galsim_wcs() != obs.jacobian.get_galsim_wcs()
    obs.jacobian = new_jac
    assert new_jac.get_galsim_wcs() == obs.jacobian.get_galsim_wcs()

    new_meta = {'new': 5}
    assert obs.meta != new_meta
    obs.meta = new_meta
    assert obs.meta == new_meta

    new_meta = {'blue': 10}
    new_meta.update(obs.meta)
    assert obs.meta != new_meta
    obs.update_meta_data({'blue': 10})
    assert obs.meta == new_meta

    new_gmix = GMix(pars=rng.uniform(size=6))
    assert np.all(obs.gmix.get_full_pars() != new_gmix.get_full_pars())
    obs.gmix = new_gmix
    assert np.all(obs.gmix.get_full_pars() == new_gmix.get_full_pars())

    new_psf = Observation(image=rng.normal(size=obs.psf.image.shape),
                          meta={'ispsf': True})
    assert np.all(obs.psf.image != new_psf.image)
    obs.psf = new_psf
    assert np.all(obs.psf.image == new_psf.image)