casa
$Rev:20696$
|
00001 //# Imager.h: Imager functionality sits here; 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library 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 Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 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 //# 00025 //# $Id$ 00026 00027 #ifndef SYNTHESIS_IMAGER_H 00028 #define SYNTHESIS_IMAGER_H 00029 00030 #include <casa/aips.h> 00031 #include <casa/OS/Timer.h> 00032 #include <casa/Containers/Record.h> 00033 #include <ms/MeasurementSets/MeasurementSet.h> 00034 #include <casa/Arrays/IPosition.h> 00035 #include <casa/Quanta/Quantum.h> 00036 #include <components/ComponentModels/ConstantSpectrum.h> 00037 00038 #include <measures/Measures/MDirection.h> 00039 #include <components/ComponentModels/FluxStandard.h> 00040 //#include <measures/Measures/MDirection.h 00041 #include <measures/Measures/MPosition.h> 00042 #include <measures/Measures/MRadialVelocity.h> 00043 00044 #include <synthesis/TransformMachines/FTMachine.h> 00045 #include <synthesis/TransformMachines/StokesImageUtil.h> 00046 00047 #include <synthesis/MeasurementComponents/CleanImageSkyModel.h> 00048 #include <synthesis/TransformMachines/EVLAAperture.h> 00049 #include <synthesis/TransformMachines/BeamSquint.h> 00050 #include <synthesis/MeasurementComponents/WFCleanImageSkyModel.h> 00051 #include <synthesis/MeasurementComponents/ClarkCleanImageSkyModel.h> 00052 #include <synthesis/MeasurementEquations/SkyEquation.h> 00053 #include <synthesis/TransformMachines/ATerm.h> 00054 #include <graphics/GenericPlotter/SimplePlotter.h> 00055 00056 00057 namespace casa { //# NAMESPACE CASA - BEGIN 00058 00059 // Forward declarations 00060 class VisSet; 00061 class VisImagingWeight_p; 00062 class MSHistoryHandler; 00063 class PBMath; 00064 class MeasurementSet; 00065 class MDirection; 00066 class MFrequency; 00067 class File; 00068 class VPSkyJones; 00069 class EPJones; 00070 class ViewerProxy; 00071 template<class T> class ImageInterface; 00072 00073 // <summary> Class that contains functions needed for imager </summary> 00074 00075 00076 class Imager 00077 { 00078 public: 00079 // Default constructor 00080 00081 Imager(); 00082 00083 Imager(MeasurementSet& ms, Bool compress=False, Bool useModel=False); 00084 Imager(MeasurementSet& ms, Bool compress=False); 00085 00086 // Copy constructor and assignment operator 00087 Imager(const Imager&); 00088 Imager& operator=(const Imager&); 00089 00090 // Destructor 00091 virtual ~Imager(); 00092 00093 // open all the subtables as userNoReadLock 00094 virtual Bool openSubTables(); 00095 00096 00097 // Lock the ms and its subtables 00098 virtual Bool lock(); 00099 00100 // Unlock the ms and its subtables 00101 virtual Bool unlock(); 00102 00103 00104 // Utility function to do channel selection 00105 00106 Bool selectDataChannel(Vector<Int>& spectralwindowids, 00107 String& dataMode, 00108 Vector<Int>& dataNchan, 00109 Vector<Int>& dataStart, Vector<Int>& dataStep, 00110 MRadialVelocity& mDataStart, 00111 MRadialVelocity& mDataStep); 00112 //Utility function to check coordinate match with existing image 00113 00114 virtual Bool checkCoord(const CoordinateSystem& coordsys, 00115 const String& imageName); 00116 00117 virtual void setImageParam(Int& nx, Int& ny, Int& npol, Int& nchan); 00118 00119 //VisSet and resort 00120 virtual void makeVisSet(MeasurementSet& ms, 00121 Bool compress=False, Bool mosaicOrder=False); 00122 //Just to create the SORTED_TABLE if one can 00123 //virtual void makeVisSet(MeasurementSet& ms, 00124 // Bool compress=False, Bool mosaicOrder=False); 00125 00126 virtual void writeHistory(LogIO& os); 00127 00128 virtual void writeCommand(LogIO& os); 00129 00130 //make an empty image 00131 Bool makeEmptyImage(CoordinateSystem& imageCoord, String& name, Int fieldID=0); 00132 00133 //Functions to make Primary beams 00134 Bool makePBImage(ImageInterface<Float>& pbImage, 00135 Bool useSymmetricBeam=True); 00136 Bool makePBImage(const CoordinateSystem& imageCoord, 00137 const String& telescopeName, const String& diskPBName, 00138 Bool useSymmetricBeam=True, Double dishdiam=-1.0); 00139 00140 Bool makePBImage(const CoordinateSystem& imageCoord, 00141 const Table& vpTable, const String& diskPBName); 00142 00143 Bool makePBImage(const Table& vpTable, ImageInterface<Float>& pbImage); 00144 00145 Bool makePBImage(const CoordinateSystem& imageCoord, PBMath& pbMath, const String& diskPBName); 00146 00147 Bool makePBImage(PBMath& pbMath, ImageInterface<Float>& pbImage); 00148 00149 void setObsInfo(ObsInfo& obsinfo); 00150 ObsInfo& latestObsInfo(); 00151 // Close the current ms, and replace it with the supplied ms. 00152 // Optionally compress the attached calibration data 00153 // columns if they are created here. 00154 Bool open(MeasurementSet &thems, Bool compress=False, Bool useModel=False); 00155 00156 // Flush the ms to disk and detach from the ms file. All function 00157 // calls after this will be a no-op. 00158 Bool close(); 00159 00160 // Return the name of the MeasurementSet 00161 String name() const; 00162 00163 // The following setup methods define the state of the imager. 00164 // <group> 00165 // Set image construction parameters 00166 virtual Bool setimage(const Int nx, const Int ny, 00167 const Quantity& cellx, const Quantity& celly, 00168 const String& stokes, 00169 Bool doShift, 00170 const MDirection& phaseCenter, 00171 const Quantity& shiftx, const Quantity& shifty, 00172 const String& mode, const Int nchan, 00173 const Int start, const Int step, 00174 const MRadialVelocity& mStart, const MRadialVelocity& mStep, 00175 const Vector<Int>& spectralwindowids, const Int fieldid, 00176 const Int facets, const Quantity& distance); 00177 00178 virtual Bool defineImage(const Int nx, const Int ny, 00179 const Quantity& cellx, const Quantity& celly, 00180 const String& stokes, 00181 const MDirection& phaseCenter, 00182 const Int fieldid, 00183 const String& mode, const Int nchan, 00184 const Int start, const Int step, 00185 const MFrequency& mFreqStart, 00186 const MRadialVelocity& mStart, 00187 const Quantity& qStep, 00188 const Vector<Int>& spectralwindowids, 00189 const Int facets=1, 00190 const Quantity& restFreq=Quantity(0,"Hz"), 00191 const MFrequency::Types& mFreqFrame=MFrequency::LSRK, 00192 const Quantity& distance=Quantity(0,"m"), 00193 const Bool trackSource=False, const MDirection& 00194 trackDir=MDirection(Quantity(0.0, "deg"), 00195 Quantity(90.0, "deg"))); 00196 // Set the data selection parameters 00197 00198 // The parameters useModelcol and readonly is dummy here 00199 //as they are useful for the ImagerMultiMS version only 00200 virtual Bool setDataPerMS(const String& msname, const String& mode, 00201 const Vector<Int>& nchan, 00202 const Vector<Int>& start, 00203 const Vector<Int>& step, 00204 const Vector<Int>& spectralwindowids, 00205 const Vector<Int>& fieldid, 00206 const String& msSelect="", 00207 const String& timerng="", 00208 const String& fieldnames="", 00209 const Vector<Int>& antIndex=Vector<Int>(), 00210 const String& antnames="", 00211 const String& spwstring="", 00212 const String& uvdist="", 00213 const String& scan="", 00214 const String& obs="", 00215 const Bool useModelCol=False, 00216 const Bool readonly=False); 00217 00218 // Select some data. 00219 // Sets nullSelect_p and returns !nullSelect_p. 00220 // be_calm: lowers the logging level of some messages if True. 00221 Bool setdata(const String& mode, const Vector<Int>& nchan, 00222 const Vector<Int>& start, 00223 const Vector<Int>& step, const MRadialVelocity& mStart, 00224 const MRadialVelocity& mStep, 00225 const Vector<Int>& spectralwindowids, 00226 const Vector<Int>& fieldid, 00227 const String& msSelect="", 00228 const String& timerng="", 00229 const String& fieldnames="", 00230 const Vector<Int>& antIndex=Vector<Int>(), 00231 const String& antnames="", 00232 const String& spwstring="", 00233 const String& uvdist="", 00234 const String& scan="", 00235 const String& obs="", 00236 const Bool usemodelCol=False, 00237 const Bool be_calm=false); 00238 00239 // Set the processing options 00240 Bool setoptions(const String& ftmachine, const Long cache, const Int tile, 00241 const String& gridfunction, const MPosition& mLocation, 00242 const Float padding, 00243 const Int wprojplanes=1, 00244 const String& epJTableName="", 00245 const Bool applyPointingOffsets=True, 00246 const Bool doPointingCorrection=True, 00247 const String& cfCacheDirName="", 00248 const Float& rotpastep=5.0, 00249 const Float& computepastep=360.0, 00250 const Float& pbLimit=5.0e-2, 00251 const String& freqinterpmethod="linear", 00252 const Int imageTileSizeInPix=0, 00253 const Bool singleprecisiononly=False, 00254 const Int numthreads=-1, 00255 const Bool psTermOn=True, 00256 const Bool aTermOn=True, 00257 const Bool mTermOn=False, 00258 const Bool wbAWP=False, 00259 const Bool conjBeams=True); 00260 00261 // Set the single dish processing options 00262 Bool setsdoptions(const Float scale, const Float weight, 00263 const Int convsupport=-1, String pointingColToUse="DIRECTION", 00264 const Quantity truncate=Quantity(), 00265 const Quantity gwidth=Quantity(), 00266 const Quantity jwidth=Quantity()); 00267 00268 // Set the voltage pattern 00269 Bool setvp(const Bool dovp, 00270 const Bool defaultVP, 00271 const String& vpTable, 00272 const Bool doSquint, 00273 const Quantity &parAngleInc, 00274 const Quantity &skyPosThreshold, 00275 String defaultTel="", 00276 const Bool verbose=true); 00277 00278 // Set the scales to be searched in Multi Scale clean 00279 Bool setscales(const String& scaleMethod, // "nscales" or "uservector" 00280 const Int inscales, 00281 const Vector<Float>& userScaleSizes); 00282 // set bias 00283 Bool setSmallScaleBias(const Float inbias); 00284 00285 // Set the number of taylor series terms in the expansion of the 00286 // image as a function of frequency. 00287 Bool settaylorterms(const Int intaylor, 00288 const Double inreffreq); 00289 00290 // </group> 00291 00292 // Advise on suitable values 00293 Bool advise(const Bool takeAdvice, const Float amplitudeloss, 00294 const Quantity& fieldOfView, 00295 Quantity& cell, Int& npixels, Int& facets, 00296 MDirection& phaseCenter); 00297 00298 // Output a summary of the state of the object 00299 Bool summary(); 00300 00301 // Return the state of the object as a string 00302 String state(); 00303 00304 // Return the # of visibilities accessible to *rvi, optionally excluding 00305 // flagged ones (if unflagged_only is true) and/or ones without imaging 00306 // weights (if must_have_imwt is true). 00307 uInt count_visibilities(ROVisibilityIterator *rvi, 00308 const Bool unflagged_only, const Bool must_have_imwt); 00309 00310 // Return the image coordinates 00311 Bool imagecoordinates(CoordinateSystem& coordInfo, const Bool verbose=true); 00312 // new version 00313 Bool imagecoordinates2(CoordinateSystem& coordInfo, const Bool verbose=true); 00314 00315 // Return the image shape 00316 IPosition imageshape() const; 00317 00318 // Weight the MeasurementSet 00319 //For some time of weighting briggs/uniform ...one can do it on a per field basis to calculate 00320 //weight density distribution. If that is what is wanted multiField should be set to True 00321 //multifield is inoperative for natural, radial weighting 00322 Bool weight(const String& algorithm, const String& rmode, 00323 const Quantity& noise, const Double robust, 00324 const Quantity& fieldofview, const Int npixels, const Bool multiField=False); 00325 00326 // Filter the MeasurementSet 00327 Bool filter(const String& type, const Quantity& bmaj, const Quantity& bmin, 00328 const Quantity& bpa); 00329 00330 // Apply a uvrange 00331 Bool uvrange(const Double& uvmin, const Double& uvmax); 00332 00333 // Sensitivity 00334 Bool sensitivity(Quantity& pointsourcesens, Double& relativesens, Double& sumwt, 00335 Matrix<Int>& mssChanSel, 00336 Vector<Vector<Int> >& nData, 00337 Vector<Vector<Double> >& sumwtChan, 00338 Vector<Vector<Double> >& sumwtsqChan, 00339 Vector<Vector<Double> >& sumInverseVarianceChan); 00340 00341 // Make plain image + keep the complex image as well if complexImageName != "". 00342 Bool makeimage(const String& type, const String& imageName, 00343 const String& complexImageName="", const Bool verbose=true); 00344 00345 // Fill in a region of a mask 00346 Bool boxmask(const String& mask, const Vector<Int>& blc, 00347 const Vector<Int>& trc,const Float value); 00348 00349 //Make a region either from record or array of blc trc 00350 //(Matrix(nboxes,4)) into a mask image 00351 //value is the value of the mask pixels 00352 //circular masks has form Matrix(ncircles,3) 00353 //where the 3 values on a row are radius, x, y pixel values 00354 Bool regionmask(const String& maskimage, Record* imageRegRec, 00355 Matrix<Quantity>& blctrcs, Matrix<Float>& circles, 00356 const Float& value=1.0); 00357 00358 static Bool regionToImageMask(const String& maskimage, Record* imageRegRec, 00359 Matrix<Quantity>& blctrcs, 00360 Matrix<Float>& circles, 00361 const Float& value=1.0); 00362 // Clip on Stokes I 00363 Bool clipimage(const String& image, const Quantity& threshold); 00364 00365 // Make a mask image 00366 static Bool mask(const String& mask, const String& imageName, 00367 const Quantity& threshold); 00368 00369 // Restore 00370 Bool restore(const Vector<String>& model, const String& complist, 00371 const Vector<String>& image, const Vector<String>& residual); 00372 00373 // similar to restore except this is to be called if you fiddle with the model and complist 00374 // outside of this object (say you clip stuff etc) ...keep the sm_p and se_p state but just calculate new residuals and 00375 // restored images. Will throw an exception is se_p or sm_p is not valid (i.e you should have used clean, mem etc before hand). 00376 Bool updateresidual(const Vector<String>& model, const String& complist, 00377 const Vector<String>& image, const Vector<String>& residual); 00378 00379 // Setbeam 00380 Bool setbeam(const ImageBeamSet& beam); 00381 00382 // Residual 00383 Bool residual(const Vector<String>& model, const String& complist, 00384 const Vector<String>& image); 00385 00386 // Approximate PSF 00387 Bool approximatepsf(const String& psf); 00388 00389 // Smooth 00390 Bool smooth(const Vector<String>& model, 00391 const Vector<String>& image, Bool usefit, 00392 ImageBeamSet& mbeam, 00393 Bool normalizeVolume); 00394 00395 // Clean algorithm 00396 Record clean(const String& algorithm, 00397 const Int niter, 00398 const Float gain, 00399 const Quantity& threshold, 00400 const Bool displayProgress, 00401 const Vector<String>& model, const Vector<Bool>& fixed, 00402 const String& complist, 00403 const Vector<String>& mask, 00404 const Vector<String>& restored, 00405 const Vector<String>& residual, 00406 const Vector<String>& psf=Vector<String>(0), 00407 const Bool firstrun=true); 00408 00409 Record iClean(const String& algorithm, 00410 const Int niter, 00411 const Double gain, 00412 //const String& threshold, 00413 const Quantity& threshold, 00414 const Bool displayprogress, 00415 const Vector<String>& model, 00416 const Vector<Bool>& keepfixed, const String& complist, 00417 const Vector<String>& mask, 00418 const Vector<String>& image, 00419 const Vector<String>& residual, 00420 const Vector<String>& psfnames, 00421 const Bool interactive, const Int npercycle, 00422 const String& masktemplate); 00423 00424 // MEM algorithm 00425 Bool mem(const String& algorithm, 00426 const Int niter, const Quantity& sigma, 00427 const Quantity& targetflux, 00428 const Bool constrainflux, 00429 const Bool displayProgress, 00430 const Vector<String>& model, const Vector<Bool>& fixed, 00431 const String& complist, 00432 const Vector<String>& prior, 00433 const Vector<String>& mask, 00434 const Vector<String>& restored, 00435 const Vector<String>& residual); 00436 00437 // pixon algorithm 00438 Bool pixon(const String& algorithm, 00439 const Quantity& sigma, 00440 const String& model); 00441 00442 // NNLS algorithm 00443 Bool nnls(const String& algorithm, const Int niter, const Float tolerance, 00444 const Vector<String>& model, const Vector<Bool>& fixed, 00445 const String& complist, 00446 const Vector<String>& fluxMask, const Vector<String>& dataMask, 00447 const Vector<String>& restored, 00448 const Vector<String>& residual); 00449 00450 // Multi-field control parameters 00451 //flat noise is the parameter that control the search of clean components 00452 //in a flat noise image or an optimum beam^2 image 00453 Bool setmfcontrol(const Float cyclefactor, 00454 const Float cyclespeedup, 00455 const Float cyclemaxpsffraction, 00456 const Int stoplargenegatives, 00457 const Int stoppointmode, 00458 const String& scaleType, 00459 const Float minPB, 00460 const Float constPB, 00461 const Vector<String>& fluxscale, 00462 const Bool flatnoise=True); 00463 00464 // Feathering algorithm 00465 Bool feather(const String& image, 00466 const String& highres, 00467 const String& lowres, 00468 const String& lowpsf, const Float dishDiam=-1.0, const Bool lowPassFilterSD=False); 00469 00470 // Apply or correct for Primary Beam or Voltage Pattern 00471 Bool pb(const String& inimage, 00472 const String& outimage, 00473 const String& incomps, 00474 const String& outcomps, 00475 const String& operation, 00476 const MDirection& pointngCenter, 00477 const Quantity& pa, 00478 const String& pborvp); 00479 00480 // Make a linear mosaic of several images 00481 Bool linearmosaic(const String& mosaic, 00482 const String& fluxscale, 00483 const String& sensitivity, 00484 const Vector<String>& images, 00485 const Vector<Int>& fieldids); 00486 00487 // Fourier transform the model and componentlist. 00488 // Returns its nominal success value. 00489 Bool ft(const Vector<String>& model, const String& complist, 00490 Bool incremental=False); 00491 00492 // Compute the model visibility using specified source flux densities 00493 Bool setjy(const Int fieldid, const Int spectralwindowid, 00494 const Vector<Double>& fluxDensity, const String& standard); 00495 Bool setjy(const Vector<Int>& fieldid, const Vector<Int>& spectralwindowid, 00496 const String& fieldnames, const String& spwstring, 00497 const Vector<Double>& fluxDensity, const String& standard); 00498 00499 //Setjy with model image. If chanDep=True then the scaling is calculated on a 00500 //per channel basis for the model image...otherwise the whole spw gets the 00501 //same flux density. 00502 Bool setjy(const Vector<Int>& fieldid, 00503 const Vector<Int>& spectralwindowid, 00504 const String& fieldnames, const String& spwstring, 00505 const String& model, 00506 const Vector<Double>& fluxDensity, const String& standard, 00507 const Bool chanDep=False, const Double spix=0.0, 00508 const MFrequency& reffreq=MFrequency(Quantity(1.0, "GHz"), 00509 MFrequency::LSRK), 00510 const String& timerange="", const String& scanstr="", 00511 const String& obsidstr=""); 00512 00513 // Make an empty image 00514 Bool make(const String& model); 00515 00516 // make a model from a SD image. 00517 // This model then can be used as initial clean model to include the 00518 // shorter spacing. 00519 Bool makemodelfromsd(const String& sdImage, const String& modelimage, 00520 const String& lowPSF, 00521 String& maskImage); 00522 00523 // Write a component list to disk, starting with prefix, using a setjy 00524 // standard, and return the name of the list. 00525 String make_comp(const String& objName, const String& standard, 00526 const MEpoch& mtime, const Vector<MFrequency>& freqv, 00527 const String& prefix); 00528 00529 // Clone an image 00530 static Bool clone(const String& imageName, const String& newImageName); 00531 00532 // Fit the psf 00533 Bool fitpsf(const String& psf, ImageBeamSet& mbeam); 00534 00535 // Correct the visibility data (OBSERVED->CORRECTED) 00536 Bool correct(const Bool doparallactic, const Quantity& t); 00537 00538 // Plot the uv plane 00539 Bool plotuv(const Bool rotate); 00540 00541 // Plot the visibilities 00542 Bool plotvis(const String& type, const Int increment); 00543 00544 // Plot the weights 00545 Bool plotweights(const Bool gridded, const Int increment); 00546 00547 // Plot a summary 00548 Bool plotsummary(); 00549 00550 // Clip visibilities 00551 Bool clipvis(const Quantity& threshold); 00552 00553 00554 //Check if can proceed with this object 00555 Bool valid() const; 00556 00557 00558 //Interactive mask drawing 00559 //forceReload..forces the viewer to dump previous image that is being displayed 00560 Int interactivemask(const String& imagename, const String& maskname, 00561 Int& niter, Int& ncycles, String& threshold, const Bool forceReload=False); 00562 00563 00564 //helper function to copy a mask from one image to another 00565 00566 Bool copyMask(ImageInterface<Float>& out, const ImageInterface<Float>& in, String maskname="mask0", Bool setdefault=True); 00567 00568 00569 // Supports the "[] or -1 => everything" convention using the rule: 00570 // If v is empty or only has 1 element, and it is < 0, 00571 // replace v with 0, 1, ..., nelem - 1. 00572 // Returns whether or not it modified v. 00573 // If so, v is modified in place. 00574 static Bool expand_blank_sel(Vector<Int>& v, const uInt nelem); 00575 00576 //spectral gridding calculation for output images (use SubMS::calcChanFreqs) 00577 Bool calcImFreqs(Vector<Double>& imfreqs, Vector<Double>& imfreqres, 00578 const MFrequency::Types& oldRefFrame, 00579 const MEpoch& obsEpoch, const MPosition& obsPosition, 00580 const Double& restFreq); 00581 00582 // Advise the chanselection needed for the frequency range or 00583 // give the frequency range for a give spwselection if getFreqRange==True 00584 // if the parameter msname is used then the MSs associated associated with 00585 // this object (that have been either 'open'ed or 'selectvis'ed) are ignored 00586 // In this mode it is a helper function to the general world ...no need to 00587 // open or selectvis. You need to specify the field_id for which this calculation is 00588 // being done for in the helper mode. 00589 // If you have already set MS's and selected data and msname="" then 00590 // the calulation is done for the field(s) selected in selectvis. 00591 // getFreqRange=True then the freqrange in the frame and spwselection you choose is 00592 // returned in freqStart and freqEnd (in the case of msname="" then it is for the fields 00593 //and spw you have chosen in selectvis). 00594 Bool adviseChanSelex(Double& freqStart, Double& freqEnd, 00595 const Double& freqStep, const MFrequency::Types& freqframe, 00596 Vector< Vector<Int> >& spw, Vector< Vector<Int> >& start, 00597 Vector< Vector<Int> >& nchan, const String& msname="", 00598 const Int fieldid=0, const Bool getFreqRange=False, 00599 const String spwselection=""); 00600 00601 00602 //These are utility functions when weights from different imager instances 00603 //need to reconciled in parallel gridding by different instances of imagers 00604 //for example. 00605 // when type is "imaging" 00606 // getweightGrid will get the weight density for uniform style imaging weight 00607 // the Block elements are for different fields if independent field weighting 00608 // was done. 00609 // when type is "ftweight"..then a Vector of string is expected in weightimage 00610 // which is of the same length as the number of models put in clean etc 00611 00612 Bool getWeightGrid(Block<Matrix<Float> >&weightgrid, const String& type, const Vector<String>& weightImagenames=Vector<String>()); 00613 Bool setWeightGrid(const Block<Matrix<Float> >& weightgrid, const String& type); 00614 String dQuantitytoString(const Quantity& dq); 00615 00616 protected: 00617 00618 CountedPtr<MeasurementSet> ms_p; 00619 CountedPtr<MSHistoryHandler> hist_p; 00620 Table antab_p; 00621 Table datadesctab_p; 00622 Table feedtab_p; 00623 Table fieldtab_p; 00624 Table obstab_p; 00625 Table pointingtab_p; 00626 Table poltab_p; 00627 Table proctab_p; 00628 Table spwtab_p; 00629 Table statetab_p; 00630 Table dopplertab_p; 00631 Table flagcmdtab_p; 00632 Table freqoffsettab_p; 00633 Table historytab_p; 00634 Table sourcetab_p; 00635 Table syscaltab_p; 00636 Table weathertab_p; 00637 Int lockCounter_p; 00638 Int nx_p, ny_p, npol_p, nchan_p; 00639 ObsInfo latestObsInfo_p; 00640 //What should be the tile volume on disk 00641 Int imageTileVol_p; 00642 00643 00644 00645 String msname_p; 00646 CountedPtr<MeasurementSet> mssel_p; 00647 VisSet *vs_p; 00648 ROVisibilityIterator* rvi_p; 00649 VisibilityIterator* wvi_p; 00650 FTMachine *ft_p; 00651 ComponentFTMachine *cft_p; 00652 SkyEquation* se_p; 00653 CleanImageSkyModel* sm_p; 00654 VPSkyJones* vp_p; 00655 VPSkyJones* gvp_p; 00656 00657 Bool setimaged_p, nullSelect_p; 00658 Bool redoSkyModel_p; // if clean is run multiply ..use this to check 00659 // if setimage was changed hence redo the skyModel. 00660 Float rotPAStep_p, computePAStep_p, pbLimit_p; 00661 Int facets_p; 00662 Int wprojPlanes_p; 00663 Quantity mcellx_p, mcelly_p; 00664 String stokes_p; 00665 String dataMode_p; 00666 String imageMode_p; // channel, (optical)velocity, mfs, or frequency 00667 Vector<Int> dataNchan_p; 00668 Int imageNchan_p; 00669 Vector<Int> dataStart_p, dataStep_p; 00670 Int imageStart_p, imageStep_p; 00671 MRadialVelocity mDataStart_p, mImageStart_p; 00672 MRadialVelocity mDataStep_p, mImageStep_p; 00673 MFrequency mfImageStart_p, mfImageStep_p; 00674 MFrequency::Types freqFrame_p; 00675 MDirection phaseCenter_p; 00676 Quantity restFreq_p; 00677 Quantity distance_p; 00678 Bool doShift_p; 00679 Quantity shiftx_p; 00680 Quantity shifty_p; 00681 String ftmachine_p, gridfunction_p; 00682 Bool wfGridding_p; 00683 Long cache_p; 00684 Int tile_p; 00685 MPosition mLocation_p; 00686 Bool doVP_p; 00687 ImageBeamSet beam_p; 00688 Bool beamValid_p; 00689 Float padding_p; 00690 Float sdScale_p; 00691 Float sdWeight_p; 00692 Int sdConvSupport_p; 00693 00694 Quantity qtruncate_p; 00695 Quantity qgwidth_p; 00696 Quantity qjwidth_p; 00697 00698 // special mf control parms, etc 00699 Float cyclefactor_p; 00700 Float cyclespeedup_p; 00701 Float cyclemaxpsffraction_p; 00702 Int stoplargenegatives_p; 00703 Int stoppointmode_p; 00704 Vector<String> fluxscale_p; 00705 String scaleType_p; // type of image-plane scaling: NONE, SAULT 00706 Float minPB_p; // minimum value of generalized-PB pattern 00707 Float constPB_p; // above this level, constant flux-scale 00708 00709 Vector<Int> spectralwindowids_p; 00710 Int fieldid_p; 00711 00712 Vector<Int> dataspectralwindowids_p; 00713 Vector<Int> datadescids_p; 00714 Vector<Int> datafieldids_p; 00715 //TT 00716 Cube<Int> spwchansels_p; 00717 Matrix<Double> freqrange_p; 00718 Matrix<Double> mssFreqSel_p; 00719 Matrix<Int> mssChanSel_p; 00720 00721 Int numMS_p; 00722 00723 String telescope_p; 00724 String vpTableStr_p; // description of voltage patterns for various telescopes 00725 // in the MS 00726 Quantity parAngleInc_p; 00727 Quantity skyPosThreshold_p; 00728 BeamSquint::SquintType squintType_p; 00729 Bool doDefaultVP_p; // make default VPs, rather than reading in a vpTable 00730 00731 00732 Bool doMultiFields_p; // Do multiple fields? 00733 Bool multiFields_p; // multiple fields have been specified in setdata 00734 00735 Bool doWideBand_p; // Do Multi Frequency Synthesis Imaging 00736 String freqInterpMethod_p; //frequency interpolation mode 00737 00738 Bool flatnoise_p; 00739 00740 // Set the defaults 00741 void defaults(); 00742 00743 // check if it is dettahced from ms. 00744 Bool detached() const; 00745 00746 // Create the FTMachines when necessary or when the control parameters 00747 // have changed. 00748 Bool createFTMachine(); 00749 00750 void openSubTable (const Table & otherTable, Table & table, const TableLock & tableLock); 00751 00752 Bool removeTable(const String& tablename); 00753 Bool updateSkyModel(const Vector<String>& model, 00754 const String complist); 00755 Bool createSkyEquation(const String complist=""); 00756 Bool createSkyEquation(const Vector<String>& image, 00757 const Vector<Bool>& fixed, 00758 const String complist=""); 00759 Bool createSkyEquation(const Vector<String>& image, 00760 const String complist=""); 00761 Bool createSkyEquation(const Vector<String>& image, 00762 const Vector<Bool>& fixed, 00763 const Vector<String>& mask, 00764 const String complist=""); 00765 Bool createSkyEquation(const Vector<String>& image, 00766 const Vector<Bool>& fixed, 00767 const Vector<String>& mask, 00768 const Vector<String>& fluxMask, 00769 const String complist=""); 00770 ATerm* createTelescopeATerm(MeasurementSet& ms, const Bool& isATermOn=True); 00771 void destroySkyEquation(); 00772 00773 //add residual to the private vars or create residual images 00774 Bool addResiduals(const Vector<String>& residual); 00775 // Add the residuals to the SkyEquation 00776 Bool addResidualsToSkyEquation(const Vector<String>& residual); 00777 00778 // Add or replace the masks 00779 Bool addMasksToSkyEquation(const Vector<String>& mask, const Vector<Bool>& fixed=Vector<Bool>(0)); 00780 00781 // Get the rest frequency ..returns 1 element in restfreq 00782 // if user specified or try to get the info from the SOURCE table 00783 Bool getRestFreq(Vector<Double>& restFreq, const Int& spw); 00784 00785 Bool restoreImages(const Vector<String>& restored, Bool modresiduals=True); 00786 00787 // names of flux scale images 00788 Bool writeFluxScales(const Vector<String>& fluxScaleNames); 00789 00790 // Helper functions to hide some setjy code. 00791 Unit sjy_setup_arrs(Vector<Vector<Flux<Double> > >& returnFluxes, 00792 Vector<Vector<Flux<Double> > >& returnFluxErrs, 00793 Vector<String>& tempCLs, 00794 Vector<Vector<MFrequency> >& mfreqs, 00795 const ROMSSpWindowColumns& spwcols, const uInt nspws, 00796 const Vector<Int>& selToRawSpwIds, const Bool chanDep); 00797 // Returns whether it might have made any visibilities. 00798 Bool sjy_make_visibilities(TempImage<Float> *tmodimage, LogIO& os, 00799 const Int rawspwid, const Int fldid, 00800 const String& clname, const String& timerange="", 00801 const String& scanstr="", 00802 const String& obsidstr="", 00803 const Vector<Double>& freqofscale=Vector<Double>(0), 00804 const Vector<Double>& scale=Vector<Double>(0) ); 00805 // Returns whether it found a source. 00806 Bool sjy_computeFlux(LogIO& os, FluxStandard& fluxStd, 00807 Vector<Vector<Flux<Double> > >& returnFluxes, 00808 Vector<Vector<Flux<Double> > >& returnFluxErrs, 00809 Vector<String>& tempCLs, Vector<Double>& fluxUsed, 00810 String& fluxScaleName, 00811 const Vector<Vector<MFrequency> >& mfreqs, 00812 const String& model, const String& fieldName, 00813 const ROMSColumns& msc, const Int fldid, 00814 const MDirection& fieldDir, const String& standard); 00815 // Returns NULL if no image is prepared. 00816 TempImage<Float>* sjy_prepImage(LogIO& os, FluxStandard& fluxStd, 00817 Vector<Double>& fluxUsed, 00818 Vector<Double>& freq, 00819 Vector<Double>& scale, const String& model, 00820 const ROMSSpWindowColumns& spwcols, 00821 const Int rawspwid, const Bool chanDep, 00822 const Vector<Vector<MFrequency> >& mfreqs, 00823 const uInt selspw, const String& fieldName, 00824 const MDirection& fieldDir, const Unit& freqUnit, 00825 const Vector<Double>& fluxdens, 00826 const Bool precompute, const Double spix, 00827 const MFrequency& reffreq); 00828 // Returns True or throws up. 00829 Bool sjy_regridCubeChans(TempImage<Float>* tmodimage, 00830 PagedImage<Float>& modimage, Int freqAxis); 00831 00832 // set a radius limit if the model image is one of the known source 00833 // otherwise simply copy modimage to tmodimage 00834 Bool sjy_setRadiusLimit(TempImage<Float>* tmodimage, 00835 PagedImage<Float>& modimage, const String& model, 00836 DirectionCoordinate& dircsys); 00837 00838 String imageName(); 00839 00840 Bool pbguts(ImageInterface<Float>& in, 00841 ImageInterface<Float>& out, 00842 const MDirection&, 00843 const Quantity&); 00844 00845 // Helper func for printing clean's restoring beam to the logger. May find 00846 // the restoring beam as a side effect, so sm_p can't be const. 00847 void printbeam(CleanImageSkyModel *sm_p, LogIO &os, const Bool firstrun=true); 00848 00849 // Helper func for createFTMachine(). Returns phaseCenter_p as a String, 00850 // *assuming* it is set. It does not check! 00851 String tangentPoint(); 00852 00853 00854 Bool assertDefinedImageParameters() const; 00855 // Virtual methods to set the ImageSkyModel and SkyEquation. 00856 // This allows derived class pimager to set parallelized 00857 // specializations. 00858 // 00859 virtual void setWFCleanImageSkyModel() 00860 {sm_p = new WFCleanImageSkyModel(facets_p, wfGridding_p); return;}; 00861 00862 virtual void setClarkCleanImageSkyModel() 00863 {sm_p = new ClarkCleanImageSkyModel(); return;}; 00864 virtual void setSkyEquation(); 00865 00866 virtual void savePSF(const Vector<String>& psf); 00867 00868 String frmtTime(const Double time); 00869 00870 //copy imageregion to pixels on image as value given 00871 static Bool regionToMask(ImageInterface<Float>& maskImage, ImageRegion& imagreg, const Float& value=1.0); 00872 00873 //set the mosaic ft machine and right convolution function 00874 virtual void setMosaicFTMachine(Bool useDoublePrec=False); 00875 00876 // Makes a component list on disk containing cmp (with fluxval and cspectrum) 00877 // named msname_p.fieldName.spw<spwid>.tempcl and returns the name. 00878 String makeComponentList(const String& fieldName, const Int spwid, 00879 const Flux<Double>& fluxval, 00880 const ComponentShape& cmp, 00881 const ConstantSpectrum& cspectrum) const; 00882 00883 Vector<Int> decideNPolPlanes(Bool checkwithMS); 00884 00885 ComponentList* componentList_p; 00886 00887 String scaleMethod_p; // "nscales" or "uservector" 00888 Int nscales_p; 00889 Int ntaylor_p; 00890 Double reffreq_p; 00891 Bool useNewMTFT_p; 00892 Vector<Float> userScaleSizes_p; 00893 Bool scaleInfoValid_p; // This means that we have set the information, not the scale beams 00894 Float smallScaleBias_p; //ms-clean 00895 Int nmodels_p; 00896 // Everything here must be a real class since we make, handle and 00897 // destroy these. 00898 Block<CountedPtr<PagedImage<Float> > > images_p; 00899 Block<CountedPtr<PagedImage<Float> > > masks_p; 00900 Block<CountedPtr<PagedImage<Float> > > fluxMasks_p; 00901 Block<CountedPtr<PagedImage<Float> > > residuals_p; 00902 00903 // Freq frame is good and valid conversions can be done (or not) 00904 Bool freqFrameValid_p; 00905 00906 // Preferred complex polarization representation 00907 StokesImageUtil::PolRep polRep_p; 00908 00909 //Whether to use model column or use it in memory on the fly 00910 Bool useModelCol_p; 00911 00912 //Force single precision always 00913 Bool singlePrec_p; 00914 //sink used to store history mainly 00915 LogSink logSink_p; 00916 00917 00918 // 00919 // Objects required for pointing correction (ftmachine=PBWProject) 00920 // 00921 EPJones *epJ; 00922 String epJTableName_p, cfCacheDirName_p; 00923 Bool doPointing, doPBCorr, psTermOn_p, aTermOn_p, mTermOn_p, wbAWP_p, conjBeams_p; 00924 //SimplePlotterPtr plotter_p; 00925 Record interactiveState_p; 00926 00927 //Track moving source stuff 00928 Bool doTrackSource_p; 00929 MDirection trackDir_p; 00930 String pointingDirCol_p; 00931 VisImagingWeight imwgt_p; 00932 00933 // viewer connection 00934 ViewerProxy *viewer_p; 00935 int clean_panel_p; 00936 int image_id_p; 00937 int mask_id_p; 00938 int prev_image_id_p; 00939 int prev_mask_id_p; 00940 //numthreads 00941 Int numthreads_p; 00942 }; 00943 00944 00945 } //# NAMESPACE CASA - END 00946 00947 #endif