code: def select_to_constraint(cls, dataset, selection):
          
          import iris
  
          def get_slicer(start, end):
              def slicer(cell):
                  return start <= cell.point < end
              return slicer
          constraint_kwargs = {}
          for dim, constraint in selection.items():
              if isinstance(constraint, slice):
                  constraint = (constraint.start, constraint.stop)
              if isinstance(constraint, tuple):
                  if constraint == (None, None):
                      continue
                  constraint = get_slicer(*constraint)
              dim = dataset.get_dimension(dim, strict=True)
              constraint_kwargs[dim.name] = constraint
          return iris.Constraint(**constraint_kwargs)
docs: Transform a selection dictionary to an iris Constraint.