File size: 7,951 Bytes
5ab75a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
function [data] = BFMC_lis_reader(fileName)
% BFMC_lis_reader - Read a BFMC .lis file and load into a data table.
%                   (For CARA analysis team internal use)
%
% Syntax: data = BFMC_lis_reader(fileName);
%
% =========================================================================
%
% Copyright (c) 2026 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% =========================================================================
%
% Input:
%
%    fileName   -   Path to BFMC .lis file
%
% =========================================================================
%
% Output:
%
%   data        -   Matlab table containing parsed .lis file data
%
% =========================================================================
%
% Initial version: Feb 2024;  Latest update: Apr 2026
%
% ----------------- BEGIN CODE -----------------

A = fileread(fileName);

if ~isempty(A)
    
    % if contains(A,'satellite vector information')
    if ~isempty(strfind(A,'satellite vector information'))
        
        fid = fopen(fileName);

        newline = '';
        while ~strcmpi(strtrim(newline), 'satellite vector information')
            newline = fgetl(fid);
        end

        fgetl(fid);

        % sat vec info
        % pri
        newline = fgetl(fid);
        data = [str2double(newline(end-4:end))];

        newline = fgetl(fid);
        data = [data datenum([str2double(newline(32:35)) 0 str2double(newline(36:38)) str2double(newline(40:41)) ...
            str2double(newline(42:43)) str2double(newline(45:end))])];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{5}) str2double(lineparts{6}) str2double(lineparts{7})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{5}) str2double(lineparts{6}) str2double(lineparts{7})];

        % sec
        newline = fgetl(fid);
        data = [data str2double(newline(end-4:end))];

        newline = fgetl(fid);
        data = [data datenum([str2double(newline(32:35)) 0 str2double(newline(36:38)) str2double(newline(40:41)) ...
            str2double(newline(42:43)) str2double(newline(45:end))])];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{5}) str2double(lineparts{6}) str2double(lineparts{7})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{5}) str2double(lineparts{6}) str2double(lineparts{7})];

        % pca info
        fgetl(fid);
        fgetl(fid);
        fgetl(fid);

        newline = fgetl(fid);
        data = [data datenum([str2double(newline(32:35)) 0 str2double(newline(36:38)) str2double(newline(40:41)) ...
            str2double(newline(42:43)) str2double(newline(45:end))])];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{end})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{5}) str2double(lineparts{6}) str2double(lineparts{7})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{5}) str2double(lineparts{6}) str2double(lineparts{7})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{6}) str2double(lineparts{7}) str2double(lineparts{8})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{end})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{5}) str2double(lineparts{6}) str2double(lineparts{7})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{5}) str2double(lineparts{6}) str2double(lineparts{7})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{6}) str2double(lineparts{7}) str2double(lineparts{8})];

        % conj pars info
        fgetl(fid);
        fgetl(fid);
        fgetl(fid);

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{5}) str2double(lineparts{6}) str2double(lineparts{7})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{6}) str2double(lineparts{7}) str2double(lineparts{8})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{end})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{end})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{end})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{5}) str2double(lineparts{6})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{end})];

        newline = fgetl(fid);
        lineparts = strsplit(newline, ' ');
        data = [data str2double(lineparts{end})];

        newline = fgetl(fid);
        if strcmp(newline, '-------------------------------------------')
            data = [data 0 0 0];
        else
            lineparts = strsplit(newline, ' ');
            data = [data str2double(lineparts{end-1}) str2double(lineparts{end})];
        
            newline = fgetl(fid);
            if ~ischar(newline)
                warning('Error in read of lis file, not returning data')
                data = [];
                return;
            end
            lineparts = strsplit(newline, ' ');
            data = [data str2double(lineparts{end})];
        end

        fclose(fid);

        data = array2table(data, 'VariableNames', {'PriSatno', 'PriEpochDN', 'PriEpochX', 'PriEpochY', 'PriEpochZ', 'PriEpochXdot', 'PriEpochYdot', 'PriEpochZdot',...
            'SecSatno', 'SecEpochDN', 'SecEpochX', 'SecEpochY', 'SecEpochZ', 'SecEpochXdot', 'SecEpochYdot', 'SecEpochZdot',...
            'TCA', 'PriPropTime', 'PriX', 'PriY', 'PriZ', 'PriXdot', 'PriYdot', 'PriZdot', 'PriUsig', 'PriVsig', 'PriWsig',...
            'SecPropTime', 'SecX', 'SecY', 'SecZ', 'SecXdot', 'SecYdot', 'SecZdot', 'SecUsig', 'SecVsig', 'SecWsig',...
            'RelU', 'RelV', 'RelW', 'RelUsig', 'RelVsig', 'RelWsig', 'RelSep', 'RelVel', 'SigmaPenetrationLevel', 'Pc1', 'Pc2', 'TwoSigMiss', 'TwoSigTime',...
            'MChit', 'MCcounts', 'MCPocHitsPerTrial'});
    else

        warning('Bad read of lis file, not returning data')
        data = [];
        
    end
    
else
    
    warning('Empty lis file, not returning any data')
    data = [];
    
end

return
end


% ----------------- END OF CODE ------------------
%
% Please record any changes to the software in the change history
% shown below:
%
% ----------------- CHANGE HISTORY ------------------
% Developer |     Date    | Description
% ---------------------------------------------------
% D. Hall   | 2024-Feb-26 | Initial version.
% J. Halpin | 2026-Apr-22 | Added header and footer
% =========================================================================
%
% Copyright (c) 2026 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% =========================================================================