Ejemplo n.º 1
0
def test_stack_code_error(monkeypatch):
    def mock_func(*args, **kwargs):
        raise urllib.error.HTTPError(
            url="http://from.mock",
            code=500,
            msg="from mock",
            hdrs=None,
            fp=None,
        )

    monkeypatch.setattr(SkyView, "get_images", mock_func)

    [ra1, dec1, ra2, dec2] = [
        229.38791793999997,
        -15.1525941155219059,
        229.38705890000003,
        -15.1513408255219060,
    ]

    with pytest.raises(urllib.error.HTTPError):
        scorpio.stack_pair(
            ra1=ra1,
            dec1=dec1,
            ra2=ra2,
            dec2=dec2,
            resolution=450,
            filters=["g"],
        )
Ejemplo n.º 2
0
def test_download_and_stack_data(mget_images, monkeypatch):

    ra1, dec1, ra2, dec2 = [
        126.39162693999999,
        47.296980665521900,
        126.38991429000001,
        47.305200665521902,
    ]

    expected_g1 = np.array([
        [-2.45361328e-02, -6.26220703e-02, -1.12152100e-02],
        [1.62239075e-02, 2.85937500e00, 1.81388855e-02],
        [-3.85131836e-02, 8.28247070e-02, 8.54492188e-04],
    ])

    expected_g2 = np.array([
        [1.13616943e-01, -1.66931152e-02, 4.88281250e-04],
        [1.61819458e-02, 2.73291016e00, 9.80529785e-02],
        [2.47344971e-02, -2.17952728e-02, 4.67758179e-02],
    ])

    monkeypatch.setattr(SkyView, "get_images", mget_images)

    data_stack = scorpio.stack_pair(ra1=ra1,
                                    dec1=dec1,
                                    ra2=ra2,
                                    dec2=dec2,
                                    resolution=3)

    stack_g1 = data_stack[0][0]
    stack_g2 = data_stack[0][1]

    np.testing.assert_allclose(stack_g1, expected_g1)
    np.testing.assert_allclose(stack_g2, expected_g2)
Ejemplo n.º 3
0
def test_download_invalid_survey():
    [ra1, dec1, ra2, dec2] = [
        126.39162693999999,
        47.296980665521900,
        126.38991429000001,
        47.305200665521902,
    ]

    with pytest.raises(ValueError):
        scorpio.stack_pair(
            ra1=ra1,
            dec1=dec1,
            ra2=ra2,
            dec2=dec2,
            resolution=200,
            survey="JABB",
        )