Skip to content

Commit

Permalink
Fixes within issues from #30
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Lawrence committed Oct 31, 2024
1 parent 0a196d6 commit e7721cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include my_package/tests/realistic/data/*
10 changes: 9 additions & 1 deletion cfs/db/cfa_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ def consistent_hash(mylist):
data = str(tuple_list).encode('utf-8')
return hashlib.md5(data).hexdigest()

def cf_cells_overlap(value0, value1, units=None):
""" Will be in next CF release"""
#FIXME: When in general release, remove
return cf.Query("ge", value0, units=units, attr="upper_bounds") & cf.Query(
"le", value1, units=units, attr="lower_bounds"
)

def get_quark_field(instance, start_date, end_date):
""" Given a CFS manifest field (i.e. an instance of the Manifest class
found in the django models.py) and a pair of bounding dates, return
Expand Down Expand Up @@ -64,7 +71,8 @@ def get_quark_field(instance, start_date, end_date):
raise RuntimeError(
'Number of of manifest fragments ({nf}) not equal to time data length ({nt}).')
print('Subspacing using cellwi to ',start_date, end_date)
quark = fld.subspace(time=cf.cellwi(start_date, end_date))

quark = fld.subspace(time=cf_cells_overlap(start_date, end_date))
dimT = quark.dimension_coordinate('T')
bounds_range(dimT.bounds)
return quark
Expand Down
4 changes: 2 additions & 2 deletions tests/realistic/test_01_canari.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def test_quarks(django_dependencies):
assert quark.id != manifest.id
assert quark.is_quark is True
print(quark)
expected = 'cn134a_999_6hr_u_pt_cordex__197012-197012.nc(unavailable)'
expected = 'cn134a_999_6hr_u_pt_cordex__197012-197012.nc'
fragments = list(quark.fragments.files.all())
assert expected == fragments[-1]
assert expected == fragments[-1].name



Expand Down

0 comments on commit e7721cc

Please sign in to comment.