Ejemplo n.º 1
0
//
// add: add a CwBadBand to the final list
//
// Notes:
//		Converts the internal bad band format to the format
//		expected by the SSE
//
void
CwBadBandList::add(CwBadBand& band)
{
    ::CwBadBand cwBand;

    lock();
    cwBand.band.centerFreq
        = binsToAbsoluteMHz(band.band.bin + band.band.width / 2);
    cwBand.band.bandwidth = binsToMHz(band.band.width);
    cwBand.pol = band.band.pol;
    cwBand.paths = band.paths;
    cwBand.maxPathCount = band.maxPaths;

    // build the maximum strength path
    cwBand.maxPath.rfFreq =  binsToAbsoluteMHz(band.maxPath.bin);
    float64_t driftHz = binsToHz(band.maxPath.drift);
    cwBand.maxPath.drift = driftHz / getObsLength();
    cwBand.maxPath.width = getBinWidth();
    cwBand.maxPath.power = band.maxPath.power;

    finalList.push_back(cwBand);
    unlock();
}
Ejemplo n.º 2
0
void
PulseClusterer::clusterDone(Train &cluster)
{
	// allocate enough memory to hold the header and the
	size_t len = sizeof(PulseSignalHeader)
			+ cluster.pulses.size() * sizeof(::Pulse);
	PulseSignalHeader *hdr =
			static_cast<PulseSignalHeader *> (fftwf_malloc(len));
	Assert(hdr);

	// do 2nd linear regression for start bin and drift
	initLR();
	map<int,Pulse>::iterator i;
//	cout << "train begin" << endl;
	for (i = cluster.pulses.begin(); i!= cluster.pulses.end(); i++) {
		Pulse pulse = (*i).second;
//		cout << "p = " << pulse.pole << ", s = " << (dec) << pulse.spectrum;
//		cout << ", b = " << (dec) << pulse.bin << ", p = " << pulse.power;
//		cout << endl;
		addPulseToLR((*i).second);
	}
	float32_t driftInBinsPerSpectrum;
	float32_t startBin;
	if (!getLRResult(&startBin,&driftInBinsPerSpectrum))
		Fatal(666);

	// format cluster description
	hdr->sig.path.rfFreq = binsToAbsoluteMHz((int) startBin);
#ifdef notdef
	hdr->sig.signalId = 0; // XXX
#endif
	hdr->sig.path.drift = binsToRelativeHz((int) (driftInBinsPerSpectrum
									  * getSpectraPerObs()))/getSecondsPerObs();
	hdr->sig.path.width
			= binsToRelativeHz((int) (1 + cluster.hiBin - cluster.loBin));
//	cout << "f " << hdr->sig.path.rfFreq << ", d " << hdr->sig.drift;
//	cout << ", w " << hdr->sig.path.width << endl;
	int32_t n = 0;
	for (i = cluster.pulses.begin(); i!= cluster.pulses.end(); ++i)
	{
		if (i == cluster.pulses.begin()) {
			hdr->sig.path.power = (*i).second.power;
			hdr->sig.pol = (*i).second.pole;
		}
		else {
			hdr->sig.path.power += (*i).second.power;
			if (hdr->sig.pol != (*i).second.pole)
				hdr->sig.pol = POL_MIXED;
		}
		// dual-pol signals count as two bins
		switch ((*i).second.pole) {
		case POL_BOTH:
			++n;
		case POL_LEFTCIRCULAR:
		case POL_RIGHTCIRCULAR:
		default:
			++n;
			break;
		}
//		cout << "pulse (" << (*i).second.spectrum << ", " << (*i).second.bin;
//		cout << ", " << (*i).second.power << ")" << endl;
	}

//	cout << "total power " << hdr->sig.power << endl;
//	cout << "pulse count " << n << endl;
//	cout << "bin width " << binsToRelativeHz(1) << endl;
	// compute the SNR and PFA for the signal
	hdr->cfm.snr = ((hdr->sig.path.power - n) / n) * binsToRelativeHz(1);
	hdr->cfm.pfa = computePfa(n, hdr->sig.path.power);

	hdr->sig.sigClass = CLASS_UNINIT; // XXX
	hdr->sig.reason = CLASS_REASON_UNINIT; // XXX
	Tr(detail,(
		"cluster @%f drift %f lo %f hi %f",
		hdr->sig.path.rfFreq, hdr->path.ig.drift, cluster.loBin,
		cluster.hiBin));

	map<int,Counter>::iterator j;
	int hiCount = 0;
	int periodInSpectra = 0;
	for (j = cluster.histogram.begin(); j!= cluster.histogram.end(); j++) {
		if ((*j).second.val > hiCount) {
			hiCount = (*j).second.val;
			periodInSpectra = (*j).first;
		}
	}
	hdr->train.pulsePeriod = (periodInSpectra * getSecondsPerObs())
							/ getSpectraPerObs();
	hdr->train.numberOfPulses = cluster.pulses.size();
	hdr->train.res = resolution;

	// array of individual pulses
	::Pulse *p = (::Pulse *)(hdr + 1);
//	cout << "PulseClusterer, record pulses" << endl;
	for (i = cluster.pulses.begin(); i!= cluster.pulses.end(); i++) {
		p->rfFreq = binsToAbsoluteMHz((*i).second.bin);
		p->power = (*i).second.power;
		p->spectrumNumber = (*i).second.spectrum;
		p->binNumber = (*i).second.bin;
		p->pol = (*i).second.pole;
//		cout << "pulse " << *p;
		p++;
	}

	clusterList.push_back(hdr);
}