Ejemplo n.º 1
0
//
// selectCandidates: build a list of candidates
//
// Notes:
//		For primary detection.
void
SignalClassifier::classifySignals(Activity *act)
{
	SystemType origin = act->getMode();

	Debug(DEBUG_NEVER, 1, "classify signals");

	params = act->getActivityParams();
	int32_t maxCandidates = params.maxNumberOfCandidates;
	recentRfi = act->getRecentRfiMask();
	testSignal = act->getTestSignalMask();
	operations = params.operations;

	act->setCandidatesOverMax(candidatesOverMax = 0);

	SuperClusterer *superClusterer = act->getSuperClusterer();
	Assert(superClusterer);
	// scan the list of signals
	for (int32_t i = 0; i < superClusterer->getCount(); i++) {
		// get the next signal
		ClusterTag tag = superClusterer->getNthMainSignal(i);
		CwClusterer *cwClusterer = tag.holder->getCw();
		PulseClusterer *pulseClusterer = tag.holder->getPulse();
		if (cwClusterer) {
			Debug(DEBUG_NEVER, i, "cw clusterer");
			CwPowerSignal& signal = cwClusterer->getNth(tag.index);
			classifySignal(act, signal.sig, superClusterer, i, maxCandidates);
			signal.sig.containsBadBands = applyBadBands(act, signal.sig);
			if (signal.sig.sigClass == CLASS_CAND)
				act->addCwCandidate(&signal, origin);
			act->addCwSignal(&signal);
		}
		else if (pulseClusterer) {
			Debug(DEBUG_NEVER, i, "pulse cluster");
			PulseSignalHeader *signal = &pulseClusterer->getNth(tag.index);
//			cout << "SignalClassifier pulse " << *signal;
//			Pulse *p = (Pulse *) (signal + 1);
//			for (int j = 0; j < signal->train.numberOfPulses; ++j)
//				cout << "pulse " << j << p[j];
			classifySignal(act, signal->sig, superClusterer, i, maxCandidates);
			signal->sig.containsBadBands = applyBadBands(act, signal->sig);
			if (signal->sig.sigClass == CLASS_CAND)
				act->addPulseCandidate(signal, origin);
			act->addPulseSignal(signal);
//			displayPulseSignal(*signal);
		}
	}
	act->setCandidatesOverMax(candidatesOverMax);
}
Ejemplo n.º 2
0
bool
PulseClusterer::isStronger(int idx, ClusterTag *old)
{
	if (!isComplete() || (idx < 0 || idx > (int) clusterList.size()))
		Fatal(666);
	lock();
	PulseClusterer *oldClust = old->holder->getPulse();
	bool stronger = false;
	if (oldClust) {
		const PulseSignalHeader &oldpd = oldClust->getNth(old->index);
		const PulseSignalHeader &newpd = getNth(idx);
		stronger = (newpd.sig.path.power > oldpd.sig.path.power);
	}
	unlock();
	return (stronger);
}
Ejemplo n.º 3
0
void
SuperClusterer::compute()
{
	vector<int> index;
	vector<float64_t> freq;

	if (!children.size())
		return;

	// initialize merge cursors for each cluster list
	lock();
	for (int i = 0; i < (int) children.size(); ++i) {
		ChildClusterer *ch = children[i];
		index.push_back(0);
		freq.push_back(ch->getCount() ? ch->getNominalFreq(0) : 0);
	}
	unlock();

	SuperClusterDescription *lastSuper = 0;

	// until everything is merged
	Tr(detail,("begin computing superclusters"));
	lock();
	while (true) {
		// find the lowest next frequency
		int nextList = -1;
		for (int i = 0; i < (int) children.size(); ++i) {
			if (freq[i] && (nextList < 0 || freq[i] < freq[nextList])) {
				// still clusters in this list
				nextList = i;
			}
		}
		if (nextList < 0)
			break; // no more clusters in any list

		if (lastSuper && freq[nextList] < lastSuper->hiBound) {
			// merge this cluster into super cluster
			lastSuper->hiBound = freq[nextList] + superClusterGap;
			ClusterTag tag;
			tag.holder = children[nextList];
			tag.index = index[nextList];
			lastSuper->clusters.push_back(tag);
			if (tag.holder->isStronger(tag.index, &lastSuper->strongest))
				lastSuper->strongest = tag;
			// add this signal polarization to the supercluster
			setTypeAndPol(tag, lastSuper);
			Tr(detail,("merge cluster from list %d @%f, hiBound %f",
					nextList, freq[nextList], lastSuper->hiBound));
		}
		else {
			// create new super cluster
			SuperClusterDescription desc;
			desc.signalId = signalIdGen.getNextId();
			desc.hiBound = freq[nextList] + superClusterGap;
			ClusterTag tag;
			tag.holder = children[nextList];
			tag.index = index[nextList];
			desc.strongest = tag;
			desc.clusters.push_back(desc.strongest);
			CwClusterer *cwCluster;
			PulseClusterer *pulseCluster;
			// set the initial polarization based on the first cluster
			cwCluster = tag.holder->getCw();
			pulseCluster = tag.holder->getPulse();
			if (cwCluster) {
				CwPowerSignal cwSig = cwCluster->getNth(tag.index);
				desc.type = CW_POWER;
				desc.pol = cwSig.sig.pol;
			}
			else if (pulseCluster) {
				PulseSignalHeader pulseSig = pulseCluster->getNth(tag.index);
				desc.type = PULSE;
				desc.pol = pulseSig.sig.pol;
			}
			superClusters.push_back(desc);
			lastSuper = &superClusters[superClusters.size() - 1];
			Tr(detail,("create new supercluster from list %d @%f, hiBound %f",
					nextList, freq[nextList], desc.hiBound));
		}
		// advance cursor for the cluster list we just merged from
		ChildClusterer *ch = children[nextList];
		if (++index[nextList] >= ch->getCount())
			freq[nextList] = 0;
		else
			freq[nextList] = ch->getNominalFreq(index[nextList]);
	}
	unlock();
	Tr(detail,("done computing %d supercluster(s)",superClusters.size()));
}