Exemplo n.º 1
0
def test_magic_methods():
    assert not Profile()
    # __len__
    assert len(Profile().from_tuples(PROFILER)) == 83
    # __eq__
    assert Profile() == Profile()
    assert Profile(x=[], y=[]) == Profile()
    assert Profile(x=[0], y=[0]) != Profile()
    # __copy__
    original = Profile()
    same = original
    assert same == original
    # __str__
    empty_profile = Profile()
    print(empty_profile)
    profiler = Profile().from_tuples(PROFILER)
    assert profiler.__str__()
    # __add__, __radd__, __iadd__
    profiler = Profile().from_tuples(PROFILER)
    assert np.isclose(profiler.get_y(0), (profiler + 2).get_y(2))
    # __sub__, __rsub__, __isub__
    profiler = Profile().from_tuples(PROFILER)
    assert np.isclose(profiler.get_y(0), (profiler - 2).get_y(-2))
    # __mul__, __rmul__, __imul__
    profiler = Profile().from_tuples(PROFILER)
    assert np.isclose(4 * sum(profiler.y), sum((4 * profiler).y))
    assert np.isclose(4 * sum(profiler.y), sum((profiler * 4).y))
    ref = 4 * sum(profiler.y)
    profiler *= 4
    assert np.isclose(sum(profiler.y), ref)
Exemplo n.º 2
0
def test_from_snc_profiler():
    file_name = get_data_file("test_varian_open.prs")

    x_profile = Profile().from_snc_profiler(file_name, "tvs")
    y_profile = Profile().from_snc_profiler(file_name, "rad")
    assert np.isclose(x_profile.get_y(0), 45.50562901780488)
    assert np.isclose(y_profile.get_y(0), 45.50562901780488)
    assert x_profile.meta["SSD"] == y_profile.meta["SSD"]
Exemplo n.º 3
0
def test_slice_penumbra():
    profiler = Profile().from_tuples(PROFILER).resample_x(0.1)
    lt_penum, rt_penum = profiler.slice_penumbra()
    assert np.all(lt_penum.x < 0)
    assert np.all(rt_penum.x > 0)
    assert np.all(lt_penum.y < profiler.get_y(0))
    assert np.all(rt_penum.y < profiler.get_y(0))
Exemplo n.º 4
0
def test_make_flipped():
    profiler = Profile().from_tuples(PROFILER)
    assert np.isclose(profiler.get_y(3), profiler.make_flipped().get_y(-3))
Exemplo n.º 5
0
def test_get_y():
    profiler = Profile().from_tuples(PROFILER)
    assert np.isclose(profiler.get_y(0), 45.23)
Exemplo n.º 6
0
def test_from_narrow_png():
    file_name = get_data_file("FilmCalib_EBT_vert_strip.png")

    png = Profile().from_narrow_png(file_name)
    assert np.isclose(png.get_y(0), 0.609074819347117)