00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00037 #include <measures/Measures/MDirection.h>
00038 #include <measures/Measures/MPosition.h>
00039 #include <measures/Measures/MRadialVelocity.h>
00040
00041 #include <synthesis/MeasurementComponents/CleanImageSkyModel.h>
00042 #include <synthesis/MeasurementComponents/BeamSquint.h>
00043 #include <synthesis/MeasurementComponents/WFCleanImageSkyModel.h>
00044 #include <synthesis/MeasurementComponents/ClarkCleanImageSkyModel.h>
00045 #include <synthesis/MeasurementEquations/SkyEquation.h>
00046 #include <graphics/GenericPlotter/SimplePlotter.h>
00047
00048 namespace casa {
00049
00050
00051 class VisSet;
00052 class MSHistoryHandler;
00053 class PBMath;
00054 class MeasurementSet;
00055 class MFrequency;
00056 class File;
00057 class VPSkyJones;
00058 class PGPlotter;
00059 class EPJones;
00060 template<class T> class ImageInterface;
00061
00062
00063
00064
00065 class Imager
00066 {
00067 public:
00068
00069
00070 Imager();
00071
00072 Imager(MeasurementSet& ms, Bool compress=False);
00073 Imager(MeasurementSet& ms, PGPlotter& pgplotter, Bool compress=False);
00074
00075
00076 Imager(const Imager&);
00077 Imager& operator=(const Imager&);
00078
00079
00080 virtual ~Imager();
00081
00082
00083 virtual Bool openSubTables();
00084
00085
00086
00087 virtual Bool lock();
00088
00089
00090 virtual Bool unlock();
00091
00092
00093
00094
00095 Bool selectDataChannel(VisSet& vs, Vector<Int>& spectralwindowids,
00096 String& dataMode,
00097 Vector<Int>& dataNchan,
00098 Vector<Int>& dataStart, Vector<Int>& dataStep,
00099 MRadialVelocity& mDataStart,
00100 MRadialVelocity& mDataStep);
00101
00102
00103 virtual Bool checkCoord(CoordinateSystem& coordsys,
00104 String& imageName);
00105
00106 virtual void setImageParam(Int& nx, Int& ny, Int& npol, Int& nchan);
00107
00108
00109 virtual void makeVisSet(VisSet* & vs, MeasurementSet& ms,
00110 Bool compress=False, Bool mosaicOrder=False);
00111
00112 virtual void makeVisSet(MeasurementSet& ms,
00113 Bool compress=False, Bool mosaicOrder=False);
00114
00115 virtual void writeHistory(LogIO& os);
00116
00117 virtual void writeCommand(LogIO& os);
00118
00119
00120 Bool makeEmptyImage(CoordinateSystem& imageCoord, String& name, Int fieldID=0);
00121
00122
00123 Bool makePBImage(ImageInterface<Float>& pbImage,
00124 Bool useSymmetricBeam=True);
00125 Bool makePBImage(const CoordinateSystem& imageCoord,
00126 const String& telescopeName, const String& diskPBName,
00127 Bool useSymmetricBeam=True);
00128
00129 Bool makePBImage(const CoordinateSystem& imageCoord,
00130 const Table& vpTable, const String& diskPBName);
00131
00132 Bool makePBImage(const Table& vpTable, ImageInterface<Float>& pbImage);
00133
00134 Bool makePBImage(const CoordinateSystem& imageCoord, PBMath& pbMath, const String& diskPBName);
00135
00136 Bool makePBImage(PBMath& pbMath, ImageInterface<Float>& pbImage);
00137
00138 void setObsInfo(ObsInfo& obsinfo);
00139 ObsInfo& latestObsInfo();
00140
00141
00142
00143 Bool open(MeasurementSet &thems, Bool compress=False);
00144
00145
00146
00147 Bool close();
00148
00149
00150 String name() const;
00151
00152
00153
00154
00155 virtual Bool setimage(const Int nx, const Int ny,
00156 const Quantity& cellx, const Quantity& celly,
00157 const String& stokes,
00158 Bool doShift,
00159 const MDirection& phaseCenter,
00160 const Quantity& shiftx, const Quantity& shifty,
00161 const String& mode, const Int nchan,
00162 const Int start, const Int step,
00163 const MRadialVelocity& mStart, const MRadialVelocity& mStep,
00164 const Vector<Int>& spectralwindowids, const Int fieldid,
00165 const Int facets, const Quantity& distance);
00166
00167 virtual Bool defineImage(const Int nx, const Int ny,
00168 const Quantity& cellx, const Quantity& celly,
00169 const String& stokes,
00170 const MDirection& phaseCenter,
00171 const Int fieldid,
00172 const String& mode, const Int nchan,
00173 const Int start, const Int step,
00174 const MFrequency& mFreqStart,
00175 const MRadialVelocity& mStart,
00176 const Quantity& qStep,
00177 const Vector<Int>& spectralwindowids,
00178 const Quantity& restFreq,
00179 const Int facets, const Quantity& distance,
00180 const Bool trackSource=False, const MDirection&
00181 trackDir=MDirection(Quantity(0.0, "deg"),
00182 Quantity(90.0, "deg")));
00183
00184
00185 virtual Bool setDataPerMS(const String& msname, const String& mode,
00186 const Vector<Int>& nchan,
00187 const Vector<Int>& start,
00188 const Vector<Int>& step,
00189 const Vector<Int>& spectralwindowids,
00190 const Vector<Int>& fieldid,
00191 const String& msSelect="",
00192 const String& timerng="",
00193 const String& fieldnames="",
00194 const Vector<Int>& antIndex=Vector<Int>(),
00195 const String& antnames="",
00196 const String& spwstring="",
00197 const String& uvdist="",
00198 const String& scan="");
00199
00200
00201 Bool setdata(const String& mode, const Vector<Int>& nchan,
00202 const Vector<Int>& start,
00203 const Vector<Int>& step, const MRadialVelocity& mStart,
00204 const MRadialVelocity& mStep,
00205 const Vector<Int>& spectralwindowids,
00206 const Vector<Int>& fieldid,
00207 const String& msSelect="",
00208 const String& timerng="",
00209 const String& fieldnames="",
00210 const Vector<Int>& antIndex=Vector<Int>(),
00211 const String& antnames="",
00212 const String& spwstring="",
00213 const String& uvdist="",
00214 const String& scan="");
00215
00216
00217 Bool setoptions(const String& ftmachine, const Long cache, const Int tile,
00218 const String& gridfunction, const MPosition& mLocation,
00219 const Float padding, const Bool usemodelcol=True,
00220 const Int wprojplanes=1,
00221 const String& epJTableName="",
00222 const Bool applyPointingOffsets=True,
00223 const Bool doPointingCorrection=True,
00224 const String& cfCacheDirName="",
00225 const Float& pastep=5.0,
00226 const Float& pbLimit=5.0e-2);
00227
00228
00229 Bool setsdoptions(const Float scale, const Float weight,
00230 const Int convsupport=-1);
00231
00232
00233 Bool setvp(const Bool dovp,
00234 const Bool defaultVP,
00235 const String& vpTable,
00236 const Bool doSquint,
00237 const Quantity &parAngleInc,
00238 const Quantity &skyPosThreshold,
00239 String defaultTel="");
00240
00241
00242 Bool setscales(const String& scaleMethod,
00243 const Int inscales,
00244 const Vector<Float>& userScaleSizes);
00245
00246
00247 Bool settaylorterms(const Int intaylor);
00248
00249
00250
00251
00252 Bool advise(const Bool takeAdvice, const Float amplitudeloss,
00253 const Quantity& fieldOfView,
00254 Quantity& cell, Int& npixels, Int& facets,
00255 MDirection& phaseCenter);
00256
00257
00258 Bool summary();
00259
00260
00261 String state();
00262
00263
00264 Bool imagecoordinates(CoordinateSystem& coordInfo);
00265
00266
00267 IPosition imageshape() const;
00268
00269
00270 Bool weight(const String& algorithm, const String& rmode,
00271 const Quantity& noise, const Double robust,
00272 const Quantity& fieldofview, const Int npixels);
00273
00274
00275 Bool filter(const String& type, const Quantity& bmaj, const Quantity& bmin,
00276 const Quantity& bpa);
00277
00278
00279 Bool uvrange(const Double& uvmin, const Double& uvmax);
00280
00281
00282 Bool sensitivity(Quantity& pointsourcesens, Double& relativesens, Double& sumwt);
00283
00284
00285 Bool makeimage(const String& type, const String& imageName);
00286
00287
00288 Bool makeimage(const String& type, const String& imageName,
00289 const String& complexImageName);
00290
00291
00292 Bool boxmask(const String& mask, const Vector<Int>& blc,
00293 const Vector<Int>& trc, const Float value);
00294
00295
00296
00297
00298 Bool regionmask(const String& maskimage, Record* imageRegRec,
00299 Matrix<Quantity>& blctrcs, const Float& value=1.0);
00300
00301 static Bool regionToImageMask(const String& maskimage, Record* imageRegRec,
00302 Matrix<Quantity>& blctrcs,
00303 const Float& value=1.0);
00304
00305 Bool clipimage(const String& image, const Quantity& threshold);
00306
00307
00308 Bool mask(const String& mask, const String& imageName,
00309 const Quantity& threshold);
00310
00311
00312 Bool restore(const Vector<String>& model, const String& complist,
00313 const Vector<String>& image, const Vector<String>& residual);
00314
00315
00316 Bool setbeam(const Quantity& bmaj, const Quantity& bmin, const Quantity& bpa);
00317
00318
00319 Bool residual(const Vector<String>& model, const String& complist,
00320 const Vector<String>& image);
00321
00322
00323 Bool approximatepsf(const String& psf);
00324
00325
00326 Bool smooth(const Vector<String>& model,
00327 const Vector<String>& image, Bool usefit,
00328 Quantity& bmaj, Quantity& bmin, Quantity& bpa,
00329 Bool normalizeVolume);
00330
00331
00332 Bool clean(const String& algorithm,
00333 const Int niter,
00334 const Float gain,
00335 const Quantity& threshold,
00336 const Bool displayProgress,
00337 const Vector<String>& model, const Vector<Bool>& fixed,
00338 const String& complist,
00339 const Vector<String>& mask,
00340 const Vector<String>& restored,
00341 const Vector<String>& residual,
00342 const Vector<String>& psf=Vector<String>(0));
00343
00344
00345 Bool mem(const String& algorithm,
00346 const Int niter, const Quantity& sigma,
00347 const Quantity& targetflux,
00348 const Bool constrainflux,
00349 const Bool displayProgress,
00350 const Vector<String>& model, const Vector<Bool>& fixed,
00351 const String& complist,
00352 const Vector<String>& prior,
00353 const Vector<String>& mask,
00354 const Vector<String>& restored,
00355 const Vector<String>& residual);
00356
00357
00358 Bool pixon(const String& algorithm,
00359 const Quantity& sigma,
00360 const String& model);
00361
00362
00363 Bool nnls(const String& algorithm, const Int niter, const Float tolerance,
00364 const Vector<String>& model, const Vector<Bool>& fixed,
00365 const String& complist,
00366 const Vector<String>& fluxMask, const Vector<String>& dataMask,
00367 const Vector<String>& restored,
00368 const Vector<String>& residual);
00369
00370
00371 Bool setmfcontrol(const Float cyclefactor,
00372 const Float cyclespeedup,
00373 const Int stoplargenegatives,
00374 const Int stoppointmode,
00375 const String& scaleType,
00376 const Float minPB,
00377 const Float constPB,
00378 const Vector<String>& fluxscale);
00379
00380
00381 Bool feather(const String& image,
00382 const String& highres,
00383 const String& lowres,
00384 const String& lowpsf);
00385
00386
00387 Bool pb(const String& inimage,
00388 const String& outimage,
00389 const String& incomps,
00390 const String& outcomps,
00391 const String& operation,
00392 const MDirection& pointngCenter,
00393 const Quantity& pa,
00394 const String& pborvp);
00395
00396
00397 Bool linearmosaic(const String& mosaic,
00398 const String& fluxscale,
00399 const String& sensitivity,
00400 const Vector<String>& images,
00401 const Vector<Int>& fieldids);
00402
00403
00404 Bool ft(const Vector<String>& model, const String& complist,
00405 Bool incremental=False);
00406
00407
00408 Bool setjy(const Int fieldid, const Int spectralwindowid,
00409 const Vector<Double>& fluxDensity, const String& standard);
00410 Bool setjy(const Vector<Int>& fieldid, const Vector<Int>& spectralwindowid,
00411 const String& fieldnames, const String& spwstring,
00412 const Vector<Double>& fluxDensity, const String& standard);
00413
00414 Bool setjy(const Vector<Int>& fieldid,
00415 const Vector<Int>& spectralwindowid,
00416 const String& fieldnames, const String& spwstring,
00417 const String& model,
00418 const Vector<Double>& fluxDensity, const String& standard);
00419
00420
00421 Bool make(const String& model);
00422
00423
00424
00425
00426 Bool makemodelfromsd(const String& sdImage, const String& modelimage,
00427 const String& lowPSF,
00428 String& maskImage);
00429
00430
00431 Bool clone(const String& imageName, const String& newImageName);
00432
00433
00434 Bool fitpsf(const String& psf, Quantity& mbmaj, Quantity& mbmin,
00435 Quantity& mbpa);
00436
00437
00438 Bool correct(const Bool doparallactic, const Quantity& t);
00439
00440
00441 Bool plotuv(const Bool rotate);
00442
00443
00444 Bool plotvis(const String& type, const Int increment);
00445
00446
00447 Bool plotweights(const Bool gridded, const Int increment);
00448
00449
00450 Bool plotsummary();
00451
00452
00453 Bool clipvis(const Quantity& threshold);
00454
00455
00456
00457
00458
00459 PGPlotter& getPGPlotter();
00460 void setPGPlotter(PGPlotter& thePlotter);
00461
00462
00463 Bool valid() const;
00464
00465
00466
00467 Int interactivemask(const String& imagename, const String& maskname,
00468 Int& niter, Int& ncycles, String& threshold);
00469
00470 protected:
00471
00472 MeasurementSet* ms_p;
00473 MSHistoryHandler *hist_p;
00474 Table antab_p;
00475 Table datadesctab_p;
00476 Table feedtab_p;
00477 Table fieldtab_p;
00478 Table obstab_p;
00479 Table pointingtab_p;
00480 Table poltab_p;
00481 Table proctab_p;
00482 Table spwtab_p;
00483 Table statetab_p;
00484 Table dopplertab_p;
00485 Table flagcmdtab_p;
00486 Table freqoffsettab_p;
00487 Table historytab_p;
00488 Table sourcetab_p;
00489 Table syscaltab_p;
00490 Table weathertab_p;
00491 Int lockCounter_p;
00492 Int nx_p, ny_p, npol_p, nchan_p;
00493 ObsInfo latestObsInfo_p;
00494
00495
00496
00497
00498 String msname_p;
00499 MeasurementSet *mssel_p;
00500 VisSet *vs_p;
00501 FTMachine *ft_p;
00502 ComponentFTMachine *cft_p;
00503 SkyEquation* se_p;
00504 CleanImageSkyModel* sm_p;
00505 VPSkyJones* vp_p;
00506 VPSkyJones* gvp_p;
00507
00508 Bool setimaged_p, nullSelect_p;
00509 Bool redoSkyModel_p;
00510
00511 Float paStep_p, pbLimit_p;
00512 Int facets_p;
00513 Int wprojPlanes_p;
00514 Quantity mcellx_p, mcelly_p;
00515 String stokes_p;
00516 String dataMode_p, imageMode_p;
00517 Vector<Int> dataNchan_p;
00518 Int imageNchan_p;
00519 Vector<Int> dataStart_p, dataStep_p;
00520 Int imageStart_p, imageStep_p;
00521 MRadialVelocity mDataStart_p, mImageStart_p;
00522 MRadialVelocity mDataStep_p, mImageStep_p;
00523 MFrequency mfImageStart_p, mfImageStep_p;
00524 MDirection phaseCenter_p;
00525 Quantity restFreq_p;
00526 Quantity distance_p;
00527 Bool doShift_p;
00528 Quantity shiftx_p;
00529 Quantity shifty_p;
00530 String ftmachine_p, gridfunction_p;
00531 Bool wfGridding_p;
00532 Long cache_p;
00533 Int tile_p;
00534 MPosition mLocation_p;
00535 Bool doVP_p;
00536 Quantity bmaj_p, bmin_p, bpa_p;
00537 Bool beamValid_p;
00538 Float padding_p;
00539 Float sdScale_p;
00540 Float sdWeight_p;
00541 Int sdConvSupport_p;
00542
00543 Float cyclefactor_p;
00544 Float cyclespeedup_p;
00545 Int stoplargenegatives_p;
00546 Int stoppointmode_p;
00547 Vector<String> fluxscale_p;
00548 String scaleType_p;
00549 Float minPB_p;
00550 Float constPB_p;
00551
00552 Vector<Int> spectralwindowids_p;
00553 Int fieldid_p;
00554
00555 Vector<Int> dataspectralwindowids_p;
00556 Vector<Int> datadescids_p;
00557 Vector<Int> datafieldids_p;
00558
00559 String telescope_p;
00560 String vpTableStr_p;
00561
00562 Quantity parAngleInc_p;
00563 Quantity skyPosThreshold_p;
00564 BeamSquint::SquintType squintType_p;
00565 Bool doDefaultVP_p;
00566
00567 PGPlotter* pgplotter_p;
00568
00569 Bool doMultiFields_p;
00570 Bool multiFields_p;
00571
00572 Bool doWideBand_p;
00573
00574
00575 void defaults();
00576
00577
00578 Bool detached() const;
00579
00580
00581
00582 Bool createFTMachine();
00583
00584 Bool removeTable(const String& tablename);
00585
00586 Bool createSkyEquation(const String complist="");
00587 Bool createSkyEquation(const Vector<String>& image,
00588 const Vector<Bool>& fixed,
00589 const String complist="");
00590 Bool createSkyEquation(const Vector<String>& image,
00591 const String complist="");
00592 Bool createSkyEquation(const Vector<String>& image,
00593 const Vector<Bool>& fixed,
00594 const Vector<String>& mask,
00595 const String complist="");
00596 Bool createSkyEquation(const Vector<String>& image,
00597 const Vector<Bool>& fixed,
00598 const Vector<String>& mask,
00599 const Vector<String>& fluxMask,
00600 const String complist="");
00601 void destroySkyEquation();
00602
00603
00604 Bool addResidualsToSkyEquation(const Vector<String>& residual);
00605
00606
00607 Bool addMasksToSkyEquation(const Vector<String>& mask);
00608
00609
00610
00611 Bool getRestFreq(Vector<Double>& restFreq, const Int& spw);
00612
00613 Bool restoreImages(const Vector<String>& restored);
00614
00615
00616 Bool writeFluxScales(const Vector<String>& fluxScaleNames);
00617
00618 String imageName();
00619
00620 Bool pbguts(ImageInterface<Float>& in,
00621 ImageInterface<Float>& out,
00622 const MDirection&,
00623 const Quantity&);
00624
00625 Bool assertDefinedImageParameters() const;
00626
00627
00628
00629
00630 virtual void setWFCleanImageSkyModel()
00631 {sm_p = new WFCleanImageSkyModel(facets_p, wfGridding_p); return;};
00632
00633 virtual void setClarkCleanImageSkyModel()
00634 {sm_p = new ClarkCleanImageSkyModel(); return;};
00635 virtual void setSkyEquation();
00636
00637 virtual void savePSF(const Vector<String>& psf);
00638
00639 String frmtTime(const Double time);
00640
00641
00642 ComponentList* componentList_p;
00643
00644 String scaleMethod_p;
00645 Int nscales_p;
00646 Int ntaylor_p;
00647 Vector<Float> userScaleSizes_p;
00648 Bool scaleInfoValid_p;
00649
00650 Int nmodels_p;
00651
00652
00653 Block<CountedPtr<PagedImage<Float> > > images_p;
00654 Block<CountedPtr<PagedImage<Float> > > masks_p;
00655 Block<CountedPtr<PagedImage<Float> > > fluxMasks_p;
00656 Block<CountedPtr<PagedImage<Float> > > residuals_p;
00657
00658
00659 Bool freqFrameValid_p;
00660
00661
00662 SkyModel::PolRep polRep_p;
00663
00664
00665 Bool useModelCol_p;
00666
00667
00668 LogSink logSink_p;
00669
00670
00671
00672
00673
00674 EPJones *epJ;
00675 String epJTableName_p, cfCacheDirName_p;
00676 Bool doPointing, doPBCorr;
00677 SimplePlotterPtr plotter_p;
00678 Record interactiveState_p;
00679
00680
00681 Bool doTrackSource_p;
00682 MDirection trackDir_p;
00683
00684
00685 };
00686
00687
00688 }