ECOdyagnostics/operations.py
def _get_metric_by_pos(self, axes, pos):
        """
        Returns the metrics for given axes corresponding to a grid point position.

        :param da:  data variable or vector as xarray.Dataarray or List(xarray.Dataarray, ...)

        :return:    position of data varaible or vector
        """
        if type(axes) is list:
            metric_out = []
            for ax in axes:
                check = False
                for i in self.points[pos]:
                    metric_dims = self._get_dims(self.grid._metrics[frozenset(ax)])

                    if any([i == a for a in metric_dims]):
                        check = True
                        ind = np.where([i == a for a in metric_dims])[0]
                        #print(ind)
                        if len(ind) == 1:
                            metric_out.append(self.grid._metrics[frozenset(ax)][ind[0]])
                        else:
                            raise Exception(
                                "Found multiple matches for the metric, ensure that metrics are not doubled.")
                if not check:
                    raise Exception("No matching metric was found on axis %s for position %s" % (ax, pos))
        else:
            ax = axes
            #metric_out = []
            check = False
            for i in self.points[pos]:
                metric_dims = self._get_dims(self.grid._metrics[frozenset(ax)])
                if any([i == a for a in metric_dims]):
                    check = True
                    ind = np.where([i == a for a in metric_dims])[0]
                    if len(ind) == 1:
                        #metric_out.append(self.grid._metrics[frozenset(ax)][ind[0]])
                        metric_out = self.grid._metrics[frozenset(ax)][ind[0]]
                    else:
                        raise Exception(
                            "Found multiple matches for the metric, ensure that metrics are not doubled.")
            if not check:
                raise Exception("No matching metric was found on axis %s for position %s" % (ax, pos))

        return metric_out

        Returns the metrics for given axes corresponding to a grid point position.

        :param da:  data variable or vector as xarray.Dataarray or List(xarray.Dataarray, ...)

        :return:    position of data varaible or vector
        
Returns the metrics for given axes corresponding to a grid point position.
Returns the metrics for given axes corresponding to a grid point position .
def _get_metric_by_pos(self, axes, pos):
        if type(axes) is list:
            metric_out = []
            for ax in axes:
                check = False
                for i in self.points[pos]:
                    metric_dims = self._get_dims(self.grid._metrics[frozenset(ax)])
                    if any([i == a for a in metric_dims]):
                        check = True
                        ind = np.where([i == a for a in metric_dims])[0]
                        if len(ind) == 1:
                            metric_out.append(self.grid._metrics[frozenset(ax)][ind[0]])
                        else:
                            raise Exception(
                                "Found multiple matches for the metric, ensure that metrics are not doubled.")
                if not check:
                    raise Exception("No matching metric was found on axis %s for position %s" % (ax, pos))
        else:
            ax = axes
            check = False
            for i in self.points[pos]:
                metric_dims = self._get_dims(self.grid._metrics[frozenset(ax)])
                if any([i == a for a in metric_dims]):
                    check = True
                    ind = np.where([i == a for a in metric_dims])[0]
                    if len(ind) == 1:
                        metric_out = self.grid._metrics[frozenset(ax)][ind[0]]
                    else:
                        raise Exception(
                            "Found multiple matches for the metric, ensure that metrics are not doubled.")
            if not check:
                raise Exception("No matching metric was found on axis %s for position %s" % (ax, pos))
        return metric_out
def _get_metric_by_pos ( self , axes , pos ) : if type ( axes ) is list : metric_out = [ ] for ax in axes : check = False for i in self . points [ pos ] : metric_dims = self . _get_dims ( self . grid . _metrics [ frozenset ( ax ) ] ) if any ( [ i == a for a in metric_dims ] ) : check = True ind = np . where ( [ i == a for a in metric_dims ] ) [ 0 ] if len ( ind ) == 1 : metric_out . append ( self . grid . _metrics [ frozenset ( ax ) ] [ ind [ 0 ] ] ) else : raise Exception ( "Found multiple matches for the metric, ensure that metrics are not doubled." ) if not check : raise Exception ( "No matching metric was found on axis %s for position %s" % ( ax , pos ) ) else : ax = axes check = False for i in self . points [ pos ] : metric_dims = self . _get_dims ( self . grid . _metrics [ frozenset ( ax ) ] ) if any ( [ i == a for a in metric_dims ] ) : check = True ind = np . where ( [ i == a for a in metric_dims ] ) [ 0 ] if len ( ind ) == 1 : metric_out = self . grid . _metrics [ frozenset ( ax ) ] [ ind [ 0 ] ] else : raise Exception ( "Found multiple matches for the metric, ensure that metrics are not doubled." ) if not check : raise Exception ( "No matching metric was found on axis %s for position %s" % ( ax , pos ) ) return metric_out
Returns the metrics for given axes corresponding to a grid point position.
Returns the metrics for given axes corresponding to a grid point position .
"""
        Returns the metrics for given axes corresponding to a grid point position.

        :param da:  data variable or vector as xarray.Dataarray or List(xarray.Dataarray, ...)

        :return:    position of data varaible or vector
        """ #print(ind) #metric_out = [] #metric_out.append(self.grid._metrics[frozenset(ax)][ind[0]])
position of data varaible or vector
position of data varaible or vector
self
axes
pos
da
data variable or vector as xarray.Dataarray or List(xarray.Dataarray, ...)
data variable or vector as xarray . Dataarray or List ( xarray . Dataarray ... )