예제 #1
0
def Direction_PeakDetection(parameters, theta, distribution, Flag):

    #------------------------------------
    #	peak detection
    #------------------------------------
    # domain dichotomy
    angle = 360 - UT.CartesianNautical(
        parameters.CoastNormalOrientation) if Flag else UT.CartesianNautical(
            parameters.CoastNormalOrientation)

    theta1, distribution1, theta2, distribution2 = DirectionDichotomy(
        theta, distribution, angle)

    Directions = np.zeros(2)
    # parameter for peak detection
    ratio = 20. / 100
    if parameters.submethod in {
            'clusterpower', 'ClusterPower', 'centroidpower', 'CentroidPower'
    }:
        power = 2
    else:
        power = 1

    PeakParameters = CL.PeakParameters(power, ratio)
    # data for peak detection
    DataDirection1 = CL.DataPeak(theta1, distribution1)
    DataDirection2 = CL.DataPeak(theta2, distribution2)

    # estimate mean direction
    Directions[0] = UT.PeakDetection(PeakParameters, parameters.submethod,
                                     DataDirection1)
    Directions[1] = UT.PeakDetection(PeakParameters, parameters.submethod,
                                     DataDirection2)

    flagplot = 0
    if flagplot > 0:
        fig, ax1 = plt.subplots(1)
        ax1.plot(theta1, distribution1, 'o')
        ax1.plot(theta2, distribution2, 'o')
        ax1.axvline(x=Directions[0]), ax1.axvline(x=Directions[1])
        ax1.axhline(y=ratio * np.max(distribution1)), ax1.axhline(
            y=ratio * np.max(distribution2))
    plt.show()

    return Directions
예제 #2
0
def WavelengthEstimate(ComputingParameters, k, spectrum):
    #-----------------------------------------
    #	Estimate Peak Wavelength
    #----------------------------------------
    # parameters
    if ComputingParameters.SpectrumParameters.WaveSpectrumParameters.SpectrumType == 'Radial':
        kth = 0.01
        data = CL.DataPeak(k[np.where(k > kth)], spectrum[np.where(k > kth)])
    else:
        data = CL.DataPeak(k, spectrum)
    WavelengthParameters = ComputingParameters.SpectrumParameters.WavelengthEstimationParameters
    peak_parameters = CL.PeakParameters(WavelengthParameters.Power)

    # mean wavenumber estimate
    PeakWavenumber = UT.PeakDetection(
        peak_parameters, WavelengthParameters.PeakDeterminationMethod, data)

    # wavelength
    PeakWavelength = 2 * np.pi / PeakWavenumber

    return PeakWavelength