Home > fvcom_prepro > set_spectide.m

set_spectide

PURPOSE ^

Setup spectral tides on the open boundary and dump a spectral file

SYNOPSIS ^

function set_spectide(Mobj,nComps,SpectralFile,MyTitle)

DESCRIPTION ^

 Setup spectral tides on the open boundary and dump a spectral file

 function set_spectide(Mobj,nComps,SpectralFile,MyTitle)

 DESCRIPTION:
    Setup spectral tides on the open boundary and dump a spectral file

 INPUT
    Mobj         = Matlab mesh object with fields:
        Components = names of tidal constituents (e.g. M2).
        nObs       = number of open boundaries
        nObcNodes  = number of open boundary nodes
        obc_nodes  = open boundary node IDs
        period_obc = periods of tides at the open boundary nodes
        beta_love  = beta Love numbers of tides at the open boundary nodes
        equilibrium_amp = equilibrium amplitudes of tides at the open
                   boundary nodes
        amp_obc    = amplitude at the open boundary nodes
        phase_obc  = phase at the open boundary nodes
    nComps       = Number of tidal components
    SpectralFile = Output file name
    MyTitle      = Title in resulting NetCDF file.

 OUTPUT:

 EXAMPLE USAGE
    set_spectide(Mobj,nComps,SpectralFile,MyTitle)

 Author(s):
    Geoff Cowles (University of Massachusetts Dartmouth)
    Pierre Cazenave (Plymouth Marine Laboratory)

 Revision history
    2012-06-15 Added support for variables when calling set_spectide.
    2012-08-02 Can now write out equilibrium amplitudes and beta love
    numbers.
    2016-02-198 Clean up the help a bit.

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function set_spectide(Mobj,nComps,SpectralFile,MyTitle)
0002 % Setup spectral tides on the open boundary and dump a spectral file
0003 %
0004 % function set_spectide(Mobj,nComps,SpectralFile,MyTitle)
0005 %
0006 % DESCRIPTION:
0007 %    Setup spectral tides on the open boundary and dump a spectral file
0008 %
0009 % INPUT
0010 %    Mobj         = Matlab mesh object with fields:
0011 %        Components = names of tidal constituents (e.g. M2).
0012 %        nObs       = number of open boundaries
0013 %        nObcNodes  = number of open boundary nodes
0014 %        obc_nodes  = open boundary node IDs
0015 %        period_obc = periods of tides at the open boundary nodes
0016 %        beta_love  = beta Love numbers of tides at the open boundary nodes
0017 %        equilibrium_amp = equilibrium amplitudes of tides at the open
0018 %                   boundary nodes
0019 %        amp_obc    = amplitude at the open boundary nodes
0020 %        phase_obc  = phase at the open boundary nodes
0021 %    nComps       = Number of tidal components
0022 %    SpectralFile = Output file name
0023 %    MyTitle      = Title in resulting NetCDF file.
0024 %
0025 % OUTPUT:
0026 %
0027 % EXAMPLE USAGE
0028 %    set_spectide(Mobj,nComps,SpectralFile,MyTitle)
0029 %
0030 % Author(s):
0031 %    Geoff Cowles (University of Massachusetts Dartmouth)
0032 %    Pierre Cazenave (Plymouth Marine Laboratory)
0033 %
0034 % Revision history
0035 %    2012-06-15 Added support for variables when calling set_spectide.
0036 %    2012-08-02 Can now write out equilibrium amplitudes and beta love
0037 %    numbers.
0038 %    2016-02-198 Clean up the help a bit.
0039 %
0040 %==============================================================================
0041 subname = 'set_spectide';
0042 global ftbverbose;
0043 if ftbverbose
0044     fprintf('\nbegin : %s\n', subname)
0045 end
0046 
0047 %------------------------------------------------------------------------------
0048 % Set Component Periods
0049 %------------------------------------------------------------------------------
0050 % Components = {   'M2',    'N2',    'S2',   'O1',    'K1'};
0051 % Period     = [44714.16, 45570.05, 43200, 92949.63, 86164.09];
0052 
0053 %------------------------------------------------------------------------------
0054 % Setup user defined phase and amplitude along the open boundaries
0055 % need to set:
0056 %   1.) Period - vector containing component period in seconds
0057 %   2.) Amp    - array of size [Nobcs, Ncomponents] containing amplitude in m
0058 %   3.) Phase  - array of size [Nobcs, Ncomponents] containing phase in degrees
0059 %------------------------------------------------------------------------------
0060 if nComps > numel(Mobj.Components)
0061     error('Too few components given in Mobj. Check and try again.')
0062 end
0063 
0064 if(Mobj.nObs==0)
0065     warning('cannot setup spectral open boundary, there is no open boundary in the mesh struct')
0066     return
0067 end
0068 
0069 cnt = 0;
0070 Amp = nan(sum(Mobj.nObcNodes),nComps);
0071 Phase = nan(sum(Mobj.nObcNodes),nComps);
0072 ObcNodes = nan(1,sum(Mobj.nObcNodes));
0073 for ob=1:Mobj.nObs
0074     nObcs = Mobj.nObcNodes(ob);
0075     for j=1:nObcs
0076         cnt = cnt + 1;
0077         ObcNodes(cnt) = Mobj.obc_nodes(ob,j);  % set the open boundary nodes
0078 
0079         Amp(cnt,:) = Mobj.amp_obc{ob}(:,j);
0080         Phase(cnt,:) = Mobj.phase_obc{ob}(:,j);
0081     end
0082 end
0083 
0084 %------------------------------------------------------------------------------
0085 % Dump a spectral tide file in NetCDF
0086 %------------------------------------------------------------------------------
0087 %write_FVCOM_spectide(ObcNodes,Mobj.period_obc(1:nComps),Phase,Amp,Mobj.beta_love,Mobj.equilibrium_amp,SpectralFile,MyTitle)
0088 write_FVCOM_spectide(ObcNodes,Mobj.Components,Mobj.period_obc(1:nComps),Phase,Amp,Mobj.beta_love,Mobj.equilibrium_amp,SpectralFile,MyTitle)
0089 if(ftbverbose); fprintf(['end   : ' subname '\n']); end

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