LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - MakeApproxPSFAlgorithm.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 8 57 14.0 %
Date: 2024-11-06 17:42:47 Functions: 4 7 57.1 %

          Line data    Source code
       1             : //# MakeAppproxPSFAlgorithm.cc: implementation of MakeApproxPSFAlgorithm.h
       2             : //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id$
      27             : 
      28             : #include <casacore/casa/BasicSL/String.h>
      29             : #include <casacore/casa/Arrays/Array.h>
      30             : #include <casacore/casa/Arrays/ArrayMath.h>
      31             : #include <casacore/casa/Arrays/Array.h>
      32             : #include <casacore/lattices/Lattices/ArrayLattice.h>
      33             : #include <casacore/lattices/Lattices/PagedArray.h>
      34             : #include <casacore/lattices/LEL/LatticeExpr.h>
      35             : #include <casacore/lattices/Lattices/SubLattice.h>
      36             : #include <casacore/lattices/LRegions/LCBox.h>
      37             : #include <casacore/lattices/LEL/LatticeExprNode.h>
      38             : #include <casacore/casa/OS/File.h>
      39             : #include <casacore/casa/Exceptions/Error.h>
      40             : #include <casacore/casa/BasicSL/String.h>
      41             : #include <casacore/casa/Utilities/Assert.h>
      42             : #include <msvis/MSVis/VisSet.h>
      43             : #include <msvis/MSVis/VisSetUtil.h>
      44             : #include <msvis/MSVis/VisibilityIterator.h>
      45             : #include <msvis/MSVis/VisBuffer.h>
      46             : #include <sstream>
      47             : #include <casacore/casa/Logging/LogMessage.h>
      48             : #include <casacore/casa/Logging/LogIO.h>
      49             : #include <casacore/casa/Logging/LogSink.h>
      50             : #include <casacore/ms/MeasurementSets/MeasurementSet.h>
      51             : #include <casacore/ms/MeasurementSets/MSColumns.h>
      52             : #include <synthesis/MeasurementComponents/MakeApproxPSFAlgorithm.h>
      53             : #include <casacore/casa/OS/Time.h>
      54             : #include <casacore/images/Images/ImageInterface.h>
      55             : #include <casacore/images/Images/PagedImage.h>
      56             : #include <casacore/images/Images/TempImage.h>
      57             : #include <synthesis/TransformMachines/StokesImageUtil.h>
      58             : #include <unistd.h>
      59             : 
      60             : using namespace casacore;
      61             : namespace casa { //# NAMESPACE CASA - BEGIN
      62             : 
      63             : extern Applicator applicator; 
      64             : 
      65           1 : MakeApproxPSFAlgorithm::MakeApproxPSFAlgorithm() : 
      66           1 :   myName_p("MakeApproxPSFAlgorithm"), 
      67           1 :   msFileName_p(""), beam_p(0), beamArray_p(0)
      68             : {
      69           1 : };
      70             : 
      71           2 : MakeApproxPSFAlgorithm::~MakeApproxPSFAlgorithm(){
      72           2 : };
      73             : 
      74           0 : void MakeApproxPSFAlgorithm::get(){
      75             : 
      76           0 :   Record container_ft;
      77           0 :   applicator.get(container_ft);
      78             : 
      79             :   // Construct the FTMachine
      80           0 :   ft_p = new GridFT(container_ft);
      81           0 :   applicator.get(msFileName_p);
      82           0 :   applicator.get(weight_p);
      83             :   
      84           0 :   Record image_container;
      85           0 :   applicator.get(image_container);
      86           0 :   cImage_p = new TempImage<Complex> ();
      87           0 :   String error;
      88           0 :   cImage_p->fromRecord(error, image_container);
      89           0 :   psf_p = new TempImage<Float>(cImage_p->shape(), cImage_p->coordinates());
      90           0 : };
      91             : 
      92           0 : void MakeApproxPSFAlgorithm::put(){
      93             : 
      94           0 :   applicator.put(beam_p);
      95           0 :   applicator.put(*beamArray_p);
      96           0 :   delete ft_p;
      97           0 :   delete cImage_p;
      98           0 :   delete psf_p;
      99           0 :   beamArray_p->resize();
     100           0 :   weight_p.resize();
     101           0 : };
     102             : 
     103           1 : String& MakeApproxPSFAlgorithm::name(){
     104           1 :   return myName_p;
     105             : };
     106             :  
     107           0 : void MakeApproxPSFAlgorithm::task(){
     108             : 
     109             :   try{
     110           0 :     MeasurementSet ms(msFileName_p, TableLock(TableLock::UserNoReadLocking),
     111           0 :                       Table::Update);
     112             :     // Deal with subtle sorted_table locking issues
     113           0 :     ms.unlock(); 
     114           0 :     Block<Int> sort(0);
     115           0 :     Matrix<Int> noselection;
     116           0 :     Double interval=10.0;
     117           0 :     VisSet vs(ms, sort, noselection, interval);
     118             : 
     119           0 :     ft_p->makeImage(FTMachine::PSF, vs, *cImage_p,
     120           0 :                     weight_p);
     121           0 :     StokesImageUtil::To(*psf_p, *cImage_p);
     122             : 
     123           0 :     beam_p= *(new Vector<Float>(3));
     124           0 :     StokesImageUtil::FitGaussianPSF(*psf_p, beam_p);
     125             : 
     126           0 :     Int nx=psf_p->shape()(0);
     127           0 :     Int ny=psf_p->shape()(1);
     128           0 :     LCBox psfbox(IPosition(4, 0, 0, 0, 0), 
     129           0 :                  IPosition(4, nx-1, ny-1, 0, 0),
     130           0 :                  psf_p->shape());
     131             :   
     132           0 :     SubLattice<Float>  psf_sl (*psf_p, psfbox, true);
     133           0 :     Array<Float> tempbeamArray;
     134             :     //Bool rStat = ((Lattice<Float> &)psf_sl).get(tempbeamArray);
     135             :     //UNUSED: Bool rStat = psf_sl.get(tempbeamArray);
     136             : 
     137           0 :     if (beamArray_p) delete beamArray_p;
     138           0 :     beamArray_p= new Array<Float>(tempbeamArray);
     139             : 
     140           0 :     ms.unlock();
     141             : 
     142           0 :   } catch (AipsError x) {
     143           0 :     cout <<  "Exceptionally yours: " << x.getMesg() << endl;
     144           0 :   };
     145           0 : };
     146             : 
     147             : 
     148             : 
     149             : 
     150             : 
     151             : 
     152             : 
     153             : 
     154             : } //# NAMESPACE CASA - END
     155             : 

Generated by: LCOV version 1.16