dtrange = iris.Constraint(time = lambda t: t.bound is not None and tu.date2num(dtmin) <= t.bound <= tu.date2num(dtmax))
Notes on cell comparison:
Cells are compared in two ways, depending on whether they are compared to another Cell, or to a number/string.
Cell-Cell comparison is defined to produce a strict ordering. If two cells are not exactly equal (i.e. including whether they both define bounds or not) then they will have a consistent relative order.
Cell-number and Cell-string comparison is defined to support Constraint matching. The number/string will equal the Cell if, and only if, it is within the Cell (including on the boundary). The relative comparisons (lt, le, ..) are defined to be consistent with this interpretation. So for a given value n and Cell cell, only one of the following can be true:
n < celln == celln > cellSimilarly, n <= cell implies either n < cell or n == cell. And n >= cell implies either n > cell or n == cell.
time_constraint = iris.Constraint(time=iris.time.PartialDateTime(month=6))