File size: 3,081 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
function [EphemSatID,EphemFile] = getEphemFile(SatID,inputPath)
% getEphemFile - Get a satellite's ephemeris file name, checking for 5
%                or 9 digit satellite ID number variants. Return empty
%                set if no file found.
%
% Syntax: [EphemSatID, EphemFile] = getEphemFile(SatID, inputPath);
%
% =========================================================================
%
% Copyright (c) 2026 United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% =========================================================================
%
% Input:
%
%    SatID      -   Satellite ID string (5 or 9 digit)
%
%    inputPath  -   Path to directory containing ephemeris files
%
% =========================================================================
%
% Output:
%
%   EphemSatID -   Satellite ID string of found ephemeris file
%                  (empty if not found)
%
%   EphemFile  -   Full path to ephemeris file
%                  (empty if not found)
%
% =========================================================================
%
% Initial version: Feb 2024;  Latest update: Apr 2026
%
% ----------------- BEGIN CODE -----------------

% Try the default ephemeris file name

EphemSatID = SatID;
EphemFile = fullfile(inputPath,[SatID '.eci']);
EphemFileExists = exist(EphemFile,'file');

if EphemFileExists
    return;
end

% If default file doesn't exist, then try the 5 or 9 digit name variants,
% if possible

EphemSatID = [];
EphemFile  = [];

NumID = str2double(SatID);
if isempty(NumID) || isnan(NumID) || (NumID < 0)
    % SatID does not define a usable number, so no variant file name can be
    % constructed
    return;
end

LenID = length(SatID);

if LenID == 5
    % Try 9 digit variant
    SatIDAlt = ['0000' SatID];
    EphemFileAlt = fullfile(inputPath,[SatIDAlt '.eci']);
    if exist(EphemFileAlt,'file')
        EphemSatID = SatIDAlt;
        EphemFile  = EphemFileAlt;
    end
elseif (LenID == 9) && strcmpi(SatID(1:4),'0000')
    % Try 5 digit variant
    SatIDAlt = SatID(5:9);
    EphemFileAlt = fullfile(inputPath,[SatIDAlt '.eci']);
    if exist(EphemFileAlt,'file')
        EphemSatID = SatIDAlt;
        EphemFile  = EphemFileAlt;
    end
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.
%
% =========================================================================