ECOdyagnostics/diagnostics/energetics.py
def center_of_gravity_eta(self, eta, rho, eta_r=0, boussinesq=False, **maskargs):
        """
        Computes the position of the center of mass.
        Returns the location for each axis. Operates on a 3D grid.
        """
        try:
            pos = self.ops._get_position(rho)
        except:
            pos = 'T'
        dr = self.ops._get_metric_by_pos(['X', 'Y', 'Z'], pos)
        dV = np.prod(dr)
        dA_s = dr[0]*dr[1]
        #g = self.properties.constants['g']
        rho0 = self.properties.constants['rho0']

        mask = self.ops._get_mask(rho, **maskargs)

        rho = rho * mask

        if boussinesq:
            mass_full = (rho0 * dV * mask).sum(
                self.ops.grid._get_dims_from_axis(dV, ('X', 'Y', 'Z')))
        else:
            mass_full = (rho * dV).sum(self.ops.grid._get_dims_from_axis(rho, ('X', 'Y', 'Z')))

        zg_eta = (0.5  * rho0 * dA_s* (eta**2-eta_r**2)).sum(self.ops.grid._get_dims_from_axis(eta, ('X', 'Y'))) / mass_full#self.ops.average(h, ['X','Y','Z'],mask='nan') / g

        return zg_eta

        Computes the position of the center of mass.
        Returns the location for each axis. Operates on a 3D grid.
        
Computes the position of the center of mass.
Returns the location for each axis. Operates on a 3D grid.
Computes the position of the center of mass . Returns the location for each axis . Operates on a 3D grid .
def center_of_gravity_eta(self, eta, rho, eta_r=0, boussinesq=False, **maskargs):
        try:
            pos = self.ops._get_position(rho)
        except:
            pos = 'T'
        dr = self.ops._get_metric_by_pos(['X', 'Y', 'Z'], pos)
        dV = np.prod(dr)
        dA_s = dr[0]*dr[1]
        rho0 = self.properties.constants['rho0']
        mask = self.ops._get_mask(rho, **maskargs)
        rho = rho * mask
        if boussinesq:
            mass_full = (rho0 * dV * mask).sum(
                self.ops.grid._get_dims_from_axis(dV, ('X', 'Y', 'Z')))
        else:
            mass_full = (rho * dV).sum(self.ops.grid._get_dims_from_axis(rho, ('X', 'Y', 'Z')))
        zg_eta = (0.5  * rho0 * dA_s* (eta**2-eta_r**2)).sum(self.ops.grid._get_dims_from_axis(eta, ('X', 'Y'))) / mass_full
        return zg_eta
def center_of_gravity_eta ( self , eta , rho , eta_r = 0 , boussinesq = False , ** maskargs ) : try : pos = self . ops . _get_position ( rho ) except : pos = 'T' dr = self . ops . _get_metric_by_pos ( [ 'X' , 'Y' , 'Z' ] , pos ) dV = np . prod ( dr ) dA_s = dr [ 0 ] * dr [ 1 ] rho0 = self . properties . constants [ 'rho0' ] mask = self . ops . _get_mask ( rho , ** maskargs ) rho = rho * mask if boussinesq : mass_full = ( rho0 * dV * mask ) . sum ( self . ops . grid . _get_dims_from_axis ( dV , ( 'X' , 'Y' , 'Z' ) ) ) else : mass_full = ( rho * dV ) . sum ( self . ops . grid . _get_dims_from_axis ( rho , ( 'X' , 'Y' , 'Z' ) ) ) zg_eta = ( 0.5 * rho0 * dA_s * ( eta ** 2 - eta_r ** 2 ) ) . sum ( self . ops . grid . _get_dims_from_axis ( eta , ( 'X' , 'Y' ) ) ) / mass_full return zg_eta
Computes the position of the center of mass.
Computes the position of the center of mass .
"""
        Computes the position of the center of mass.
        Returns the location for each axis. Operates on a 3D grid.
        """ #g = self.properties.constants['g'] #self.ops.average(h, ['X','Y','Z'],mask='nan') / g
self
eta
rho
eta_r
boussinesq