예제 #1
0
def test_prepare_data_to_post_no_var():
    start = pd.Timestamp('2109-10-04T1200Z')
    end = pd.Timestamp('2109-10-04T1300Z')
    data = pd.DataFrame({'notavar': [0, 1]})
    with pytest.raises(KeyError):
        common._prepare_data_to_post(data, 'GHI 7', test_kwarg_observation,
                                     start, end)
예제 #2
0
def test_prepare_data_to_post_empty():
    inp = pd.DataFrame({'ghi': [0.0]},
                       index=pd.DatetimeIndex(['2019-01-01 00:00Z']))
    start = pd.Timestamp('2019-10-04T1200Z')
    end = pd.Timestamp('2019-10-04T1205Z')
    variable = 'ghi'
    out = common._prepare_data_to_post(inp, variable, test_kwarg_observation,
                                       start, end)
    assert out.empty
예제 #3
0
def test_prepare_data_to_post_first(inp, expected):
    start = pd.Timestamp('2019-10-04T1200Z')
    end = pd.Timestamp('2019-10-04T1205Z')
    variable = 'ghi'
    out = common._prepare_data_to_post(inp,
                                       variable,
                                       test_observation_first,
                                       start,
                                       end,
                                       resample_how='first')
    pd.testing.assert_frame_equal(out, expected)
예제 #4
0
def test_prepare_data_to_post_offset():
    # offset data is kept as is. If this is a problem we'll need to
    # probably resample the reference data to the appropriate index
    start = pd.Timestamp('2019-10-04T1200Z')
    end = pd.Timestamp('2019-10-04T1215Z')
    variable = 'ghi'
    inp = pd.DataFrame({'ghi': [0, 1, 4.0]},
                       index=pd.date_range('2019-10-04T1201Z',
                                           freq='5min',
                                           periods=3))
    expected = pd.DataFrame({
        'value': [0, 1, 4.0],
        'quality_flag': [0, 0, 0]
    },
                            index=pd.date_range('2019-10-04T1201Z',
                                                freq='5min',
                                                periods=3))
    out = common._prepare_data_to_post(inp, variable,
                                       observation_with_extra_params, start,
                                       end)
    pd.testing.assert_frame_equal(out, expected)