Home > matpower5.0 > 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 %   $Id: checkDataIntegrity.m 2229 2013-12-11 01:28:09Z ray $
0011 %   by Rui Bo
0012 %   Copyright (c) 2009-2010 by Rui Bo
0013 %
0014 %   This file is part of MATPOWER.
0015 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0016 %
0017 %   MATPOWER is free software: you can redistribute it and/or modify
0018 %   it under the terms of the GNU General Public License as published
0019 %   by the Free Software Foundation, either version 3 of the License,
0020 %   or (at your option) any later version.
0021 %
0022 %   MATPOWER is distributed in the hope that it will be useful,
0023 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0024 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0025 %   GNU General Public License for more details.
0026 %
0027 %   You should have received a copy of the GNU General Public License
0028 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0029 %
0030 %   Additional permission under GNU GPL version 3 section 7
0031 %
0032 %   If you modify MATPOWER, or any covered work, to interface with
0033 %   other modules (such as MATLAB code and MEX-files) available in a
0034 %   MATLAB(R) or comparable environment containing parts covered
0035 %   under other licensing terms, the licensors of MATPOWER grant
0036 %   you additional permission to convey the resulting work.
0037 
0038 %% options
0039 verbose = 2;
0040 
0041 success     = 1;    % pass integrity check?
0042 nowarning   = 1;    % no warning found?
0043 
0044 %% check input data consistency
0045 % for PF
0046 if length(measure.PF) ~= length(idx.idx_zPF)
0047     fprintf('Warning: measurement vector and index vector for PF do not have the same length. The longer vector will be truncated.\n');
0048     min_len = min(length(measure.PF), length(idx.idx_zPF));
0049     measure.PF  = measure.PF(1:min_len);
0050     idx.idx_zPF = idx.idx_zPF(1:min_len);
0051     nowarning = 0;
0052 end
0053 if ~isempty(idx.idx_zPF) && length(sigma.sigma_PF) <= 0 % no sigma defined
0054     fprintf('Error: Sigma for PF is not specified.\n');
0055     success = 0;
0056 end
0057 if length(sigma.sigma_PF) > 1
0058     fprintf('Warning: Sigma for PF is assigned multiple values. The first value will be used.\n');    
0059     sigma.sigma_PF = sigma.sigma_PF(1);
0060     nowarning = 0;
0061 end
0062 
0063 % for PT
0064 if length(measure.PT) ~= length(idx.idx_zPT)
0065     fprintf('Warning: measurement vector and index vector for PT do not have the same length. The longer vector will be truncated.\n');
0066     min_len = min(length(measure.PT), length(idx.idx_zPT));
0067     measure.PT  = measure.PT(1:min_len);
0068     idx.idx_zPT = idx.idx_zPT(1:min_len);
0069     nowarning = 0;
0070 end
0071 if ~isempty(idx.idx_zPT) && length(sigma.sigma_PT) <= 0 % no sigma defined
0072     fprintf('Error: Sigma for PT is not specified.\n');
0073     success = 0;
0074 end
0075 if length(sigma.sigma_PT) > 1
0076     fprintf('Warning: Sigma for PT is assigned multiple values. The first value will be used.\n');    
0077     sigma.sigma_PT = sigma.sigma_PT(1);
0078     nowarning = 0;
0079 end
0080 
0081 % for PG
0082 if length(measure.PG) ~= length(idx.idx_zPG)
0083     fprintf('Warning: measurement vector and index vector for PG do not have the same length. The longer vector will be truncated.\n');
0084     min_len = min(length(measure.PG), length(idx.idx_zPG));
0085     measure.PG  = measure.PG(1:min_len);
0086     idx.idx_zPG = idx.idx_zPG(1:min_len);
0087     nowarning = 0;
0088 end
0089 if ~isempty(idx.idx_zPG) && length(sigma.sigma_PG) <= 0 % no sigma defined
0090     fprintf('Error: Sigma for PG is not specified.\n');
0091     success = 0;
0092 end
0093 if length(sigma.sigma_PG) > 1
0094     fprintf('Warning: Sigma for PG is assigned multiple values. The first value will be used.\n');    
0095     sigma.sigma_PG = sigma.sigma_PG(1);
0096     nowarning = 0;
0097 end
0098 
0099 % for Va
0100 if length(measure.Va) ~= length(idx.idx_zVa)
0101     fprintf('Warning: measurement vector and index vector for Va do not have the same length. The longer vector will be truncated.\n');
0102     min_len = min(length(measure.Va), length(idx.idx_zVa));
0103     measure.Va  = measure.Va(1:min_len);
0104     idx.idx_zVa = idx.idx_zVa(1:min_len);
0105     nowarning = 0;
0106 end
0107 if ~isempty(idx.idx_zVa) && length(sigma.sigma_Va) <= 0 % no sigma defined
0108     fprintf('Error: Sigma for Va is not specified.\n');
0109     success = 0;
0110 end
0111 if length(sigma.sigma_Va) > 1
0112     fprintf('Warning: Sigma for Va is assigned multiple values. The first value will be used.\n');    
0113     sigma.sigma_Va = sigma.sigma_Va(1);
0114     nowarning = 0;
0115 end
0116 
0117 % for QF
0118 if length(measure.QF) ~= length(idx.idx_zQF)
0119     fprintf('Warning: measurement vector and index vector for QF do not have the same length. The longer vector will be truncated.\n');
0120     min_len = min(length(measure.QF), length(idx.idx_zQF));
0121     measure.QF  = measure.QF(1:min_len);
0122     idx.idx_zQF = idx.idx_zQF(1:min_len);
0123     nowarning = 0;
0124 end
0125 if ~isempty(idx.idx_zQF) && length(sigma.sigma_QF) <= 0 % no sigma defined
0126     fprintf('Error: Sigma for QF is not specified.\n');
0127     success = 0;
0128 end
0129 if length(sigma.sigma_QF) > 1
0130     fprintf('Warning: Sigma for QF is assigned multiple values. The first value will be used.\n');    
0131     sigma.sigma_QF = sigma.sigma_QF(1);
0132     nowarning = 0;
0133 end
0134 
0135 % for QT
0136 if length(measure.QT) ~= length(idx.idx_zQT)
0137     fprintf('Warning: measurement vector and index vector for QT do not have the same length. The longer vector will be truncated.\n');
0138     min_len = min(length(measure.QT), length(idx.idx_zQT));
0139     measure.QT  = measure.QT(1:min_len);
0140     idx.idx_zQT = idx.idx_zQT(1:min_len);
0141     nowarning = 0;
0142 end
0143 if ~isempty(idx.idx_zQT) && length(sigma.sigma_QT) <= 0 % no sigma defined
0144     fprintf('Error: Sigma for QT is not specified.\n');
0145     success = 0;
0146 end
0147 if length(sigma.sigma_QT) > 1
0148     fprintf('Warning: Sigma for QT is assigned multiple values. The first value will be used.\n');    
0149     sigma.sigma_QT = sigma.sigma_QT(1);
0150     nowarning = 0;
0151 end
0152 
0153 % for QG
0154 if length(measure.QG) ~= length(idx.idx_zQG)
0155     fprintf('Warning: measurement vector and index vector for QG do not have the same length. The longer vector will be truncated.\n');
0156     min_len = min(length(measure.QG), length(idx.idx_zQG));
0157     measure.QG  = measure.QG(1:min_len);
0158     idx.idx_zQG = idx.idx_zQG(1:min_len);
0159     nowarning = 0;
0160 end
0161 if ~isempty(idx.idx_zQG) && length(sigma.sigma_QG) <= 0 % no sigma defined
0162     fprintf('Error: Sigma for QG is not specified.\n');
0163     success = 0;
0164 end
0165 if length(sigma.sigma_QG) > 1
0166     fprintf('Warning: Sigma for QG is assigned multiple values. The first value will be used.\n');    
0167     sigma.sigma_QG = sigma.sigma_QG(1);
0168     nowarning = 0;
0169 end
0170 
0171 % for Vm
0172 if length(measure.Vm) ~= length(idx.idx_zVm)
0173     fprintf('Warning: measurement vector and index vector for Vm do not have the same length. The longer vector will be truncated.\n');
0174     min_len = min(length(measure.Vm), length(idx.idx_zVm));
0175     measure.Vm  = measure.Vm(1:min_len);
0176     idx.idx_zVm = idx.idx_zVm(1:min_len);
0177     nowarning = 0;
0178 end
0179 if ~isempty(idx.idx_zVm) && length(sigma.sigma_Vm) <= 0 % no sigma defined
0180     fprintf('Error: Sigma for Vm is not specified.\n');
0181     success = 0;
0182 end
0183 if length(sigma.sigma_Vm) > 1
0184     fprintf('Warning: Sigma for Vm is assigned multiple values. The first value will be used.\n');    
0185     sigma.sigma_Vm = sigma.sigma_Vm(1);
0186     nowarning = 0;
0187 end
0188 
0189 % pause when warnings are present
0190 if success && ~nowarning
0191     fprintf('Press any key to continue...\n');
0192     pause;
0193 end
0194 
0195 %% check if total number of measurements is no less than total number of
0196 %% variables to be estimated
0197 allMeasure = [
0198                 measure.PF
0199                 measure.PT
0200                 measure.PG
0201                 measure.Va
0202                 measure.QF
0203                 measure.QT
0204                 measure.QG
0205                 measure.Vm    
0206                 ];
0207 if length(allMeasure) < 2*(nbus - 1)
0208     fprintf('Error: There are less measurements (%d) than number of variables to be estimated (%d).\n', length(allMeasure), 2*(nbus - 1));
0209     success = 0;
0210 end

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005