Closed bnlawrence closed 2 weeks ago
Hi Bryan,
...
Bounds range [[1950-01-01 06:00:00, 1950-02-01 00:00:00]] 360_day [[2014-12-01 06:00:00, 2015-01-01 00:00:00]] 360_day
Subspacing using cellwi to 1950-01-01 06:00:00 360_day 1970-12-10 00:00:00 360_day
Bounds range [[1950-01-01 06:00:00, 1950-02-01 00:00:00]] 360_day [[1970-11-01 06:00:00, 1970-12-01 00:00:00]] 360_day
...
But this looks right to me ... You asked for cells that lie completely inside 1950-01-01 06:00
to 1970-12-10 00:00
, and that's what you got I realize, however, that the "completely" part of this was not made wholly clear :)
If you inspect the query you see that it's just a convenience function for creating a mode complicated Query
object:
>>> print(cf.cellwi(start_date, end_date))
<CF Query: [lower_bounds(ge 1950-01-01 06:00:00) & upper_bounds(le 1970-12-10 00:00:00)]>
We can create a new "cell overlaps" query as follows, that should do what you want (edited):
>>> q1 = cf.ge(start_date, attr='upper_bounds')
>>> q2 = cf.le(end_date, attr='lower_bounds')
>>> cell_overlaps = q1 & q2
>>> cell_overlaps
<CF Query: [upper_bounds(ge 1950-01-01 06:00:00) & lower_bounds(le 1970-12-10 00:00:00)]>
and then
quark = fld.subspace(time=cell_overlaps(start_date, end_date))
I shall create this as a new cf.cell_overlaps
function.
cf.cell_overlaps
will be in the next version of cf-python: https://github.com/NCAS-CMS/cf-python/issues/824
Great. For the moment I have stuffed an explicit version into my code, and will replace it when the new CF comes out. The explicit version passes my tests!
I am trying to subset a manifest file using the bounds that are stored in the database.
The particular test that is manifesting the issue will fail with the
pytest -s -x tests/realistic
in the within branch.The code which is causing the error can be found in
cfs/db/cfa_tools.py
This code, when run in the test yields this output (before failing the assertion in the error below):
We are expected it to grab the next cell.
The relevant test failure is this one:
which occurs because it's not getting to the next cell where that fragment file should have been present.