void DevSuite::devSidelobeRejection() { Logger msg( "devSidelobeRejection" ); msg << Msg::Info << "Running devSidelobeRejection..." << Msg::EndReq; size_t fourierSize = 4096; const SamplingInfo samplingInfo; Synthesizer::SineGenerator sinGen( samplingInfo ); sinGen.setFrequency( 440 ); RawPcmData::Ptr waveData = sinGen.generate( fourierSize ); WaveAnalysis::SpectralReassignmentTransform transformAlg( samplingInfo, fourierSize, 3*fourierSize, 2 ); const WaveAnalysis::StftData::Ptr stftData = transformAlg.execute( *waveData ); const WaveAnalysis::SrSpectrum& spec = stftData->getSrSpectrum( 0 ); Math::Log10Function log10; gPlotFactory().createPlot( "devSidelobeRejection/Spectrum" ); gPlotFactory().createGraph( spec.getFrequencies() - spec.getFrequencyCorrections(), spec.getMagnitude() ); const RealVector& magnitudeVec = spec.getMagnitude(); FeatureAlgorithm::NaivePeaks peakAlg( FeatureAlgorithm::NaivePeaks::Max ); std::vector< Feature::Peak* > peaks = peakAlg.execute( magnitudeVec ); for ( size_t iPeak = 0; iPeak < peaks.size(); ++iPeak ) { const Feature::Peak& peak = *peaks[ iPeak ]; msg << Msg::Info << "Peak " << iPeak << " with height " << peak.getPedestal() << Msg::EndReq; delete peaks[ iPeak ]; } }
/**************************************************************************** Function: tableGen Description: This routine initializes a table of baseband real and imaginary data. This routine only generates data that is valid for the 6228. Inputs: table - pointer to the data table tableLen - length of table dataType - 0 for real, 1 for complex numberBits - 16 or 8 packingMode - use defines: P6228_PACK_MODE_CHANNEL_PACK, P6228_PACK_MODE_HL_TIME_PACK, P6228_PACK_MODE_LH_TIME_PACK. Returns: 0 if a valid table was generated, 1 if invalid arguments were found. ****************************************************************************/ int tableGen (unsigned int *table, unsigned int tableLen, unsigned int dataType, unsigned int numberBits, unsigned int packingMode) { #define pointsPerCycle 32 volatile int cntr1; volatile int cntr2; volatile int iData[pointsPerCycle]; volatile int qData[pointsPerCycle]; volatile int err = 0; /* verify that table length is a multiple of 32 to match the single * cycle length used here (32 points per cycle). Note that this error * will not stop the table from being generated. */ if (tableLen % pointsPerCycle) err = 1; /* generate one cycle of sine and cosine data ("1" in function call means * one cycle). */ sinGen((int *)&iData, pointsPerCycle, 1, numberBits); cosGen((int *)&qData, pointsPerCycle, 1, numberBits); /* check parameters and generate the data table */ switch (packingMode) { /* channel packed 16-bit data - data can be real or complex. The * most significent 16 bits contains DAC B data, the least significent * 16 bits contains DAC A data. */ case P6228_PACK_MODE_CHANNEL_PACK: if (numberBits == 8) /* check number of bits */ err = 1; /* 8 bits is invalid */ else if (dataType == 0) /* real data */ for (cntr1 = 0; cntr1 < tableLen; cntr1++) table[cntr1] = (iData[cntr1 & (pointsPerCycle-1)] & 0xFFFF) | (iData[cntr1 & (pointsPerCycle-1)] & 0xFFFF) << 16; else /* complex data */ for (cntr1 = 0; cntr1 < tableLen; cntr1++) table[cntr1] = (qData[cntr1 & (pointsPerCycle-1)] & 0xFFFF) | (iData[cntr1 & (pointsPerCycle-1)] & 0xFFFF) << 16; break; /* Time packed data, time t in the most significent 16 bits of the * 32-bit word, time t-1 in the least significent 16 bits. If data * is 8-bit, the upper 8 bits of each 16 bits is sent to DAC A and * the lower 8 bits is sent to DAC B in the DAC5686. */ case P6228_PACK_MODE_HL_TIME_PACK: if (numberBits == 16) /* check number of bits */ { if (dataType == 1) /* check data type */ err = 1; /* complex is invalid */ else { for (cntr1 = cntr2 = 0; cntr1 < tableLen; cntr1++) { table[cntr1] = (iData[cntr2 & (pointsPerCycle-1)] & 0xFFFF) << 16 | (iData[(cntr2+1) & (pointsPerCycle-1)] & 0xFFFF); cntr2 += 2; } } } else { if (dataType == 0) /* real data */ { for (cntr1 = cntr2 = 0; cntr1 < tableLen; cntr1++) { table[cntr1] = (iData[cntr2 & (pointsPerCycle-1)] & 0xFF) << 24 | (iData[cntr2 & (pointsPerCycle-1)] & 0xFF) << 16 | (iData[(cntr2+1) & (pointsPerCycle-1)] & 0xFF) << 8 | (iData[(cntr2+1) & (pointsPerCycle-1)] & 0xFF); cntr2 += 2; } } else /* complex data */ { for (cntr1 = cntr2 = 0; cntr1 < tableLen; cntr1++) { table[cntr1] = (iData[cntr2 & (pointsPerCycle-1)] & 0xFF) << 24 | (qData[cntr2 & (pointsPerCycle-1)] & 0xFF) << 16 | (iData[(cntr2+1) & (pointsPerCycle-1)] & 0xFF) << 8 | (qData[(cntr2+1) & (pointsPerCycle-1)] & 0xFF); cntr2 += 2; } } } break; /* Time packed data, time t-1 in the most significent 16 bits of the * 32-bit word, time t in the least significent 16 bits. If data * is 8-bit, the upper 8 bits of each 16 bits is sent to DAC A and * the lower 8 bits is sent to DAC B in the DAC5686. */ case P6228_PACK_MODE_LH_TIME_PACK: if (numberBits == 16) /* check number of bits */ { if (dataType == 1) /* check data type */ err = 1; /* complex is invalid */ else { for (cntr1 = cntr2 = 0; cntr1 < tableLen; cntr1++) { table[cntr1] = (iData[(cntr2+1) & (pointsPerCycle-1)] & 0xFFFF) << 16 | (iData[cntr2 & (pointsPerCycle-1)] & 0xFFFF); cntr2 += 2; } } } else { if (dataType == 0) /* real data */ { for (cntr1 = cntr2 = 0; cntr1 < tableLen; cntr1++) { table[cntr1] = (iData[(cntr2+1) & (pointsPerCycle-1)] & 0xFF) << 24 | (iData[(cntr2+1) & (pointsPerCycle-1)] & 0xFF) << 16 | (iData[cntr2 & (pointsPerCycle-1)] & 0xFF) << 8 | (iData[cntr2 & (pointsPerCycle-1)] & 0xFF); cntr2 += 2; } } else /* complex data */ { for (cntr1 = cntr2 = 0; cntr1 < tableLen; cntr1++) { table[cntr1] = (iData[(cntr2+1) & (pointsPerCycle-1)] & 0xFF) << 24 | (qData[(cntr2+1) & (pointsPerCycle-1)] & 0xFF) << 16 | (iData[cntr2 & (pointsPerCycle-1)] & 0xFF) << 8 | (qData[cntr2 & (pointsPerCycle-1)] & 0xFF); cntr2 += 2; } } } break; } return (err); }