Skip to content

Commit

Permalink
add new point examples of date ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
mathleur committed Dec 5, 2023
1 parent 0086059 commit cd47066
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/test_slice_date_range_fdb_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import pandas as pd
import pytest

from polytope.datacube.backends.fdb import FDBDatacube
from polytope.engine.hullslicer import HullSlicer
from polytope.polytope import Polytope, Request
from polytope.shapes import Select, Span


class TestSlicingFDBDatacube:
def setup_method(self, method):
# Create a dataarray with 3 labelled axes using different index types
self.options = {
"values": {
"transformation": {"mapper": {"type": "regular", "resolution": 30, "axes": ["latitude", "longitude"]}}
},
"date": {"transformation": {"merge": {"with": "time", "linkers": ["T", "00"]}}},
"step": {"transformation": {"type_change": "int"}},
}
self.config = {"class": "ea", "expver": "0001", "levtype": "pl", "step": 0}
self.fdbdatacube = FDBDatacube(self.config, axis_options=self.options)
self.slicer = HullSlicer()
self.API = Polytope(datacube=self.fdbdatacube, engine=self.slicer, axis_options=self.options)

# Testing different shapes
@pytest.mark.skip(reason="can't install fdb branch on CI")
def test_fdb_datacube(self):
request = Request(
Select("step", [0]),
Select("levtype", ["pl"]),
Span("date", pd.Timestamp("20170101T120000"), pd.Timestamp("20170102T120000")),
Select("domain", ["g"]),
Select("expver", ["0001"]),
Select("param", ["129"]),
Select("class", ["ea"]),
Select("stream", ["enda"]),
Select("type", ["an"]),
Select("latitude", [0]),
Select("longitude", [0]),
Select("levelist", ["500", "850"]),
Select("number", ["0"]),
)
result = self.API.retrieve(request)
result.pprint()
assert len(result.leaves) == 6

0 comments on commit cd47066

Please sign in to comment.