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