LCOV - code coverage report
Current view: top level - imageanalysis/ImageAnalysis - ImageFactory.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 2 0.0 %
Date: 2024-10-12 00:35:29 Functions: 0 1 0.0 %

          Line data    Source code
       1             : //# tSubImage.cc: Test program for class SubImage
       2             : //# Copyright (C) 1998,1999,2000,2001,2003
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This program is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU General Public License as published by the Free
       7             : //# Software Foundation; either version 2 of the License, or (at your option)
       8             : //# any later version.
       9             : //#
      10             : //# This program 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 License for
      13             : //# more details.
      14             : //#
      15             : //# You should have received a copy of the GNU General Public License along
      16             : //# with this program; if not, write to the Free Software Foundation, Inc.,
      17             : //# 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: tSubImage.cc 20567 2009-04-09 23:12:39Z gervandiepen $
      27             : 
      28             : #ifndef IMAGEANALYSIS_IMAGEFACTORY_H
      29             : #define IMAGEANALYSIS_IMAGEFACTORY_H
      30             : 
      31             : #include <imageanalysis/ImageTypedefs.h>
      32             : 
      33             : #include <imageanalysis/Images/ComponentListImage.h>
      34             : 
      35             : #include <casacore/casa/Arrays/Array.h>
      36             : #include <casacore/casa/BasicSL/String.h>
      37             : #include <casacore/casa/Containers/Record.h>
      38             : #include <casacore/casa/Logging/LogOrigin.h>
      39             : #include <casacore/casa/namespace.h>
      40             : #include <casacore/lattices/Lattices/LatticeBase.h>
      41             : #include <casacore/casa/Arrays/ArrayFwd.h>
      42             : #include <utility>
      43             : #include <vector>
      44             : 
      45             : namespace casacore{
      46             : 
      47             : class CoordinateSystem;
      48             : class IPosition;
      49             : class Record;
      50             : template <class T> class TempImage;
      51             : 
      52             : }
      53             : 
      54             : namespace casa {
      55             : 
      56             : class ImageFactory {
      57             :         // <summary>
      58             :         // Static methods for creating images 
      59             :         // </summary>
      60             : 
      61             :         // <reviewed reviewer="" date="" tests="" demos="">
      62             :         // </reviewed>
      63             : 
      64             :         // <prerequisite>
      65             :         // </prerequisite>
      66             : 
      67             :         // <etymology>
      68             :         // </etymology>
      69             : 
      70             :         // <synopsis>
      71             :         // </synopsis>
      72             : 
      73             : public:
      74             : 
      75             :         enum ComplexToFloatFunction {
      76             :                 REAL,
      77             :                 IMAG
      78             :         };
      79             : 
      80             :         ImageFactory() = delete;
      81             : 
      82             :     ~ImageFactory() {};
      83             : 
      84             :     // Create a casacore::TempImage if outfile is empty, otherwise a PagedImage.
      85             :     // If log is true, log useful messages, quiet if false. Created image
      86             :     // has all pixel values set to zero and is unmasked.
      87             :     template <class T> static SPIIT createImage(
      88             :         const casacore::String& outfile,
      89             :         const casacore::CoordinateSystem& cSys, const casacore::IPosition& shape,
      90             :         casacore::Bool log, casacore::Bool overwrite,
      91             :         const std::vector<std::pair<casacore::LogOrigin, casacore::String> > *const &msgs
      92             :     );
      93             : 
      94             :     // create a ComponentListImage
      95             :     static std::shared_ptr<ComponentListImage> createComponentListImage(
      96             :         const casacore::String& outfile, const casacore::Record& cl,
      97             :         const casacore::Vector<casacore::Int>& shape,
      98             :         const casacore::Record& csys, casacore::Bool overwrite,
      99             :         casacore::Bool log, casacore::Bool cache
     100             :     );
     101             : 
     102           0 :     static casacore::String className() {
     103           0 :         static const casacore::String s = "ImageFactory"; return s;
     104             :     }
     105             : 
     106             :     // create an image with the specified shape and specified coordinate system.
     107             :     // If outfile is blank, the returned object is a casacore::TempImage, casacore::PagedImage otherwise.
     108             :     // If csys is empty,
     109             :     // a default coordiante system is attached to the image, and if linear
     110             :     // is true, it has linear coordinates in place of the direction coordinate.
     111             : 
     112             :     static SPIIF floatImageFromShape(
     113             :         const casacore::String& outfile,
     114             :         const casacore::Vector<casacore::Int>& shape,
     115             :         const casacore::Record& csys, casacore::Bool linear=true,
     116             :         casacore::Bool overwrite=false, casacore::Bool verbose=true,
     117             :         const std::vector<
     118             :             std::pair<casacore::LogOrigin, casacore::String>
     119             :         > *const &msgs=nullptr
     120             :     );
     121             : 
     122             :     static SPIIC complexImageFromShape(
     123             :         const casacore::String& outfile,
     124             :         const casacore::Vector<casacore::Int>& shape,
     125             :         const casacore::Record& csys, casacore::Bool linear=true,
     126             :         casacore::Bool overwrite=false, casacore::Bool verbose=true,
     127             :         const std::vector<
     128             :             std::pair<casacore::LogOrigin, casacore::String>
     129             :         > *const &msgs=nullptr
     130             :     );
     131             : 
     132             :     static SPIID doubleImageFromShape(
     133             :         const casacore::String& outfile,
     134             :         const casacore::Vector<casacore::Int>& shape,
     135             :         const casacore::Record& csys, casacore::Bool linear=true,
     136             :         casacore::Bool overwrite=false, casacore::Bool verbose=true,
     137             :         const std::vector<
     138             :             std::pair<casacore::LogOrigin, casacore::String>
     139             :         > *const &msgs=nullptr
     140             :     );
     141             : 
     142             :     static SPIIDC complexDoubleImageFromShape(
     143             :         const casacore::String& outfile, const casacore::Vector<casacore::Int>& shape,
     144             :         const casacore::Record& csys, casacore::Bool linear=true,
     145             :         casacore::Bool overwrite=false, casacore::Bool verbose=true,
     146             :         const std::vector<
     147             :             std::pair<casacore::LogOrigin, casacore::String>
     148             :         > *const &msgs=nullptr
     149             :     );
     150             : 
     151             :     // only the pointer of the correct data type will be valid, the other
     152             :     // will be null.
     153             :     static ITUPLE fromImage(
     154             :         const casacore::String& outfile, const casacore::String& infile,
     155             :         const casacore::Record& region, const casacore::String& mask,
     156             :         casacore::Bool dropdeg=false,
     157             :         casacore::Bool overwrite=false
     158             :     );
     159             : 
     160             :     template <class T> static SPIIT imageFromArray(
     161             :         const casacore::String& outfile, const casacore::Array<T>& pixels,
     162             :         const casacore::Record& csys, casacore::Bool linear=false,
     163             :         casacore::Bool overwrite=false, casacore::Bool verbose=true,
     164             :         const std::vector<
     165             :             std::pair<casacore::LogOrigin, casacore::String>
     166             :         > *const &msgs=nullptr
     167             :     );
     168             : /*
     169             :     static SPIIF fromASCII(
     170             :         const casacore::String& outfile, const casacore::String& infile,
     171             :         const casacore::IPosition& shape, const casacore::String& sep,
     172             :         const casacore::Record& csys, const casacore::Bool linear,
     173             :         const casacore::Bool overwrite
     174             :     );
     175             : */
     176             :     template <class T> static SPIIT fromShape(
     177             :         const casacore::String& outfile,
     178             :         const casacore::Vector<casacore::Int>& shape,
     179             :         const casacore::Record& csys, casacore::Bool linear=false,
     180             :         casacore::Bool overwrite=false, casacore::Bool verbose=false,
     181             :         const std::vector<
     182             :             std::pair<casacore::LogOrigin, casacore::String>
     183             :         > *const &msgs=nullptr
     184             :     );
     185             : 
     186             :     // Create a float-valued image from a complex-valued image. All metadata is
     187             :     // copied and pixel values are initialized according to <src>func</src>.
     188             :     template<class T>
     189             :     static std::shared_ptr<casacore::TempImage<T>> floatFromComplex(
     190             :         std::shared_ptr<
     191             :             const casacore::ImageInterface<std::complex<T>>
     192             :         > complexImage, ComplexToFloatFunction func
     193             :     );
     194             : 
     195             :     // Create a complex-valued image from two real valued images. All metadata
     196             :     // is copied from the real image and pixel values are initialized to
     197             :     // realPart + i*complexPart
     198             :     template<class T>
     199             :     static std::shared_ptr<casacore::TempImage<std::complex<T>>> makeComplexImage(
     200             :         SPCIIT realPart, SPCIIT imagPart
     201             :     );
     202             : 
     203             :     // Create a complex-valued image from two real-valued images. All metadata
     204             :     // is copied from the real image and pixel values are initialized to
     205             :     // realPart + i*complexPart
     206             :     template<class T>
     207             :     static std::shared_ptr<casacore::ImageInterface<std::complex<T>>> makeComplex(
     208             :         SPCIIT realPart, SPCIIT imagPart, const casacore::String& outfile,
     209             :                 const casacore::Record& region, casacore::Bool overwrite = false
     210             :     );
     211             : 
     212             :     // exactly one of the pointers will not be null, indicating the
     213             :     // pixel data type. Cache is only used if the image is a CompoenentListImage
     214             :     static ITUPLE fromFile(
     215             :         const casacore::String& filename, casacore::Bool cache=casacore::True
     216             :     );
     217             : 
     218             :     // for specific types
     219             :     static SPIIF fromFile(
     220             :         const casacore::String& filename, casacore::Float, casacore::Bool cache=casacore::True
     221             :     );
     222             : 
     223             :     static SPIID fromFile(
     224             :         const casacore::String& filename, casacore::Double, casacore::Bool cache=casacore::True
     225             :     );
     226             : 
     227             :     static SPIIC fromFile(
     228             :         const casacore::String& filename, casacore::Complex, casacore::Bool cache=casacore::True
     229             :     );
     230             : 
     231             :     static SPIIDC fromFile(
     232             :         const casacore::String& filename, casacore::DComplex, casacore::Bool cache=casacore::True
     233             :     ); 
     234             : 
     235             :     static SPIIF fromFITS(
     236             :         const casacore::String& outfile, const casacore::String& fitsfile,
     237             :         const casacore::Int whichrep, const casacore::Int whichhdu,
     238             :         const casacore::Bool zeroBlanks, const casacore::Bool overwrite
     239             :     );
     240             : 
     241             :     static std::pair<SPIIF, SPIIC> fromRecord(
     242             :         const casacore::RecordInterface& rec, const casacore::String& imagename=""
     243             :     );
     244             : 
     245             :     template <class T> static void remove(SPIIT& image, casacore::Bool verbose);
     246             : 
     247             :     // if successful, image will be reset to point to new image upon return
     248             :     static void rename(
     249             :         SPIIF& image, const casacore::String& name, const casacore::Bool overwrite
     250             :     );
     251             : 
     252             :     static void rename(
     253             :         SPIIC& image, const casacore::String& name, const casacore::Bool overwrite
     254             :     );
     255             : 
     256             :     // open a canonical image
     257             :     static SPIIF testImage(
     258             :         const casacore::String& outfile, const casacore::Bool overwrite,
     259             :         const casacore::String& imagetype="2d"
     260             :     );
     261             : /*
     262             :     static void toASCII(
     263             :         SPCIIF image,
     264             :         const casacore::String& outfile, casacore::Record& region, const casacore::String& mask,
     265             :         const casacore::String& sep=" ", const casacore::String& format="%e",
     266             :         casacore::Double maskvalue=-999, casacore::Bool overwrite=false,
     267             :         casacore::Bool extendMask=false
     268             :     );
     269             : */
     270             :     static void toFITS(
     271             :         SPCIIF image, const casacore::String& outfile, casacore::Bool velocity,
     272             :                 casacore::Bool optical, casacore::Int bitpix, casacore::Double minpix, casacore::Double maxpix,
     273             :                 const casacore::Record& region, const casacore::String& mask,
     274             :                 casacore::Bool overwrite=false, casacore::Bool dropdeg=false, casacore::Bool deglast=false,
     275             :                 casacore::Bool dropstokes=false, casacore::Bool stokeslast=false,
     276             :                 casacore::Bool wavelength=false, casacore::Bool airWavelength=false,
     277             :                 const casacore::String& origin="", casacore::Bool stretch=false, casacore::Bool history=true
     278             :     );
     279             : 
     280             : private:
     281             : 
     282             :         template <class T> static SPIIT _fromRecord(
     283             :             const casacore::RecordInterface& rec, const casacore::String& name
     284             :         );
     285             : 
     286             :         static void _centerRefPix(
     287             :                 casacore::CoordinateSystem& csys, const casacore::IPosition& shape
     288             :         );
     289             : 
     290             :         static void _checkInfile(const casacore::String& infile);
     291             : 
     292             :     // Convert a casacore::Record to a CoordinateSystem
     293             :     static casacore::CoordinateSystem* _makeCoordinateSystem(
     294             :         const casacore::Record& cSys,
     295             :         const casacore::IPosition& shape
     296             :     );
     297             : 
     298             :     static void _checkOutfile(const casacore::String& outfile, casacore::Bool overwrite);
     299             : 
     300             :     static ITUPLE _fromLatticeBase(
     301             :         std::unique_ptr<casacore::LatticeBase>& latt
     302             :     );
     303             : 
     304             :     static casacore::String _imageCreationMessage(
     305             :         const casacore::String& outfile, const ITUPLE& imagePtrs
     306             :     );
     307             : 
     308             :     static casacore::String _imageCreationMessage(
     309             :         const casacore::String& outfile, const casacore::IPosition& shape,
     310             :         casacore::DataType dataType
     311             :     );
     312             : 
     313             :     // if successful, image will point to the newly named image
     314             :     // upone return
     315             :     template <class T> static ITUPLE _rename(
     316             :         SPIIT& image, const casacore::String& name,
     317             :         const casacore::Bool overwrite
     318             :     );
     319             : 
     320             : };
     321             : }
     322             : 
     323             : #ifndef AIPS_NO_TEMPLATE_SRC
     324             : #include <imageanalysis/ImageAnalysis/ImageFactory.tcc>
     325             : #endif
     326             : 
     327             : #endif

Generated by: LCOV version 1.16