LCOV - code coverage report
Current view: top level - synthesis/ImagerObjects - CubeMakeImageAlgorithm.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 52 0.0 %
Date: 2024-10-09 13:55:54 Functions: 0 7 0.0 %

          Line data    Source code
       1             : //# CubeMajorCycleAlgorithm.cc: implementation of class to grid cube in parallel/serial 
       2             : //# Copyright (C) 2019
       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 General Public License as published by
       7             : //# the Free Software Foundation; either version 3 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 General Public
      13             : //# License for more details.
      14             : //#
      15             : //# https://www.gnu.org/licenses/
      16             : //#
      17             : //# Queries concerning CASA should be submitted at
      18             : //#        https://help.nrao.edu
      19             : //#
      20             : //#        Postal address: CASA Project Manager 
      21             : //#                        National Radio Astronomy Observatory
      22             : //#                        520 Edgemont Road
      23             : //#                        Charlottesville, VA 22903-2475 USA
      24             : //#
      25             : //#
      26             : //# $Id$
      27             : #include <casacore/lattices/Lattices/LatticeLocker.h>
      28             : #include <synthesis/ImagerObjects/CubeMakeImageAlgorithm.h>
      29             : #include <synthesis/ImagerObjects/SynthesisImagerVi2.h>
      30             : #include <casacore/casa/Containers/Record.h>
      31             : #include <synthesis/ImagerObjects/SimpleSIImageStore.h>
      32             : #include <imageanalysis/Utilities/SpectralImageUtil.h>
      33             : 
      34             : using namespace casacore;
      35             : namespace casa { //# NAMESPACE CASA - BEGIN
      36             : extern Applicator applicator;
      37             : 
      38           0 : CubeMakeImageAlgorithm::CubeMakeImageAlgorithm() : myName_p("CubeMakeImageAlgorithm"), polRep_p(0), status_p(False){
      39             :         
      40           0 : }
      41           0 : CubeMakeImageAlgorithm::~CubeMakeImageAlgorithm() {
      42             :         
      43           0 : }
      44             :         
      45           0 : void CubeMakeImageAlgorithm::get() {
      46             : 
      47             :         //cerr << "in get for child process " << applicator.isWorker() << endl;
      48           0 :         Record imParsRec;
      49           0 :         Record vecSelParsRec;
      50           0 :         Record gridParsRec;
      51             :         // get data sel params #1
      52           0 :         applicator.get(vecSelParsRec);
      53             :         // get image sel params #2
      54           0 :         applicator.get(imParsRec);
      55             :         // get gridders params #3
      56           0 :         applicator.get(gridParsRec);
      57             :         // get which channel to process #4
      58           0 :         applicator.get(chanRange_p);
      59             :         //cerr <<"GET chanRange " << chanRange_p << endl;
      60             :         // which type of image #5
      61           0 :         applicator.get(imageType_p);
      62             :         // weight params #6
      63           0 :         applicator.get(weightParams_p);
      64             :         // output complex_image name #7
      65           0 :         applicator.get(cimageName_p);
      66             :         //Somewhere before this we have to make sure that vecSelPars has more than 0 fields)
      67           0 :         dataSel_p.resize(vecSelParsRec.nfields());
      68             :         /// Fill the private variables
      69           0 :         for (Int k=0; k < Int(dataSel_p.nelements()); ++k){
      70           0 :                 (dataSel_p[k]).fromRecord(vecSelParsRec.asRecord(String::toString(k)));
      71             :                 //cerr << k << "datasel " << vecSelParsRec.asRecord(String::toString(k)) << endl;
      72             :         }
      73             :         //cerr << "GET record " << imParsRec << endl;
      74           0 :         imSel_p.fromRecord(imParsRec);
      75           0 :         gridSel_p.fromRecord(gridParsRec);
      76           0 :         if(gridParsRec.isDefined("ftmachine")){
      77           0 :                 ftmRec_p=gridParsRec.asRecord("ftmachine");
      78             :         }
      79             :                         
      80             :         
      81             :         
      82             :         
      83           0 : }
      84           0 : void CubeMakeImageAlgorithm::put() {
      85             :         
      86             :         
      87             :         //cerr << "in put " << status_p << endl;
      88           0 :         applicator.put(status_p);       
      89             :         
      90           0 : }
      91             :         
      92           0 : void CubeMakeImageAlgorithm::task(){
      93           0 :         status_p = False;
      94             :         //SynthesisImagerVi2 imgr;
      95             :         //imgr.selectData(dataSel_p);
      96             :         // We do not use chanchunking in this model
      97           0 :         gridSel_p.chanchunks = 1;
      98             : 
      99             :         //imgr.defineImage(imSel_p,gridSel_p);
     100             :         // need to find how many subfields/outliers have been set
     101             :         //CountedPtr<SIImageStore> imstor =imgr.imageStore(0);
     102             :         //CountedPtr<ImageInterface<Float> > resid=imstor->residual();
     103             :         //Int nchan = resid->shape()(3);
     104             :         //std::shared_ptr<SIImageStore> subImStor=imstor->getSubImageStore(0, 1, chanId_p, nchan, 0,1);
     105             :         
     106           0 :         SynthesisImagerVi2 subImgr;
     107           0 :         for (Int k=0; k < Int(dataSel_p.nelements()); ++k){
     108             :                 //model is already cleared in original SythesisImagerVi2
     109           0 :                 dataSel_p[k].incrmodel=True;
     110           0 :                 subImgr.selectData(dataSel_p[k]);
     111             :         }
     112           0 :         subImgr.defineImage(imSel_p, gridSel_p);
     113             :         // TO DO get weight param and set weight
     114           0 :         if(!weightParams_p.isDefined("type") || weightParams_p.asString("type")=="natural")
     115           0 :                 subImgr.weight("natural");
     116             :         else
     117           0 :                 subImgr.weight(weightParams_p);
     118             :         
     119             :         //get the vi and ft machine
     120           0 :         CountedPtr<vi::VisibilityIterator2> vi=subImgr.getVi();
     121           0 :         CountedPtr<refim::FTMachine> ift=subImgr.getFTM(0);
     122           0 :         refim::FTMachine::Type seType=(refim::FTMachine::Type)imageType_p;
     123             :         
     124           0 :         if(seType >= refim::FTMachine::N_types || seType < refim::FTMachine::OBSERVED)
     125           0 :                 throw(AipsError("CubeMakeImage error: Donot know how to make type of image requested"));
     126           0 :         PagedImage<Complex> origCImage(cimageName_p, TableLock::UserNoReadLocking);
     127           0 :         shared_ptr<ImageInterface<Complex> > subCimage;
     128           0 :         subCimage.reset(SpectralImageUtil::getChannel(origCImage, chanRange_p[0], chanRange_p[1], true));
     129           0 :         Matrix<Float> weight;
     130           0 :         ift->makeImage(seType, *vi, *subCimage, weight);
     131           0 :         ift->cleanupTempFiles("");
     132           0 :         status_p = True;
     133           0 : }
     134           0 : String&     CubeMakeImageAlgorithm::name(){
     135           0 :         return myName_p;
     136             : }
     137             : 
     138             : 
     139             :         
     140             :         
     141             :         
     142             : } //# NAMESPACE CASA - END

Generated by: LCOV version 1.16