示例#1
0
def test_time_axis(time_intervals):
    axis = TimeMapAxis(time_intervals["t_min"], time_intervals["t_max"],
                       time_intervals["t_ref"])

    axis_copy = axis.copy()

    assert axis.nbin == 20
    assert axis.name == "time"
    assert axis.node_type == "intervals"

    assert_allclose(axis.time_delta.to_value("min"), 60)
    assert_allclose(axis.time_mid[0].mjd, 58927.020833333336)

    assert "time" in axis.__str__()
    assert "20" in axis.__str__()

    with pytest.raises(ValueError):
        axis.assert_name("bad")

    assert axis_copy == axis

    assert not axis.is_contiguous

    ax_cont = axis.to_contiguous()
    assert_allclose(ax_cont.nbin, 39)
示例#2
0
def test_time_axis_plot_helpers():
    time_ref = Time('1999-01-01T00:00:00.123456789')

    time_axis = TimeMapAxis(edges_min=[0, 1, 3] * u.d,
                            edges_max=[0.8, 1.9, 5.4] * u.d,
                            reference_time=time_ref)

    labels = time_axis.as_plot_labels
    assert labels[0] == "1999-01-01 00:00:00.123 - 1999-01-01 19:12:00.123"

    center = time_axis.as_plot_center
    assert center[0].year == 1999

    edges = time_axis.to_contiguous().as_plot_edges
    assert edges[0].year == 1999