Changeset 1634
- Timestamp:
- 09/18/09 18:42:35 (15 years ago)
- Location:
- branches/alma
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/python/asapmath.py
r1633 r1634 860 860 verify: verify calibration 861 861 """ 862 print 'param: %s, %s, %s' %(scannos, calmode, verify)863 862 antname = scantab.get_antennaname() 864 863 if ( calmode == 'nod' ): -
branches/alma/src/STMath.cpp
r1633 r1634 3368 3368 3369 3369 // process each on scan 3370 ArrayColumn<Float> tsysCol ; 3371 tsysCol.attach( out->table(), "TSYS" ) ; 3370 3372 for ( int i = 0 ; i < out->nrow() ; i++ ) { 3371 3373 vector<float> sp = getCalibratedSpectra( out, aoff, asky, ahot, acold, i, antname ) ; 3372 3374 out->setSpectrum( sp, i ) ; 3375 string reftime = out->getTime( i ) ; 3376 vector<int> ii( 1, out->getIF( i ) ) ; 3377 vector<int> ib( 1, out->getBeam( i ) ) ; 3378 vector<int> ip( 1, out->getPol( i ) ) ; 3379 sel.setIFs( ii ) ; 3380 sel.setBeams( ib ) ; 3381 sel.setPolarizations( ip ) ; 3382 asky->setSelection( sel ) ; 3383 vector<float> sptsys = getTsysFromTime( reftime, asky, "linear" ) ; 3384 const Vector<Float> Vtsys( sptsys ) ; 3385 tsysCol.put( i, Vtsys ) ; 3386 asky->unsetSelection() ; 3387 sel.reset() ; 3373 3388 } 3374 3389 … … 3381 3396 } 3382 3397 srcnameCol.putColumn( srcnames ) ; 3398 3399 // flux unit 3400 out->setFluxUnit( "K" ) ; 3383 3401 3384 3402 return out ; … … 3496 3514 3497 3515 // process each sig and ref scan 3516 ArrayColumn<Float> tsysCollo ; 3517 tsysCollo.attach( ssig->table(), "TSYS" ) ; 3518 ArrayColumn<Float> tsysColhi ; 3519 tsysColhi.attach( sref->table(), "TSYS" ) ; 3498 3520 for ( int i = 0 ; i < ssig->nrow() ; i++ ) { 3499 3521 vector< CountedPtr<Scantable> > sky( 2 ) ; … … 3508 3530 vector<float> sp = getFSCalibratedSpectra( ssig, sref, sky, hot, cold, i ) ; 3509 3531 ssig->setSpectrum( sp, i ) ; 3532 string reftime = ssig->getTime( i ) ; 3533 vector<int> ii( 1, ssig->getIF( i ) ) ; 3534 vector<int> ib( 1, ssig->getBeam( i ) ) ; 3535 vector<int> ip( 1, ssig->getPol( i ) ) ; 3536 sel.setIFs( ii ) ; 3537 sel.setBeams( ib ) ; 3538 sel.setPolarizations( ip ) ; 3539 askylo->setSelection( sel ) ; 3540 vector<float> sptsys = getTsysFromTime( reftime, askylo, "linear" ) ; 3541 const Vector<Float> Vtsyslo( sptsys ) ; 3542 tsysCollo.put( i, Vtsyslo ) ; 3543 askylo->unsetSelection() ; 3544 sel.reset() ; 3510 3545 sky[0] = askyhi ; 3511 3546 sky[1] = askylo ; … … 3516 3551 sp = getFSCalibratedSpectra( sref, ssig, sky, hot, cold, i ) ; 3517 3552 sref->setSpectrum( sp, i ) ; 3553 reftime = sref->getTime( i ) ; 3554 ii[0] = sref->getIF( i ) ; 3555 ib[0] = sref->getBeam( i ) ; 3556 ip[0] = sref->getPol( i ) ; 3557 sel.setIFs( ii ) ; 3558 sel.setBeams( ib ) ; 3559 sel.setPolarizations( ip ) ; 3560 askyhi->setSelection( sel ) ; 3561 sptsys = getTsysFromTime( reftime, askyhi, "linear" ) ; 3562 const Vector<Float> Vtsyshi( sptsys ) ; 3563 tsysColhi.put( i, Vtsyshi ) ; 3564 askyhi->unsetSelection() ; 3565 sel.reset() ; 3518 3566 } 3519 3567 … … 3600 3648 3601 3649 // process each sig and ref scan 3650 ArrayColumn<Float> tsysCollo ; 3651 tsysCollo.attach( ssig->table(), "TSYS" ) ; 3652 ArrayColumn<Float> tsysColhi ; 3653 tsysColhi.attach( sref->table(), "TSYS" ) ; 3602 3654 for ( int i = 0 ; i < ssig->nrow() ; i++ ) { 3603 3655 vector<float> sp = getCalibratedSpectra( ssig, aofflo, askylo, ahotlo, acoldlo, i, antname ) ; 3604 3656 ssig->setSpectrum( sp, i ) ; 3605 3657 sp = getCalibratedSpectra( sref, aoffhi, askyhi, ahothi, acoldhi, i, antname ) ; 3658 string reftime = ssig->getTime( i ) ; 3659 vector<int> ii( 1, ssig->getIF( i ) ) ; 3660 vector<int> ib( 1, ssig->getBeam( i ) ) ; 3661 vector<int> ip( 1, ssig->getPol( i ) ) ; 3662 sel.setIFs( ii ) ; 3663 sel.setBeams( ib ) ; 3664 sel.setPolarizations( ip ) ; 3665 askylo->setSelection( sel ) ; 3666 vector<float> sptsys = getTsysFromTime( reftime, askylo, "linear" ) ; 3667 const Vector<Float> Vtsyslo( sptsys ) ; 3668 tsysCollo.put( i, Vtsyslo ) ; 3669 askylo->unsetSelection() ; 3670 sel.reset() ; 3606 3671 sref->setSpectrum( sp, i ) ; 3672 reftime = sref->getTime( i ) ; 3673 ii[0] = sref->getIF( i ) ; 3674 ib[0] = sref->getBeam( i ) ; 3675 ip[0] = sref->getPol( i ) ; 3676 sel.setIFs( ii ) ; 3677 sel.setBeams( ib ) ; 3678 sel.setPolarizations( ip ) ; 3679 askyhi->setSelection( sel ) ; 3680 sptsys = getTsysFromTime( reftime, askyhi, "linear" ) ; 3681 const Vector<Float> Vtsyshi( sptsys ) ; 3682 tsysColhi.put( i, Vtsyshi ) ; 3683 askyhi->unsetSelection() ; 3684 sel.reset() ; 3607 3685 } 3608 3686 } … … 3656 3734 3657 3735 // process each sig and ref scan 3736 ArrayColumn<Float> tsysColsig ; 3737 tsysColsig.attach( ssig->table(), "TSYS" ) ; 3738 ArrayColumn<Float> tsysColref ; 3739 tsysColref.attach( ssig->table(), "TSYS" ) ; 3658 3740 for ( int i = 0 ; i < ssig->nrow() ; i++ ) { 3659 3741 vector<float> sp = getFSCalibratedSpectra( ssig, sref, asky, ahot, acold, i ) ; 3660 3742 ssig->setSpectrum( sp, i ) ; 3743 string reftime = ssig->getTime( i ) ; 3744 vector<int> ii( 1, ssig->getIF( i ) ) ; 3745 vector<int> ib( 1, ssig->getBeam( i ) ) ; 3746 vector<int> ip( 1, ssig->getPol( i ) ) ; 3747 sel.setIFs( ii ) ; 3748 sel.setBeams( ib ) ; 3749 sel.setPolarizations( ip ) ; 3750 asky->setSelection( sel ) ; 3751 vector<float> sptsys = getTsysFromTime( reftime, asky, "linear" ) ; 3752 const Vector<Float> Vtsys( sptsys ) ; 3753 tsysColsig.put( i, Vtsys ) ; 3754 asky->unsetSelection() ; 3755 sel.reset() ; 3661 3756 sp = getFSCalibratedSpectra( sref, ssig, asky, ahot, acold, i ) ; 3662 3757 sref->setSpectrum( sp, i ) ; 3758 tsysColref.put( i, Vtsys ) ; 3663 3759 } 3664 3760 } … … 3743 3839 } 3744 3840 3745 out = merge( tmp ) ; 3841 if ( tmp.size() > 1 ) { 3842 out = merge( tmp ) ; 3843 } 3844 else { 3845 out = tmp[0] ; 3846 } 3847 3848 // flux unit 3849 out->setFluxUnit( "K" ) ; 3746 3850 3747 3851 return out ; … … 4048 4152 } 4049 4153 return tcal ; 4154 } 4155 } 4156 4157 vector<float> STMath::getTsysFromTime( string reftime, 4158 CountedPtr<Scantable>& s, 4159 string mode ) 4160 { 4161 LogIO os( LogOrigin( "STMath", "getTsysFromTime", WHERE ) ) ; 4162 ArrayColumn<Float> tsysCol ; 4163 tsysCol.attach( s->table(), "TSYS" ) ; 4164 vector<float> tsys ; 4165 String time ; 4166 Vector<Float> tsysval ; 4167 if ( s->nrow() == 0 ) { 4168 os << LogIO::SEVERE << "No row in the input scantable. Return empty tsys." << LogIO::POST ; 4169 return tsys ; 4170 } 4171 else if ( s->nrow() == 1 ) { 4172 os << "use row " << 0 << LogIO::POST ; 4173 tsysval = tsysCol( 0 ) ; 4174 tsysval.tovector( tsys ) ; 4175 return tsys ; 4176 } 4177 else { 4178 vector<int> idx = getRowIdFromTime( reftime, s ) ; 4179 if ( mode == "before" ) { 4180 int id = -1 ; 4181 if ( idx[0] != -1 ) { 4182 id = idx[0] ; 4183 } 4184 else if ( idx[1] != -1 ) { 4185 os << LogIO::WARN << "Failed to find a scan before reftime. return a spectrum just after the reftime." << LogIO::POST ; 4186 id = idx[1] ; 4187 } 4188 os << "use row " << id << LogIO::POST ; 4189 tsysval = tsysCol( id ) ; 4190 tsysval.tovector( tsys ) ; 4191 } 4192 else if ( mode == "after" ) { 4193 int id = -1 ; 4194 if ( idx[1] != -1 ) { 4195 id = idx[1] ; 4196 } 4197 else if ( idx[0] != -1 ) { 4198 os << LogIO::WARN << "Failed to find a scan after reftime. return a spectrum just before the reftime." << LogIO::POST ; 4199 id = idx[1] ; 4200 } 4201 os << "use row " << id << LogIO::POST ; 4202 tsysval = tsysCol( id ) ; 4203 tsysval.tovector( tsys ) ; 4204 } 4205 else if ( mode == "nearest" ) { 4206 int id = -1 ; 4207 if ( idx[0] == -1 ) { 4208 id = idx[1] ; 4209 } 4210 else if ( idx[1] == -1 ) { 4211 id = idx[0] ; 4212 } 4213 else if ( idx[0] == idx[1] ) { 4214 id = idx[0] ; 4215 } 4216 else { 4217 double t0 = getMJD( s->getTime( idx[0] ) ) ; 4218 double t1 = getMJD( s->getTime( idx[1] ) ) ; 4219 double tref = getMJD( reftime ) ; 4220 if ( abs( t0 - tref ) > abs( t1 - tref ) ) { 4221 id = idx[1] ; 4222 } 4223 else { 4224 id = idx[0] ; 4225 } 4226 } 4227 os << "use row " << id << LogIO::POST ; 4228 tsysval = tsysCol( id ) ; 4229 tsysval.tovector( tsys ) ; 4230 } 4231 else if ( mode == "linear" ) { 4232 if ( idx[0] == -1 ) { 4233 // use after 4234 os << LogIO::WARN << "Failed to interpolate. return a spectrum just after the reftime." << LogIO::POST ; 4235 int id = idx[1] ; 4236 os << "use row " << id << LogIO::POST ; 4237 tsysval = tsysCol( id ) ; 4238 tsysval.tovector( tsys ) ; 4239 } 4240 else if ( idx[1] == -1 ) { 4241 // use before 4242 os << LogIO::WARN << "Failed to interpolate. return a spectrum just before the reftime." << LogIO::POST ; 4243 int id = idx[0] ; 4244 os << "use row " << id << LogIO::POST ; 4245 tsysval = tsysCol( id ) ; 4246 tsysval.tovector( tsys ) ; 4247 } 4248 else if ( idx[0] == idx[1] ) { 4249 // use before 4250 os << "No need to interporate." << LogIO::POST ; 4251 int id = idx[0] ; 4252 os << "use row " << id << LogIO::POST ; 4253 tsysval = tsysCol( id ) ; 4254 tsysval.tovector( tsys ) ; 4255 } 4256 else { 4257 // do interpolation 4258 os << "interpolate between " << idx[0] << " and " << idx[1] << " (scanno: " << s->getScan( idx[0] ) << ", " << s->getScan( idx[1] ) << ")" << LogIO::POST ; 4259 double t0 = getMJD( s->getTime( idx[0] ) ) ; 4260 double t1 = getMJD( s->getTime( idx[1] ) ) ; 4261 double tref = getMJD( reftime ) ; 4262 vector<float> tsys0 ; 4263 vector<float> tsys1 ; 4264 tsysval = tsysCol( idx[0] ) ; 4265 tsysval.tovector( tsys0 ) ; 4266 tsysval = tsysCol( idx[1] ) ; 4267 tsysval.tovector( tsys1 ) ; 4268 for ( unsigned int i = 0 ; i < tsys0.size() ; i++ ) { 4269 float v = ( tsys1[i] - tsys0[i] ) / ( t1 - t0 ) * ( tref - t0 ) + tsys0[i] ; 4270 tsys.push_back( v ) ; 4271 } 4272 } 4273 } 4274 else { 4275 os << LogIO::SEVERE << "Unknown mode" << LogIO::POST ; 4276 } 4277 return tsys ; 4050 4278 } 4051 4279 } … … 4213 4441 return sp ; 4214 4442 } 4443 4444 CountedPtr<Scantable> STMath::pressedOut( const casa::CountedPtr<Scantable> &in, 4445 const float numpoly, 4446 const float radius, 4447 const float threshold ) 4448 { 4449 // scan pattern analysis 4450 4451 4452 // for each channel 4453 int nchan = in->nchan() ; 4454 for ( int i = 0 ; i < nchan ; i++ ) { 4455 // smoothing 4456 4457 // get dTij 4458 4459 // polynomial fitting 4460 4461 // remove scanning effect from the map 4462 4463 } 4464 4465 return in ; 4466 } -
branches/alma/src/STMath.h
r1633 r1634 317 317 throw (casa::AipsError) ; 318 318 319 /*** 320 * "Pressed-Out" method (Sofe & Reich 1979) 321 * @param input scantable 322 * @param order of polynomial fitting function 323 * @param smoothing beam radius [arcsec] 324 * @param threshold valus in the unit of sigma (standard deviation) 325 ***/ 326 casa::CountedPtr<Scantable> 327 pressedOut( const casa::CountedPtr<Scantable> &in, 328 const float numpoly, 329 const float radius, 330 const float threshold ) ; 319 331 320 332 private: … … 361 373 vector<float> getSpectrumFromTime( string reftime, casa::CountedPtr<Scantable>& s, string mode = "before" ) ; 362 374 vector<float> getTcalFromTime( string reftime, casa::CountedPtr<Scantable>& s, string mode="before" ) ; 375 vector<float> getTsysFromTime( string reftime, casa::CountedPtr<Scantable>& s, string mode="before" ) ; 363 376 vector<int> getRowIdFromTime( string reftime, casa::CountedPtr<Scantable>& s ) ; 364 377 vector<float> getCalibratedSpectra( casa::CountedPtr<Scantable>& on, -
branches/alma/src/Scantable.h
r1603 r1634 309 309 float getParAngle(int whichrow) const 310 310 { return paraCol_(whichrow); } 311 int getTcalId(int whichrow) const 312 { return mtcalidCol_(whichrow); } 311 313 312 314 std::string getSourceName(int whichrow) const
Note:
See TracChangeset
for help on using the changeset viewer.