0001 function [startMJD, endMJD, startPlotMJD, endPlotMJD, estimateMJDs] = ...
0002 checkLoadDates(startMJD, endMJD, startPlotMJD, endPlotMJD, ...
0003 archiveDir, newEstimatesDir, templateMJDs)
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 fileListArch = dir([archiveDir '*-*-*T*.bin']);
0028 fileListLocal = dir([newEstimatesDir '*-*-*T*.bin']);
0029
0030 fileList = cat(1,fileListArch,fileListLocal);
0031 nFiles = length(fileList);
0032
0033
0034
0035 estimateMJDs = zeros(1,nFiles);
0036
0037 for k=1:nFiles
0038
0039 fileDate = regexp(fileList(k).name, ...
0040 '(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})T(?<hour>[0-9]{2})', 'names');
0041
0042
0043
0044
0045 estimateMJDs(k) = date2mjd( ...
0046 str2double(fileDate.year),str2double(fileDate.month), ...
0047 str2double(fileDate.day),str2double(fileDate.hour));
0048
0049 end
0050
0051 maxEstimateMJD = max(estimateMJDs);
0052
0053
0054
0055
0056
0057 lastLoadMJD = lastAlphaValue();
0058
0059 maxAlphaMJD = lastLoadMJD - 1.9 / 24;
0060
0061
0062
0063 disp(' Your input arguments have been modified/rounded as follows:');
0064
0065
0066
0067
0068 if startMJD == -Inf
0069 startMJD = maxEstimateMJD + 1/12;
0070 else
0071 startMJD = floor(startMJD * 12 + 0.1) / 12;
0072 end
0073
0074 if endMJD > maxAlphaMJD
0075 endMJD = floor(maxAlphaMJD * 12) / 12;
0076 else
0077 endMJD = floor(endMJD * 12 + 0.1) / 12;
0078 end
0079
0080 disp([' - Your calculation range is ' mjd2string(startMJD) ' to ' mjd2string(endMJD)]);
0081
0082 if endMJD <= startMJD+0.1/12
0083 disp('WARNING: Your endTime is not after your startTime.');
0084 disp(' You will not calculate any new estimates.');
0085 end
0086
0087
0088
0089
0090
0091 if min(startMJD,startPlotMJD) > min(templateMJDs)
0092 startPlotMJD = max(templateMJDs((min(startMJD,startPlotMJD) - templateMJDs) >= 0));
0093 else
0094 startPlotMJD = min(startMJD,min(estimateMJDs));
0095 end
0096
0097 if endPlotMJD < Inf
0098 if endPlotMJD > max(templateMJDs) && endMJD > max(templateMJDs)
0099 endPlotMJD = endMJD;
0100 else
0101 endPlotMJD = min(templateMJDs((templateMJDs - max(endMJD,endPlotMJD)) >= 0));
0102 end
0103 else
0104 endPlotMJD = max(endMJD,templateMJDs(end));
0105 end
0106
0107 disp([' - Your plotting range is ' mjd2string(startPlotMJD) ' to ' mjd2string(endPlotMJD)]);
0108
0109 if endPlotMJD <= startPlotMJD
0110 error('WARNING: Your plotting range makes no sense.');
0111 end
0112
0113
0114 disp(' ');
0115
0116 end