ECOdyagnostics/diagnostics/energetics.py
def center_of_gravity_PE(self, rho, Z_r=0, boussinesq=True, **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)
        # Compute Sum(PE*dV) and Sum(rho*dV)

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

        rho = rho * mask

        if boussinesq:
            mass_full = (self.properties.constants['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')))

        PE = self.potential_energy(rho, Z_r=Z_r)
        TPE_full = (PE * dV).sum(self.ops.grid._get_dims_from_axis(PE, ('X', 'Y', 'Z')))

        g = self.properties.constants['g']

        # Return center of gravity
        return TPE_full / (g * mass_full)

        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_PE(self, rho, Z_r=0, boussinesq=True, **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)
        mask = self.ops._get_mask(rho, **maskargs)
        rho = rho * mask
        if boussinesq:
            mass_full = (self.properties.constants['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')))
        PE = self.potential_energy(rho, Z_r=Z_r)
        TPE_full = (PE * dV).sum(self.ops.grid._get_dims_from_axis(PE, ('X', 'Y', 'Z')))
        g = self.properties.constants['g']
        return TPE_full / (g * mass_full)
def center_of_gravity_PE ( self , rho , Z_r = 0 , boussinesq = True , ** 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 ) mask = self . ops . _get_mask ( rho , ** maskargs ) rho = rho * mask if boussinesq : mass_full = ( self . properties . constants [ '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' ) ) ) PE = self . potential_energy ( rho , Z_r = Z_r ) TPE_full = ( PE * dV ) . sum ( self . ops . grid . _get_dims_from_axis ( PE , ( 'X' , 'Y' , 'Z' ) ) ) g = self . properties . constants [ 'g' ] return TPE_full / ( g * mass_full )
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.
        """ # Compute Sum(PE*dV) and Sum(rho*dV) # Return center of gravity
self
rho
Z_r
boussinesq