Skip to content
Snippets Groups Projects
Select Git revision
  • f76b9ed9b6e5fb9a78cfa0e34c20a1afec43ff99
  • master default protected
  • L2SS-1914-fix_job_dispatch
  • TMSS-3170
  • TMSS-3167
  • TMSS-3161
  • TMSS-3158-Front-End-Only-Allow-Changing-Again
  • TMSS-3133
  • TMSS-3319-Fix-Templates
  • test-fix-deploy
  • TMSS-3134
  • TMSS-2872
  • defer-state
  • add-custom-monitoring-points
  • TMSS-3101-Front-End-Only
  • TMSS-984-choices
  • SDC-1400-Front-End-Only
  • TMSS-3079-PII
  • TMSS-2936
  • check-for-max-244-subbands
  • TMSS-2927---Front-End-Only-PXII
  • Before-Remove-TMSS
  • LOFAR-Release-4_4_318 protected
  • LOFAR-Release-4_4_317 protected
  • LOFAR-Release-4_4_316 protected
  • LOFAR-Release-4_4_315 protected
  • LOFAR-Release-4_4_314 protected
  • LOFAR-Release-4_4_313 protected
  • LOFAR-Release-4_4_312 protected
  • LOFAR-Release-4_4_311 protected
  • LOFAR-Release-4_4_310 protected
  • LOFAR-Release-4_4_309 protected
  • LOFAR-Release-4_4_308 protected
  • LOFAR-Release-4_4_307 protected
  • LOFAR-Release-4_4_306 protected
  • LOFAR-Release-4_4_304 protected
  • LOFAR-Release-4_4_303 protected
  • LOFAR-Release-4_4_302 protected
  • LOFAR-Release-4_4_301 protected
  • LOFAR-Release-4_4_300 protected
  • LOFAR-Release-4_4_299 protected
41 results

