Changeset 2917
- Timestamp:
- 04/03/14 19:17:29 (11 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STMath.cpp
r2916 r2917 57 57 #include "STIdxIter.h" 58 58 59 #include "CalibrationHelper.h" 60 59 61 using namespace casa; 60 62 using namespace asap; 63 64 // namespace { 65 // class CalibrationIterator 66 // { 67 // public: 68 // CalibrationIterator() 69 // : table_(table) 70 // {} 71 // ~CalibrationIterator() {} 72 // void Iterate() { 73 // STSelector sel; 74 // vector<string> cols( 3 ) ; 75 // cols[0] = "BEAMNO" ; 76 // cols[1] = "POLNO" ; 77 // cols[2] = "IFNO" ; 78 // STIdxIter2 iter(out, cols); 79 // while ( !iter.pastEnd() ) { 80 // Record ids = iter.currentValue(); 81 // stringstream ss ; 82 // ss << "SELECT FROM $1 WHERE " 83 // << "BEAMNO==" << ids.asuInt("BEAMNO") << "&&" 84 // << "POLNO==" << ids.asuInt("POLNO") << "&&" 85 // << "IFNO==" << ids.asuInt("IFNO") ; 86 // //cout << "TaQL string: " << ss.str() << endl ; 87 // sel.setTaQL( ss.str() ) ; 88 // //// 89 // // begin individual processing 90 // aoff->setSelection( sel ) ; 91 // ahot->setSelection( sel ) ; 92 // asky->setSelection( sel ) ; 93 // Vector<uInt> rows = iter.getRows( SHARE ) ; 94 // // out should be an exact copy of s except that SPECTRA column is empty 95 // calibrateCW( out, s, aoff, asky, ahot, acold, rows, antname ) ; 96 // aoff->unsetSelection() ; 97 // ahot->unsetSelection() ; 98 // asky->unsetSelection() ; 99 // // end individual processing 100 // //// 101 // sel.reset() ; 102 // iter.next() ; 103 // } 104 // }; 105 // protected: 106 // CountedPtr<Scantable> table_; 107 // }; 108 109 110 // } // anonymous namespace 61 111 62 112 // 2012/02/17 TN … … 4006 4056 } 4007 4057 4008 Vector<Float> STMath::getSpectrumFromTime( double reftime,4009 const Vector<Double> &timeVec,4010 const vector<int> &idx,4011 const Matrix<Float>& spectra,4012 string mode )4013 {4014 LogIO os( LogOrigin( "STMath", "getSpectrumFromTime", WHERE ) ) ;4015 Vector<Float> sp ;4016 uInt ncol = spectra.ncolumn() ;4017 4018 if ( ncol == 0 ) {4019 os << LogIO::SEVERE << "No spectra in the input scantable. Return empty spectrum." << LogIO::POST ;4020 return sp ;4021 }4022 else if ( ncol == 1 ) {4023 //os << "use row " << 0 << " (scanno = " << s->getScan( 0 ) << ")" << LogIO::POST ;4024 sp.reference( spectra.column( 0 ) ) ;4025 return sp ;4026 }4027 else {4028 if ( mode == "before" ) {4029 int id = -1 ;4030 if ( idx[0] != -1 ) {4031 id = idx[0] ;4032 }4033 else if ( idx[1] != -1 ) {4034 os << LogIO::WARN << "Failed to find a scan before reftime. return a spectrum just after the reftime." << LogIO::POST ;4035 id = idx[1] ;4036 }4037 //os << "use row " << id << " (scanno = " << s->getScan( id ) << ")" << LogIO::POST ;4038 sp.reference( spectra.column( id ) ) ;4039 }4040 else if ( mode == "after" ) {4041 int id = -1 ;4042 if ( idx[1] != -1 ) {4043 id = idx[1] ;4044 }4045 else if ( idx[0] != -1 ) {4046 os << LogIO::WARN << "Failed to find a scan after reftime. return a spectrum just before the reftime." << LogIO::POST ;4047 id = idx[1] ;4048 }4049 //os << "use row " << id << " (scanno = " << s->getScan( id ) << ")" << LogIO::POST ;4050 sp.reference( spectra.column( id ) ) ;4051 }4052 else if ( mode == "nearest" ) {4053 int id = -1 ;4054 if ( idx[0] == -1 ) {4055 id = idx[1] ;4056 }4057 else if ( idx[1] == -1 ) {4058 id = idx[0] ;4059 }4060 else if ( idx[0] == idx[1] ) {4061 id = idx[0] ;4062 }4063 else {4064 double t0 = timeVec[idx[0]] ;4065 double t1 = timeVec[idx[1]] ;4066 double tref = reftime ;4067 if ( abs( t0 - tref ) > abs( t1 - tref ) ) {4068 id = idx[1] ;4069 }4070 else {4071 id = idx[0] ;4072 }4073 }4074 //os << "use row " << id << " (scanno = " << s->getScan( id ) << ")" << LogIO::POST ;4075 sp.reference( spectra.column( id ) ) ;4076 }4077 else if ( mode == "linear" ) {4078 if ( idx[0] == -1 ) {4079 // use after4080 os << LogIO::WARN << "Failed to interpolate. return a spectrum just after the reftime." << LogIO::POST ;4081 int id = idx[1] ;4082 //os << "use row " << id << " (scanno = " << s->getScan( id ) << ")" << LogIO::POST ;4083 sp.reference( spectra.column( id ) ) ;4084 }4085 else if ( idx[1] == -1 ) {4086 // use before4087 os << LogIO::WARN << "Failed to interpolate. return a spectrum just before the reftime." << LogIO::POST ;4088 int id = idx[0] ;4089 //os << "use row " << id << " (scanno = " << s->getScan( id ) << ")" << LogIO::POST ;4090 sp.reference( spectra.column( id ) ) ;4091 }4092 else if ( idx[0] == idx[1] ) {4093 // use before4094 //os << "No need to interporate." << LogIO::POST ;4095 int id = idx[0] ;4096 //os << "use row " << id << " (scanno = " << s->getScan( id ) << ")" << LogIO::POST ;4097 sp.reference( spectra.column( id ) ) ;4098 }4099 else {4100 // do interpolation4101 //os << "interpolate between " << idx[0] << " and " << idx[1] << " (scanno: " << s->getScan( idx[0] ) << ", " << s->getScan( idx[1] ) << ")" << LogIO::POST ;4102 double t0 = timeVec[idx[0]] ;4103 double t1 = timeVec[idx[1]] ;4104 double tref = reftime ;4105 sp = spectra.column( idx[0] ).copy() ;4106 Vector<Float> sp1( spectra.column( idx[1] ) ) ;4107 double tfactor = ( tref - t0 ) / ( t1 - t0 ) ;4108 for ( unsigned int i = 0 ; i < sp.size() ; i++ ) {4109 sp[i] = ( sp1[i] - sp[i] ) * tfactor + sp[i] ;4110 }4111 }4112 }4113 else {4114 os << LogIO::SEVERE << "Unknown mode" << LogIO::POST ;4115 }4116 return sp ;4117 }4118 }4119 4120 vector<int> STMath::getRowIdFromTime( double reftime, const Vector<Double> &t )4121 {4122 // double reft = reftime ;4123 double dtmin = 1.0e100 ;4124 double dtmax = -1.0e100 ;4125 // vector<double> dt ;4126 int just_before = -1 ;4127 int just_after = -1 ;4128 Vector<Double> dt = t - reftime ;4129 for ( unsigned int i = 0 ; i < dt.size() ; i++ ) {4130 if ( dt[i] > 0.0 ) {4131 // after reftime4132 if ( dt[i] < dtmin ) {4133 just_after = i ;4134 dtmin = dt[i] ;4135 }4136 }4137 else if ( dt[i] < 0.0 ) {4138 // before reftime4139 if ( dt[i] > dtmax ) {4140 just_before = i ;4141 dtmax = dt[i] ;4142 }4143 }4144 else {4145 // just a reftime4146 just_before = i ;4147 just_after = i ;4148 dtmax = 0 ;4149 dtmin = 0 ;4150 break ;4151 }4152 }4153 4154 vector<int> v(2) ;4155 v[0] = just_before ;4156 v[1] = just_after ;4157 4158 return v ;4159 }4160 4161 Vector<Float> STMath::getTcalFromTime( double reftime,4162 const Vector<Double> &timeVec,4163 const vector<int> &idx,4164 const CountedPtr<Scantable>& s,4165 string mode )4166 {4167 LogIO os( LogOrigin( "STMath", "getTcalFromTime", WHERE ) ) ;4168 STTcal tcalTable = s->tcal() ;4169 String time ;4170 Vector<Float> tcalval ;4171 if ( s->nrow() == 0 ) {4172 os << LogIO::SEVERE << "No row in the input scantable. Return empty tcal." << LogIO::POST ;4173 return tcalval ;4174 }4175 else if ( s->nrow() == 1 ) {4176 uInt tcalid = s->getTcalId( 0 ) ;4177 //os << "use row " << 0 << " (tcalid = " << tcalid << ")" << LogIO::POST ;4178 tcalTable.getEntry( time, tcalval, tcalid ) ;4179 return tcalval ;4180 }4181 else {4182 if ( mode == "before" ) {4183 int id = -1 ;4184 if ( idx[0] != -1 ) {4185 id = idx[0] ;4186 }4187 else if ( idx[1] != -1 ) {4188 os << LogIO::WARN << "Failed to find a scan before reftime. return a spectrum just after the reftime." << LogIO::POST ;4189 id = idx[1] ;4190 }4191 uInt tcalid = s->getTcalId( id ) ;4192 //os << "use row " << id << " (tcalid = " << tcalid << ")" << LogIO::POST ;4193 tcalTable.getEntry( time, tcalval, tcalid ) ;4194 }4195 else if ( mode == "after" ) {4196 int id = -1 ;4197 if ( idx[1] != -1 ) {4198 id = idx[1] ;4199 }4200 else if ( idx[0] != -1 ) {4201 os << LogIO::WARN << "Failed to find a scan after reftime. return a spectrum just before the reftime." << LogIO::POST ;4202 id = idx[1] ;4203 }4204 uInt tcalid = s->getTcalId( id ) ;4205 //os << "use row " << id << " (tcalid = " << tcalid << ")" << LogIO::POST ;4206 tcalTable.getEntry( time, tcalval, tcalid ) ;4207 }4208 else if ( mode == "nearest" ) {4209 int id = -1 ;4210 if ( idx[0] == -1 ) {4211 id = idx[1] ;4212 }4213 else if ( idx[1] == -1 ) {4214 id = idx[0] ;4215 }4216 else if ( idx[0] == idx[1] ) {4217 id = idx[0] ;4218 }4219 else {4220 double t0 = timeVec[idx[0]] ;4221 double t1 = timeVec[idx[1]] ;4222 if ( abs( t0 - reftime ) > abs( t1 - reftime ) ) {4223 id = idx[1] ;4224 }4225 else {4226 id = idx[0] ;4227 }4228 }4229 uInt tcalid = s->getTcalId( id ) ;4230 //os << "use row " << id << " (tcalid = " << tcalid << ")" << LogIO::POST ;4231 tcalTable.getEntry( time, tcalval, tcalid ) ;4232 }4233 else if ( mode == "linear" ) {4234 if ( idx[0] == -1 ) {4235 // use after4236 os << LogIO::WARN << "Failed to interpolate. return a spectrum just after the reftime." << LogIO::POST ;4237 int id = idx[1] ;4238 uInt tcalid = s->getTcalId( id ) ;4239 //os << "use row " << id << " (tcalid = " << tcalid << ")" << LogIO::POST ;4240 tcalTable.getEntry( time, tcalval, tcalid ) ;4241 }4242 else if ( idx[1] == -1 ) {4243 // use before4244 os << LogIO::WARN << "Failed to interpolate. return a spectrum just before the reftime." << LogIO::POST ;4245 int id = idx[0] ;4246 uInt tcalid = s->getTcalId( id ) ;4247 //os << "use row " << id << " (tcalid = " << tcalid << ")" << LogIO::POST ;4248 tcalTable.getEntry( time, tcalval, tcalid ) ;4249 }4250 else if ( idx[0] == idx[1] ) {4251 // use before4252 //os << "No need to interporate." << LogIO::POST ;4253 int id = idx[0] ;4254 uInt tcalid = s->getTcalId( id ) ;4255 //os << "use row " << id << " (tcalid = " << tcalid << ")" << LogIO::POST ;4256 tcalTable.getEntry( time, tcalval, tcalid ) ;4257 }4258 else {4259 // do interpolation4260 //os << "interpolate between " << idx[0] << " and " << idx[1] << " (scanno: " << s->getScan( idx[0] ) << ", " << s->getScan( idx[1] ) << ")" << LogIO::POST ;4261 double t0 = timeVec[idx[0]] ;4262 double t1 = timeVec[idx[1]] ;4263 Vector<Float> tcal0 ;4264 uInt tcalid0 = s->getTcalId( idx[0] ) ;4265 uInt tcalid1 = s->getTcalId( idx[1] ) ;4266 tcalTable.getEntry( time, tcal0, tcalid0 ) ;4267 tcalTable.getEntry( time, tcalval, tcalid1 ) ;4268 double tfactor = (reftime - t0) / (t1 - t0) ;4269 for ( unsigned int i = 0 ; i < tcal0.size() ; i++ ) {4270 tcalval[i] = ( tcalval[i] - tcal0[i] ) * tfactor + tcal0[i] ;4271 }4272 }4273 }4274 else {4275 os << LogIO::SEVERE << "Unknown mode" << LogIO::POST ;4276 }4277 return tcalval ;4278 }4279 }4280 4281 Vector<Float> STMath::getTsysFromTime( double reftime,4282 const Vector<Double> &timeVec,4283 const vector<int> &idx,4284 const CountedPtr<Scantable> &s,4285 string mode )4286 {4287 LogIO os( LogOrigin( "STMath", "getTsysFromTime", WHERE ) ) ;4288 ArrayColumn<Float> tsysCol ;4289 tsysCol.attach( s->table(), "TSYS" ) ;4290 Vector<Float> tsysval ;4291 if ( s->nrow() == 0 ) {4292 os << LogIO::SEVERE << "No row in the input scantable. Return empty tsys." << LogIO::POST ;4293 return tsysval ;4294 }4295 else if ( s->nrow() == 1 ) {4296 //os << "use row " << 0 << LogIO::POST ;4297 tsysval = tsysCol( 0 ) ;4298 return tsysval ;4299 }4300 else {4301 if ( mode == "before" ) {4302 int id = -1 ;4303 if ( idx[0] != -1 ) {4304 id = idx[0] ;4305 }4306 else if ( idx[1] != -1 ) {4307 os << LogIO::WARN << "Failed to find a scan before reftime. return a spectrum just after the reftime." << LogIO::POST ;4308 id = idx[1] ;4309 }4310 //os << "use row " << id << LogIO::POST ;4311 tsysval = tsysCol( id ) ;4312 }4313 else if ( mode == "after" ) {4314 int id = -1 ;4315 if ( idx[1] != -1 ) {4316 id = idx[1] ;4317 }4318 else if ( idx[0] != -1 ) {4319 os << LogIO::WARN << "Failed to find a scan after reftime. return a spectrum just before the reftime." << LogIO::POST ;4320 id = idx[1] ;4321 }4322 //os << "use row " << id << LogIO::POST ;4323 tsysval = tsysCol( id ) ;4324 }4325 else if ( mode == "nearest" ) {4326 int id = -1 ;4327 if ( idx[0] == -1 ) {4328 id = idx[1] ;4329 }4330 else if ( idx[1] == -1 ) {4331 id = idx[0] ;4332 }4333 else if ( idx[0] == idx[1] ) {4334 id = idx[0] ;4335 }4336 else {4337 double t0 = timeVec[idx[0]] ;4338 double t1 = timeVec[idx[1]] ;4339 if ( abs( t0 - reftime ) > abs( t1 - reftime ) ) {4340 id = idx[1] ;4341 }4342 else {4343 id = idx[0] ;4344 }4345 }4346 //os << "use row " << id << LogIO::POST ;4347 tsysval = tsysCol( id ) ;4348 }4349 else if ( mode == "linear" ) {4350 if ( idx[0] == -1 ) {4351 // use after4352 os << LogIO::WARN << "Failed to interpolate. return a spectrum just after the reftime." << LogIO::POST ;4353 int id = idx[1] ;4354 //os << "use row " << id << LogIO::POST ;4355 tsysval = tsysCol( id ) ;4356 }4357 else if ( idx[1] == -1 ) {4358 // use before4359 os << LogIO::WARN << "Failed to interpolate. return a spectrum just before the reftime." << LogIO::POST ;4360 int id = idx[0] ;4361 //os << "use row " << id << LogIO::POST ;4362 tsysval = tsysCol( id ) ;4363 }4364 else if ( idx[0] == idx[1] ) {4365 // use before4366 //os << "No need to interporate." << LogIO::POST ;4367 int id = idx[0] ;4368 //os << "use row " << id << LogIO::POST ;4369 tsysval = tsysCol( id ) ;4370 }4371 else {4372 // do interpolation4373 //os << "interpolate between " << idx[0] << " and " << idx[1] << " (scanno: " << s->getScan( idx[0] ) << ", " << s->getScan( idx[1] ) << ")" << LogIO::POST ;4374 double t0 = timeVec[idx[0]] ;4375 double t1 = timeVec[idx[1]] ;4376 Vector<Float> tsys0 ;4377 tsys0 = tsysCol( idx[0] ) ;4378 tsysval = tsysCol( idx[1] ) ;4379 double tfactor = (reftime - t0) / (t1 - t0) ;4380 for ( unsigned int i = 0 ; i < tsys0.size() ; i++ ) {4381 tsysval[i] = ( tsysval[i] - tsys0[i] ) * tfactor + tsys0[i] ;4382 }4383 }4384 }4385 else {4386 os << LogIO::SEVERE << "Unknown mode" << LogIO::POST ;4387 }4388 return tsysval ;4389 }4390 }4391 4392 4058 void STMath::calibrateCW( CountedPtr<Scantable> &out, 4393 4059 const CountedPtr<Scantable>& on, … … 4413 4079 timeCol.attach( on->table(), "TIME" ) ; 4414 4080 ROArrayColumn<Float> arrayFloatCol( off->table(), "SPECTRA" ) ; 4415 Matrix<Float> offspectra = arrayFloatCol.getColumn();4081 SpectralData offspectra(arrayFloatCol.getColumn()); 4416 4082 arrayFloatCol.attach( sky->table(), "SPECTRA" ) ; 4417 Matrix<Float> skyspectra = arrayFloatCol.getColumn();4083 SpectralData skyspectra(arrayFloatCol.getColumn()); 4418 4084 arrayFloatCol.attach( hot->table(), "SPECTRA" ) ; 4419 Matrix<Float> hotspectra = arrayFloatCol.getColumn() ; 4085 SpectralData hotspectra(arrayFloatCol.getColumn()); 4086 TcalData tcaldata(sky); 4087 TsysData tsysdata(sky); 4420 4088 unsigned int spsize = on->nchan( on->getIF(rows[0]) ) ; 4421 4089 // I know that the data is contiguous … … 4427 4095 double reftime = timeCol.asdouble(*p) ; 4428 4096 ids = getRowIdFromTime( reftime, timeOff ) ; 4429 Vector<Float> spoff = getSpectrumFromTime( reftime, timeOff, ids, offspectra, "linear" );4097 Vector<Float> spoff = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeOff, ids, offspectra, "linear"); 4430 4098 ids = getRowIdFromTime( reftime, timeSky ) ; 4431 Vector<Float> spsky = getSpectrumFromTime( reftime, timeSky, ids, skyspectra, "linear" );4432 Vector<Float> tcal = getTcalFromTime( reftime, timeSky, ids, sky, "linear" );4433 Vector<Float> tsys = getTsysFromTime( reftime, timeSky, ids, sky, "linear" );4099 Vector<Float> spsky = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeSky, ids, skyspectra, "linear"); 4100 Vector<Float> tcal = SimpleInterpolationHelper<TcalData>::GetFromTime(reftime, timeSky, ids, tcaldata, "linear"); 4101 Vector<Float> tsys = SimpleInterpolationHelper<TsysData>::GetFromTime(reftime, timeSky, ids, tsysdata, "linear"); 4434 4102 ids = getRowIdFromTime( reftime, timeHot ) ; 4435 Vector<Float> sphot = getSpectrumFromTime( reftime, timeHot, ids, hotspectra, "linear" );4103 Vector<Float> sphot = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeHot, ids, hotspectra, "linear"); 4436 4104 Vector<Float> spec = on->specCol_( *p ) ; 4437 4105 if ( antname.find( "APEX" ) != String::npos ) { … … 4489 4157 timeCol.attach( on->table(), "TIME" ) ; 4490 4158 ROArrayColumn<Float> arrayFloatCol( off->table(), "SPECTRA" ) ; 4491 Matrix<Float> offspectra = arrayFloatCol.getColumn();4159 SpectralData offspectra(arrayFloatCol.getColumn()); 4492 4160 unsigned int spsize = on->nchan( on->getIF(rows[0]) ) ; 4493 4161 // I know that the data is contiguous … … 4499 4167 double reftime = timeCol.asdouble(*p) ; 4500 4168 ids = getRowIdFromTime( reftime, timeVec ) ; 4501 Vector<Float> spoff = getSpectrumFromTime( reftime, timeVec, ids, offspectra, "linear" ) ; 4502 //Vector<Float> spoff = getSpectrumFromTime( reftime, timeVec, off, "linear" ) ; 4169 Vector<Float> spoff = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeVec, ids, offspectra, "linear"); 4503 4170 Vector<Float> spec = on->specCol_( *p ) ; 4504 4171 Vector<Float> tsys = on->tsysCol_( *p ) ; … … 4557 4224 ROScalarColumn<Double> timeCol2( ref->table(), "TIME" ) ; 4558 4225 ROArrayColumn<Float> arrayFloatCol( sky[0]->table(), "SPECTRA" ) ; 4559 Matrix<Float> skyspectraS = arrayFloatCol.getColumn();4226 SpectralData skyspectraS(arrayFloatCol.getColumn()); 4560 4227 arrayFloatCol.attach( sky[1]->table(), "SPECTRA" ) ; 4561 Matrix<Float> skyspectraR = arrayFloatCol.getColumn();4228 SpectralData skyspectraR(arrayFloatCol.getColumn()); 4562 4229 arrayFloatCol.attach( hot[0]->table(), "SPECTRA" ) ; 4563 Matrix<Float> hotspectraS = arrayFloatCol.getColumn();4230 SpectralData hotspectraS(arrayFloatCol.getColumn()); 4564 4231 arrayFloatCol.attach( hot[1]->table(), "SPECTRA" ) ; 4565 Matrix<Float> hotspectraR = arrayFloatCol.getColumn() ; 4232 SpectralData hotspectraR(arrayFloatCol.getColumn()); 4233 TcalData tcaldataS(sky[0]); 4234 TsysData tsysdataS(sky[0]); 4235 TcalData tcaldataR(sky[1]); 4236 TsysData tsysdataR(sky[1]); 4566 4237 unsigned int spsize = sig->nchan( sig->getIF(rows[0]) ) ; 4567 4238 Vector<Float> spec( spsize ) ; … … 4574 4245 double reftime = timeCol.asdouble(*p) ; 4575 4246 ids = getRowIdFromTime( reftime, timeSkyS ) ; 4576 Vector<Float> spskyS = getSpectrumFromTime( reftime, timeSkyS, ids, skyspectraS, "linear" );4577 Vector<Float> tcalS = getTcalFromTime( reftime, timeSkyS, ids, sky[0], "linear" );4578 Vector<Float> tsysS = getTsysFromTime( reftime, timeSkyS, ids, sky[0], "linear" );4247 Vector<Float> spskyS = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeSkyS, ids, skyspectraS, "linear"); 4248 Vector<Float> tcalS = SimpleInterpolationHelper<TcalData>::GetFromTime(reftime, timeSkyS, ids, tcaldataS, "linear"); 4249 Vector<Float> tsysS = SimpleInterpolationHelper<TsysData>::GetFromTime(reftime, timeSkyS, ids, tsysdataS, "linear"); 4579 4250 ids = getRowIdFromTime( reftime, timeHotS ) ; 4580 Vector<Float> sphotS = getSpectrumFromTime( reftime, timeHotS, ids, hotspectraS );4251 Vector<Float> sphotS = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeHotS, ids, hotspectraS, "linear"); 4581 4252 reftime = timeCol2.asdouble(*p) ; 4582 4253 ids = getRowIdFromTime( reftime, timeSkyR ) ; 4583 Vector<Float> spskyR = getSpectrumFromTime( reftime, timeSkyR, ids, skyspectraR, "linear" );4584 Vector<Float> tcalR = getTcalFromTime( reftime, timeSkyR, ids, sky[1], "linear" );4585 Vector<Float> tsysR = getTsysFromTime( reftime, timeSkyR, ids, sky[1], "linear" );4254 Vector<Float> spskyR = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeSkyR, ids, skyspectraR, "linear"); 4255 Vector<Float> tcalR = SimpleInterpolationHelper<TcalData>::GetFromTime(reftime, timeSkyR, ids, tcaldataR, "linear"); 4256 Vector<Float> tsysR = SimpleInterpolationHelper<TsysData>::GetFromTime(reftime, timeSkyR, ids, tsysdataR, "linear"); 4586 4257 ids = getRowIdFromTime( reftime, timeHotR ) ; 4587 Vector<Float> sphotR = getSpectrumFromTime( reftime, timeHotR, ids, hotspectraR );4258 Vector<Float> sphotR = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeHotR, ids, hotspectraR, "linear"); 4588 4259 Vector<Float> spsig = on[0]->specCol_( *p ) ; 4589 4260 Vector<Float> spref = on[1]->specCol_( *p ) ; … … 4637 4308 ROScalarColumn<Double> timeCol2( ref->table(), "TIME" ) ; 4638 4309 ROArrayColumn<Float> arrayFloatCol( sky->table(), "SPECTRA" ) ; 4639 Matrix<Float> skyspectra = arrayFloatCol.getColumn();4310 SpectralData skyspectra(arrayFloatCol.getColumn()); 4640 4311 arrayFloatCol.attach( hot->table(), "SPECTRA" ) ; 4641 Matrix<Float> hotspectra = arrayFloatCol.getColumn() ; 4312 SpectralData hotspectra(arrayFloatCol.getColumn()); 4313 TcalData tcaldata(sky); 4314 TsysData tsysdata(sky); 4642 4315 unsigned int spsize = sig->nchan( sig->getIF(rows[0]) ) ; 4643 4316 Vector<Float> spec( spsize ) ; … … 4650 4323 double reftime = timeCol.asdouble(*p) ; 4651 4324 ids = getRowIdFromTime( reftime, timeSky ) ; 4652 Vector<Float> spsky = getSpectrumFromTime( reftime, timeSky, ids, skyspectra, "linear" );4653 Vector<Float> tcal = getTcalFromTime( reftime, timeSky, ids, sky, "linear" );4654 Vector<Float> tsys = getTsysFromTime( reftime, timeSky, ids, sky, "linear" );4325 Vector<Float> spsky = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeSky, ids, skyspectra, "linear"); 4326 Vector<Float> tcal = SimpleInterpolationHelper<TcalData>::GetFromTime(reftime, timeSky, ids, tcaldata, "linear"); 4327 Vector<Float> tsys = SimpleInterpolationHelper<TsysData>::GetFromTime(reftime, timeSky, ids, tsysdata, "linear"); 4655 4328 ids = getRowIdFromTime( reftime, timeHot ) ; 4656 Vector<Float> sphot = getSpectrumFromTime( reftime, timeHot, ids, hotspectra );4329 Vector<Float> sphot = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeHot, ids, hotspectra, "linear"); 4657 4330 Vector<Float> spsig = rsig->specCol_( *p ) ; 4658 4331 Vector<Float> spref = rref->specCol_( *p ) ; … … 4680 4353 4681 4354 reftime = timeCol2.asdouble(*p) ; 4682 spsky = getSpectrumFromTime( reftime, timeSky, ids, skyspectra, "linear" ) ; 4683 tcal = getTcalFromTime( reftime, timeSky, ids, sky, "linear" ) ; 4684 tsys = getTsysFromTime( reftime, timeSky, ids, sky, "linear" ) ; 4355 ids = getRowIdFromTime( reftime, timeSky ) ; 4356 spsky = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeSky, ids, skyspectra, "linear"); 4357 tcal = SimpleInterpolationHelper<TcalData>::GetFromTime(reftime, timeSky, ids, tcaldata, "linear"); 4358 tsys = SimpleInterpolationHelper<TsysData>::GetFromTime(reftime, timeSky, ids, tsysdata, "linear"); 4685 4359 ids = getRowIdFromTime( reftime, timeHot ) ; 4686 sphot = getSpectrumFromTime( reftime, timeHot, ids, hotspectra );4360 sphot = SimpleInterpolationHelper<SpectralData>::GetFromTime(reftime, timeHot, ids, hotspectra, "linear"); 4687 4361 // using gain array 4688 4362 for ( unsigned int j = 0 ; j < spsize ; j++ ) { -
trunk/src/STMath.h
r2900 r2917 401 401 casa::Vector<casa::uChar> 402 402 flagsFromMA(const casa::MaskedArray<casa::Float>& ma); 403 404 casa::Vector<casa::Float> getSpectrumFromTime( double reftime, const casa::Vector<casa::Double> &v, const vector<int> &idx, const casa::Matrix<casa::Float>& sp, string mode = "before" ) ;405 casa::Vector<casa::Float> getTcalFromTime( double reftime, const casa::Vector<casa::Double> &v, const vector<int> &idx, const casa::CountedPtr<Scantable>& s, string mode="before" ) ;406 casa::Vector<casa::Float> getTsysFromTime( double reftime, const casa::Vector<casa::Double> &v, const vector<int> &idx, const casa::CountedPtr<Scantable>& s, string mode="before" ) ;407 vector<int> getRowIdFromTime( double reftime, const casa::Vector<casa::Double>& t ) ;408 403 409 404 // Chopper-Wheel type calibration
Note:
See TracChangeset
for help on using the changeset viewer.