casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ImageAnalysis.h
Go to the documentation of this file.
00001 //# ImageAnalysis.h: Image analysis and handling tool
00002 //# Copyright (C) 2007
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This program is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU General Public License as published by the Free
00007 //# Software Foundation; either version 2 of the License, or (at your option)
00008 //# any later version.
00009 //#
00010 //# This program is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00013 //# more details.
00014 //#
00015 //# You should have received a copy of the GNU General Public License along
00016 //# with this program; if not, write to the Free Software Foundation, Inc.,
00017 //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 
00026 #ifndef _IMAGEANALYSIS__H__
00027 #define _IMAGEANALYSIS__H__
00028 
00029 
00030 //# put includes here
00031 #include <coordinates/Coordinates/CoordinateSystem.h>
00032 #include <lattices/LatticeMath/Fit2D.h>
00033 #include <casa/Quanta.h>
00034 #include <measures/Measures/Stokes.h>
00035 #include <images/Images/ImageInfo.h>
00036 #include <images/Images/ImageInterface.h>
00037 #include <components/ComponentModels/ComponentType.h>
00038 #include <casa/Arrays/AxesSpecifier.h>
00039 #include <casa/Utilities/PtrHolder.h>
00040 #include <measures/Measures/Stokes.h>
00041 
00042 #include <memory>
00043 
00044 namespace casa {
00045 
00046 class DirectionCoordinate;
00047 class LogIO;
00048 class SkyComponent;
00049 class Record;
00050 class Fit2D;
00051 class ImageRegion;
00052 class ComponentList;
00053 template<class T> class Array;
00054 template<class T> class Block;
00055 template<class T> class PtrBlock; 
00056 template<class T> class Flux;
00057 template<class T> class ImageStatistics;
00058 template<class T> class ImageHistograms;
00059 template<class T> class MaskedArray;
00060 template<class T> class Quantum;
00061 template<class T> class SubLattice;
00062 template<class T> class SubImage;
00063 template<class T> class Vector;
00064 class ImageMomentsProgressMonitor;
00065 
00066 // <summary>
00067 // Image analysis and handling tool
00068 // </summary>
00069 
00070 // <synopsis>
00071 // This the casapy image tool.
00072 // One time it should be merged with pyrap's image tool ImageProxy.
00073 // </synopsis>
00074 
00075 class ImageAnalysis
00076 {
00077   public:
00078 
00079     ImageAnalysis();
00080 
00081     //ImageInterface constructor
00082     ImageAnalysis(const ImageInterface<Float>* inImage);
00083     
00084     //Use this constructor with cloneInputPointer=False if you want this object
00085     // to take over management of the input pointer. The input pointer will be deleted
00086     // when this object is destroyed.
00087     ImageAnalysis(ImageInterface<Float>* inImage, const Bool cloneInputPointer);
00088 
00089     virtual ~ImageAnalysis();
00090 
00091     Bool addnoise(const String& type, const Vector<Double>& pars,
00092                   Record& region, const Bool zero = False);
00093 
00094     ImageInterface<Float> * imagecalc(const String& outfile, 
00095                                       const String& pixels, 
00096                                       const Bool overwrite = False);
00097 
00098     ImageInterface<Float> * imageconcat(const String& outfile, 
00099                                         const Vector<String>& infiles, 
00100                                         const Int axis, 
00101                                         const Bool relax = False, 
00102                                         const Bool tempclose = True, 
00103                                         const Bool overwrite = False);
00104 
00105     Bool imagefromarray(const String& outfile, Array<Float>& pixels, 
00106                         const Record& csys, const Bool linear = False, 
00107                         const Bool overwrite = False, const Bool log = True);
00108 
00109     Bool imagefromascii(const String& outfile, const String& infile, 
00110                         const Vector<Int>& shape, const String& sep, 
00111                         const Record& csys, const Bool linear = False, 
00112                         const Bool overwrite = False);
00113 
00114     Bool imagefromfits(const String& outfile, const String& infile, 
00115                        const Int whichrep = 0, const Int whichhdu = 0, 
00116                        const Bool zeroblanks = False, 
00117                        const Bool overwrite = False);
00118 
00119     Bool imagefromimage(const String& outfile, const String& infile, 
00120                         Record& region, const String& mask, 
00121                         const Bool dropdeg = False, 
00122                         const Bool overwrite = False);
00123 
00124     Bool imagefromshape(const String& outfile, const Vector<Int>& shape, 
00125                         const Record& csys, const Bool linear = True, 
00126                         const Bool overwrite = False, const Bool log = True);
00127 
00128     ImageInterface<Float> * convolve(
00129         const String& outfile,
00130         Array<Float>& kernel,
00131         const String& kernImage,
00132         const Double scale,
00133         Record& region, String& mask,
00134         const Bool overwrite=False,
00135         const Bool async=False,
00136         const Bool stretch=False
00137     );
00138 
00139     Record* boundingbox(const Record& region);
00140 
00141     String brightnessunit();
00142 
00143     Bool calc(const String& pixels);
00144 
00145     // regions should be a Record of Records having different regions
00146 
00147     Bool calcmask(const String& mask, Record& regions, const String& name, 
00148                   const Bool asdefault = True);
00149 
00150 
00151     ImageInterface<Float> * continuumsub(const String& outline, 
00152                                          const String& outcont, Record& region,
00153                                          const Vector<int>& channels, 
00154                                          const String& pol = "", 
00155                                          const Int fitorder = 0, 
00156                                          const Bool overwrite = false);
00157 /*
00158     // the output <src>fakeBeam</src> indicates if there was no beam in the header and a fake one
00159     // was assumed to do the conversion. <src>channel</src> and <src>polarization</src> are
00160     // used only in the case the image has per plane beams.
00161     Quantity convertflux(
00162         Bool& fakeBeam, const Quantity& value, const Quantity& major,
00163         const Quantity& minor,
00164         const String& type = "Gaussian",
00165         const Bool topeak = True,
00166         const Bool supressNoBeamWarnings = False,
00167         const Int channel=-1,
00168         const Int polarization=-1
00169     ) const;
00170 */
00171     ImageInterface<Float>* convolve2d(
00172                 const String& outfile, const Vector<Int>& axes,
00173             const String& type, const Quantity& major,
00174             const Quantity& minor, const Quantity& pa,
00175             Double scale, Record& region, const String& mask,
00176             const Bool overwrite = False, const Bool stretch=False,
00177             const Bool targetres = False
00178     );
00179 
00180     CoordinateSystem coordsys(const Vector<int>& axes);
00181 
00182     CoordinateSystem csys(const Vector<int>& axes);
00183 
00184     Record* coordmeasures(Quantity& intensity, Record& direction, 
00185                           Record& frequency, Record& velocity, 
00186                           const Vector<double>& pixel);
00187 
00188    Matrix<Float> decompose(
00189                    Record& region, const String& mask,
00190            const Bool simple = false,
00191            const Double threshold = -1,
00192            const Int ncontour = 11,
00193            const Int minrange = 1,
00194            const Int naxis = 2,
00195            const Bool fit = True,
00196            const Double maxrms = -1,
00197            const Int maxretry = -1,
00198            const Int maxiter = 256,
00199            const Double convcriteria = 0.0001
00200    );
00201 
00202    Matrix<Float> decompose(
00203                    Matrix<Int>& blcs, Matrix<Int>& trcs,
00204                    Record& region, const String& mask,
00205                    const Bool simple = false,
00206                    const Double threshold = -1,
00207                    const Int ncontour = 11,
00208                    const Int minrange = 1,
00209                    const Int naxis = 2,
00210                    const Bool fit = True,
00211                    const Double maxrms = -1,
00212                    const Int maxretry = -1,
00213                    const Int maxiter = 256,
00214                    const Double convcriteria = 0.0001,
00215                    const Bool stretch=False
00216    );
00217 
00218     Record deconvolvecomponentlist(
00219         const Record& complist, const Int channel, const Int polarization
00220     );
00221 
00222     Bool remove(Bool verbose=true);
00223 
00224     Bool fft(
00225         const String& real, const String& imag, const String& amp,
00226         const String& phase, const Vector<Int>& axes, Record& region,
00227         const String& mask, const Bool stretch
00228     );
00229 
00230     Record findsources(const Int nmax, const Double cutoff, Record& region, 
00231                         const String& mask, const Bool point = True, 
00232                         const Int width = 5, const Bool negfind = False);
00233 
00234     Bool getchunk(Array<Float>& pixel, Array<Bool>& pixmask, 
00235                   const Vector<Int>& blc, const Vector<Int>& trc, 
00236                   const Vector<Int>& inc, const Vector<Int>& axes, 
00237                   const Bool list = False, const Bool dropdeg = False, 
00238                   const bool getmask = False);
00239 
00240     Bool getregion(
00241         Array<Float>& pixels, Array<Bool>& pixmask, Record& region,
00242         const Vector<Int>& axes, const String& mask,
00243         const Bool list=False, const Bool dropdeg=False,
00244         const Bool getmask=False, const Bool extendMask=False
00245     );
00246 
00247     Record* getslice(const Vector<Double>& x, const Vector<Double>& y, 
00248                      const Vector<Int>& axes, const Vector<Int>& coord, 
00249                      const Int npts = 0, const String& method = "linear");
00250 
00251     ImageInterface<Float>* hanning(
00252         const String& outfile, Record& region,
00253         const String& mask, const Int axis=-10,
00254         const Bool drop=True,
00255         const bool overwrite=False,
00256         const Bool extendMask=True
00257     );
00258 
00259     Vector<Bool> haslock();
00260 
00261     Record histograms(
00262         const Vector<Int>& axes, Record& region,
00263         const String& mask, const Int nbins,
00264         const Vector<Double>& includepix, const Bool gauss,
00265         const Bool cumu, const Bool log, const Bool list,
00266         const Bool force=False,
00267         const Bool disk=False, const Bool extendMask=False
00268     );
00269 
00270     Vector<String> history(const Bool list = False, const Bool browse = True);
00271 
00272     Bool insert(
00273         const String& infile, Record& region,
00274         const Vector<double>& locate, Bool verbose
00275     );
00276 
00277     //    Bool isopen();
00278 
00279     Bool ispersistent();
00280 
00281     Bool lock(const Bool writelock = False, const Int nattempts = 0);
00282 
00283     Bool makecomplex(const String& outfile, const String& imag, Record& region,
00284                      const Bool overwrite = False);
00285 
00286     Vector<String> maskhandler(const String& op,const Vector<String>& nam);
00287 
00288     Record miscinfo();
00289 
00290     Bool modify(
00291         Record& model, Record& region , const String& mask,
00292         const Bool subtract = True, const Bool list=True, const Bool extendMask=False
00293     );
00294 
00295     Record maxfit(Record& region, const Bool point, const Int width = 5, 
00296                    const Bool negfind = False, const Bool list = True);
00297 
00298     ImageInterface<Float> * moments(
00299         const Vector<Int>& moments, const Int axis, Record& region,
00300         const String& mask, const Vector<String>& method,
00301         const Vector<Int>& smoothaxes,
00302         const Vector<String>& smoothtypes,
00303         const Vector<Quantity>& smoothwidths,
00304         const Vector<Float>& includepix,
00305         const Vector<Float>& excludepix,
00306         const Double peaksnr, const Double stddev,
00307         const String& doppler = "RADIO",  const String& outfile = "",
00308         const String& smoothout="", const String& plotter="/NULL",
00309         const Int nx=1, const Int ny=1,  const Bool yind=False,
00310         const Bool overwrite=False, const Bool drop=True,
00311         const Bool stretchMask=False
00312     );
00313 
00314     void setMomentsProgressMonitor( ImageMomentsProgressMonitor* progressMonitor );
00315 
00316     String name(const Bool strippath = False);
00317 
00318     Bool open(const String& infile);
00319 
00320     Record* pixelvalue(const Vector<Int>& pixel);
00321     void pixelValue (Bool& offImage, Quantum<Double>& value, Bool& mask,
00322                      Vector<Int>& pos) const;
00323 
00324     Bool putchunk(const Array<Float>& pixels, const Vector<Int>& blc, 
00325                   const Vector<Int>& inc, const Bool list = False, 
00326                   const Bool locking = True, const Bool replicate = False);
00327 
00328     Bool putregion(const Array<Float>& pixels, const Array<Bool>& pixelmask, 
00329                    Record& region, const Bool list = False, 
00330                    const Bool usemask = True, 
00331                    const Bool locking = True, const Bool replicate = False);
00332 
00333     ImageInterface<Float> * rebin(
00334         const String& outfile,
00335         const Vector<Int>& bin, Record& region,
00336         const String& mask, const Bool dropdeg,
00337         const Bool overwrite=False,
00338         const Bool extendMask=False
00339     );
00340 
00341     //regrids to a given coordinate system...one uses a record that is 
00342     //converted to a CoordinateSytem 
00343 
00344     ImageInterface<Float> * regrid(
00345         const String& outfile, const Vector<Int>& shape,
00346         const Record& csys, const Vector<Int>& axes,
00347         Record& region, const String& mask,
00348         const String& method="linear", const Int decimate=10,
00349         const Bool replicate=False, const Bool doref=True,
00350         const Bool dropdeg=False, const Bool overwrite=False,
00351         const Bool force=False, const Bool specAsVelocity=False,
00352         const Bool extendAxes=False
00353     ) const;
00354     
00355 
00356     // regrids to match the "other" image interface...
00357     ImageInterface<Float> * regrid(
00358         const String& outfile, const ImageInterface<Float>*other,
00359         const String& method="linear",
00360         const Bool specAsVelocity=False,
00361         const Vector<Int>& axes = Vector<Int>(0),
00362         const Record &region = Record(),
00363         const String& mask="",
00364         const Int decimate=10,
00365         const Bool replicate=False,
00366         const Bool doref=True,
00367         const Bool dropdeg=False,
00368         const Bool overwrite=False,
00369         const Bool force=False,
00370         const Bool extendAxes=False
00371     ) const;
00372 
00373     ImageInterface<Float>* rotate(
00374         const String& outfile,
00375         const Vector<int>& shape,
00376         const Quantity& pa, Record& region,
00377         const String& mask,
00378         const String& method="cubic",
00379         const Int decimate=0,
00380         const Bool replicate=False,
00381         const Bool dropdeg=False,
00382         const Bool overwrite=False,
00383         const Bool extendMask=False
00384     );
00385 
00386     Bool rename(const String& name, const Bool overwrite = False);
00387 
00388     Bool replacemaskedpixels(
00389         const String& pixels, Record& region,
00390         const String& mask, const Bool update=False,
00391         const Bool list=False, const Bool extendMask=False
00392     );
00393 
00394     ImageInterface<Float>* sepconvolve(
00395         const String& outfile,
00396         const Vector<Int>& axes,
00397         const Vector<String>& types,
00398         const Vector<Quantity>& widths,
00399         Double scale,
00400         Record& region,
00401         const String& mask,
00402         const bool overwrite=False,
00403         const bool extendMask=False
00404     );
00405 
00406     Bool set(const String& pixels, const Int pixelmask, 
00407              Record& region, const Bool list = false);
00408 
00409     Bool setbrightnessunit(const String& unit);
00410 
00411     bool setcoordsys(const Record& csys);
00412 
00413     bool sethistory(const String& origin, const Vector<String>& history);
00414 
00415     bool setmiscinfo(const Record& info);
00416 
00417     inline static String className() {const static String x = "ImageAnalysis"; return x; }
00418 
00419     Bool setrestoringbeam(
00420         const Quantity& major, const Quantity& minor,
00421         const Quantity& pa, const Record& beam,
00422         const Bool remove = False, const Bool log = True,
00423         Int channel=-1, Int polarization=-1
00424     );
00425 
00426 
00427 
00428     bool twopointcorrelation(
00429         const String& outfile, Record& region,
00430         const String& mask, const Vector<Int>& axes,
00431         const String& method="structurefunction",
00432         const Bool overwrite=False, const Bool stretch=False
00433     );
00434 
00435     /*
00436     ImageInterface<Float> * subimage(const String& outfile, Record& region, 
00437                                      const String& mask, 
00438                                      const Bool dropdeg = False, 
00439                                      const Bool overwrite = False, 
00440                                      const Bool list = True, const Bool extendMask=False);
00441 */
00442     Record summary(
00443         const String& doppler = "RADIO",
00444         const Bool list = True,
00445         const Bool pixelorder = True,
00446         const Bool verbose = False
00447     );
00448 
00449     Bool tofits(
00450         const String& outfile, const Bool velocity, const Bool optical,
00451         const Int bitpix, const Double minpix, const Double maxpix,
00452         Record& region, const String& mask,
00453         const Bool overwrite=False,
00454         const Bool dropdeg=False, const Bool deglast=False,
00455         const Bool dropstokes=False, const Bool stokeslast=False,
00456         const Bool wavelength=False, const Bool airWavelength=False,
00457         const String& origin="", Bool stretch=False,
00458         const Bool history=True
00459     );
00460 
00461     Bool toASCII(
00462         const String& outfile, Record& region, const String& mask,
00463         const String& sep=" ", const String& format="%e",
00464         const Double maskvalue=-999, const Bool overwrite=False,
00465         const Bool extendMask=False
00466     );
00467 
00468 
00469     Vector<Double> topixel(Record& value);
00470 
00471     Record toworld(const Vector<double>& value, const String& format = "n");
00472 
00473     Bool unlock();
00474 
00475     Bool detached();
00476 
00477     Record setregion(const Vector<Int>& blc, const Vector<Int>& trc, 
00478                       const String& infile = "");
00479 
00480     Record setboxregion(const Vector<Double>& blc, const Vector<Double>& trc,
00481                         const Bool frac = False, const String& infile = "");
00482 
00483     //make test image...cube or 2d (default)
00484     bool maketestimage(const String& outfile="", const Bool overwrite=False, 
00485                        const String& imagetype="2d");
00486 
00487     ImageInterface<Float> * newimage(const String& infile,
00488                                      const String& outfile,
00489                                      Record& region,
00490                                      const String& Mask,
00491                                      const bool dropdeg = False,
00492                                      const bool overwrite = False);
00493 
00494     ImageInterface<Float> * newimagefromfile(const String& fileName);
00495 
00496     ImageInterface<Float> * newimagefromarray(const String& outfile,
00497                                               Array<Float> & pixelsArray,
00498                                               const Record& csys,
00499                                               const Bool linear = False,
00500                                               const Bool overwrite = False,
00501                                               const Bool log = True);
00502 
00503     ImageInterface<Float> * newimagefromshape(const String& outfile,
00504                                               const Vector<Int>& shape, 
00505                                               const Record& csys,
00506                                               const Bool linear = True, 
00507                                               const Bool overwrite = False,
00508                                               const Bool log = True);
00509 
00510     ImageInterface<Float> * newimagefromfits(const String& outfile,
00511                                              const String& infile, 
00512                                              const Int whichrep = 0,
00513                                              const Int whichhdu = 0, 
00514                                              const Bool zeroblanks = False, 
00515                                              const Bool overwrite = False);
00516 
00517     Record* echo(Record& v, const Bool godeep = False);
00518 
00519 
00520     //Functions to get you back a spectral profile at direction position x, y.
00521     //x, y are to be in the world coord value or pixel value...user specifies
00522     //by parameter xytype ("world" or "pixel").
00523     //On success returns true
00524     //return value of profile is in zyaxisval, zxaxisval contains the spectral
00525     //values at which zyaxisval is evaluated its in the spectral type
00526     //specified by specaxis...possibilities are "pixel", "frequency", "radio velocity"
00527     //"optical velocity", "wavelength" or "air wavelength" (the code checks for the
00528     //keywords "pixel", "freq", "vel", "optical", and "radio" in the string)
00529     // if "vel" is found but no "radio" or "optical", the full relativistic velocity
00530     // is generated (MFrequency::RELATIVISTIC)
00531     // xunits determines the units of the x-axis values...default is "GHz" for
00532     // freq and "km/s" for vel, "mm" for wavelength and "um" for "air wavelength"
00533     //PLEASE note that the returned value of zyaxisval are the units of the image
00534     //specframe can be a valid frame from MFrequency...i.e LSRK, LSRD etc...
00535     Bool getFreqProfile(const Vector<Double>& xy,
00536                  Vector<Float>& zxaxisval, Vector<Float>& zyaxisval,
00537                  const String& xytype="world",
00538                  const String& specaxis="freq",
00539                  const Int& whichStokes=0,
00540                  const Int& whichTabular=0,
00541                  const Int& whichLinear=0,
00542                  const String& xunits="",
00543                  const String& specframe="",
00544                  const Int& whichQuality=0,
00545                  const String& restValue="");
00546 
00547     //how about using this ?
00548     //for x.shape(xn) & y shape(yn)
00549     //if xn == yn == 1, single point
00550     //if xn == yn == 2, rectangle
00551     //if (xn == yn) > 2, polygon (could originate from ellipse)
00552     Bool getFreqProfile(const Vector<Double>& x,
00553                         const Vector<Double>& y,
00554                         Vector<Float>& zxaxisval, Vector<Float>& zyaxisval,
00555                         const String& xytype="world",
00556                         const String& specaxis="freq",
00557                         const Int& whichStokes=0,
00558                         const Int& whichTabular=0,
00559                         const Int& whichLinear=0,
00560                         const String& xunits="",
00561                         const String& specframe="",
00562                         const Int &combineType=0,
00563                         const Int& whichQuality=0,
00564                         const String& restValue="",
00565                         Int beamChannel = -1);
00566 
00567     // Return a record of the associates ImageInterface 
00568     Bool toRecord(RecordInterface& rec);
00569     // Create a pagedimage if imagename is not "" else create a tempimage
00570     Bool fromRecord(const RecordInterface& rec, const String& imagename="");
00571 
00572     // get the associated ImageInterface object
00573     const ImageInterface<Float>* getImage() const;
00574 
00575     // If file name empty make TempImage (allowTemp=T) or do nothing.
00576     // Otherwise, make a PagedImage from file name and copy mask and
00577     // misc from inimage.   Returns T if image made, F if not
00578     static Bool makeExternalImage (
00579         std::auto_ptr<ImageInterface<Float> >& image,
00580         const String& fileName,
00581         const CoordinateSystem& cSys,
00582         const IPosition& shape,
00583         const ImageInterface<Float>& inImage,
00584         LogIO& os, Bool overwrite=False,
00585         Bool allowTemp=False,
00586         Bool copyMask=True
00587     );
00588 
00589 
00590  private:
00591     
00592     std::auto_ptr<ImageInterface<Float> > _image;
00593     std::auto_ptr<LogIO> _log;
00594 
00595     // Having private version of IS and IH means that they will
00596     // only recreate storage images if they have to
00597 
00598     std::auto_ptr<ImageHistograms<Float> > _histograms;
00599     IPosition last_chunk_shape_p;
00600 
00601     casa::ImageRegion* pOldHistRegionRegion_p;
00602     casa::ImageRegion* pOldHistMaskRegion_p;
00603     Bool oldHistStorageForce_p;
00604     ImageMomentsProgressMonitor* imageMomentsProgressMonitor;
00605 
00606    
00607     // Center refpix apart from STokes
00608     void centreRefPix (casa::CoordinateSystem& cSys,
00609                        const casa::IPosition& shape) const;
00610     
00611     // Convert types
00612     casa::ComponentType::Shape convertModelType (casa::Fit2D::Types typeIn) const;
00613    
00614     // Delete private ImageStatistics and ImageHistograms objects
00615     bool deleteHist();
00616    
00617     static Bool _haveRegionsChanged (
00618         ImageRegion* pNewRegionRegion,
00619         ImageRegion* pNewMaskRegion,
00620         ImageRegion* pOldRegionRegion,
00621         ImageRegion* pOldMaskRegion
00622     );
00623     // Hanning smooth a vector
00624     void hanning_smooth (casa::Array<casa::Float>& out,
00625                          casa::Array<casa::Bool>& maskOut,
00626                          const casa::Vector<casa::Float>& in,
00627                          const casa::Array<casa::Bool>& maskIn,
00628                          casa::Bool isMasked) const;
00629     
00630     
00631 // Make a new image with given CS
00632     casa::Bool make_image(casa::String &error, const casa::String &image,
00633                           const casa::CoordinateSystem& cSys,
00634                           const casa::IPosition& shape,
00635                           casa::LogIO& os, casa::Bool log=casa::True,
00636                           casa::Bool overwrite=casa::False);
00637     
00638     /*
00639 
00640     // Make a mask and define it in the image.
00641     static Bool makeMask(casa::ImageInterface<Float>& out,
00642                         String& maskName,
00643                         Bool init, Bool makeDefault,
00644                         LogIO& os, Bool list);
00645 
00646 */
00647 
00648 // Convert a Record to a CoordinateSystem
00649     casa::CoordinateSystem*
00650       makeCoordinateSystem(const casa::Record& cSys,
00651                            const casa::IPosition& shape) const;
00652     
00653     // Make a block of regions from a Record
00654     void makeRegionBlock(casa::PtrBlock<const casa::ImageRegion*>& regions,
00655                          const casa::Record& Regions,
00656                          casa::LogIO& logger);
00657     
00658     // Set the cache
00659     void set_cache(const casa::IPosition& chunk_shape) const;
00660     
00661 
00662     // Prints an error message if the image DO is detached and returns True.
00663     //bool detached() const;
00664     
00665     // Convert object-id's in the expression to LatticeExprNode objects.
00666     // It returns a string where the object-id's are placed by $n.
00667     // That string can be parsed by ImageExprParse.
00668     // Furthermore it fills the string exprName with the expression
00669     // where the object-id's are replaced by the image names.
00670     // Note that an image name can be an expression in itself, so
00671     // this string is not suitable for the ImageExprParse.
00672     //casa::String substituteOID (casa::Block<casa::LatticeExprNode>& nodes,
00673     //                            casa::String& exprName,
00674     //                            const casa::String& expr) const;
00675 
00676 
00677     // Some helper functions that needs to be in casa namespace coordsys
00678     
00679     Record toWorldRecord (const Vector<Double>& pixel, 
00680                        const String& format) const;
00681 
00682     Record worldVectorToRecord (const Vector<Double>& world, 
00683                                 Int c, const String& format, 
00684                                 Bool isAbsolute, Bool showAsAbsolute) const;
00685 
00686     Record worldVectorToMeasures(const Vector<Double>& world, 
00687                                  Int c, Bool abs) const;
00688 
00689     void trim (Vector<Double>& inout, 
00690                const Vector<Double>& replace) const;
00691 
00692     //return a vector of the spectral axis values in units requested
00693     //e.g "vel", "fre" or "pix"..specVal has to be sized already 
00694     Bool getSpectralAxisVal(const String& specaxis, Vector<Float>& specVal, 
00695                             const CoordinateSystem& cSys, const String& xunits, 
00696                             const String& freqFrame="", const String& restValue="");
00697     //return a vector of the spectral axis values in units requested
00698     //e.g "vel", "fre" or "pix"..specVal has to be sized already
00699 
00700 
00701     ImageInterface<Float> * _regrid(
00702         const String& outfile, const Vector<Int>& shape,
00703         const CoordinateSystem& csys, const Vector<Int>& axes,
00704         const Record& region, const String& mask,
00705         const String& method, const Int decimate,
00706         const Bool replicate, const Bool doref,
00707         const Bool dropdeg, const Bool overwrite,
00708         const Bool force, const Bool extendMask
00709     ) const;
00710 
00711     ImageInterface<Float>* _regridByVelocity(
00712         const String& outfile, const Vector<Int>& shape,
00713         const CoordinateSystem& csysTemplate, const Vector<Int>& axes,
00714         const Record& region, const String& mask,
00715         const String& method, const Int decimate,
00716         const Bool replicate, const Bool doref,
00717         const Bool dropdeg, const Bool overwrite,
00718         const Bool force, const Bool extendMask
00719     ) const;
00720 
00721     ImageInterface<Float>* _fitpolynomial(
00722         const String& residfile,
00723         const String& fitfile,
00724         const String& sigmafile,
00725         const Int axis, const Int order,
00726         Record& region, const String& mask,
00727         const bool overwrite = false
00728     );
00729 
00730 };
00731 
00732 } // casac namespace
00733 #endif
00734