function p = wave_parameter(varargin)
%WAVE_PARAMETER  Set the parameters for the dispersion relation
%   P = WAVE_PARAMETER  returns the default parameters used for the
%   dispersion relation. P is a structure containing 4 fields. The default
%   values are those of an air-water interface under normal temperature and
%   pressure conditions, with infinite depth:
%     g = 9.81 m/s^2             gravity
%     gamma = 0.072 N/m          surface tension
%     rho = 1000 Kg/m3           density
%     h0 = inf m                 depth
%
%   P = WAVE_PARAMETER(P) returns the same parameters as those given
%   in the input argument P, and fills the missing fields by the default
%   ones.
%
%   P = WAVE_PARAMETER('gamma',G,'rho',r,...) sets the values for the
%   specified fields, and fills the missing fields by the default ones.
%
%   P = WAVE_PARAMETER(P,'gamma',G,'rho',r,...) combines the two previous
%   syntax.
%
%   Example:
%     p = wave_parameter('gamma',0.06);
%     k = kfromw(2*pi*30, p);
%
%   See also OMEGA, KFROMW, KCKG

%   F. Moisy, moisy_at_fast.u-psud.fr
%   Revision: 1.10,  Date: 2010/04/20

% 2010/04/20: v1.00, first version

p = [];
if nargin>0
    if isstruct(varargin{1})
        p = varargin{1};
    end
end

% default values
if ~isfield(p,'g'),       p.g = 9.81;      end  % gravity, m/s^2
if ~isfield(p,'gamma'),   p.gamma = 0.072; end  % surface tention, N/m
if ~isfield(p,'rho'),     p.rho = 1000;    end  % density, Kg/m^3
if ~isfield(p,'h0'),      p.h0 = inf;      end  % depth, m

for i=1:numel(varargin)
    if ischar(varargin{i}) && isnumeric(varargin{i+1})
        p.(varargin{i}) = varargin{i+1};
    end
end
