/// <summary> /// Each ensemble will have its own file. So the filename will contain the subsystem and /// ensemble number. /// </summary> /// <param name="ensemble">Ensemble to encode to PD0.</param> /// <param name="isMultipleFile">Set flag if you want individual files per ensemble or combine it all into one file.</param> public void Write(DataSet.Ensemble ensemble, bool isMultipleFile = false) { if (ensemble == null) { return; } // Check Amplitude if (!_options.IsAmplitudeDataSetOn) { ensemble.IsAmplitudeAvail = false; } else { // Verify the dataset exist if (ensemble.IsAmplitudeAvail) { // Get the size int size = (_options.AmplitudeMaxBin - _options.AmplitudeMinBin) + 1; // Verify a change in the bins if (_options.AmplitudeMinBin != 0 || _options.AmplitudeMaxBin != ensemble.EnsembleData.NumBins - 1) { // Verify the max bin if (_options.AmplitudeMaxBin > ensemble.EnsembleData.NumBins - 1) { _options.AmplitudeMaxBin = (byte)(ensemble.EnsembleData.NumBins - 1); size = (_options.AmplitudeMaxBin - _options.AmplitudeMinBin) + 1; } // Truncate the data float[,] tempAmp = ensemble.AmplitudeData.AmplitudeData; ensemble.AmplitudeData.AmplitudeData = new float[size, tempAmp.GetLength(1)]; Buffer.BlockCopy(tempAmp, _options.AmplitudeMinBin, ensemble.AmplitudeData.AmplitudeData, 0, size); } } else { // Set that data set was not used _options.IsAmplitudeDataSetOn = false; } } // Check Beam Velocity if (!_options.IsBeamVelocityDataSetOn) { ensemble.IsBeamVelocityAvail = false; } else { // Verify the dataset exist if (ensemble.IsBeamVelocityAvail) { // Get the size int size = (_options.BeamMaxBin - _options.BeamMinBin) + 1; // Verify a change in the bins if (_options.BeamMinBin != 0 || _options.BeamMaxBin != ensemble.EnsembleData.NumBins - 1) { // Verify the max bin if (_options.BeamMaxBin > ensemble.EnsembleData.NumBins - 1) { _options.BeamMaxBin = (byte)(ensemble.EnsembleData.NumBins - 1); size = (_options.BeamMaxBin - _options.BeamMinBin) + 1; } // Truncate the data float[,] tempBeam = ensemble.BeamVelocityData.BeamVelocityData; ensemble.BeamVelocityData.BeamVelocityData = new float[size, tempBeam.GetLength(1)]; Buffer.BlockCopy(tempBeam, _options.BeamMinBin, ensemble.BeamVelocityData.BeamVelocityData, 0, size); } } else { // Set that data set was not used _options.IsBeamVelocityDataSetOn = false; } } // Check Earth Velocity if (!_options.IsEarthVelocityDataSetOn) { ensemble.IsEarthVelocityAvail = false; } else { // Verify the dataset exist if (ensemble.IsEarthVelocityAvail) { // Get the size int size = (_options.EarthMaxBin - _options.EarthMinBin) + 1; // Verify a change in the bins if (_options.EarthMinBin != 0 || _options.EarthMaxBin != ensemble.EnsembleData.NumBins - 1) { // Verify the max bin if (_options.EarthMaxBin > ensemble.EnsembleData.NumBins - 1) { _options.EarthMaxBin = (byte)(ensemble.EnsembleData.NumBins - 1); size = (_options.EarthMaxBin - _options.EarthMinBin) + 1; } // Truncate the data float[,] tempEarth = ensemble.EarthVelocityData.EarthVelocityData; ensemble.EarthVelocityData.EarthVelocityData = new float[size, tempEarth.GetLength(1)]; Buffer.BlockCopy(tempEarth, _options.EarthMinBin, ensemble.EarthVelocityData.EarthVelocityData, 0, size); } } else { // Set that data set was not used _options.IsEarthVelocityDataSetOn = false; } } // Check Instrument Velocity if (!_options.IsInstrumentVelocityDataSetOn) { ensemble.IsInstrumentVelocityAvail = false; } else { // Verify the dataset exist if (ensemble.IsInstrumentVelocityAvail) { // Get the size int size = (_options.InstrumentMaxBin - _options.InstrumentMinBin) + 1; // Verify a change in the bins if (_options.InstrumentMinBin != 0 || _options.InstrumentMaxBin != ensemble.EnsembleData.NumBins - 1) { // Verify the max bin if (_options.InstrumentMaxBin > ensemble.EnsembleData.NumBins - 1) { _options.InstrumentMaxBin = (byte)(ensemble.EnsembleData.NumBins - 1); size = (_options.InstrumentMaxBin - _options.InstrumentMinBin) + 1; } // Truncate the data float[,] tempInstr = ensemble.InstrumentVelocityData.InstrumentVelocityData; ensemble.InstrumentVelocityData.InstrumentVelocityData = new float[size, tempInstr.GetLength(1)]; Buffer.BlockCopy(tempInstr, _options.InstrumentMinBin, ensemble.InstrumentVelocityData.InstrumentVelocityData, 0, size); } } else { // Set that data set was not used _options.IsInstrumentVelocityDataSetOn = false; } } // Check Correlation if (!_options.IsCorrelationDataSetOn) { ensemble.IsCorrelationAvail = false; } else { // Verify the dataset exist if (ensemble.IsCorrelationAvail) { // Get the size int size = (_options.CorrelationMaxBin - _options.CorrelationMinBin) + 1; // Verify a change in the bins if (_options.CorrelationMinBin != 0 || _options.CorrelationMaxBin != ensemble.EnsembleData.NumBins - 1) { // Verify the max bin if (_options.CorrelationMaxBin > ensemble.EnsembleData.NumBins - 1) { _options.CorrelationMaxBin = (byte)(ensemble.EnsembleData.NumBins - 1); size = (_options.CorrelationMaxBin - _options.CorrelationMinBin) + 1; } // Truncate the data float[,] tempCorr = ensemble.CorrelationData.CorrelationData; ensemble.CorrelationData.CorrelationData = new float[size, tempCorr.GetLength(1)]; Buffer.BlockCopy(tempCorr, _options.CorrelationMinBin, ensemble.CorrelationData.CorrelationData, 0, size); } } else { // Set that data set was not used _options.IsCorrelationDataSetOn = false; } } // Check Good Beam if (!_options.IsGoodBeamDataSetOn) { ensemble.IsGoodBeamAvail = false; } else { // Verify the dataset exist if (ensemble.IsGoodBeamAvail) { // Get the size int size = (_options.GoodBeamMaxBin - _options.GoodBeamMinBin) + 1; // Verify a change in the bins if (_options.GoodBeamMinBin != 0 || _options.GoodBeamMaxBin != ensemble.EnsembleData.NumBins - 1) { // Verify the max bin if (_options.GoodBeamMaxBin > ensemble.EnsembleData.NumBins - 1) { _options.GoodBeamMaxBin = (byte)(ensemble.EnsembleData.NumBins - 1); size = (_options.GoodBeamMaxBin - _options.GoodBeamMinBin) + 1; } // Truncate the data int[,] tempGB = ensemble.GoodBeamData.GoodBeamData; ensemble.GoodBeamData.GoodBeamData = new int[size, tempGB.GetLength(1)]; Buffer.BlockCopy(tempGB, _options.GoodBeamMinBin, ensemble.GoodBeamData.GoodBeamData, 0, size); } } else { // Set that data set was not used _options.IsGoodBeamDataSetOn = false; } } // Check Good Earth if (!_options.IsGoodEarthDataSetOn) { ensemble.IsGoodEarthAvail = false; } else { // Verify the dataset exist if (ensemble.IsGoodEarthAvail) { // Get the size int size = (_options.GoodEarthMaxBin - _options.GoodEarthMinBin) + 1; // Verify a change in the bins if (_options.GoodEarthMinBin != 0 || _options.GoodEarthMaxBin != ensemble.EnsembleData.NumBins - 1) { // Verify the max bin if (_options.GoodEarthMaxBin > ensemble.EnsembleData.NumBins - 1) { _options.GoodEarthMaxBin = (byte)(ensemble.EnsembleData.NumBins - 1); size = (_options.GoodEarthMaxBin - _options.GoodEarthMinBin) + 1; } // Truncate the data int[,] tempGB = ensemble.GoodEarthData.GoodEarthData; ensemble.GoodEarthData.GoodEarthData = new int[size, tempGB.GetLength(1)]; Buffer.BlockCopy(tempGB, _options.GoodEarthMinBin, ensemble.GoodEarthData.GoodEarthData, 0, size); } } else { // Set that data set was not used _options.IsGoodEarthDataSetOn = false; } } // Check Bottom Track if (!_options.IsBottomTrackDataSetOn) { ensemble.IsBottomTrackAvail = false; } else { if (!ensemble.IsBottomTrackAvail) { // Set that data set was not used _options.IsBottomTrackDataSetOn = false; } } // Check Earth Water Mass if (!_options.IsEarthWaterMassDataSetOn) { ensemble.IsEarthWaterMassAvail = false; } else { if (!ensemble.IsEarthWaterMassAvail) { // Set that data set was not used _options.IsEarthWaterMassDataSetOn = false; } } // Check Instrument Water Mass if (!_options.IsInstrumentWaterMassDataSetOn) { ensemble.IsInstrumentWaterMassAvail = false; } else { if (!ensemble.IsInstrumentWaterMassAvail) { // Set that data set was not used _options.IsInstrumentWaterMassDataSetOn = false; } } // Check Nmea Data if (!_options.IsNmeaDataSetOn) { ensemble.IsNmeaAvail = false; } else { if (!ensemble.IsNmeaAvail) { // Set that data set was not used _options.IsNmeaDataSetOn = false; } } // Check Profile Engineering if (!_options.IsProfileEngineeringDataSetOn) { ensemble.IsProfileEngineeringAvail = false; } else { if (!ensemble.IsProfileEngineeringAvail) { // Set that data set was not used _options.IsProfileEngineeringDataSetOn = false; } } // Check System Setup if (!_options.IsSystemSetupDataSetOn) { ensemble.IsSystemSetupAvail = false; } else { if (!ensemble.IsSystemSetupAvail) { // Set that data set was not used _options.IsSystemSetupDataSetOn = false; } } // Check ADCP GPS if (!_options.IsAdcpGpsDataSetOn) { ensemble.IsAdcpGpsDataAvail = false; } else { if (!ensemble.IsAdcpGpsDataAvail) { // Set that data set was not used _options.IsAdcpGpsDataSetOn = false; } } // Check GPS 1 if (!_options.IsGps1DataSetOn) { ensemble.IsGps1DataAvail = false; } else { if (!ensemble.IsGps1DataAvail) { // Set that data set was not used _options.IsGps1DataSetOn = false; } } // Check GPS 2 if (!_options.IsGps2DataSetOn) { ensemble.IsGps2DataAvail = false; } else { if (!ensemble.IsGps2DataAvail) { // Set that data set was not used _options.IsGps2DataSetOn = false; } } // Check NMEA 1 if (!_options.IsNmea1DataSetOn) { ensemble.IsNmea1DataAvail = false; } else { if (!ensemble.IsNmea1DataAvail) { // Set that data set was not used _options.IsNmea1DataSetOn = false; } } // Check NMEA 2 if (!_options.IsNmea2DataSetOn) { ensemble.IsNmea2DataAvail = false; } else { if (!ensemble.IsNmea2DataAvail) { // Set that data set was not used _options.IsNmea2DataSetOn = false; } } // Write the data to the file _writer.Write(ensemble.EncodePd0Ensemble(_options.CoordinateTransform)); }