sopt_mltb_div_op_sphere - Compute divergence on sphere Compute the divergence (adjoint of the gradient) of a two dimensional signal on the sphere. The phi direction (x) is periodic, while the theta direction (y) is not. Inputs: - dx: Gradient in x. - dy: Gradient in y. - includeNorthPole: Flag indicating whether the North pole is included in the sampling grid (1 = North pole included, 0 = North pole not included). - weights_dx: Weights in the x (phi) direction. - weights_dy: Weights in the y (theta) direction. Outputs: - I: Divergence.
0001 function I = sopt_mltb_div_op_sphere(dx, dy, includeNorthpole, ... 0002 weights_dx, weights_dy) 0003 % sopt_mltb_div_op_sphere - Compute divergence on sphere 0004 % 0005 % Compute the divergence (adjoint of the gradient) of a two dimensional 0006 % signal on the sphere. The phi direction (x) is periodic, while the theta 0007 % direction (y) is not. 0008 % 0009 % Inputs: 0010 % 0011 % - dx: Gradient in x. 0012 % 0013 % - dy: Gradient in y. 0014 % 0015 % - includeNorthPole: Flag indicating whether the North pole is included 0016 % in the sampling grid (1 = North pole included, 0 = North pole not 0017 % included). 0018 % 0019 % - weights_dx: Weights in the x (phi) direction. 0020 % 0021 % - weights_dy: Weights in the y (theta) direction. 0022 % 0023 % Outputs: 0024 % 0025 % - I: Divergence. 0026 0027 if nargin > 3 0028 dx = dx .* conj(weights_dx); 0029 dy = dy .* conj(weights_dy); 0030 end 0031 if(includeNorthpole) 0032 I = [zeros(1, size(dx,2)) ; dx(2, :); dx(3:end-1, :)-dx(2:end-2, :); -dx(end-1, :)]; 0033 I = I + [dy(:, 1) - dy(:,end) , dy(:, 2:end)-dy(:, 1:end-1)]; 0034 else 0035 I = [dx(1, :) ; dx(2:end-1, :)-dx(1:end-2, :) ; -dx(end-1, :)]; 0036 I = I + [dy(:, 1) - dy(:,end) , dy(:, 2:end)-dy(:, 1:end-1)]; 0037 end 0038 end