Commits
Kumar Golap authored and Ville Suoranta committed 528267faf71 Merge
36 36 | |
37 37 | |
38 38 | |
39 39 | |
40 40 | |
41 41 | |
42 42 | |
43 43 | |
44 44 | |
45 45 | |
46 + | |
46 47 | |
47 48 | |
48 49 | |
49 50 | |
50 51 | |
51 52 | |
52 53 | |
53 54 | |
54 55 | |
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 | } |