-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performs conversion of geomagnetic potential coeffficients
- Loading branch information
Showing
1 changed file
with
37 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,64 @@ | ||
function lmcosip=plm2mag(lmcosiS,r,a,wat) | ||
% lmcosip=plm2mag(lmcosiS,r,a,wat) | ||
function lmcosip=plm2mag(lmcosi,r,a,wat,schm) | ||
% lmcosip=PLM2MAG(lmcosi,r,a,wat,schm) | ||
% | ||
% Converts a (Schmidt-normalized) real-spherical-harmonic array of | ||
% magnetic-potential cosine and sine coefficients into a same-size | ||
% spherical harmonic array with modified coefficients, depending on given | ||
% input and requested output, e.g. for upward and downward continuation, | ||
% differentiation to individual components, and the like. | ||
% | ||
% INPUT: | ||
% | ||
% lmcosiS [l m Ccos Csin] degrees, order, coefficients in the | ||
% Schmidt semi-normalized basis | ||
% r Requested radius, in m [default: a] | ||
% a Reference radius [default: 6371200] | ||
% wat 1 radial-component magnetic field u_r [default] | ||
% 2 colatitudinal tangential-component u_th | ||
% 3 longitudinal tangential-component u_ph | ||
% lmcosi [l m Ccos Csin] degrees, order, cos/sin potential coefficients | ||
% r Requested radius for the input, in m [default: a] | ||
% a Reference radius for the output [default: 6371200] | ||
% wat 1 output is radial-component field [default] | ||
% 2 output is colatitudinal tangential-component field [default] | ||
% 3 output is longitudinal tangential-component field [default] | ||
% schm 1 change normalization from being appropriate for expansion | ||
% into Schmidt semi-normalized harmonics to being | ||
% appropriate for expansion into 4pi-normalized ones [default] | ||
% Otherwise, keep the normalization as it is. | ||
% | ||
% OUPUT: | ||
% | ||
% lmcosip [l m Ccos Csin] degrees, order, coefficients of output in | ||
% the 4pi fully normalized basis good for PLM2XYZ | ||
% lmcosip [l m Ccos Csin] degrees, order, cos/sin coefficients of output | ||
% | ||
% Written by by fjsimons-at-alum.mit.edu, 03/05/2009 | ||
% Modified by Jarno Saarimaki, 07/01/2011 | ||
% Last modified by fjsimons-at-alum.mit.edu, 05/04/2018 | ||
|
||
% Default values | ||
% Deafult input values | ||
defval('a',6371200) | ||
defval('r',a) | ||
defval('wat',1) | ||
defval('schm',1) | ||
|
||
% Get the spherical harmonic degree | ||
el=lmcosiS(:,1); | ||
el=lmcosi(:,1); | ||
|
||
% Precalculate a certain upward-continuation factor | ||
arl2=(a/r).^(el+2); | ||
|
||
% Convert from Schmidt semi-normalized to 4pi-normalized | ||
lmcosiS(:,3:4)=lmcosiS(:,3:4)./sqrt(2*[el el]+1); | ||
lmcosip=lmcosiS; | ||
if schm == 1 | ||
% Convert coefficients from being expanded into Schmidt semi-normalized | ||
% to being expanded into 4pi-normalized real spherical harmonics | ||
lmcosi(:,3:4)=lmcosi(:,3:4)./sqrt(2*[el el]+1); | ||
end | ||
|
||
% Convert | ||
% Perform the upward or downward continuation portion first | ||
lmcosi(:,3:4)=lmcosi(:,3:4).*arl2*[1 1]; | ||
|
||
% Convert to other things | ||
switch wat | ||
case 1 | ||
% Blakely p. 169 (8.20) | ||
fact=(el+1).*arl2*[1 1]; | ||
% [Blakely 1995 p. 169 after eq. (8.20)] | ||
disp('Calculating radial field from potential') | ||
lmcosip(:,3:4)=lmcosi(:,3:4).*(el+1)*[1 1]; | ||
case 2 | ||
% Kono | ||
disp('Calculating colatitudinal tangential field from potential') | ||
case 3 | ||
% Kono | ||
disp('Calculating longitudinal tangential field from potential') | ||
end | ||
|
||
% Factor in the factor | ||
lmcosip(:,3:4)=fact.*lmcosiS(:,3:4); |