Commits

Takeshi Nakazato authored c670a85fd7f Merge
Merge pull request #450 in CASA/casa from feature/CAS-10787 to master

* commit 'd4c3f65ff2b50b49c0b4bf10e2edb71b43eb10fe': add test for cubic interpolation update test_apply_sky06 add a comment update unit test test_apply_sky06 since interp='cubic' is now available modified so that CTTimeInterp::interpolate() can interpolate data with cubic line.

code/synthesis/CalTables/test/tCTTimeInterp1.cc

Modified
96 96
97 97 if (verbose) cout << "Testing 'nearest' (tol="<<tol<<")..." << endl;
98 98 for (uInt itime=0;itime<timelist.nelements();++itime) {
99 99 // Call time interpolation
100 100 sci.interpolate(timelist(itime));
101 101 Complex cfval=NewCalTable::NCTtestvalueC(0,0,0,ntimelist(itime),refTime,tint);
102 102 RIorAPArray f(result);
103 103 // Matrix<Complex> c(f.c());
104 104 Complex rc=Matrix<Complex>(f.c())(0,0);
105 105 Float diff=abs(rc-cfval);
106 - if (verbose)
106 + //if (verbose)
107 107 cout << "t="<<timelist(itime)<<" (dt="<<(timelist(itime)-refTime)/tint<<")"
108 108 << " result = " << rc << " cf=" << cfval << " diff="<< diff << " near=" << boolalpha << nearAbs(diff,0.0f,tol) << endl;
109 109 AlwaysAssert(nearAbs(diff,0.0f,tol),AipsError);
110 110 }
111 111 }
112 112
113 113 // Reset to linear
114 114 itype="linear";
115 115 sci.setInterpType(itype);
116 116
133 133 timelist(5)=refTime+1.e5*tint; ntimelist(5)=refTime+(nTime-1)*tint; // a way late point
134 134
135 135 if (verbose) cout << "Testing 'linear' (tol="<<tol<<")..." << endl;
136 136 for (uInt itime=0;itime<timelist.nelements();++itime) {
137 137 // Call time interpolation
138 138 sci.interpolate(timelist(itime));
139 139 Complex cfval=NewCalTable::NCTtestvalueC(0,0,0,ntimelist(itime),refTime,tint);
140 140 RIorAPArray f(result);
141 141 Complex rc=Matrix<Complex>(f.c())(0,0);
142 142 Float diff=abs(rc-cfval);
143 - if (verbose)
143 + //if (verbose)
144 + cout << "t="<<timelist(itime)<<" (dt="<<(timelist(itime)-refTime)/tint<<")"
145 + << " result = " << rc << " cf=" << cfval << " diff="<<diff<< " near=" << boolalpha << nearAbs(diff,0.0f,tol) << endl;
146 + AlwaysAssert(nearAbs(diff,0.0f,tol),AipsError);
147 + }
148 + }
149 +
150 + // Reset to cubic
151 + itype="cubic";
152 + sci.setInterpType(itype);
153 +
154 + if (verbose)
155 + sci.state();
156 +
157 + if (verbose) cout << "sci.timeType() = " << sci.timeType() << endl;
158 + AlwaysAssert( (sci.timeType()==itype), AipsError);
159 +
160 +
161 +
162 + {
163 + // Testing cubic in various ways
164 + Vector<Double> timelist(6), ntimelist(6);
165 + timelist(0)=refTime-1.e5*tint; ntimelist(0)=refTime; // a way early point
166 + timelist(1)=refTime+tint; ntimelist(1)=timelist(1); // an exact point
167 + timelist(2)=refTime+2.2*tint; ntimelist(2)=timelist(2); // nearest to left
168 + timelist(3)=refTime+2.9*tint; ntimelist(3)=timelist(3); // nearest to right (same interval)
169 + timelist(4)=refTime+3.1*tint; ntimelist(4)=timelist(4); // new time, new interval
170 + timelist(5)=refTime+1.e5*tint; ntimelist(5)=refTime+(nTime-1)*tint; // a way late point
171 +
172 + if (verbose) cout << "Testing 'cubic' (tol="<<tol<<")..." << endl;
173 + for (uInt itime=0;itime<timelist.nelements();++itime) {
174 + // Call time interpolation
175 + sci.interpolate(timelist(itime));
176 + Complex cfval=NewCalTable::NCTtestvalueC(0,0,0,ntimelist(itime),refTime,tint);
177 + RIorAPArray f(result);
178 + Complex rc=Matrix<Complex>(f.c())(0,0);
179 + Float diff=abs(rc-cfval);
180 + //if (verbose)
144 181 cout << "t="<<timelist(itime)<<" (dt="<<(timelist(itime)-refTime)/tint<<")"
145 182 << " result = " << rc << " cf=" << cfval << " diff="<<diff<< " near=" << boolalpha << nearAbs(diff,0.0f,tol) << endl;
146 183 AlwaysAssert(nearAbs(diff,0.0f,tol),AipsError);
147 184 }
148 185 }
149 186
150 187 }
151 188
152 189
153 190 }

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

Add shortcut