PSSE2MPC Converts a PSS/E RAW data file into a MATPOWER case struct. MPC = PSSE2MPC(RAWFILE_NAME) MPC = PSSE2MPC(RAWFILE_NAME, VERBOSE) MPC = PSSE2MPC(RAWFILE_NAME, VERBOSE, REV) MPC = PSSE2MPC(RAWFILE_NAME, MPC_NAME) MPC = PSSE2MPC(RAWFILE_NAME, MPC_NAME, VERBOSE) MPC = PSSE2MPC(RAWFILE_NAME, MPC_NAME, VERBOSE, REV) [MPC, WARNINGS] = PSSE2MPC(RAWFILE_NAME, ...) Converts a PSS/E RAW data file into a MATPOWER case struct. Input: RAWFILE_NAME : name of the PSS/E RAW file to be converted (opened directly with FILEREAD) MPC_NAME : (optional) file name to use to save the resulting MATPOWER case VERBOSE : 1 (default) to display progress info, 0 otherwise REV : (optional) assume the input file is of this PSS/E revision number, attempts to determine REV from the file by default Output(s): MPC : resulting MATPOWER case struct WARNINGS : (optional) cell array of strings containing warning messages (included by default in comments of MPC_NAME). NOTE: The data sections to be read in the PSS/E raw file includes: identification data; bus data; branch data; fixed shunt data; generator data; transformer data; switched shunt data; area data and hvdc line data. Other data sections are currently ignored.
0001 function [mpc, warnings] = psse2mpc(rawfile_name, mpc_name, verbose, rev) 0002 %PSSE2MPC Converts a PSS/E RAW data file into a MATPOWER case struct. 0003 % MPC = PSSE2MPC(RAWFILE_NAME) 0004 % MPC = PSSE2MPC(RAWFILE_NAME, VERBOSE) 0005 % MPC = PSSE2MPC(RAWFILE_NAME, VERBOSE, REV) 0006 % MPC = PSSE2MPC(RAWFILE_NAME, MPC_NAME) 0007 % MPC = PSSE2MPC(RAWFILE_NAME, MPC_NAME, VERBOSE) 0008 % MPC = PSSE2MPC(RAWFILE_NAME, MPC_NAME, VERBOSE, REV) 0009 % [MPC, WARNINGS] = PSSE2MPC(RAWFILE_NAME, ...) 0010 % 0011 % Converts a PSS/E RAW data file into a MATPOWER case struct. 0012 % 0013 % Input: 0014 % RAWFILE_NAME : name of the PSS/E RAW file to be converted 0015 % (opened directly with FILEREAD) 0016 % MPC_NAME : (optional) file name to use to save the resulting 0017 % MATPOWER case 0018 % VERBOSE : 1 (default) to display progress info, 0 otherwise 0019 % REV : (optional) assume the input file is of this 0020 % PSS/E revision number, attempts to determine 0021 % REV from the file by default 0022 % 0023 % Output(s): 0024 % MPC : resulting MATPOWER case struct 0025 % WARNINGS : (optional) cell array of strings containing warning 0026 % messages (included by default in comments of MPC_NAME). 0027 % 0028 % NOTE: The data sections to be read in the PSS/E raw file includes: 0029 % identification data; bus data; branch data; fixed shunt data; 0030 % generator data; transformer data; switched shunt data; area data 0031 % and hvdc line data. Other data sections are currently ignored. 0032 0033 % MATPOWER 0034 % $Id: psse2mpc.m 2441 2014-12-05 16:08:31Z ray $ 0035 % by Yujia Zhu, PSERC ASU 0036 % and Ray Zimmerman, PSERC Cornell 0037 % Based on mpraw2mp.m, written by: Yujia Zhu, Jan 2014, yzhu54@asu.edu. 0038 % Copyright (c) 2014 by Power System Engineering Research Center (PSERC) 0039 % 0040 % This file is part of MATPOWER. 0041 % See http://www.pserc.cornell.edu/matpower/ for more info. 0042 % 0043 % MATPOWER is free software: you can redistribute it and/or modify 0044 % it under the terms of the GNU General Public License as published 0045 % by the Free Software Foundation, either version 3 of the License, 0046 % or (at your option) any later version. 0047 % 0048 % MATPOWER is distributed in the hope that it will be useful, 0049 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0050 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0051 % GNU General Public License for more details. 0052 % 0053 % You should have received a copy of the GNU General Public License 0054 % along with MATPOWER. If not, see <http://www.gnu.org/licenses/>. 0055 % 0056 % Additional permission under GNU GPL version 3 section 7 0057 % 0058 % If you modify MATPOWER, or any covered work, to interface with 0059 % other modules (such as MATLAB code and MEX-files) available in a 0060 % MATLAB(R) or comparable environment containing parts covered 0061 % under other licensing terms, the licensors of MATPOWER grant 0062 % you additional permission to convey the resulting work. 0063 0064 %% handle input args 0065 if nargin < 2 0066 rev = 0; 0067 verbose = 1; 0068 mpc_name = ''; 0069 elseif ischar(mpc_name) %% save the file 0070 if nargin < 4 0071 rev = 0; 0072 if nargin < 3 0073 verbose = 1; 0074 end 0075 elseif isempty(rev) 0076 rev = 0; 0077 end 0078 else %% don't save the file 0079 if nargin < 3 0080 rev = 0; 0081 else 0082 rev = verbose; 0083 end 0084 verbose = mpc_name; 0085 mpc_name = ''; 0086 end 0087 0088 %% read data from PSS/E RAW file 0089 [records, sections] = psse_read(rawfile_name, verbose); 0090 0091 %% parse data 0092 [data, warnings] = psse_parse(records, sections, verbose, rev); 0093 0094 %% convert to MATPOWER case file 0095 [mpc, warnings] = psse_convert(warnings, data, verbose); 0096 0097 %% (optionally) save MATPOWER case file 0098 if ~isempty(mpc_name) 0099 if ~rev 0100 rev = data.id.REV; 0101 end 0102 comments = {''}; 0103 for k = 0:2 0104 str = data.id.(sprintf('comment%d', k)); 0105 if ~isempty(str) 0106 comments{end+1} = sprintf(' %s', str); 0107 end 0108 end 0109 comments{end+1} = ''; 0110 comments{end+1} = sprintf(' Converted by MATPOWER %s using PSSE2MPC on %s', mpver, date); 0111 comments{end+1} = sprintf(' from ''%s'' using PSS/E rev %d format.', rawfile_name, rev); 0112 0113 %% warnings 0114 comments{end+1} = ''; 0115 comments{end+1} = ' WARNINGS:'; 0116 for k = 1:length(warnings) 0117 comments{end+1} = sprintf(' %s', warnings{k}); 0118 end 0119 comments{end+1} = ''; 0120 comments{end+1} = sprintf(' See CASEFORMAT for details on the MATPOWER case file format.'); 0121 0122 if verbose 0123 spacers = repmat('.', 1, 45-length(mpc_name)); 0124 fprintf('Saving to MATPOWER case ''%s'' %s', mpc_name, spacers); 0125 end 0126 savecase(mpc_name, comments, mpc); 0127 if verbose 0128 fprintf(' done.\n'); 0129 end 0130 end