File size: 3,108 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
function [VCMFile] = getVCMFile(SatID,inputPath)
% getVCMFile - Get a satellite's VCM file name, checking for 5 or 9
%              digit satellite ID number variants. Return empty set if
%              no file found.
%
% Syntax: VCMFile = getVCMFile(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 VCM files
%
% =========================================================================
%
% Output:
%
%   VCMFile    -   VCM file name (empty if not found)
%
% =========================================================================
%
% Initial version: Feb 2024;  Latest update: Apr 2026
%
% ----------------- BEGIN CODE -----------------

% Initialize output

VCMFile  = [];

% Search using input SatID

template = fullfile(inputPath,[SatID '*.vcm']);
dl = dir(template);
if ~isempty(dl)
    if numel(dl) > 1
        warning('More than one candidate VCM file found; using first');
        VCMFile = [dl(1).name ' (among ' numel(dl) ' candidates ']; 
    else
        VCMFile = dl.name;
    end
    return;
end

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

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];
    template = fullfile(inputPath,[SatIDAlt '*.vcm']);
    dl = dir(template);
elseif (LenID == 9) && strcmpi(SatID(1:4),'0000')
    % Try 5 digit variant
    SatIDAlt = SatID(5:9);
    template = fullfile(inputPath,[SatIDAlt '*.vcm']);
    dl = dir(template);
end

if ~isempty(dl)
    if numel(dl) > 1
        warning('More than one candidate VCM file found; using first');
        VCMFile = [dl(1).name ' (among ' numel(dl) ' candidates ']; 
    else
        VCMFile = dl.name;
    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.
%
% =========================================================================