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

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