Exemple #1
0
    def get_distributed_slice(self, slc, **kwargs):
        """
        Slice a distributed object.

        :param slc: A slice-like object.
        :type slc: <varying>
        :param dict kwargs: Optional arguments to :meth:`~ocgis.Variable.get_distributed_slice`.
        :rtype: :class:`ocgis.spatial.geomc.AbstractGeometryCoordinates`
        """

        slc = get_formatted_slice(slc, self.ndim)
        if self.cindex is None:
            target = self.x
        else:
            target = self.cindex
        if len(slc) != target.ndim:
            dslc = get_dslice(self.dimensions, slc)
            for dim in target.dimensions:
                if dim.name not in dslc:
                    dslc[dim.name] = slice(None)
            slc = [dslc[dim.name] for dim in target.dimensions]
        new_parent = target.get_distributed_slice(slc, **kwargs).parent
        ret = self.copy()
        ret.parent = new_parent
        return ret
Exemple #2
0
 def __getitem__(self, slc):
     slc = get_formatted_slice(slc, self.ndim)
     if not isinstance(slc, dict):
         slc = get_dslice(self.dimensions, slc)
     ret = self.copy()
     new_parent = ret.parent[slc]
     ret.parent = new_parent
     return ret