def _read_fluid_selection(self, chunks, selector, fields, size):
    from sys import version
    rv = {}
    chunks = list(chunks)
    if isinstance(selector, GridSelector):
        if (not (len(chunks) == len(chunks[0].objs) == 1)):
            raise RuntimeError
        grid = chunks[0].objs[0]
        h5f = h5py.File(grid.filename, mode='r')
        gds = h5f.get(_grid_dname(grid.id))
        for (ftype, fname) in fields:
            if (self.ds.field_ordering == 1):
                rv[(ftype, fname)] = gds.get(fname)[()].swapaxes(0, 2)
            else:
                rv[(ftype, fname)] = gds.get(fname)[()]
        h5f.close()
        return rv
    if (size is None):
        size = sum((grid.count(selector) for chunk in chunks for grid in chunk.objs))
    if any(((ftype != 'gdf') for (ftype, fname) in fields)):
        raise NotImplementedError
    for field in fields:
        (ftype, fname) = field
        fsize = size
        rv[field] = np.empty(fsize, dtype='float64')
    ngrids = sum((len(chunk.objs) for chunk in chunks))
    mylog.debug('Reading %s cells of %s fields in %s blocks', size, [fn for (ft, fn) in fields], ngrids)
    ind = 0
    for chunk in chunks:
        fid = None
        for grid in chunk.objs:
            if (grid.filename is None):
                continue
            if (fid is None):
                if (version < '3'):
                    fid = h5py.h5f.open(grid.filename, h5py.h5f.ACC_RDONLY)
                else:
                    fid = h5py.h5f.open(bytes(grid.filename, 'utf-8'), h5py.h5f.ACC_RDONLY)
            if (self.ds.field_ordering == 1):
                data = np.empty(grid.ActiveDimensions[::(- 1)], dtype='float64')
                data_view = data.swapaxes(0, 2)
            else:
                data_view = data = np.empty(grid.ActiveDimensions, dtype='float64')
            for field in fields:
                (ftype, fname) = field
                if (version < '3'):
                    dg = h5py.h5d.open(fid, _field_dname(grid.id, fname))
                else:
                    dg = h5py.h5d.open(fid, bytes(_field_dname(grid.id, fname), 'utf-8'))
                dg.read(h5py.h5s.ALL, h5py.h5s.ALL, data)
                nd = grid.select(selector, data_view, rv[field], ind)
            ind += nd
        if (fid is not None):
            fid.close()
    return rv
def _read_fluid_selection(self, chunks, selector, fields, size):
    from sys import version
    rv = {}
    chunks = list(chunks)
    if isinstance(selector, GridSelector):
        if (not (len(chunks) == len(chunks[0].objs) == 1)):
            raise RuntimeError
        grid = chunks[0].objs[0]
        h5f = h5py.File(grid.filename, mode='r')
        gds = h5f.get(_grid_dname(grid.id))
        for (ftype, fname) in fields:
            if (self.ds.field_ordering == 1):
                rv[(ftype, fname)] = gds.get(fname)[()].swapaxes(0, 2)
            else:
                rv[(ftype, fname)] = gds.get(fname)[()]
        h5f.close()
        return rv
    if (size is None):
        size = sum((grid.count(selector) for chunk in chunks for grid in chunk.objs))
    if any(((ftype != 'gdf') for (ftype, fname) in fields)):
        raise NotImplementedError
    for field in fields:
        (ftype, fname) = field
        fsize = size
        rv[field] = np.empty(fsize, dtype='float64')
    ngrids = sum((len(chunk.objs) for chunk in chunks))
    mylog.debug('Reading %s cells of %s fields in %s blocks', size, [fn for (ft, fn) in fields], ngrids)
    ind = 0
    for chunk in chunks:
        fid = None
        for grid in chunk.objs:
            if (grid.filename is None):
                continue
            if (fid is None):
                if (version < '3'):
                    fid = h5py.h5f.open(grid.filename, h5py.h5f.ACC_RDONLY)
                else:
                    fid = h5py.h5f.open(bytes(grid.filename, 'utf-8'), h5py.h5f.ACC_RDONLY)
            if (self.ds.field_ordering == 1):
                data = np.empty(grid.ActiveDimensions[::(- 1)], dtype='float64')
                data_view = data.swapaxes(0, 2)
            else:
                data_view = data = np.empty(grid.ActiveDimensions, dtype='float64')
            for field in fields:
                (ftype, fname) = field
                if (version < '3'):
                    dg = h5py.h5d.open(fid, _field_dname(grid.id, fname))
                else:
                    dg = h5py.h5d.open(fid, bytes(_field_dname(grid.id, fname), 'utf-8'))
                dg.read(h5py.h5s.ALL, h5py.h5s.ALL, data)
                nd = grid.select(selector, data_view, rv[field], ind)
            ind += nd
        if (fid is not None):
            fid.close()
    return rv