0001 function [success, measure, idx, sigma] = checkDataIntegrity(measure, idx, sigma, nbus)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 verbose = 2;
0019
0020 success = 1;
0021 nowarning = 1;
0022
0023
0024
0025 if length(measure.PF) ~= length(idx.idx_zPF)
0026 fprintf('Warning: measurement vector and index vector for PF do not have the same length. The longer vector will be truncated.\n');
0027 min_len = min(length(measure.PF), length(idx.idx_zPF));
0028 measure.PF = measure.PF(1:min_len);
0029 idx.idx_zPF = idx.idx_zPF(1:min_len);
0030 nowarning = 0;
0031 end
0032 if ~isempty(idx.idx_zPF) && length(sigma.sigma_PF) <= 0
0033 fprintf('Error: Sigma for PF is not specified.\n');
0034 success = 0;
0035 end
0036 if length(sigma.sigma_PF) > 1
0037 fprintf('Warning: Sigma for PF is assigned multiple values. The first value will be used.\n');
0038 sigma.sigma_PF = sigma.sigma_PF(1);
0039 nowarning = 0;
0040 end
0041
0042
0043 if length(measure.PT) ~= length(idx.idx_zPT)
0044 fprintf('Warning: measurement vector and index vector for PT do not have the same length. The longer vector will be truncated.\n');
0045 min_len = min(length(measure.PT), length(idx.idx_zPT));
0046 measure.PT = measure.PT(1:min_len);
0047 idx.idx_zPT = idx.idx_zPT(1:min_len);
0048 nowarning = 0;
0049 end
0050 if ~isempty(idx.idx_zPT) && length(sigma.sigma_PT) <= 0
0051 fprintf('Error: Sigma for PT is not specified.\n');
0052 success = 0;
0053 end
0054 if length(sigma.sigma_PT) > 1
0055 fprintf('Warning: Sigma for PT is assigned multiple values. The first value will be used.\n');
0056 sigma.sigma_PT = sigma.sigma_PT(1);
0057 nowarning = 0;
0058 end
0059
0060
0061 if length(measure.PG) ~= length(idx.idx_zPG)
0062 fprintf('Warning: measurement vector and index vector for PG do not have the same length. The longer vector will be truncated.\n');
0063 min_len = min(length(measure.PG), length(idx.idx_zPG));
0064 measure.PG = measure.PG(1:min_len);
0065 idx.idx_zPG = idx.idx_zPG(1:min_len);
0066 nowarning = 0;
0067 end
0068 if ~isempty(idx.idx_zPG) && length(sigma.sigma_PG) <= 0
0069 fprintf('Error: Sigma for PG is not specified.\n');
0070 success = 0;
0071 end
0072 if length(sigma.sigma_PG) > 1
0073 fprintf('Warning: Sigma for PG is assigned multiple values. The first value will be used.\n');
0074 sigma.sigma_PG = sigma.sigma_PG(1);
0075 nowarning = 0;
0076 end
0077
0078
0079 if length(measure.Va) ~= length(idx.idx_zVa)
0080 fprintf('Warning: measurement vector and index vector for Va do not have the same length. The longer vector will be truncated.\n');
0081 min_len = min(length(measure.Va), length(idx.idx_zVa));
0082 measure.Va = measure.Va(1:min_len);
0083 idx.idx_zVa = idx.idx_zVa(1:min_len);
0084 nowarning = 0;
0085 end
0086 if ~isempty(idx.idx_zVa) && length(sigma.sigma_Va) <= 0
0087 fprintf('Error: Sigma for Va is not specified.\n');
0088 success = 0;
0089 end
0090 if length(sigma.sigma_Va) > 1
0091 fprintf('Warning: Sigma for Va is assigned multiple values. The first value will be used.\n');
0092 sigma.sigma_Va = sigma.sigma_Va(1);
0093 nowarning = 0;
0094 end
0095
0096
0097 if length(measure.QF) ~= length(idx.idx_zQF)
0098 fprintf('Warning: measurement vector and index vector for QF do not have the same length. The longer vector will be truncated.\n');
0099 min_len = min(length(measure.QF), length(idx.idx_zQF));
0100 measure.QF = measure.QF(1:min_len);
0101 idx.idx_zQF = idx.idx_zQF(1:min_len);
0102 nowarning = 0;
0103 end
0104 if ~isempty(idx.idx_zQF) && length(sigma.sigma_QF) <= 0
0105 fprintf('Error: Sigma for QF is not specified.\n');
0106 success = 0;
0107 end
0108 if length(sigma.sigma_QF) > 1
0109 fprintf('Warning: Sigma for QF is assigned multiple values. The first value will be used.\n');
0110 sigma.sigma_QF = sigma.sigma_QF(1);
0111 nowarning = 0;
0112 end
0113
0114
0115 if length(measure.QT) ~= length(idx.idx_zQT)
0116 fprintf('Warning: measurement vector and index vector for QT do not have the same length. The longer vector will be truncated.\n');
0117 min_len = min(length(measure.QT), length(idx.idx_zQT));
0118 measure.QT = measure.QT(1:min_len);
0119 idx.idx_zQT = idx.idx_zQT(1:min_len);
0120 nowarning = 0;
0121 end
0122 if ~isempty(idx.idx_zQT) && length(sigma.sigma_QT) <= 0
0123 fprintf('Error: Sigma for QT is not specified.\n');
0124 success = 0;
0125 end
0126 if length(sigma.sigma_QT) > 1
0127 fprintf('Warning: Sigma for QT is assigned multiple values. The first value will be used.\n');
0128 sigma.sigma_QT = sigma.sigma_QT(1);
0129 nowarning = 0;
0130 end
0131
0132
0133 if length(measure.QG) ~= length(idx.idx_zQG)
0134 fprintf('Warning: measurement vector and index vector for QG do not have the same length. The longer vector will be truncated.\n');
0135 min_len = min(length(measure.QG), length(idx.idx_zQG));
0136 measure.QG = measure.QG(1:min_len);
0137 idx.idx_zQG = idx.idx_zQG(1:min_len);
0138 nowarning = 0;
0139 end
0140 if ~isempty(idx.idx_zQG) && length(sigma.sigma_QG) <= 0
0141 fprintf('Error: Sigma for QG is not specified.\n');
0142 success = 0;
0143 end
0144 if length(sigma.sigma_QG) > 1
0145 fprintf('Warning: Sigma for QG is assigned multiple values. The first value will be used.\n');
0146 sigma.sigma_QG = sigma.sigma_QG(1);
0147 nowarning = 0;
0148 end
0149
0150
0151 if length(measure.Vm) ~= length(idx.idx_zVm)
0152 fprintf('Warning: measurement vector and index vector for Vm do not have the same length. The longer vector will be truncated.\n');
0153 min_len = min(length(measure.Vm), length(idx.idx_zVm));
0154 measure.Vm = measure.Vm(1:min_len);
0155 idx.idx_zVm = idx.idx_zVm(1:min_len);
0156 nowarning = 0;
0157 end
0158 if ~isempty(idx.idx_zVm) && length(sigma.sigma_Vm) <= 0
0159 fprintf('Error: Sigma for Vm is not specified.\n');
0160 success = 0;
0161 end
0162 if length(sigma.sigma_Vm) > 1
0163 fprintf('Warning: Sigma for Vm is assigned multiple values. The first value will be used.\n');
0164 sigma.sigma_Vm = sigma.sigma_Vm(1);
0165 nowarning = 0;
0166 end
0167
0168
0169 if success && ~nowarning
0170 fprintf('Press any key to continue...\n');
0171 pause;
0172 end
0173
0174
0175
0176 allMeasure = [
0177 measure.PF
0178 measure.PT
0179 measure.PG
0180 measure.Va
0181 measure.QF
0182 measure.QT
0183 measure.QG
0184 measure.Vm
0185 ];
0186 if length(allMeasure) < 2*(nbus - 1)
0187 fprintf('Error: There are less measurements (%d) than number of variables to be estimated (%d).\n', length(allMeasure), 2*(nbus - 1));
0188 success = 0;
0189 end