Example #1
0
	bool ForEachBaselineAction::IsBaselineSelected(ImageSetIndex &index)
	{
		ImageSet *imageSet = _artifacts->ImageSet();
		MSImageSet *msImageSet = dynamic_cast<MSImageSet*>(imageSet);
		size_t a1id, a2id;
		if(msImageSet != 0)
		{
			a1id = msImageSet->GetAntenna1(index);
			a2id = msImageSet->GetAntenna2(index);
		} else {
			a1id = 0;
			a2id = 0;
		}
		if(_antennaeToSkip.count(a1id) != 0 || _antennaeToSkip.count(a2id) != 0)
			return false;
		if(!_antennaeToInclude.empty() && (_antennaeToInclude.count(a1id) == 0 && _antennaeToInclude.count(a2id) == 0))
			return false;
		
		// For SD/BHFits files, we want to select everything -- it's confusing
		// if the default option "only flag cross correlations" would also
		// hold for sdfits files.
		if(dynamic_cast<FitsImageSet*>(imageSet)!=0 || dynamic_cast<BHFitsImageSet*>(imageSet)!=0)
			return true;

		switch(_selection)
		{
			case All:
				return true;
			case CrossCorrelations:
			{
				return a1id != a2id;
			}
			case AutoCorrelations:
				return a1id == a2id;
			case EqualToCurrent: {
				if(!_hasInitAntennae)
					throw BadUsageException("For each baseline over 'EqualToCurrent' with no current baseline");
				throw BadUsageException("Not implemented");
			}
			case AutoCorrelationsOfCurrentAntennae:
				if(!_hasInitAntennae)
					throw BadUsageException("For each baseline over 'AutoCorrelationsOfCurrentAntennae' with no current baseline");
				return a1id == a2id && (_initAntenna1.id == a1id || _initAntenna2.id == a1id);
			default:
				return false;
		}
	}