-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathloadframe.m
More file actions
65 lines (55 loc) · 1.92 KB
/
Copy pathloadframe.m
File metadata and controls
65 lines (55 loc) · 1.92 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
function [ne,mlatsrc,mlonsrc,xg,v1,Ti,Te,J1,v2,v3,J2,J3,filename,Phitop,ns,vs1,Ts] = loadframe(direc,ymd,UTsec,flagoutput,mloc,xg)
cwd = fileparts(mfilename('fullpath'));
addpath([cwd, '/../script_utils'])
narginchk(3,6)
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 < 5 || isempty(flagoutput) || isempty(mloc)
[~,~,~,~,flagoutput,mloc] = readconfig([direc, filesep, 'inputs']);
end
validateattr(flagoutput,{'numeric'},{'scalar'},mfilename,'output flag',4)
if ~isempty(mloc)
validateattr(mloc, {'numeric'}, {'vector', 'numel', 2}, mfilename, 'magnetic coordinates', 5)
end
if nargin < 6 || isempty(xg)
xg = readgrid([direc, '/inputs']);
end
validateattr(xg, {'struct'}, {'scalar'}, mfilename, 'grid structure', 6)
direc = absolute_path(direc);
%% 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
stem0 = datelab(ymd, UTsec);
for ext = {'.h5', '.dat'}
stem = stem0;
filename = [stem, ext{1}];
if is_file([direc, filesep, filename])
break
end
% switch microsecond to one for first time step
stem(end) = '1';
filename = [stem, ext{1}];
if is_file([direc, filesep, filename])
break
end
end
assert(is_file([direc, filesep, filename]), ['loadframe: ', [direc,filesep,stem,'.{dat,h5}'], ' does not exist.'])
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