Commits

Kumar Golap authored and Ville Suoranta committed 528267faf71 Merge
Pull request #647: CAS-13942

Merge in CASA/casa6 from CAS-13942 to master * commit '0f0d268ecb647e18fcc4e994cbe0813fa1ab3fa5': make the behavior for 2 sided shapes as before when using flux instead of sample. This fix some failures in test_simobserve Implemented reviewer's suggestions + some cleanup Fixed a problem arising from SkyComponent::flux returning a fixed number when spectralModel is of the varying kind. Now used the SkyComponent::sample method

casatools/src/code/synthesis/TransformMachines/BeamSkyJones.cc

Modified
36 36 #include <casacore/tables/Tables.h>
37 37 #include <casacore/measures/Measures/Stokes.h>
38 38 #include <casacore/measures/Measures/MeasConvert.h>
39 39
40 40 #include <casacore/casa/BasicSL/Constants.h>
41 41 #include <casacore/measures/Measures/MeasTable.h>
42 42 #include <components/ComponentModels/Flux.h>
43 43 #include <components/ComponentModels/ComponentShape.h>
44 44 #include <components/ComponentModels/TabularSpectrum.h>
45 45 #include <components/ComponentModels/ConstantSpectrum.h>
46 +#include <components/ComponentModels/PointShape.h>
46 47 #include <synthesis/TransformMachines/BeamSkyJones.h>
47 48 #include <synthesis/TransformMachines/PBMath.h>
48 49
49 50 #include <msvis/MSVis/VisBuffer.h>
50 51
51 52 #include <casacore/images/Images/ImageInterface.h>
52 53 #include <casacore/images/Regions/ImageRegion.h>
53 54
54 55 #include <casacore/casa/Utilities/Assert.h>
55 56
477 478 else{
478 479 //Damn people call this with in==out
479 480 //out=in.copy();
480 481 uInt nchan=vb.frequency().nelements();
481 482 Vector<Flux<Double> > vals(nchan, Flux<Double>(0.0));
482 483 Vector<MVFrequency> fs(nchan);
483 484
484 485 Vector<Double> freqs(nchan);
485 486 Bool conv;
486 487 SkyComponent tmp;
488 + Vector<DComplex> normFactor;
489 + normFactor.assign(in.flux().value());
490 + auto poltype=in.flux().pol();
491 + for(size_t k=0; k < normFactor.size(); ++k) {
492 + normFactor[k]= abs(normFactor[k]) >0.0 ? 1.0/abs(normFactor[k]) : 1.0;
493 + }
487 494 vb.lsrFrequency(vb.spectralWindow(), freqs, conv);
488 - for (uInt k=0; k < nchan; ++k){
489 - tmp=in.copy();
490 - myPBMath.applyPB(in, tmp, convertDir(vb, lastDirections_p[lastUpdateIndex1_p], dirType),
491 - Quantity(vb.frequency()(k), "Hz"),
492 - lastParallacticAngles_p[lastUpdateIndex1_p],
493 - doSquint_p, False, threshold(), forward);
494 - vals[k]=tmp.flux();
495 - // cerr << "freq " << freqs(k) << " flux " << vals[k].value() << endl;
496 - fs[k]=MVFrequency(Quantity(freqs(k), "Hz"));
495 + for (uInt k=0; k < nchan; ++k)
496 + {
497 + tmp=in.copy();
498 + PointShape ptshape(in.shape().refDirection());
499 + //Assuming 2 sided shape are small compared to beam otherwise
500 + // we need to know the pixel size
501 + tmp.setShape(ptshape);
502 + MVAngle res(Quantity(1, "mas"));
503 + auto multFactor=normFactor*(tmp.sample(in.shape().refDirection(), res, res,
504 + MFrequency(Quantity(vb.frequency()(k), "Hz"))).value()
505 + );
506 +
507 + myPBMath.applyPB(in, tmp,
508 + convertDir(vb,lastDirections_p[lastUpdateIndex1_p], dirType),
509 + Quantity(vb.frequency()(k), "Hz"),
510 + lastParallacticAngles_p[lastUpdateIndex1_p],
511 + doSquint_p, False, threshold(), forward
512 + );
513 + Flux<Double> tmpFlux=tmp.flux();
514 + tmpFlux.convertPol(poltype);
515 + tmpFlux.setValue(tmpFlux.value()*multFactor);
516 + vals[k]=tmpFlux;
517 + fs[k]=MVFrequency(Quantity(freqs(k), "Hz"));
497 518
498 519 }
499 520 CountedPtr<SpectralModel> spModel;
500 521 if(fs.nelements() >1){
501 522 spModel=new TabularSpectrum();
502 523 static_cast<TabularSpectrum *>(spModel.get())->setValues(fs, vals, MFrequency::Ref(MFrequency::LSRK));
503 524 }
504 525 else{
505 526 spModel=new ConstantSpectrum();
506 527 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut