-
Notifications
You must be signed in to change notification settings - Fork 1
/
importMag.m
39 lines (30 loc) · 940 Bytes
/
importMag.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function coef=importMag(fname,rplanet,Lmin,Lmax)
% coef=importMag(fname,rplanet,Lmin,Lmax)
%
% Imports the crustal magnetic field coefficients from the
% standard format and converts them to our potential-field
% spherical-harmonic normalization.
%
% Delete all header lines beforehand
%
% INPUT:
%
% fname name of the data file
% rplanet planet radius
% Lmin minimum sperical-harmonic degree
% given in the data file
% Lmax maximum sperical-harmonic degree
% given in the data file
%
% Last modified by plattner-at-alumni.ethz.ch, 03/17/2018
[~,~,~,~,~,~,~,bigl]=addmon(Lmax);
magdat=importdata(fname);
lmcosi=magdat(:,1:4);
if Lmin>0
lmcosi=[zeros(Lmin^2,4);lmcosi];
end
coef=lmcosi2coef(lmcosi);
coef=coef./sqrt(2*bigl+1)*rplanet*(-1);
% The coefficients are now in 4pi normalized form.
% We want them in unit-normailzed form
coef=coef*sqrt(4*pi);