Home > mrg > MRG_MIKE > mrg_PFS_keywords.m

mrg_PFS_keywords

PURPOSE ^

Reads all the ecolab, m21fm and plc files in a directory and returns the [header] keywords

SYNOPSIS ^

function keywords = mrg_PFS_keywords

DESCRIPTION ^

 Reads all the ecolab, m21fm and plc files in a directory and returns the [header] keywords

 INPUT
   None. The user is prompted to select a directory which can be the DHI
   installation directory or any folder with a whole heap of PFS formatted
   files from which to extract the keywords.  

 OUTPUT
   keywords    A MATLAB structure with fields:
                   variable_len: PFS keywords which might be variable in
                   length (e.g. STATE_VARIABLE_X; where X is an integer)
                   fixed_len: PFS keywords which are probably not variable
                   in length (e.g. ECO_LAB_SETUP)

 NOTES
   This can be called directly, if needed, but it is designed to work
   alongside mrg_create_npp_langdef.m

 AUTHORS
   Daniel Pritchard

 LICENCE
   Code distributed as part of the MRG toolbox from the Marine Research
   Group at Queens Univeristy Belfast (QUB) School of Planning
   Architecture and Civil Engineering (SPACE). Distributed under a
   creative commons CC BY-SA licence, retaining full copyright of the
   original authors.

   http://creativecommons.org/licenses/by-sa/3.0/
   http://www.qub.ac.uk/space/
   http://www.qub.ac.uk/research-centres/eerc/

 DEVELOPMENT
   v 1.0   2013-09-16
           First version. DP

 TODO
   Allow variable extensions at run time.

% Function Begin!

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function keywords = mrg_PFS_keywords
0002 % Reads all the ecolab, m21fm and plc files in a directory and returns the [header] keywords
0003 %
0004 % INPUT
0005 %   None. The user is prompted to select a directory which can be the DHI
0006 %   installation directory or any folder with a whole heap of PFS formatted
0007 %   files from which to extract the keywords.
0008 %
0009 % OUTPUT
0010 %   keywords    A MATLAB structure with fields:
0011 %                   variable_len: PFS keywords which might be variable in
0012 %                   length (e.g. STATE_VARIABLE_X; where X is an integer)
0013 %                   fixed_len: PFS keywords which are probably not variable
0014 %                   in length (e.g. ECO_LAB_SETUP)
0015 %
0016 % NOTES
0017 %   This can be called directly, if needed, but it is designed to work
0018 %   alongside mrg_create_npp_langdef.m
0019 %
0020 % AUTHORS
0021 %   Daniel Pritchard
0022 %
0023 % LICENCE
0024 %   Code distributed as part of the MRG toolbox from the Marine Research
0025 %   Group at Queens Univeristy Belfast (QUB) School of Planning
0026 %   Architecture and Civil Engineering (SPACE). Distributed under a
0027 %   creative commons CC BY-SA licence, retaining full copyright of the
0028 %   original authors.
0029 %
0030 %   http://creativecommons.org/licenses/by-sa/3.0/
0031 %   http://www.qub.ac.uk/space/
0032 %   http://www.qub.ac.uk/research-centres/eerc/
0033 %
0034 % DEVELOPMENT
0035 %   v 1.0   2013-09-16
0036 %           First version. DP
0037 %
0038 % TODO
0039 %   Allow variable extensions at run time.
0040 %
0041 %% Function Begin!
0042 folder_name = uigetdir('C:/', 'Please select the DHI installation directory');
0043 fileList = mrg_oswalk(folder_name);
0044 
0045 x1 = regexp(fileList, '.*\.ecolab$', 'match');
0046 y1 = x1(~cellfun('isempty',x1));
0047 
0048 x2 = regexp(fileList, '.*\.m21fm$', 'match');
0049 y2 = x2(~cellfun('isempty',x2));
0050 
0051 x3 = regexp(fileList, '.*\.plc$', 'match');
0052 y3 = x3(~cellfun('isempty',x3));
0053 
0054 a1 = [y1;y2;y3];
0055 
0056 allout = {};
0057 for a = 1:length(a1)
0058     text = fileread(char(a1{a}));
0059     matches = regexp(text, '\[(\w+)\]\s+', 'tokens');
0060     allout = [allout;matches.'];
0061 end
0062 
0063 varlen = regexp([allout{:}].', '(\w+_)\d+', 'tokens');
0064 index = ~cellfun('isempty',varlen);
0065 
0066 varlen = varlen(index);
0067 varlen = [varlen{:}];
0068 
0069 notvarlen = allout(~index);
0070 
0071 varlenout = unique([varlen{:}]);
0072 notvarlenout = unique([notvarlen{:}]);
0073 
0074 keywords = struct();
0075 keywords.variable_len = varlenout;
0076 keywords.fixed_len = notvarlenout;
0077 end

Generated on Thu 29-May-2014 21:29:53 by m2html © 2005