Ejemplo n.º 1
0
/**
 * Create a time series of input data.
 *
 * Description:\n
 * 	Creates a time series of complex floats representing a signal at
 * 	a given frequency.
 */
ComplexFloat32 *
createTdData(float64_t fMHz, float64_t driftHz, int32_t samples,
		float64_t noise)
{
	size_t size = samples * sizeof(ComplexFloat32);
	ComplexFloat32 *td = static_cast<ComplexFloat32 *> (fftwf_malloc(size));
	float64_t dfMHz = fMHz - centerFreqMHz;
	float64_t widthMHz = subchannels * subchannelWidthMHz;
	Gaussian gen;
	// no noise, just signal
	gen.setup(0, widthMHz, noise);
	gen.addCwSignal(dfMHz, driftHz, 1);
	gen.getSamples(td, samples);
	return (td);
}
Ejemplo n.º 2
0
/**
* Create LCP and RCP packets with different noise and signals
*
*/
void
createPackets(Gaussian &xGen, Gaussian &yGen, 
			ATAPacket &xPkt, ATAPacket &yPkt)
{
	//
	// we're reusing the packets, so make sure they're in the right order
	//
	xPkt.putPacket(pkt->getPacket());
	yPkt.putPacket(pkt->getPacket());

	ATADataPacketHeader& hdr = xPkt.getHeader();

	//
	// the following converts the timeval unix time into a 64-bit sec.frac
	// format; this requires converting tv_usec to a 32-bit fraction
	// of the form usec / 1e6, then conve[Brting it back to a 32-bit unsigned
	// integer by multiplying by 2^32.
	//
	timeval tp;
	gettimeofday(&tp, NULL);
	hdr.absTime = ATADataPacketHeader::timevalToAbsTime(tp);

	hdr.chan = channel;
	hdr.freq = cfreq;
//	hdr.sampleRate = bandwidth;
//	hdr.usableFraction = usable;
	hdr.seq = sequence++;
	hdr.flags |= data_valid;
	static ComplexFloat64 *samples = 0;
//   		Copy the whole packet to get the header
	memcpy(&yPkt, &xPkt, xPkt.getSize());  
//		Now fill in the samples
	if (!samples)
		samples = new ComplexFloat64[hdr.len];
	if (!local) {
//
// 	Only create samples for the pols to be sent
//
		if ( !singlePol || (singlePol && xPol))
		{
			xGen.getSamples(samples, hdr.len);
		//
		// store the samples in the  X packet
		//
			for (uint32_t i = 0; i < hdr.len; ++i) {
				ComplexFloat32 s(samples[i]);
				if (swapri)
					s = ComplexFloat32(s.imag(), s.real());
				xPkt.putSample(i, s);
			}
		}
		if ( !singlePol || (singlePol && !xPol))
		{
			yGen.getSamples(samples, hdr.len);
		//
		// store the samples in the Y packet 
		//
			for (uint32_t i = 0; i < hdr.len; ++i) {
				ComplexFloat32 s(samples[i]);
				if (swapri)
					s = ComplexFloat32(s.imag(), s.real());
				yPkt.putSample(i, s);
			}
		}
	}
	switch (polarization) {
	case ATADataPacketHeader::XLINEAR:
		xPkt.getHeader().polCode = ATADataPacketHeader::XLINEAR;
		yPkt.getHeader().polCode = ATADataPacketHeader::YLINEAR;
		break;
	case ATADataPacketHeader::RCIRC:
	default:
		xPkt.getHeader().polCode = ATADataPacketHeader::RCIRC;
		yPkt.getHeader().polCode = ATADataPacketHeader::LCIRC;
	}
}