def MergeSpectrumData(points):
    #---------------------------------------------------
    # gather all 2D spectrum data in exploitable arrays
    #---------------------------------------------------
    # get array size
    k, Spectra, SpectraStd = [point.Spectrum.WaveSpectrum.k for point in points], [point.Spectrum.WaveSpectrum.Spectrum for point in points], \
       [point.Spectrum.WaveSpectrum.StandardDeviation for point in points]

    # store and save data
    fname = os.getcwd() + '/Output/Bathymetry/WaveSpectrum.out'
    data = CL.SpectrumProcessedData(np.asarray(k), np.asarray(Spectra),
                                    np.asarray(SpectraStd))
    data.pickle(fname)

    return k, Spectra
Exemplo n.º 2
0
def ComputeSpectrum(SubsetParameters, ComputingParameters, Subsets):
    #--------------------------------------------------------------------------
    # Estimate Subsets Spectra and directions and determine their mean values
    #--------------------------------------------------------------------------

    WaveSpectra, Directions, ImageSpectra = [], [], []

    for i in range(SubsetParameters.BoxNb):
        subset = Subsets[i]
        # Compute wave related spectrum
        if ComputingParameters.SpectrumParameters.WaveSpectrumParameters.SpectrumType in {
                'waves', 'Waves'
        }:
            # use a multiple of wave signal
            SpectrumComputedData = SubsetSpectrum(ComputingParameters, subset)
        elif ComputingParameters.SpectrumParameters.WaveSpectrumParameters.SpectrumType in {
                'radial', 'Radial'
        }:
            # use the radial integration of the Image Spectrum
            SpectrumComputedData = RadialSpectrum(ComputingParameters, subset)
        else:
            sys.exit("Method for Spectrum Estimation not defined")

        # store data
        Directions.append(SpectrumComputedData.WaveDirection)
        WaveSpectra.append(SpectrumComputedData.WaveSpectrum)
        ImageSpectra.append(SpectrumComputedData.ImageSpectrum)

    # compute mean directions
    direction = np.nanmean(Directions)

    # compute mean Spectrum
    K = np.zeros((SubsetParameters.BoxNb, WaveSpectra[0].k.shape[0]))
    WSP = np.zeros((SubsetParameters.BoxNb, WaveSpectra[0].Spectrum.shape[0]))
    for i in range(SubsetParameters.BoxNb):
        K[i, :] = WaveSpectra[i].k
        WSP[i, :] = WaveSpectra[i].Spectrum
    k = np.mean(K, axis=0)
    spectrum = np.mean(WSP, axis=0)
    spectrumstd = np.std(WSP, axis=0)
    """
	fig, ax = plt.subplots(1)
	for i in range(SubsetParameters.BoxNb):
		ax.plot(K[i,:], WSP[i,:])	
	plt.show()
	"""

    # compute peak wavelength
    PeakWavelength = WavelengthEstimate(ComputingParameters, k, spectrum)

    # store processed data
    Spectrum = CL.SpectrumProcessedData(k, spectrum, spectrumstd,
                                        PeakWavelength)

    # post-processing data for figures and statistics
    SubscenesSpectrum = CL.SpectrumComputedData(Directions, WaveSpectra,
                                                ImageSpectra, Subsets)

    # store mean data
    ComputedSpectrumData = CL.SpectrumComputedData(direction, Spectrum)

    return ComputedSpectrumData, SubscenesSpectrum