forked from ilkkavir/EFISR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readVelocitiesGUISDAP.m~
133 lines (119 loc) · 3.99 KB
/
readVelocitiesGUISDAP.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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
function [v,verr,status,chisqr,ts,te,mlt,llhT,llhR,azelR,r,h,phi,site,ecefS,llhgS,llhmS,kS,B] = readVelocitiesGUISDAP( varargin )
%
% [v,verr,status,chisqr,ts,te,mlt,llhT,llhR,azelR,r,h,phi,site,ecefS,llhgS,llhmS,kS,B]
% = readVelocitiesGUISDAP( fpath [, fpath2 , fpath3 , ...] )
%
% Read ion velocities and related information from GUISDAP fit
% results.
%
% INPUT:
% fpath path(s) to GUISDAP output files or director/y/ies. Any
% combination of individual files and directories.
%
% OUTPUT:
% v velocity estimates (m/s)
% verr standard deviations of the velocity estimates (m/s)
% status fit status (0 for success)
% chisqr chi-squared
% ts integration start time (unix time)
% te integration end time (unix time)
% mlt magnetic local time at integration end time (hours)
% llhT latitude, longitude, height of the transmitter (deg,deg,m)
% llhR latitude, longitude, height of the receiver (deg,deg,m)
% azelR azimuth and elevation angles of the receiver (deg,deg)
% r range (m)
% h height (m)
% phi scattering angle (deg)
% site EISCAT site name (char)
% ecefS location of the scattering volume(s) in cartesian ecef
% (earth-centred earth-fixed) coordinates (m)
% llhgS geodetic coordinates of the scattering volume(s). (deg,deg,m)
% llhmS altitude-adjusted corrected geomagnetic (v2)
% coordinates of the scattering volume (deg,deg,m). The
% last coordinate is geocentric height (radial distance
% - Re)
% kS scattering wave vector direction(s) (unit vector(s)) in
% cartesian ecef coordinates
% B magnetic field vector in local North-East-Down
% coordinates (nT)
%
%
%
% The function returns all data, including failed iterations. Use
% e.g. the output variables "status" and "chisquare" for removing
% failed iterations and unrealistic results.
%
%
%
%
% IV 2016
%
v = [];
verr = [];
status = [];
chisqr = [];
ts = [];
te = [];
mlt = [];
llhT = [];
llhR = [];
azelR = [];
r = [];
h = [];
phi = [];
site = [];
ecefS = [];
llhgS = [];
llhmS = [];
kS = [];
B = [];
fpath = listmatfiles(varargin{:});
% fpath will be a struct if any mat files were found
if isstruct(fpath)
nf = length(fpath);
for ff = 1:nf
readThisFile = false;
if ~fpath(ff).isdir
fname = fpath(ff).name;
if length(fname)>=12
if (fname(end-3:end)) == '.mat'
tstr = str2num(fpath(ff).name(end-11:end-4));
if ~isempty(tstr)
if 0 <= tstr <= 31622400
readThisFile = true;
end
end
end
end
end
if readThisFile
%Ne,NeStd,Ti,TiStd,Tr,TrStd,Coll,CollStd,Vi,Vistd,Comp,CompStd,status,chisqr,ts,te,mlt,llhT,llhR,azelR,r,h,phi,site,ecefS,llhgS,llhmS,kS,B
disp(fpath(ff).name)
[ne,nee,ti,tie,tr,tre,col,cole,vff,verrff,com,come, ...
statusff,chisqrff,tsff,teff,mltff,llhTff,llhRff, ...
azelRff,rff,hff, phiff,siteff,ecefSff,llhgSff,llhmSff, ...
kSff,Bff] = readParametersFromFileGUISDAP(fpath(ff).name);
% should pre-allocate!!! the re-allocation takes forever...
v = [ v ; vff ];
verr = [ verr ; verrff ];
status = [ status ; statusff ];
chisqr = [chisqr ; chisqrff ];
ts = [ ts ; tsff ];
te = [ te ; teff ];
mlt = [ mlt ; mltff ];
llhT = [ llhT ; llhTff ];
llhR = [ llhR ; llhRff ];
azelR = [ azelR ; azelRff ];
r = [ r ; rff ];
h = [ h ; hff ];
phi = [ phi ; phiff ];
site = [ site ; siteff ];
ecefS = [ ecefS ; ecefSff ];
llhgS = [ llhgS ; llhgSff ];
llhmS = [ llhmS ; llhmSff ];
kS = [ kS ; kSff ];
B = [ B ; Bff ];
end
end
end
end