baselineplotpage.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    baselineplotpage.cpp 5.24 KiB
    /***************************************************************************
     *   Copyright (C) 2011 by A.R. Offringa                                   *
     *   offringa@astro.rug.nl                                                 *
     *                                                                         *
     *   This program is free software; you can redistribute it and/or modify  *
     *   it under the terms of the GNU General Public License as published by  *
     *   the Free Software Foundation; either version 2 of the License, or     *
     *   (at your option) any later version.                                   *
     *                                                                         *
     *   This program is distributed in the hope that it will be useful,       *
     *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
     *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
     *   GNU General Public License for more details.                          *
     *                                                                         *
     *   You should have received a copy of the GNU General Public License     *
     *   along with this program; if not, write to the                         *
     *   Free Software Foundation, Inc.,                                       *
     *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
     ***************************************************************************/
    
    #include <limits>
    
    #include <AOFlagger/gui/quality/baselineplotpage.h>
    
    #include <AOFlagger/quality/statisticscollection.h>
    #include <AOFlagger/quality/statisticsderivator.h>
    
    BaselinePlotPage::BaselinePlotPage() :
    	_statCollection(0),
    	_antennas(0)
    {
    	GrayScaleWidget().OnMouseMovedEvent().connect(sigc::mem_fun(*this, &BaselinePlotPage::onMouseMoved));
    	GrayScaleWidget().SetXAxisDescription("Antenna 1 index");
    	GrayScaleWidget().SetYAxisDescription("Antenna 2 index");
    }
    
    BaselinePlotPage::~BaselinePlotPage()
    {
    }
    
    std::pair<TimeFrequencyData, TimeFrequencyMetaDataCPtr> BaselinePlotPage::ConstructImage()
    {
    	if(HasStatistics())
    	{
    		const QualityTablesFormatter::StatisticKind kind = GetSelectedStatisticKind();
    		
    		const unsigned polarizationCount = _statCollection->PolarizationCount();
    		std::vector<std::pair<unsigned, unsigned> > baselines = _statCollection->BaselineStatistics().BaselineList();
    		StatisticsDerivator derivator(*_statCollection);
    		
    		const unsigned antennaCount = _statCollection->BaselineStatistics().AntennaCount();
    
    		Image2DPtr realImages[polarizationCount];
    		Image2DPtr imagImages[polarizationCount];
    		Mask2DPtr mask[polarizationCount];
    		for(unsigned p=0;p<polarizationCount;++p)
    		{
    			realImages[p] = Image2D::CreateUnsetImagePtr(antennaCount, antennaCount);
    			realImages[p]->SetAll(std::numeric_limits<num_t>::quiet_NaN());
    			imagImages[p] = Image2D::CreateUnsetImagePtr(antennaCount, antennaCount);
    			imagImages[p]->SetAll(std::numeric_limits<num_t>::quiet_NaN());
    			mask[p] = Mask2D::CreateSetMaskPtr<true>(antennaCount, antennaCount);
    		}
    		
    		for(std::vector<std::pair<unsigned, unsigned> >::const_iterator i=baselines.begin();i!=baselines.end();++i)
    		{
    			const unsigned antenna1 = i->first, antenna2 = i->second;
    			for(unsigned p=0;p<polarizationCount;++p)
    			{
    				const std::complex<long double> val = derivator.GetComplexBaselineStatistic(kind, antenna1, antenna2, p);
    				realImages[p]->SetValue(antenna1, antenna2, val.real());
    				imagImages[p]->SetValue(antenna1, antenna2, val.imag());
    				mask[p]->SetValue(antenna1, antenna2, false);
    			}
    		}
    		TimeFrequencyData data;
    		if(polarizationCount == 1)
    		{
    			data = TimeFrequencyData(TimeFrequencyData::ComplexRepresentation, SinglePolarisation, realImages[0], imagImages[0]);
    			data.SetGlobalMask(mask[0]);
    		}
    		else if(polarizationCount == 2)
    		{
    			data = TimeFrequencyData(AutoDipolePolarisation, realImages[0], imagImages[0], realImages[1], imagImages[1]);
    			data.SetIndividualPolarisationMasks(mask[0], mask[1]);
    		}
    		else if(polarizationCount == 4)
    		{
    			data = TimeFrequencyData(realImages[0], imagImages[0], realImages[1], imagImages[1], realImages[2], imagImages[2], realImages[3], imagImages[3]);
    			data.SetIndividualPolarisationMasks(mask[0], mask[1], mask[2], mask[3]);
    		}
    		else {
    			std::stringstream s;
    			s << "Set has not 1, 2 or 4 polarizations (?!?) : StatisticsCollection.PolarizationCount() == " << polarizationCount;
    			throw std::runtime_error(s.str());
    		}
    		return std::pair<TimeFrequencyData, TimeFrequencyMetaDataCPtr>(data, TimeFrequencyMetaDataCPtr());
    	} else {
    		return std::pair<TimeFrequencyData, TimeFrequencyMetaDataCPtr>(TimeFrequencyData(), TimeFrequencyMetaDataCPtr());
    	}
    }
    
    void BaselinePlotPage::onMouseMoved(size_t x, size_t y)
    {
    	std::stringstream text;
    	std::string antenna1Name, antenna2Name;
    	if(_antennas == 0)
    	{
    		std::stringstream a1, a2;
    		a1 << x;
    		a2 << y;
    		antenna1Name = a1.str();
    		antenna2Name = a2.str();
    	} else {
    		antenna1Name = (*_antennas)[x].name;
    		antenna2Name = (*_antennas)[y].name;
    	}
    	const QualityTablesFormatter::StatisticKind kind = GetSelectedStatisticKind();
    	const std::string &kindName = QualityTablesFormatter::KindToName(kind);
    	
    	text << "Correlation " << antenna1Name << " x " << antenna2Name << ", " << kindName << " = " << GrayScaleWidget().Image()->Value(x, y);
    	_signalStatusChange(text.str());
    }