ECOdyagnostics/operations.py
def _matching_dim(self, da1, da2, skip1=None, skip2=None):
        """
        Checks if the dimension of data variable da1 matches the dimension of data variable da2.

        :param da:      data variable or vector to test
        :param pos:     position to test for

        :return:        True, False or List(True/False, ...)
        """
        # Get dimensions and cut 't' and skip if given
        if skip1 != None:
            da1 = self._data_skip(da1, skip1)
        if skip2 != None:
            da2 = self._data_skip(da2, skip2)

        da1_dims = self._get_dims(da1)
        da2_dims = self._get_dims(da2)
        if 't' in da1_dims:
            ind = da1_dims.index('t')
            da1_dims = da1_dims[:ind] + da1_dims[ind + 1:]
        if 't' in da2_dims:
            ind = da2_dims.index('t')
            da2_dims = da2_dims[:ind] + da2_dims[ind + 1:]

        # Depending on type, make comparison
        if type(da1) is list and type(da2) is xr.DataArray:
            match = [da2_dims == da1_pos for da1_pos in da1_dims]
            if all(match):
                return True
            else:
                return match  # raise Exception("""False elements %s do not match position %s""" % (match, pos))
        elif type(da2) is list and type(da1) is xr.DataArray:
            match = [da1_dims == da2_pos for da2_pos in da2_dims]
            if all(match):
                return True
            else:
                return match
        elif type(da1) is list and type(da2) is list:
            if len(da1) == len(da2):
                if da1_dims == da2_dims:
                    return True
                else:
                    return False
            else:
                raise Exception("""Data variable 1 and Data variable 2 do not have the same length""")
        elif type(da1) is xr.DataArray and type(da2) is xr.DataArray:
            if da1_dims == da2_dims:
                return True
            else:
                return False

        Checks if the dimension of data variable da1 matches the dimension of data variable da2.

        :param da:      data variable or vector to test
        :param pos:     position to test for

        :return:        True, False or List(True/False, ...)
        
Checks if the dimension of data variable da1 matches the dimension of data variable da2.
Checks if the dimension of data variable da1 matches the dimension of data variable da2 .
def _matching_dim(self, da1, da2, skip1=None, skip2=None):
        if skip1 != None:
            da1 = self._data_skip(da1, skip1)
        if skip2 != None:
            da2 = self._data_skip(da2, skip2)
        da1_dims = self._get_dims(da1)
        da2_dims = self._get_dims(da2)
        if 't' in da1_dims:
            ind = da1_dims.index('t')
            da1_dims = da1_dims[:ind] + da1_dims[ind + 1:]
        if 't' in da2_dims:
            ind = da2_dims.index('t')
            da2_dims = da2_dims[:ind] + da2_dims[ind + 1:]
        if type(da1) is list and type(da2) is xr.DataArray:
            match = [da2_dims == da1_pos for da1_pos in da1_dims]
            if all(match):
                return True
            else:
                return match  
        elif type(da2) is list and type(da1) is xr.DataArray:
            match = [da1_dims == da2_pos for da2_pos in da2_dims]
            if all(match):
                return True
            else:
                return match
        elif type(da1) is list and type(da2) is list:
            if len(da1) == len(da2):
                if da1_dims == da2_dims:
                    return True
                else:
                    return False
            else:
                raise Exception("""Data variable 1 and Data variable 2 do not have the same length""")
        elif type(da1) is xr.DataArray and type(da2) is xr.DataArray:
            if da1_dims == da2_dims:
                return True
            else:
                return False
def _matching_dim ( self , da1 , da2 , skip1 = None , skip2 = None ) : if skip1 != None : da1 = self . _data_skip ( da1 , skip1 ) if skip2 != None : da2 = self . _data_skip ( da2 , skip2 ) da1_dims = self . _get_dims ( da1 ) da2_dims = self . _get_dims ( da2 ) if 't' in da1_dims : ind = da1_dims . index ( 't' ) da1_dims = da1_dims [ : ind ] + da1_dims [ ind + 1 : ] if 't' in da2_dims : ind = da2_dims . index ( 't' ) da2_dims = da2_dims [ : ind ] + da2_dims [ ind + 1 : ] if type ( da1 ) is list and type ( da2 ) is xr . DataArray : match = [ da2_dims == da1_pos for da1_pos in da1_dims ] if all ( match ) : return True else : return match elif type ( da2 ) is list and type ( da1 ) is xr . DataArray : match = [ da1_dims == da2_pos for da2_pos in da2_dims ] if all ( match ) : return True else : return match elif type ( da1 ) is list and type ( da2 ) is list : if len ( da1 ) == len ( da2 ) : if da1_dims == da2_dims : return True else : return False else : raise Exception ( """Data variable 1 and Data variable 2 do not have the same length""" ) elif type ( da1 ) is xr . DataArray and type ( da2 ) is xr . DataArray : if da1_dims == da2_dims : return True else : return False
Checks if the dimension of data variable da1 matches the dimension of data variable da2.
Checks if the dimension of data variable da1 matches the dimension of data variable da2 .
"""
        Checks if the dimension of data variable da1 matches the dimension of data variable da2.

        :param da:      data variable or vector to test
        :param pos:     position to test for

        :return:        True, False or List(True/False, ...)
        """ # Get dimensions and cut 't' and skip if given # Depending on type, make comparison # raise Exception("""False elements %s do not match position %s""" % (match, pos))
True, False or List(True/False, ...)
True False or List ( True / False ... )
self
da1
da2
skip1
skip2
da
data variable or vector to test
data variable or vector to test
pos
position to test for
position to test for