Exemplo n.º 1
0
    def __init__(self, dapvar, data=None):
        self.var = dapvar

        if data is None:
            data = dapvar.data

        # Make data iterable.
        if not isiterable(data): data = [data]

        # Put data in blocks.
        if not hasattr(data, 'shape') or len(data.shape) <= 1:
            data = [data]

        self.data = data
Exemplo n.º 2
0
    def __init__(self, dapvar, data=None):
        self.var = dapvar

        if data is None:
            data = dapvar.data

        # Make data iterable.
        if not isiterable(data): data = [data]

        # Put data in blocks.
        if not hasattr(data, 'shape') or len(data.shape) <= 1:
            data = [data]

        self.data = data
Exemplo n.º 3
0
def slicevar(dapvar, slice_):
    if slice_ != (slice(None),):
        dapvar.data = dapvar.data[slice_]

    try:
        dapvar.shape = getattr(dapvar.data, 'shape', (len(dapvar.data),))
    except TypeError:
        pass

    if isinstance(dapvar, GridType):
        if not isiterable(slice_): slice_ = (slice_,)

        # Slice the maps.
        for map_,mapslice in zip(dapvar.maps.values(), slice_):
            map_.data = map_.data[mapslice]
            map_.shape = map_.data.shape

    return dapvar