ECOdyagnostics/diagnostics/energetics.py
def center_of_gravity_classical(self, rho, boussinesq=False, coords=None, **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)
        if coords is None:
            coords = [self.properties.coords[coord] for coord in ['X','Y','Z']]
        x, y, z = coords
        # Compute Sum ( rho * V * D)
        mask = self.ops._get_mask(rho, **maskargs)
        rho = rho * mask

        if boussinesq:
            rho0 = self.properties.constants['rho0']
            mass_full = (rho0*dV*mask).sum(self.ops.grid._get_dims_from_axis(rho, ('X', 'Y', 'Z')))
        else:
            mass_full = (rho * dV).sum(self.ops.grid._get_dims_from_axis(rho, ('X', 'Y', 'Z')))
        #mass_c.sum(self.ops.grid._get_dims_from_axis(mass_c, ('X', 'Y')))
        #mass_zonal = mass_c.sum(self.ops.grid._get_dims_from_axis(mass_c, ('X', 'Z')))
        #mass_meridional = mass_c.sum(self.ops.grid._get_dims_from_axis(mass_c, ('Y', 'Z')))

        # Get center of mass
        #R_x = (rho * x * dV).sum(self.ops.grid._get_dims_from_axis(dV, ('X', 'Y', 'Z'))) / mass_full
        #R_y = (rho * y * dV).sum(self.ops.grid._get_dims_from_axis(dV, ('X', 'Y', 'Z'))) / mass_full
        R_z = (rho * z * dV).sum(self.ops.grid._get_dims_from_axis(dV, ('X', 'Y', 'Z'))) / mass_full
        #R_x = (mass_meridional * x).sum(self.ops.grid._get_dims_from_axis(mass_c, ('X'))) / mass_full
        #R_y = (mass_zonal * y).sum(self.ops.grid._get_dims_from_axis(mass_c, ('Y'))) / mass_full
        #R_z = (mass_horizontal * z).sum(self.ops.grid._get_dims_from_axis(mass_c, 'Z')) / mass_full

        return R_z

        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_classical(self, rho, boussinesq=False, coords=None, **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)
        if coords is None:
            coords = [self.properties.coords[coord] for coord in ['X','Y','Z']]
        x, y, z = coords
        mask = self.ops._get_mask(rho, **maskargs)
        rho = rho * mask
        if boussinesq:
            rho0 = self.properties.constants['rho0']
            mass_full = (rho0*dV*mask).sum(self.ops.grid._get_dims_from_axis(rho, ('X', 'Y', 'Z')))
        else:
            mass_full = (rho * dV).sum(self.ops.grid._get_dims_from_axis(rho, ('X', 'Y', 'Z')))
        R_z = (rho * z * dV).sum(self.ops.grid._get_dims_from_axis(dV, ('X', 'Y', 'Z'))) / mass_full
        return R_z
def center_of_gravity_classical ( self , rho , boussinesq = False , coords = None , ** 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 ) if coords is None : coords = [ self . properties . coords [ coord ] for coord in [ 'X' , 'Y' , 'Z' ] ] x , y , z = coords mask = self . ops . _get_mask ( rho , ** maskargs ) rho = rho * mask if boussinesq : rho0 = self . properties . constants [ 'rho0' ] mass_full = ( rho0 * dV * mask ) . sum ( self . ops . grid . _get_dims_from_axis ( rho , ( 'X' , 'Y' , 'Z' ) ) ) else : mass_full = ( rho * dV ) . sum ( self . ops . grid . _get_dims_from_axis ( rho , ( 'X' , 'Y' , 'Z' ) ) ) R_z = ( rho * z * dV ) . sum ( self . ops . grid . _get_dims_from_axis ( dV , ( 'X' , 'Y' , 'Z' ) ) ) / mass_full return R_z
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 ( rho * V * D) #mass_c.sum(self.ops.grid._get_dims_from_axis(mass_c, ('X', 'Y'))) #mass_zonal = mass_c.sum(self.ops.grid._get_dims_from_axis(mass_c, ('X', 'Z'))) #mass_meridional = mass_c.sum(self.ops.grid._get_dims_from_axis(mass_c, ('Y', 'Z'))) # Get center of mass #R_x = (rho * x * dV).sum(self.ops.grid._get_dims_from_axis(dV, ('X', 'Y', 'Z'))) / mass_full #R_y = (rho * y * dV).sum(self.ops.grid._get_dims_from_axis(dV, ('X', 'Y', 'Z'))) / mass_full #R_x = (mass_meridional * x).sum(self.ops.grid._get_dims_from_axis(mass_c, ('X'))) / mass_full #R_y = (mass_zonal * y).sum(self.ops.grid._get_dims_from_axis(mass_c, ('Y'))) / mass_full #R_z = (mass_horizontal * z).sum(self.ops.grid._get_dims_from_axis(mass_c, 'Z')) / mass_full
self
rho
boussinesq
coords