Commits

Kumar Golap authored 6f285c41ab3 Merge
Merge branch 'bugfix/CAS-11183' into bugfix/CAS-10701

code/synthesis/TransformMachines/HetArrayConvFunc.cc

Modified
471 471 //make sure we are using the same units
472 472 fieldDir.set(dc.worldAxisUnits()(0));
473 473 dc.setReferenceValue(fieldDir.getAngle().getValue());
474 474 coords.replaceCoordinate(dc, directionIndex);
475 475 Int spind=coords.findCoordinate(Coordinate::SPECTRAL);
476 476 SpectralCoordinate spCoord=coords.spectralCoordinate(spind);
477 477 spCoord.setReferencePixel(Vector<Double>(1,0.0));
478 478 spCoord.setReferenceValue(Vector<Double>(1, beamFreqs(0)));
479 479 if(beamFreqs.nelements() >1)
480 480 spCoord.setIncrement(Vector<Double>(1, beamFreqs(1)-beamFreqs(0)));
481 +
481 482 coords.replaceCoordinate(spCoord, spind);
482 483
483 484 IPosition pbShape(4, convSize_p, convSize_p, 1, nBeamChans);
484 485 //TempImage<Complex> twoDPB(pbShape, coords);
485 486
486 487
487 488 TempLattice<Complex> convFuncTemp(TiledShape(IPosition(5, convSize_p/4, convSize_p/4, nBeamPols, nBeamChans, ndishpair), IPosition(5, convSize_p/4, convSize_p/4, 1, 1, 1)), 0);
488 489 TempLattice<Complex> weightConvFuncTemp(TiledShape(IPosition(5, convSize_p/4, convSize_p/4, nBeamPols, nBeamChans, ndishpair), IPosition(5, convSize_p/4, convSize_p/4, 1, 1, 1)), 0);
489 490 //convFunc_p.resize(IPosition(5, convSize_p, convSize_p, nBeamPols, nBeamChans, ndishpair));
490 491
730 731 }
731 732 /*
732 733 rowMap.resize(vb.nRow());
733 734 for (Int k=0; k < vb.nRow(); ++k){
734 735 //plane of convfunc that match this pair of antennas
735 736 rowMap(k)=antIndexToDiamIndex_p(vb.antenna1()(k))*ndish+
736 737 antIndexToDiamIndex_p(vb.antenna2()(k));
737 738
738 739 }
739 740 */
741 +
742 +
740 743 makerowmap(vb, convFuncRowMap);
741 744 ///need to deal with only the maximum of different baselines available in this
742 745 ///vb
743 746 //cerr << "ms " << vb.msName() << " convFuncRowMap " << convFuncRowMap[0] << endl;
744 747 ndishpair=max(convFuncRowMap)+1;
745 748
746 749 convSupportBlock_p.resize(actualConvIndex_p+1);
747 750 convSizes_p.resize(actualConvIndex_p+1);
748 751 //convSupportBlock_p[actualConvIndex_p]=new Vector<Int>(ndishpair);
749 752 //(*convSupportBlock_p[actualConvIndex_p])=convSupport_p;
1023 1026 IPosition shape(5, convFuncLat.shape()[0], convFuncLat.shape()[1], 1, 1, 1);
1024 1027 //Int convSize=convSize_p;
1025 1028 Int convSize=shape(0);
1026 1029 ///use FT weightconvlat as it is wider
1027 1030 Matrix<Complex> convPlane=weightConvFuncLat.getSlice(begin, shape, true);
1028 1031 Float maxAbsConvFunc=max(amplitude(convPlane));
1029 1032 Float minAbsConvFunc=min(amplitude(convPlane));
1030 1033 Bool found=false;
1031 1034 Int trial=0;
1032 1035 for (trial=convSize/2-2;trial>0;trial--) {
1033 - //Searching down a diagonal
1034 - if(abs(convPlane(convSize/2-trial,convSize/2-trial)) > (1e-3*maxAbsConvFunc)) {
1036 + //largest of either
1037 + if((abs(convPlane(convSize/2-trial-1,convSize/2-1)) > (1e-3*maxAbsConvFunc)) || (abs(convPlane(convSize/2-1,convSize/2-trial-1)) > (1e-3*maxAbsConvFunc))) {
1035 1038 found=true;
1036 1039 trial=Int(sqrt(2.0*Float(trial*trial)));
1037 1040 break;
1038 1041 }
1039 1042 }
1040 1043 if(!found){
1041 1044 if((maxAbsConvFunc-minAbsConvFunc) > (1.0e-3*maxAbsConvFunc))
1042 1045 found=true;
1043 1046 // if it drops by more than 2 magnitudes per pixel
1044 1047 trial=( (10*convSampling) < convSize) ? 5*convSampling : (convSize/2 - 4*convSampling);
1251 1254
1252 1255 }
1253 1256
1254 1257 Array<Complex> HetArrayConvFunc::resample(const Array<Complex>& inarray, const Double factor){
1255 1258
1256 1259 Double nx=Double(inarray.shape()(0));
1257 1260 Double ny=Double(inarray.shape()(1));
1258 1261 IPosition shp=inarray.shape();
1259 1262 shp(0)=Int(nx*factor);
1260 1263 shp(1)=Int(ny*factor);
1264 + cerr << "nx " << nx << " ny " << ny << " shape " << shp << endl;
1261 1265
1262 1266 Array<Complex> out(shp);
1263 1267 ArrayIterator<Complex> inIt(inarray, 2);
1264 1268 ArrayIterator<Complex> outIt(out, 2);
1265 1269 //for (zzz=0; zzz< shp.(4); ++zzz){
1266 1270 // for(yyy=0; yyy< shp.(3); ++yyy){
1267 1271 // for(xxx=0; xxx< shp.(2); ++xxx){
1268 1272 while(!inIt.pastEnd()){
1269 1273 Matrix<Float> leReal=real(Matrix<Complex>(inIt.array()));
1270 1274 Matrix<Float> leImag=imag(Matrix<Complex>(inIt.array()));

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

Add shortcut