Home > fvcom_prepro > write_FVCOM_stations.m

write_FVCOM_stations

PURPOSE ^

Add a set of stations at which FVCOM will output wave data.

SYNOPSIS ^

function [Mobj] = write_FVCOM_stations(Mobj,filename)

DESCRIPTION ^

 Add a set of stations at which FVCOM will output wave data.

 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.

==========================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005