


Add a set of stations at which FVCOM will output time series.
function write_FVCOM_stations(Mobj,filename)
DESCRIPTION:
Given a mesh object with time series positions and names
(Mobj.Position and Mobj.Names from add_stations_list.m), write out to
ASCII file filename.
INPUT
Mobj = Matlab mesh object
filename = FVCOM stations file name
OUTPUT:
FVCOM stations file: filename
EXAMPLE USAGE
write_FVCOM_stations(Mobj, 'tst_stations.dat')
Author(s):
Pierre Cazenave (Plymouth Marine Laboratory)
Revision history
2012-11-30 First version.
==========================================================================

0001 function [Mobj] = write_FVCOM_stations(Mobj,filename) 0002 0003 % Add a set of stations at which FVCOM will output time series. 0004 % 0005 % function write_FVCOM_stations(Mobj,filename) 0006 % 0007 % DESCRIPTION: 0008 % Given a mesh object with time series positions and names 0009 % (Mobj.Position and Mobj.Names from add_stations_list.m), write out to 0010 % ASCII file filename. 0011 % 0012 % INPUT 0013 % Mobj = Matlab mesh object 0014 % filename = FVCOM stations file name 0015 % 0016 % OUTPUT: 0017 % FVCOM stations file: filename 0018 % 0019 % EXAMPLE USAGE 0020 % write_FVCOM_stations(Mobj, 'tst_stations.dat') 0021 % 0022 % Author(s): 0023 % Pierre Cazenave (Plymouth Marine Laboratory) 0024 % 0025 % Revision history 0026 % 2012-11-30 First version. 0027 % 0028 %========================================================================== 0029 subname = 'write_FVCOM_stations'; 0030 global ftbverbose 0031 if(ftbverbose) 0032 fprintf('\n'); fprintf(['begin : ' subname '\n']); 0033 end 0034 0035 %-------------------------------------------------------------------------- 0036 % Parse input arguments 0037 %-------------------------------------------------------------------------- 0038 if exist('Mobj', 'var') ~= 1 || exist('filename', 'var') ~= 1 0039 error('arguments to write_FVCOM_grid are incorrect') 0040 end 0041 0042 %-------------------------------------------------------------------------- 0043 % Dump the file 0044 %-------------------------------------------------------------------------- 0045 if strcmpi(Mobj.nativeCoords, 'cartesian') 0046 x = Mobj.Positions(:,3); 0047 y = Mobj.Positions(:,4); 0048 elseif strcmpi(Mobj.nativeCoords, 'spherical') 0049 x = Mobj.Positions(:,1); 0050 y = Mobj.Positions(:,2); 0051 else 0052 error('Unknown native coordinate system string: %s', Mobj.nativeCoords) 0053 end 0054 0055 if(ftbverbose) 0056 fprintf('writing FVCOM gridfile %s\n',filename); 0057 end 0058 0059 fid = fopen(filename,'w'); 0060 fprintf(fid, ' No X Y Node (Cell) Station Name\n'); 0061 0062 for s=1:length(Mobj.stations) 0063 fprintf(fid, '%i %f %f %i %f %s\n', cell2mat(Mobj.stations{s}(1:5)), char(Mobj.stations{s}(6))); 0064 end 0065 0066 fclose(fid); 0067 0068 if(ftbverbose) 0069 fprintf(['end : ' subname '\n']) 0070 end 0071