Beispiel #1
0
def test_solar_day():
    _s = SimpleNamespace
    ds = _s(center_time=parse_time('1987-05-22 23:07:44.2270250Z'),
            metadata=_s(lon=Range(begin=150.415,
                                  end=152.975)))

    assert solar_day(ds) == np.datetime64('1987-05-23', 'D')
    assert solar_day(ds, longitude=0) == np.datetime64('1987-05-22', 'D')

    ds.metadata = _s()

    with pytest.raises(ValueError) as e:
        solar_day(ds)

    assert 'Cannot compute solar_day: dataset is missing spatial info' in str(e.value)
def flat_map_ds(proc, obs):
    from datacube_stats.utils import tile_flatten_sources
    from datacube.api.query import solar_day

    for cell_idx, tile in obs.items():
        for ds in tile_flatten_sources(tile):
            yield proc(ds, cell_idx=cell_idx, solar_day=solar_day(ds))