-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathloadframe.m
More file actions
78 lines (63 loc) · 2.48 KB
/
Copy pathloadframe.m
File metadata and controls
78 lines (63 loc) · 2.48 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function [ne,mlatsrc,mlonsrc,xg,v1,Ti,Te,J1,v2,v3,J2,J3,filename,Phitop,ns,vs1,Ts] = loadframe(direc,ymd,UTsec,ymd0,UTsec0,tdur,dtout,flagoutput,mloc,xg)
cwd = fileparts(mfilename('fullpath'));
addpath([cwd,'/../script_utils'])
narginchk(3,10)
validateattr(direc, {'char'}, {'vector'}, mfilename, 'data directory', 1)
validateattr(ymd, {'numeric'}, {'vector', 'numel', 3}, mfilename, 'year month day', 2)
validateattr(UTsec, {'numeric'}, {'vector'}, mfilename, 'UTC second', 3)
if nargin>=4
validateattr(ymd0, {'numeric'}, {'vector', 'numel', 3}, mfilename, 'year month day', 4)
end
if nargin>=5
validateattr(UTsec0, {'numeric'}, {'scalar'}, mfilename, 'UTC second', 5)
end
if nargin>=6 && ~isempty(tdur)
validateattr(tdur,{'numeric'},{'scalar'},mfilename,'simulation duration',6)
end
if nargin>=7 && ~isempty(dtout)
validateattr(dtout,{'numeric'},{'scalar'},mfilename,'output time step',7)
end
if nargin>=8 && ~isempty(flagoutput)
validateattr(flagoutput,{'numeric'},{'scalar'},mfilename,'output flag',8)
end
if nargin>=9 && ~isempty(mloc)
validateattr(mloc, {'numeric'}, {'vector', 'numel', 2}, mfilename, 'magnetic coordinates', 9)
end
if nargin>=10 && ~isempty(xg)
validateattr(xg, {'struct'}, {'scalar'}, mfilename, 'grid structure', 10)
end
% READ IN THE SIMULATION INFORMATION IF IT HAS NOT ALREADY BEEN PROVIDED
if (~exist('UTsec0','var') || ~exist('ymd0','var') || ~exist('mloc','var') || ~exist('tdur','var') ...
|| ~exist('dtout','var') || ~exist('flagoutput','var') || ~exist('mloc','var') )
[ymd0,UTsec0,tdur,dtout,flagoutput,mloc]=readconfig([direc,'/inputs/config.ini']);
end
% CHECK WHETHER WE NEED TO RELOAD THE GRID (WHICH CAN BE TIME CONSUMING)
if nargout >= 4 && ~exist('xg','var')
xg = readgrid([direc,'/inputs/']);
end
%% SET MAGNETIC LATITUDE AND LONGITUDE OF THE SOURCE
if nargout >= 2 && ~isempty(mloc)
mlatsrc=mloc(1);
mlonsrc=mloc(2);
else
mlatsrc=[];
mlonsrc=[];
end
%% LOAD DIST. FILE
filestr=datelab(ymd,UTsec);
if ymd(1)==ymd0(1) && ymd(2)==ymd0(2) && ymd(3)==ymd0(3) && UTsec==UTsec0 %tack on the decimal part
filestr(end)='1';
end
filename=[filestr,'.dat'];
switch flagoutput
case 1
[ne,v1,Ti,Te,J1,v2,v3,J2,J3,ns,vs1,Ts,Phitop] = loadframe3Dcurv(direc,filename);
case 2
[ne,v1,Ti,Te,J1,v2,v3,J2,J3,Phitop] = loadframe3Dcurvavg(direc,filename);
ns=[]; vs1=[]; Ts=[];
otherwise
ne=loadframe3Dcurvne(direc,filename);
v1=[]; Ti=[]; Te=[]; J1=[]; v2=[]; v3=[]; J2=[]; J3=[];
ns=[]; vs1=[]; Ts=[]; Phitop=[];
end
end % function