Home > matpower5.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-2015 by Power System Engineering Research Center (PSERC)
0011 %   by Rui Bo
0012 %
0013 %   $Id: checkDataIntegrity.m 2644 2015-03-11 19:34:22Z ray $
0014 %
0015 %   This file is part of MATPOWER.
0016 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0017 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0018 
0019 %% options
0020 verbose = 2;
0021 
0022 success     = 1;    % pass integrity check?
0023 nowarning   = 1;    % no warning found?
0024 
0025 %% check input data consistency
0026 % for PF
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 % no sigma defined
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 % for PT
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 % no sigma defined
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 % for PG
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 % no sigma defined
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 % for Va
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 % no sigma defined
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 % for QF
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 % no sigma defined
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 % for QT
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 % no sigma defined
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 % for QG
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 % no sigma defined
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 % for Vm
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 % no sigma defined
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 % pause when warnings are present
0171 if success && ~nowarning
0172     fprintf('Press any key to continue...\n');
0173     pause;
0174 end
0175 
0176 %% check if total number of measurements is no less than total number of
0177 %% variables to be estimated
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

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005