


Parse the POLCOMS rivers data file.
get_POLCOMS_rivers(Mobj, polcoms_file, polcoms_grid, polcoms_ij)
DESCRIPTION:
Takes POLCOMS grid and index files and returns the positions and names
of the rivers within the index file.
INPUT:
Mobj - MATLAB mesh object into which the outputs will be added.
polcoms_flow - flow data file(s) from POLCOMS. For multiple files, give
in chronological order as a cell array of file names.
OUTPUT:
Mobj.river_discharge - array of discharges for the rivers in the
POLCOMS river flow file(s).
EXAMPLE USAGE:
Mobj = get_POLCOMS_river_discharge(Mobj, 'polcoms.flw')
Author(s):
Pierre Cazenave (Plymouth Marine Laboratory)
Revision history:
2013-04-15 - First version from the original get_POLCOMS_rivers.m.
2014-05-20 Set boolean flag to true to indicate rivers and add number
of rivers.
==========================================================================

0001 function Mobj = get_POLCOMS_river_discharge(Mobj, polcoms_flow) 0002 % Parse the POLCOMS rivers data file. 0003 % 0004 % get_POLCOMS_rivers(Mobj, polcoms_file, polcoms_grid, polcoms_ij) 0005 % 0006 % DESCRIPTION: 0007 % Takes POLCOMS grid and index files and returns the positions and names 0008 % of the rivers within the index file. 0009 % 0010 % INPUT: 0011 % Mobj - MATLAB mesh object into which the outputs will be added. 0012 % polcoms_flow - flow data file(s) from POLCOMS. For multiple files, give 0013 % in chronological order as a cell array of file names. 0014 % 0015 % OUTPUT: 0016 % Mobj.river_discharge - array of discharges for the rivers in the 0017 % POLCOMS river flow file(s). 0018 % 0019 % EXAMPLE USAGE: 0020 % Mobj = get_POLCOMS_river_discharge(Mobj, 'polcoms.flw') 0021 % 0022 % Author(s): 0023 % Pierre Cazenave (Plymouth Marine Laboratory) 0024 % 0025 % Revision history: 0026 % 2013-04-15 - First version from the original get_POLCOMS_rivers.m. 0027 % 2014-05-20 Set boolean flag to true to indicate rivers and add number 0028 % of rivers. 0029 % 0030 %========================================================================== 0031 0032 subname = 'get_POLCOMS_river_discharge'; 0033 0034 global ftbverbose; 0035 if ftbverbose 0036 fprintf(['\nbegin : ' subname '\n']) 0037 end 0038 0039 % Check inputs 0040 if exist(polcoms_flow, 'file') ~= 2 0041 error('file: %s does not exist or is not readable.', polcoms_grid) 0042 end 0043 0044 % The POLCOMS river file has a pretty straightforward format of a 2D array 0045 % of river along x and time along y. Since it's a simple text file with no 0046 % weird format, we'll just read it in with load. 0047 if iscell(polcoms_flow) 0048 pc_riv = []; 0049 for rr = 1:length(polcoms_flow) 0050 pc_riv = [pc_riv; load(polcoms_flow{rr})]; 0051 end 0052 clear rr 0053 else 0054 pc_riv = load(polcoms_flow); 0055 end 0056 [pc_nt, pc_nr] = size(pc_riv); 0057 0058 % Return the number of river and the number of times along with the actual 0059 % discharge data. 0060 Mobj.rivers.num = pc_nr; 0061 Mobj.rivers.num_time = pc_nt; 0062 Mobj.rivers.discharge = pc_riv; 0063 0064 Mobj.have_rivers = true; 0065 Mobj.nRivers = pc_nr; 0066 0067 if ftbverbose 0068 fprintf(['end : ' subname '\n']) 0069 end