Home > matpower7.1 > extras > se > checkDataIntegrity.m

checkDataIntegrity

PURPOSE ^

CHECKDATAINTEGRITY Check state estimation input data integrity.

SYNOPSIS ^

function [success, measure, idx, sigma] = checkDataIntegrity(measure, idx, sigma, nbus)

DESCRIPTION ^

CHECKDATAINTEGRITY  Check state estimation input data integrity.
   returns 1 if the data is complete, 0 otherwise.
   NOTE: for each type of measurements, the measurement vector and index
   vector should have the same length. If not, the longer vector will be
   truncated to have the same length as the shorter vector.
   created by Rui Bo on Jan 9, 2010

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [success, measure, idx, sigma] = checkDataIntegrity(measure, idx, sigma, nbus)
0002 %CHECKDATAINTEGRITY  Check state estimation input data integrity.
0003 %   returns 1 if the data is complete, 0 otherwise.
0004 %   NOTE: for each type of measurements, the measurement vector and index
0005 %   vector should have the same length. If not, the longer vector will be
0006 %   truncated to have the same length as the shorter vector.
0007 %   created by Rui Bo on Jan 9, 2010
0008 
0009 %   MATPOWER
0010 %   Copyright (c) 2009-2016, Power Systems Engineering Research Center (PSERC)
0011 %   by Rui Bo
0012 %
0013 %   This file is part of MATPOWER/mx-se.
0014 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0015 %   See https://github.com/MATPOWER/mx-se/ for more info.
0016 
0017 %% options
0018 verbose = 2;
0019 
0020 success     = 1;    % pass integrity check?
0021 nowarning   = 1;    % no warning found?
0022 
0023 %% check input data consistency
0024 % for PF
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 % no sigma defined
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 % for PT
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 % no sigma defined
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 % for PG
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 % no sigma defined
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 % for Va
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 % no sigma defined
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 % for QF
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 % no sigma defined
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 % for QT
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 % no sigma defined
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 % for QG
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 % no sigma defined
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 % for Vm
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 % no sigma defined
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 % pause when warnings are present
0169 if success && ~nowarning
0170     fprintf('Press any key to continue...\n');
0171     pause;
0172 end
0173 
0174 %% check if total number of measurements is no less than total number of
0175 %% variables to be estimated
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

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005