function q = waveProperties(time, wl, varargin)

OPT = struct( ...
    'hilbert', 1, ...
    'fres',0.01,...
    'fcutoff', 0.2);

OPT = setproperty(OPT, varargin{:});


%% input
fres        = OPT.fres;
fcutoff     = OPT.fcutoff; 

%% Total waves
int_time = linspace(time(1),time(end),length(time)); % not completly correct; wl should be interpolated as well!
[q.fx, q.vy]        = spectrumsimple(int_time, wl, 'fresolution', fres,'detrend',1, 'figures', 0);

m0                  = trapz(q.fx,q.vy);
q.Hs                = 4.*sqrt(m0);
q.Hrms              = sqrt(8*nanmean((wl-nanmean(wl)).^2));
q.eta               = nanmean(wl);


%q.skewness          = skewness2(wl);
q.skewness         = nanmean((wl-nanmean(wl)).^3)/nanmean((wl-nanmean(wl)).^2).^(1.5);
if OPT.hilbert==1
    q.A                 = abs(hilbert(wl)-nanmean(wl));
    H = imag(hilbert(wl)-nanmean(wl));
    q.groupiness        = sqrt(std(H))/mean(q.A);
    % assymetry: Elgar and Guza (1985)
    q.asymmetry         = nanmean(H.^3)/nanmean((wl-nanmean(wl)).^2).^(1.5);
end
%% LF wave
q.f_l                 = q.fx(q.fx>fcutoff/100 & q.fx<fcutoff);
q.vy_l                = q.vy(q.fx>fcutoff/100 & q.fx<fcutoff);
q.Hs_LF               = 4.*sqrt(trapz(q.f_l, q.vy_l));
[q.wl_l, dummy]       = low_filter(time ,wl,fcutoff/100,fcutoff);

%% spectra 
[m0 ,fminlim,fmaxlim]   = computeMoment(  0, q.fx', q.vy, 0.03, 2, 'no' );
[m_1,fminlim,fmaxlim]   = computeMoment( -1, q.fx', q.vy, 0.03, 2, 'no' );
[m1,fminlim,fmaxlim]    = computeMoment( 1, q.fx', q.vy, 0.03, 2, 'no' );
[m2,fminlim,fmaxlim]    = computeMoment( 2, q.fx', q.vy, 0.03, 2, 'no' );
q.Tm01                  = m0  / m1;
q.Tm02                  = sqrt( m0 / m2 );
q.Tm_10                 = m_1 / m0;
end