Home > matpower6.0 > psse2mpc.m

psse2mpc

PURPOSE ^

PSSE2MPC Converts a PSS/E RAW data file into a MATPOWER case struct.

SYNOPSIS ^

function [mpc, warnings] = psse2mpc(rawfile_name, mpc_name, verbose, rev)

DESCRIPTION ^

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.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 %   Copyright (c) 2014-2016, Power Systems Engineering Research Center (PSERC)
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 %
0039 %   This file is part of MATPOWER.
0040 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0041 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0042 
0043 %% handle input args
0044 if nargin < 2
0045     rev = 0;
0046     verbose = 1;
0047     mpc_name = '';
0048 elseif ischar(mpc_name)     %% save the file
0049     if nargin < 4
0050         rev = 0;
0051         if nargin < 3
0052             verbose = 1;
0053         end
0054     elseif isempty(rev)
0055         rev = 0;
0056     end
0057 else                        %% don't save the file
0058     if nargin < 3
0059         rev = 0;
0060     else
0061         rev = verbose;
0062     end
0063     verbose = mpc_name;
0064     mpc_name = '';
0065 end
0066 
0067 %% read data from PSS/E RAW file
0068 [records, sections] = psse_read(rawfile_name, verbose);
0069 
0070 %% parse data
0071 [data, warnings] = psse_parse(records, sections, verbose, rev);
0072 
0073 %% convert to MATPOWER case file
0074 [mpc, warnings] = psse_convert(warnings, data, verbose);
0075 
0076 %% (optionally) save MATPOWER case file
0077 if ~isempty(mpc_name)
0078     if ~rev
0079         rev = data.id.REV;
0080     end
0081     comments = {''};
0082     for k = 0:2
0083         str = data.id.(sprintf('comment%d', k));
0084         if ~isempty(str)
0085             comments{end+1} = sprintf('   %s', str);
0086         end
0087     end
0088     comments{end+1} = '';
0089     comments{end+1} = sprintf('   Converted by MATPOWER %s using PSSE2MPC on %s', mpver, date);
0090     comments{end+1} = sprintf('   from ''%s'' using PSS/E rev %d format.', rawfile_name, rev);
0091 
0092     %% warnings
0093     comments{end+1} = '';
0094     comments{end+1} = '   WARNINGS:';
0095     for k = 1:length(warnings)
0096         comments{end+1} = sprintf('       %s', warnings{k});
0097     end
0098     comments{end+1} = '';
0099     comments{end+1} = sprintf('   See CASEFORMAT for details on the MATPOWER case file format.');
0100 
0101     if verbose
0102         spacers = repmat('.', 1, 45-length(mpc_name));
0103         fprintf('Saving to MATPOWER case ''%s'' %s', mpc_name, spacers);
0104     end
0105     savecase(mpc_name, comments, mpc);
0106     if verbose
0107         fprintf(' done.\n');
0108     end
0109 end

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005