[2197] | 1 | #include <iostream> |
---|
| 2 | #include <sstream> |
---|
[2301] | 3 | #include "limits.h" |
---|
[2307] | 4 | //#include "float.h" |
---|
[2197] | 5 | |
---|
| 6 | #include <measures/Measures/MEpoch.h> |
---|
| 7 | #include <measures/Measures/MPosition.h> |
---|
| 8 | #include <measures/Measures/MDirection.h> |
---|
| 9 | #include <measures/Measures/MCDirection.h> |
---|
| 10 | #include <measures/Measures/MeasFrame.h> |
---|
| 11 | #include <measures/Measures/MeasConvert.h> |
---|
[2208] | 12 | #include <casa/Logging/LogMessage.h> |
---|
[2252] | 13 | #include <casa/BasicSL/Constants.h> |
---|
[2197] | 14 | |
---|
| 15 | #include "ASDMReader.h" |
---|
| 16 | #include <atnf/PKSIO/SrcType.h> |
---|
| 17 | |
---|
| 18 | using namespace std ; |
---|
| 19 | //using namespace casa ; |
---|
| 20 | using namespace asdm ; |
---|
| 21 | using namespace sdmbin ; |
---|
| 22 | |
---|
| 23 | // sec to day |
---|
| 24 | double s2d = 1.0 / 86400.0 ; |
---|
| 25 | |
---|
| 26 | ASDMReader::ASDMReader() |
---|
| 27 | : asdm_(0), |
---|
| 28 | sdmBin_(0), |
---|
| 29 | vmsData_(0), |
---|
| 30 | antennaId_( -1 ), |
---|
| 31 | antennaName_( "" ), |
---|
[2301] | 32 | stationName_( "" ), |
---|
[2197] | 33 | row_(-1), |
---|
[2208] | 34 | apc_(AP_CORRECTED), |
---|
[2301] | 35 | className_("ASDMReader"), |
---|
| 36 | dataIndex_( UINT_MAX ), |
---|
| 37 | //antennaRow_p( 0 ), |
---|
| 38 | //stationRow_p( 0 ), |
---|
| 39 | specWinRow_p( 0 ), |
---|
| 40 | polarizationRow_p( 0 ), |
---|
| 41 | fieldRow_p( 0 ) |
---|
[2197] | 42 | { |
---|
| 43 | configDescIdList_.resize(0) ; |
---|
| 44 | feedIdList_.resize(0) ; |
---|
| 45 | fieldIdList_.resize(0) ; |
---|
| 46 | mainRow_.resize(0) ; |
---|
| 47 | ifno_.clear() ; |
---|
[2208] | 48 | corrMode_.reset() ; |
---|
| 49 | timeSampling_.reset() ; |
---|
[2197] | 50 | } |
---|
| 51 | |
---|
| 52 | ASDMReader::~ASDMReader() |
---|
| 53 | { |
---|
[2208] | 54 | close() ; |
---|
| 55 | logsink_ = 0 ; |
---|
[2197] | 56 | } |
---|
| 57 | |
---|
| 58 | bool ASDMReader::open( const string &filename, const casa::Record &rec ) |
---|
| 59 | { |
---|
[2227] | 60 | casa::String funcName = "open" ; |
---|
[2208] | 61 | |
---|
| 62 | // return value |
---|
| 63 | bool status = true ; |
---|
| 64 | |
---|
| 65 | // set default |
---|
| 66 | timeSampling_.reset() ; |
---|
| 67 | corrMode_.reset() ; |
---|
[2215] | 68 | resolutionType_.reset() ; |
---|
[2208] | 69 | apc_ = AP_CORRECTED ; |
---|
| 70 | |
---|
[2197] | 71 | // parsing ASDM options |
---|
| 72 | if ( rec.isDefined( "asdm" ) ) { |
---|
| 73 | casa::Record asdmrec = rec.asRecord( "asdm" ) ; |
---|
[2208] | 74 | |
---|
| 75 | // antenna |
---|
[2197] | 76 | if ( asdmrec.isDefined( "antenna" ) ) { |
---|
| 77 | if ( asdmrec.type( asdmrec.fieldNumber( "antenna" ) ) == casa::TpInt ) { |
---|
| 78 | antennaId_ = asdmrec.asInt( "antenna" ) ; |
---|
| 79 | } |
---|
| 80 | else { |
---|
| 81 | antennaName_ = asdmrec.asString( "antenna" ) ; |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | else { |
---|
| 85 | antennaId_ = 0 ; |
---|
| 86 | } |
---|
[2208] | 87 | |
---|
| 88 | // ATM phase correction |
---|
[2197] | 89 | if ( asdmrec.isDefined( "apc" ) ) { |
---|
| 90 | if ( asdmrec.asBool( "apc" ) ) |
---|
| 91 | apc_ = AP_CORRECTED ; |
---|
| 92 | else |
---|
| 93 | apc_ = AP_UNCORRECTED ; |
---|
| 94 | } |
---|
[2208] | 95 | |
---|
| 96 | // time sampling |
---|
| 97 | String timeSampling = "all" ; // take all time sampling by default |
---|
| 98 | if ( asdmrec.isDefined( "sampling" ) ) { |
---|
| 99 | timeSampling = asdmrec.asString( "sampling" ) ; |
---|
| 100 | } |
---|
| 101 | if ( timeSampling == "all" ) { |
---|
| 102 | timeSampling_.set( INTEGRATION ) ; |
---|
| 103 | timeSampling_.set( SUBINTEGRATION ) ; |
---|
| 104 | } |
---|
| 105 | else if ( timeSampling == "integration" ) { |
---|
| 106 | timeSampling_.set( INTEGRATION ) ; |
---|
| 107 | } |
---|
| 108 | else if ( timeSampling == "subintegration" ) { |
---|
| 109 | timeSampling_.set( SUBINTEGRATION ) ; |
---|
| 110 | } |
---|
| 111 | else { |
---|
| 112 | //throw AipsError( "Unrecognized option for sampling" ) ; |
---|
| 113 | logsink_->postLocally( LogMessage( "Unrecognized option for time sampling: "+String::toString(timeSampling), LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; |
---|
| 114 | status = false ; |
---|
| 115 | } |
---|
| 116 | |
---|
[2215] | 117 | // spectral resolution type |
---|
[2216] | 118 | string resolutionType = "all" ; |
---|
[2215] | 119 | if ( asdmrec.isDefined( "srt" ) ) { |
---|
[2216] | 120 | resolutionType = string( asdmrec.asString( "srt" ) ) ; |
---|
[2215] | 121 | } |
---|
[2216] | 122 | string resolutionTypes[3] ; |
---|
| 123 | Int numType = split( resolutionType, resolutionTypes, 3, "," ) ; |
---|
| 124 | for ( Int it = 0 ; it < numType ; it++ ) { |
---|
| 125 | if ( resolutionTypes[it] == "all" ) { |
---|
| 126 | resolutionType_.reset() ; |
---|
| 127 | resolutionType_.set( FULL_RESOLUTION ) ; |
---|
| 128 | resolutionType_.set( BASEBAND_WIDE ) ; |
---|
| 129 | resolutionType_.set( CHANNEL_AVERAGE ) ; |
---|
| 130 | break ; |
---|
| 131 | } |
---|
| 132 | else if ( resolutionTypes[it] == "fr" ) { |
---|
| 133 | resolutionType_.set( FULL_RESOLUTION ) ; |
---|
| 134 | } |
---|
| 135 | else if ( resolutionTypes[it] == "bw" ) { |
---|
| 136 | resolutionType_.set( BASEBAND_WIDE ) ; |
---|
| 137 | } |
---|
| 138 | else if ( resolutionTypes[it] == "ca" ) { |
---|
| 139 | resolutionType_.set( CHANNEL_AVERAGE ) ; |
---|
| 140 | } |
---|
[2215] | 141 | } |
---|
[2216] | 142 | if ( resolutionType_.size() == 0 ) { |
---|
[2215] | 143 | logsink_->postLocally( LogMessage( "Unrecognized option for spectral resolution type: "+String::toString(resolutionType), LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; |
---|
| 144 | status = false ; |
---|
| 145 | } |
---|
| 146 | |
---|
[2208] | 147 | // input correlation mode |
---|
[2248] | 148 | string corrMode = "ao,ca" ; |
---|
[2208] | 149 | if ( asdmrec.isDefined( "corr" ) ) { |
---|
[2216] | 150 | corrMode = string( asdmrec.asString( "corr" ) ) ; |
---|
[2208] | 151 | //logsink_->postLocally( LogMessage("corrMode = "+String(corrMode),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2216] | 152 | } |
---|
| 153 | string corrModes[3] ; |
---|
| 154 | Int numCorr = split( corrMode, corrModes, 3, "," ) ; |
---|
| 155 | for ( Int ic = 0 ; ic < numCorr ; ic++ ) { |
---|
| 156 | if ( corrModes[ic] == "ao" ) { |
---|
| 157 | corrMode_.set( AUTO_ONLY ) ; |
---|
[2208] | 158 | } |
---|
[2216] | 159 | else if ( corrModes[ic] == "ca" ) { |
---|
| 160 | corrMode_.set( CROSS_AND_AUTO ) ; |
---|
[2208] | 161 | } |
---|
| 162 | } |
---|
[2216] | 163 | if ( corrMode_.size() == 0 ) { |
---|
| 164 | logsink_->postLocally( LogMessage( "Invalid option for correlation mode: "+String::toString(corrMode), LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; |
---|
| 165 | status = false ; |
---|
| 166 | } |
---|
[2208] | 167 | |
---|
| 168 | // logsink_->postLocally( LogMessage( "### asdmrec summary ###", LogOrigin(className_,funcName,WHERE) ) ) ; |
---|
| 169 | // ostringstream oss ; |
---|
| 170 | // asdmrec.print( oss ) ; |
---|
| 171 | // logsink_->postLocally( LogMessage( oss.str(), LogOrigin(className_,funcName,WHERE) ) ) ; |
---|
| 172 | // logsink_->postLocally( LogMessage( "#######################", LogOrigin(className_,funcName,WHERE) ) ) ; |
---|
[2197] | 173 | } |
---|
| 174 | |
---|
| 175 | // create ASDM object |
---|
| 176 | asdm_ = new ASDM() ; |
---|
| 177 | asdm_->setFromFile( filename ) ; |
---|
| 178 | |
---|
[2301] | 179 | AntennaTable &atab = asdm_->getAntenna() ; |
---|
| 180 | AntennaRow *antennaRow ; |
---|
[2197] | 181 | if ( antennaId_ == -1 ) { |
---|
| 182 | vector<AntennaRow *> rows = atab.get() ; |
---|
| 183 | int idx = -1 ; |
---|
| 184 | for ( casa::uInt irow = 0 ; irow < rows.size() ; irow++ ) { |
---|
| 185 | if ( casa::String(rows[irow]->getName()) == antennaName_ ) { |
---|
| 186 | idx = rows[irow]->getAntennaId().getTagValue() ; |
---|
| 187 | break ; |
---|
| 188 | } |
---|
| 189 | } |
---|
| 190 | if ( idx == -1 ) { |
---|
| 191 | close() ; |
---|
| 192 | throw (casa::AipsError( antennaName_ + " not found." )) ; |
---|
| 193 | } |
---|
| 194 | else { |
---|
| 195 | antennaId_ = idx ; |
---|
| 196 | } |
---|
[2301] | 197 | antennaTag_ = Tag( antennaId_, TagType::Antenna ) ; |
---|
| 198 | antennaRow = rows[antennaId_] ; |
---|
[2197] | 199 | } |
---|
[2301] | 200 | else { |
---|
| 201 | antennaTag_ = Tag( antennaId_, TagType::Antenna ) ; |
---|
| 202 | antennaRow = atab.getRowByKey( antennaTag_ ) ; |
---|
| 203 | if ( antennaRow == 0 ) { |
---|
| 204 | close() ; |
---|
| 205 | throw (casa::AipsError( "AntennaId " + casa::String::toString(antennaId_) + " is invalid." ) ) ; |
---|
| 206 | } |
---|
| 207 | } |
---|
| 208 | |
---|
[2197] | 209 | |
---|
| 210 | // set antenna name |
---|
| 211 | if ( antennaName_.size() == 0 ) { |
---|
[2301] | 212 | antennaName_ = casa::String( antennaRow->getName() ) ; |
---|
[2197] | 213 | } |
---|
| 214 | |
---|
[2301] | 215 | // get Station row |
---|
| 216 | StationRow *stationRow = antennaRow->getStationUsingStationId() ; |
---|
| 217 | |
---|
| 218 | // station name |
---|
| 219 | stationName_ = casa::String( stationRow->getName() ) ; |
---|
| 220 | |
---|
| 221 | // antenna position |
---|
| 222 | antennaPosition_.resize( 3 ) ; |
---|
| 223 | vector<Length> antpos = stationRow->getPosition() ; |
---|
| 224 | for ( casa::uInt i = 0 ; i < 3 ; i++ ) |
---|
| 225 | antennaPosition_[i] = Quantity( casa::Double( antpos[i].get() ), Unit( "m" ) ) ; |
---|
| 226 | |
---|
[2197] | 227 | // create SDMBinData object |
---|
| 228 | sdmBin_ = new SDMBinData( asdm_, filename ) ; |
---|
| 229 | |
---|
| 230 | // get Main rows |
---|
| 231 | //mainRow_ = casa::Vector<MainRow *>(asdm_->getMain().get()) ; |
---|
| 232 | |
---|
| 233 | // set up IFNO |
---|
| 234 | setupIFNO() ; |
---|
| 235 | |
---|
| 236 | // process Station table |
---|
| 237 | processStation() ; |
---|
| 238 | |
---|
[2273] | 239 | //logsink_->postLocally( LogMessage( "antennaId_ = "+String::toString(antennaId_), LogOrigin(className_,funcName,WHERE) ) ) ; |
---|
| 240 | //logsink_->postLocally( LogMessage( "antennaName_ = "+antennaName_, LogOrigin(className_,funcName,WHERE) ) ) ; |
---|
[2197] | 241 | |
---|
| 242 | return true ; |
---|
| 243 | } |
---|
| 244 | |
---|
[2208] | 245 | // void ASDMReader::fill() |
---|
| 246 | // { |
---|
| 247 | // } |
---|
[2197] | 248 | |
---|
| 249 | void ASDMReader::close() |
---|
| 250 | { |
---|
| 251 | clearMainRow() ; |
---|
| 252 | |
---|
| 253 | if ( sdmBin_ ) |
---|
| 254 | delete sdmBin_ ; |
---|
| 255 | sdmBin_ = 0 ; |
---|
| 256 | |
---|
| 257 | if ( asdm_ ) |
---|
| 258 | delete asdm_ ; |
---|
| 259 | asdm_ = 0 ; |
---|
| 260 | |
---|
| 261 | return ; |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | void ASDMReader::fillHeader( casa::Int &nchan, |
---|
| 265 | casa::Int &npol, |
---|
| 266 | casa::Int &nif, |
---|
| 267 | casa::Int &nbeam, |
---|
| 268 | casa::String &observer, |
---|
| 269 | casa::String &project, |
---|
| 270 | casa::String &obstype, |
---|
| 271 | casa::String &antennaname, |
---|
| 272 | casa::Vector<casa::Double> &antennaposition, |
---|
| 273 | casa::Float &equinox, |
---|
| 274 | casa::String &freqref, |
---|
| 275 | casa::Double &reffreq, |
---|
| 276 | casa::Double &bandwidth, |
---|
| 277 | casa::Double &utc, |
---|
| 278 | casa::String &fluxunit, |
---|
| 279 | casa::String &epoch, |
---|
| 280 | casa::String &poltype ) |
---|
| 281 | { |
---|
[2227] | 282 | casa::String funcName = "fillHeader" ; |
---|
[2197] | 283 | |
---|
| 284 | ExecBlockTable &ebtab = asdm_->getExecBlock() ; |
---|
| 285 | // at the moment take first row of ExecBlock table |
---|
| 286 | ExecBlockRow *ebrow = ebtab.get()[0] ; |
---|
| 287 | casa::String telescopeName( ebrow->getTelescopeName() ) ; |
---|
[2301] | 288 | //casa::String stationName( stationRow_p->getName() ) ; |
---|
[2197] | 289 | |
---|
| 290 | // antennaname |
---|
| 291 | // <telescopeName>//<antennaName>@stationName |
---|
[2301] | 292 | antennaname = telescopeName + "//" + antennaName_ + "@" + stationName_ ; |
---|
[2208] | 293 | //logsink_->postLocally( LogMessage("antennaName = "+antennaname,LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 294 | |
---|
| 295 | // antennaposition |
---|
| 296 | antennaposition.resize( 3 ) ; |
---|
| 297 | for ( casa::uInt i = 0 ; i < 3 ; i++ ) |
---|
[2301] | 298 | antennaposition[i] = antennaPosition_[i].getValue( Unit("m") ) ; |
---|
[2197] | 299 | |
---|
| 300 | // observer |
---|
| 301 | observer = ebrow->getObserverName() ; |
---|
| 302 | |
---|
| 303 | // project |
---|
| 304 | // T.B.D. (project UID?) |
---|
[2273] | 305 | project = "T.B.D. (" + ebrow->getProjectUID().toString() + ")" ; |
---|
[2197] | 306 | |
---|
| 307 | // utc |
---|
| 308 | // start time of the project |
---|
| 309 | utc = casa::Double( ebrow->getStartTime().getMJD() ) ; |
---|
| 310 | |
---|
| 311 | |
---|
| 312 | SpectralWindowTable &spwtab = asdm_->getSpectralWindow() ; |
---|
| 313 | vector<SpectralWindowRow *> spwrows = spwtab.get() ; |
---|
[2220] | 314 | int nspwrow = spwrows.size() ; |
---|
[2197] | 315 | |
---|
| 316 | // nif |
---|
[2220] | 317 | //nif = spwrows.size() ; |
---|
| 318 | nif = getNumIFs() ; |
---|
[2197] | 319 | |
---|
| 320 | // nchan |
---|
| 321 | int refidx = -1 ; |
---|
| 322 | vector<int> nchans ; |
---|
[2220] | 323 | for ( int irow = 0 ; irow < nspwrow ; irow++ ) { |
---|
[2197] | 324 | nchans.push_back( spwrows[irow]->getNumChan() ) ; |
---|
| 325 | if ( refidx == -1 && nchans[irow] != 1 && nchans[irow] != 4 ) |
---|
| 326 | refidx = irow ; |
---|
| 327 | } |
---|
| 328 | nchan = casa::Int( *max_element( nchans.begin(), nchans.end() ) ) ; |
---|
| 329 | |
---|
[2208] | 330 | //logsink_->postLocally( LogMessage("refidx = "+String::toString(refidx),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 331 | |
---|
| 332 | // bandwidth |
---|
| 333 | vector<double> bws ; |
---|
[2220] | 334 | for ( int irow = 0 ; irow < nspwrow ; irow++ ) { |
---|
[2197] | 335 | if ( nchans[irow] != 4 ) { // exclude WVR data |
---|
| 336 | bws.push_back( spwrows[irow]->getTotBandwidth().get() ) ; |
---|
| 337 | } |
---|
| 338 | } |
---|
| 339 | bandwidth = casa::Double( *max_element( bws.begin(), bws.end() ) ) ; |
---|
| 340 | |
---|
| 341 | // reffreq |
---|
| 342 | reffreq = casa::Double( spwrows[refidx]->getRefFreq().get() ) ; |
---|
| 343 | |
---|
| 344 | // freqref |
---|
| 345 | if ( spwrows[refidx]->isMeasFreqRefExists() ) { |
---|
| 346 | string mfr = CFrequencyReferenceCode::name( spwrows[refidx]->getMeasFreqRef() ) ; |
---|
[2225] | 347 | // if (mfr == "TOPO") { |
---|
| 348 | // freqref = "TOPOCENT"; |
---|
| 349 | // } else if (mfr == "GEO") { |
---|
| 350 | // freqref = "GEOCENTR"; |
---|
| 351 | // } else if (mfr == "BARY") { |
---|
| 352 | // freqref = "BARYCENT"; |
---|
| 353 | // } else if (mfr == "GALACTO") { |
---|
| 354 | // freqref = "GALACTOC"; |
---|
| 355 | // } else if (mfr == "LGROUP") { |
---|
| 356 | // freqref = "LOCALGRP"; |
---|
| 357 | // } else if (mfr == "CMB") { |
---|
| 358 | // freqref = "CMBDIPOL"; |
---|
| 359 | // } else if (mfr == "REST") { |
---|
| 360 | // freqref = "SOURCE"; |
---|
| 361 | // } |
---|
| 362 | freqref = String( mfr ) ; |
---|
[2197] | 363 | } |
---|
| 364 | else { |
---|
| 365 | // frequency reference is TOPOCENT by default |
---|
[2225] | 366 | //freqref = "TOPOCENT" ; |
---|
| 367 | freqref = "TOPO" ; |
---|
[2197] | 368 | } |
---|
| 369 | |
---|
| 370 | |
---|
| 371 | PolarizationTable &ptab = asdm_->getPolarization() ; |
---|
| 372 | vector<PolarizationRow *> prows = ptab.get() ; |
---|
| 373 | vector<int> npols ; |
---|
| 374 | refidx = -1 ; |
---|
| 375 | for ( unsigned int irow = 0 ; irow < prows.size() ; irow++ ) { |
---|
| 376 | npols.push_back( prows[irow]->getNumCorr() ) ; |
---|
| 377 | if ( refidx == -1 && npols[irow] != 1 ) |
---|
| 378 | refidx = irow ; |
---|
| 379 | } |
---|
| 380 | if ( refidx == -1 ) |
---|
| 381 | refidx = 0 ; |
---|
| 382 | |
---|
| 383 | // npol |
---|
| 384 | npol = casa::Int( *max_element( npols.begin(), npols.end() ) ) ; |
---|
| 385 | |
---|
| 386 | // poltype |
---|
| 387 | vector<StokesParameter> corrType = prows[refidx]->getCorrType() ; |
---|
| 388 | if ( corrType[0] == I || |
---|
| 389 | corrType[0] == Q || |
---|
| 390 | corrType[0] == U || |
---|
| 391 | corrType[0] == V ) |
---|
| 392 | poltype = "stokes" ; |
---|
| 393 | else if ( corrType[0] == RR || |
---|
| 394 | corrType[0] == RL || |
---|
| 395 | corrType[0] == LR || |
---|
| 396 | corrType[0] == LL ) |
---|
| 397 | poltype = "circular" ; |
---|
| 398 | else if ( corrType[0] == XX || |
---|
| 399 | corrType[0] == XY || |
---|
| 400 | corrType[0] == YX || |
---|
| 401 | corrType[0] == YY ) |
---|
| 402 | poltype = "linear" ; |
---|
| 403 | else if ( corrType[0] == PLINEAR || |
---|
| 404 | corrType[0] == PANGLE ) { |
---|
| 405 | poltype = "linpol" ; |
---|
| 406 | } |
---|
| 407 | else { |
---|
| 408 | poltype = "notype" ; |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | |
---|
| 412 | FeedTable &ftab = asdm_->getFeed() ; |
---|
| 413 | vector<FeedRow *> frows = ftab.get() ; |
---|
| 414 | vector<int> nbeams ; |
---|
| 415 | for ( unsigned int irow = 0 ; irow < frows.size() ; irow++ ) { |
---|
| 416 | if ( frows[irow]->isFeedNumExists() ) |
---|
| 417 | nbeams.push_back( frows[irow]->getFeedNum() ) ; |
---|
| 418 | else |
---|
| 419 | nbeams.push_back( 1 ) ; |
---|
| 420 | } |
---|
| 421 | |
---|
| 422 | // nbeam |
---|
| 423 | nbeam = casa::Int( *max_element( nbeams.begin(), nbeams.end() ) ) ; |
---|
| 424 | |
---|
| 425 | // fluxunit |
---|
| 426 | // tentatively set 'K'? or empty? |
---|
| 427 | fluxunit = "K" ; |
---|
| 428 | |
---|
| 429 | // equinox |
---|
| 430 | // tentatively set 2000.0 |
---|
| 431 | equinox = 2000.0 ; |
---|
| 432 | |
---|
| 433 | // epoch |
---|
| 434 | // tentatively set "UTC" |
---|
| 435 | epoch = "UTC" ; |
---|
| 436 | |
---|
| 437 | // obstype |
---|
| 438 | // at the moment take observingMode attribute in SBSummary table |
---|
| 439 | SBSummaryRow *sbrow = ebrow->getSBSummaryUsingSBSummaryId() ; |
---|
| 440 | vector<string> obsmode = sbrow->getObservingMode() ; |
---|
| 441 | obstype = "" ; |
---|
| 442 | for ( unsigned int imode = 0 ; imode < obsmode.size() ; imode++ ) { |
---|
| 443 | obstype += casa::String(obsmode[imode]) ; |
---|
| 444 | if ( imode != obsmode.size()-1 ) |
---|
| 445 | obstype += "#" ; |
---|
| 446 | } |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | void ASDMReader::selectConfigDescription() |
---|
| 450 | { |
---|
[2227] | 451 | casa::String funcName = "selectConfigDescription" ; |
---|
[2208] | 452 | |
---|
[2197] | 453 | vector<ConfigDescriptionRow *> cdrows = asdm_->getConfigDescription().get() ; |
---|
| 454 | vector<Tag> cdidTags ; |
---|
| 455 | for ( unsigned int irow = 0 ; irow < cdrows.size() ; irow++ ) { |
---|
[2208] | 456 | //logsink_->postLocally( LogMessage("correlationMode["+String::toString(irow)+"] = "+String::toString(cdrows[irow]->getCorrelationMode()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 457 | if ( cdrows[irow]->getCorrelationMode() != CROSS_ONLY ) { |
---|
| 458 | cdidTags.push_back( cdrows[irow]->getConfigDescriptionId() ) ; |
---|
| 459 | } |
---|
| 460 | } |
---|
| 461 | |
---|
| 462 | configDescIdList_.resize( cdidTags.size() ) ; |
---|
| 463 | for ( unsigned int i = 0 ; i < cdidTags.size() ; i++ ) { |
---|
| 464 | configDescIdList_[i] = casa::uInt( cdidTags[i].getTagValue() ) ; |
---|
| 465 | } |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | void ASDMReader::selectFeed() |
---|
| 469 | { |
---|
| 470 | feedIdList_.resize(0) ; |
---|
| 471 | vector<FeedRow *> frows = asdm_->getFeed().get() ; |
---|
| 472 | Tag atag( antennaId_, TagType::Antenna ) ; |
---|
| 473 | for ( unsigned int irow = 0 ; irow < frows.size() ; irow++ ) { |
---|
| 474 | casa::uInt feedId = (casa::uInt)(frows[irow]->getFeedId() ) ; |
---|
| 475 | if ( casa::anyEQ( feedIdList_, feedId ) ) |
---|
| 476 | continue ; |
---|
| 477 | if ( frows[irow]->getAntennaId() == atag ) { |
---|
| 478 | unsigned int oldsize = feedIdList_.size() ; |
---|
| 479 | feedIdList_.resize( oldsize+1, true ) ; |
---|
| 480 | feedIdList_[oldsize] = feedId ; |
---|
| 481 | } |
---|
| 482 | } |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | casa::Vector<casa::uInt> ASDMReader::getFieldIdList() |
---|
| 486 | { |
---|
[2227] | 487 | casa::String funcName = "getFieldIdList" ; |
---|
[2208] | 488 | |
---|
[2197] | 489 | vector<FieldRow *> frows = asdm_->getField().get() ; |
---|
| 490 | fieldIdList_.resize( frows.size() ) ; |
---|
| 491 | for ( unsigned int irow = 0 ; irow < frows.size() ; irow++ ) { |
---|
[2208] | 492 | //logsink_->postLocally( LogMessage("fieldId["+String::toString(irow)+"]="+String(frows[irow]->getFieldId().toString()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 493 | fieldIdList_[irow] = frows[irow]->getFieldId().getTagValue() ; |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | return fieldIdList_ ; |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | casa::uInt ASDMReader::getNumMainRow() |
---|
| 500 | { |
---|
| 501 | casa::uInt nrow = casa::uInt( mainRow_.size() ) ; |
---|
| 502 | |
---|
| 503 | return nrow ; |
---|
| 504 | } |
---|
| 505 | |
---|
| 506 | void ASDMReader::select() |
---|
| 507 | { |
---|
[2208] | 508 | // selection by input CorrelationMode |
---|
| 509 | EnumSet<CorrelationMode> esCorrs ; |
---|
| 510 | sdmBin_->select( corrMode_ ) ; |
---|
| 511 | |
---|
| 512 | // selection by TimeSampling |
---|
| 513 | sdmBin_->select( timeSampling_ ) ; |
---|
| 514 | |
---|
[2215] | 515 | // selection by SpectralResolutionType |
---|
| 516 | sdmBin_->select( resolutionType_ ) ; |
---|
| 517 | |
---|
[2208] | 518 | // selection by AtmPhaseCorrection and output CorrelationMode |
---|
[2197] | 519 | EnumSet<AtmPhaseCorrection> esApcs ; |
---|
| 520 | esApcs.set( apc_ ) ; |
---|
[2208] | 521 | // always take only autocorrelation data |
---|
[2197] | 522 | Enum<CorrelationMode> esCorr = AUTO_ONLY ; |
---|
| 523 | sdmBin_->selectDataSubset( esCorr, esApcs ) ; |
---|
| 524 | |
---|
| 525 | // select valid configDescriptionId |
---|
| 526 | selectConfigDescription() ; |
---|
| 527 | |
---|
| 528 | // select valid feedId |
---|
| 529 | selectFeed() ; |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | casa::Bool ASDMReader::setMainRow( casa::uInt irow ) |
---|
| 533 | { |
---|
| 534 | casa::Bool status = true ; |
---|
| 535 | row_ = irow ; |
---|
[2301] | 536 | execBlockTag_ = mainRow_[row_]->getExecBlockId() ; |
---|
[2197] | 537 | |
---|
| 538 | unsigned int cdid = mainRow_[row_]->getConfigDescriptionId().getTagValue() ; |
---|
| 539 | if ( (int)count(configDescIdList_.begin(),configDescIdList_.end(),cdid) == 0 ) |
---|
| 540 | status = false ; |
---|
| 541 | else { |
---|
| 542 | status = (casa::Bool)(sdmBin_->acceptMainRow( mainRow_[row_] )) ; |
---|
| 543 | } |
---|
| 544 | return status ; |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | casa::Bool ASDMReader::setMainRow( casa::uInt configDescId, casa::uInt fieldId ) |
---|
| 548 | { |
---|
| 549 | clearMainRow() ; |
---|
| 550 | |
---|
| 551 | Tag configDescTag( (unsigned int)configDescId, TagType::ConfigDescription ) ; |
---|
| 552 | Tag fieldTag( (unsigned int)fieldId, TagType::Field ) ; |
---|
[2705] | 553 | vector<MainRow *> *rows = asdm_->getMain().getByContext( configDescTag, fieldTag ); |
---|
| 554 | if (rows == 0) |
---|
| 555 | return false; |
---|
| 556 | mainRow_ = casa::Vector<MainRow *>( *rows ) ; |
---|
[2197] | 557 | |
---|
| 558 | return true ; |
---|
| 559 | } |
---|
| 560 | |
---|
| 561 | void ASDMReader::clearMainRow() |
---|
| 562 | { |
---|
| 563 | mainRow_.resize(0) ; |
---|
| 564 | } |
---|
| 565 | |
---|
| 566 | void ASDMReader::setupIFNO() |
---|
| 567 | { |
---|
[2227] | 568 | casa::String funcName = "setupIFNO" ; |
---|
[2208] | 569 | |
---|
[2197] | 570 | vector<SpectralWindowRow *> spwrows = asdm_->getSpectralWindow().get() ; |
---|
| 571 | unsigned int nrow = spwrows.size() ; |
---|
| 572 | ifno_.clear() ; |
---|
| 573 | casa::uInt idx = 0 ; |
---|
| 574 | casa::uInt wvridx = 0 ; |
---|
| 575 | for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { |
---|
| 576 | casa::uInt index ; |
---|
| 577 | if ( isWVR( spwrows[irow] ) ) { |
---|
[2208] | 578 | //logsink_->postLocally( LogMessage(spwrows[irow]->getSpectralWindowId().toString()+" is WVR",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 579 | index = wvridx ; |
---|
| 580 | } |
---|
| 581 | else { |
---|
| 582 | index = ++idx ; |
---|
| 583 | } |
---|
| 584 | ifno_.insert( pair<Tag,casa::uInt>(spwrows[irow]->getSpectralWindowId(),index) ) ; |
---|
[2208] | 585 | //logsink_->postLocally( LogMessage(spwrows[irow]->getSpectralWindowId().toString()+": IFNO="+String::toString(index),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 586 | } |
---|
| 587 | } |
---|
| 588 | |
---|
| 589 | bool ASDMReader::isWVR( SpectralWindowRow *row ) |
---|
| 590 | { |
---|
| 591 | BasebandName bbname = row->getBasebandName() ; |
---|
| 592 | int nchan = row->getNumChan() ; |
---|
| 593 | if ( bbname == NOBB && nchan == 4 ) |
---|
| 594 | return true ; |
---|
| 595 | else |
---|
| 596 | return false ; |
---|
| 597 | } |
---|
| 598 | |
---|
| 599 | casa::Bool ASDMReader::setData() |
---|
| 600 | { |
---|
[2227] | 601 | casa::String funcName = "setData" ; |
---|
[2208] | 602 | |
---|
| 603 | //logsink_->postLocally( LogMessage("try to retrieve binary data",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 604 | |
---|
[2208] | 605 | // EnumSet<AtmPhaseCorrection> esApcs ; |
---|
| 606 | // esApcs.set( apc_ ) ; |
---|
| 607 | // // always take only autocorrelation data |
---|
| 608 | // Enum<CorrelationMode> esCorr = AUTO_ONLY ; |
---|
| 609 | // vmsData_ = sdmBin_->getDataCols( esCorr, esApcs ) ; |
---|
| 610 | |
---|
| 611 | // 2011/07/06 TN |
---|
| 612 | // Workaround to avoid unwanted message from SDMBinData::getDataCols() |
---|
| 613 | ostringstream oss ; |
---|
| 614 | streambuf *buforg = cout.rdbuf(oss.rdbuf()) ; |
---|
[2197] | 615 | vmsData_ = sdmBin_->getDataCols() ; |
---|
[2208] | 616 | cout.rdbuf(buforg) ; |
---|
[2197] | 617 | |
---|
[2208] | 618 | // logsink_->postLocally( LogMessage("oss.str() = "+oss.str(),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 619 | // cout << "This is test: oss.str()=" << oss.str() << endl ; |
---|
[2197] | 620 | |
---|
| 621 | |
---|
[2208] | 622 | //logsink_->postLocally( LogMessage("processorId = "+String::toString(vmsData_->processorId),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 623 | //logsink_->postLocally( LogMessage("v_time.size() = "+String::toString(vmsData_->v_time.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 624 | //logsink_->postLocally( LogMessage(" v_time[0] = "+String::toString(vmsData_->v_time[0]),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 625 | //logsink_->postLocally( LogMessage("v_interval.size() = "+String::toString(vmsData_->v_interval.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 626 | //logsink_->postLocally( LogMessage(" v_interval[0] = "+String::toString(vmsData_->v_interval[0]),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 627 | //logsink_->postLocally( LogMessage("v_atmPhaseCorrection.size() = "+String::toString(vmsData_->v_atmPhaseCorrection.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 628 | //logsink_->postLocally( LogMessage("binNum = "+String::toString(vmsData_->binNum),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 629 | //logsink_->postLocally( LogMessage("v_projectPath.size() = "+String::toString(vmsData_->v_projectPath.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 630 | //logsink_->postLocally( LogMessage("v_antennaId1.size() = "+String::toString(vmsData_->v_antennaId1.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 631 | //logsink_->postLocally( LogMessage("v_antennaId2.size() = "+String::toString(vmsData_->v_antennaId2.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 632 | //logsink_->postLocally( LogMessage("v_feedId1.size() = "+String::toString(vmsData_->v_feedId1.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 633 | //logsink_->postLocally( LogMessage("v_feedId2.size() = "+String::toString(vmsData_->v_feedId2.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 634 | //logsink_->postLocally( LogMessage("v_dataDescId.size() = "+String::toString(vmsData_->v_dataDescId.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 635 | //logsink_->postLocally( LogMessage("v_timeCentroid.size() = "+String::toString(vmsData_->v_timeCentroid.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 636 | //logsink_->postLocally( LogMessage("v_exposure.size() = "+String::toString(vmsData_->v_exposure.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 637 | //logsink_->postLocally( LogMessage("v_numData.size() = "+String::toString(vmsData_->v_numData.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 638 | //logsink_->postLocally( LogMessage("vv_dataShape.size() = "+String::toString(vmsData_->vv_dataShape.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 639 | //logsink_->postLocally( LogMessage("v_m_data.size() = "+String::toString(vmsData_->v_m_data.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 640 | //logsink_->postLocally( LogMessage("v_phaseDir.size() = "+String::toString(vmsData_->v_phaseDir.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 641 | //logsink_->postLocally( LogMessage("v_stateId.size() = "+String::toString(vmsData_->v_stateId.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 642 | //logsink_->postLocally( LogMessage("v_msState.size() = "+String::toString(vmsData_->v_msState.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 643 | //logsink_->postLocally( LogMessage("v_flag.size() = "+String::toString(vmsData_->v_flag.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 644 | |
---|
| 645 | dataIdList_.clear() ; |
---|
| 646 | unsigned int numTotalData = vmsData_->v_m_data.size() ; |
---|
| 647 | for ( unsigned int idata = 0 ; idata < numTotalData ; idata++ ) { |
---|
| 648 | if ( vmsData_->v_antennaId1[idata] == (int)antennaId_ |
---|
| 649 | && vmsData_->v_antennaId2[idata] == (int)antennaId_ ) |
---|
| 650 | dataIdList_.push_back( idata ) ; |
---|
| 651 | } |
---|
| 652 | numData_ = dataIdList_.size() ; |
---|
[2208] | 653 | //logsink_->postLocally( LogMessage("numData_ = "+String::toString(numData_),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 654 | //logsink_->postLocally( LogMessage("dataSize = "+String::toString(mainRow_[row_]->getDataSize()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 655 | |
---|
| 656 | return true ; |
---|
| 657 | } |
---|
| 658 | |
---|
[2301] | 659 | void ASDMReader::prepareData( unsigned int idx ) |
---|
| 660 | { |
---|
| 661 | unsigned int i = dataIdList_[idx] ; |
---|
| 662 | if ( i != dataIndex_ ) { |
---|
| 663 | dataIndex_ = dataIdList_[idx] ; |
---|
| 664 | Tag dataDescTag( vmsData_->v_dataDescId[dataIndex_], TagType::DataDescription ) ; |
---|
| 665 | DataDescriptionRow *dataDescRow = asdm_->getDataDescription().getRowByKey( dataDescTag ) ; |
---|
| 666 | specWinTag_ = dataDescRow->getSpectralWindowId() ; |
---|
| 667 | specWinRow_p = dataDescRow->getSpectralWindowUsingSpectralWindowId() ; |
---|
| 668 | polarizationRow_p = dataDescRow->getPolarizationUsingPolOrHoloId() ; |
---|
| 669 | Tag fieldTag( vmsData_->v_fieldId[dataIndex_], TagType::Field ) ; |
---|
| 670 | fieldRow_p = asdm_->getField().getRowByKey( fieldTag ) ; |
---|
| 671 | double startSec = vmsData_->v_time[dataIndex_] - 0.5 * vmsData_->v_interval[dataIndex_] ; |
---|
| 672 | timeInterval_ = ArrayTimeInterval( startSec*s2d, vmsData_->v_interval[dataIndex_]*s2d ) ; |
---|
| 673 | } |
---|
| 674 | } |
---|
| 675 | |
---|
[2197] | 676 | casa::uInt ASDMReader::getIFNo( unsigned int idx ) |
---|
| 677 | { |
---|
[2301] | 678 | prepareData( idx ) ; |
---|
| 679 | return getIFNo() ; |
---|
| 680 | } |
---|
| 681 | |
---|
| 682 | casa::uInt ASDMReader::getIFNo() |
---|
| 683 | { |
---|
| 684 | map<Tag,casa::uInt>::iterator iter = ifno_.find( specWinTag_ ) ; |
---|
[2197] | 685 | if ( iter != ifno_.end() ) |
---|
| 686 | return iter->second ; |
---|
| 687 | else { |
---|
| 688 | return 0 ; |
---|
| 689 | } |
---|
| 690 | } |
---|
| 691 | |
---|
| 692 | int ASDMReader::getNumPol( unsigned int idx ) |
---|
| 693 | { |
---|
[2301] | 694 | prepareData( idx ) ; |
---|
| 695 | return getNumPol() ; |
---|
[2197] | 696 | } |
---|
| 697 | |
---|
[2301] | 698 | int ASDMReader::getNumPol() |
---|
| 699 | { |
---|
| 700 | return polarizationRow_p->getNumCorr() ; |
---|
| 701 | } |
---|
| 702 | |
---|
[2197] | 703 | void ASDMReader::getFrequency( unsigned int idx, |
---|
| 704 | double &refpix, |
---|
| 705 | double &refval, |
---|
[2227] | 706 | double &incr, |
---|
| 707 | string &freqref ) |
---|
[2197] | 708 | { |
---|
[2301] | 709 | prepareData( idx ) ; |
---|
| 710 | getFrequency( refpix, refval, incr, freqref ) ; |
---|
| 711 | } |
---|
| 712 | |
---|
| 713 | void ASDMReader::getFrequency( double &refpix, |
---|
| 714 | double &refval, |
---|
| 715 | double &incr, |
---|
| 716 | string &freqref ) |
---|
| 717 | { |
---|
[2227] | 718 | casa::String funcName = "getFrequency" ; |
---|
[2208] | 719 | |
---|
[2301] | 720 | int nchan = specWinRow_p->getNumChan() ; |
---|
[2227] | 721 | freqref = "TOPO" ; |
---|
[2301] | 722 | if ( specWinRow_p->isMeasFreqRefExists() ) |
---|
| 723 | freqref = CFrequencyReferenceCode::toString( specWinRow_p->getMeasFreqRef() ) ; |
---|
[2197] | 724 | if ( nchan == 1 ) { |
---|
[2208] | 725 | //logsink_->postLocally( LogMessage("channel averaged data",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 726 | refpix = 0.0 ; |
---|
[2301] | 727 | incr = specWinRow_p->getTotBandwidth().get() ; |
---|
| 728 | if ( specWinRow_p->isChanFreqStartExists() ) { |
---|
| 729 | refval = specWinRow_p->getChanFreqStart().get() ; |
---|
[2197] | 730 | } |
---|
[2301] | 731 | else if ( specWinRow_p->isChanFreqArrayExists() ) { |
---|
| 732 | refval = specWinRow_p->getChanFreqArray()[0].get() ; |
---|
[2197] | 733 | } |
---|
| 734 | else { |
---|
| 735 | throw (casa::AipsError( "Either chanFreqArray or chanFreqStart must exist." )) ; |
---|
| 736 | } |
---|
| 737 | } |
---|
| 738 | else if ( nchan % 2 ) { |
---|
| 739 | // odd |
---|
[2208] | 740 | //logsink_->postLocally( LogMessage("odd case",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 741 | refpix = 0.5 * ( (double)nchan - 1.0 ) ; |
---|
| 742 | int ic = ( nchan - 1 ) / 2 ; |
---|
[2301] | 743 | if ( specWinRow_p->isChanWidthExists() ) { |
---|
| 744 | incr = specWinRow_p->getChanWidth().get() ; |
---|
[2197] | 745 | } |
---|
[2301] | 746 | else if ( specWinRow_p->isChanWidthArrayExists() ) { |
---|
| 747 | incr = specWinRow_p->getChanWidthArray()[0].get() ; |
---|
[2197] | 748 | } |
---|
| 749 | else { |
---|
| 750 | throw (casa::AipsError( "Either chanWidthArray or chanWidth must exist." )) ; |
---|
| 751 | } |
---|
[2301] | 752 | if ( specWinRow_p->isChanFreqStepExists() ) { |
---|
| 753 | if ( specWinRow_p->getChanFreqStep().get() < 0.0 ) |
---|
[2197] | 754 | incr *= -1.0 ; |
---|
| 755 | } |
---|
[2301] | 756 | else if ( specWinRow_p->isChanFreqArrayExists() ) { |
---|
| 757 | vector<Frequency> chanFreqArr = specWinRow_p->getChanFreqArray() ; |
---|
[2197] | 758 | if ( chanFreqArr[0].get() > chanFreqArr[1].get() ) |
---|
| 759 | incr *= -1.0 ; |
---|
| 760 | } |
---|
| 761 | else { |
---|
| 762 | throw (casa::AipsError( "Either chanFreqArray or chanFreqStep must exist." )) ; |
---|
| 763 | } |
---|
[2301] | 764 | if ( specWinRow_p->isChanFreqStartExists() ) { |
---|
| 765 | refval = specWinRow_p->getChanFreqStart().get() + refpix * incr ; |
---|
[2197] | 766 | } |
---|
[2301] | 767 | else if ( specWinRow_p->isChanFreqArrayExists() ) { |
---|
| 768 | refval = specWinRow_p->getChanFreqArray()[ic].get() ; |
---|
[2197] | 769 | } |
---|
| 770 | else { |
---|
| 771 | throw (casa::AipsError( "Either chanFreqArray or chanFreqStart must exist." )) ; |
---|
| 772 | } |
---|
| 773 | } |
---|
| 774 | else { |
---|
| 775 | // even |
---|
[2208] | 776 | //logsink_->postLocally( LogMessage("even case",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 777 | refpix = 0.5 * ( (double)nchan - 1.0 ) ; |
---|
| 778 | int ic = nchan / 2 ; |
---|
[2301] | 779 | if ( specWinRow_p->isChanWidthExists() ) { |
---|
| 780 | incr = specWinRow_p->getChanWidth().get() ; |
---|
[2197] | 781 | } |
---|
[2301] | 782 | else if ( specWinRow_p->isChanWidthArrayExists() ) { |
---|
| 783 | incr = specWinRow_p->getChanWidthArray()[0].get() ; |
---|
[2197] | 784 | } |
---|
| 785 | else { |
---|
| 786 | throw (casa::AipsError( "Either chanWidthArray or chanWidth must exist." )) ; |
---|
| 787 | } |
---|
[2301] | 788 | if ( specWinRow_p->isChanFreqStepExists() ) { |
---|
| 789 | if ( specWinRow_p->getChanFreqStep().get() < 0.0 ) |
---|
[2197] | 790 | incr *= -1.0 ; |
---|
| 791 | } |
---|
[2301] | 792 | else if ( specWinRow_p->isChanFreqArrayExists() ) { |
---|
| 793 | vector<Frequency> chanFreqArr = specWinRow_p->getChanFreqArray() ; |
---|
[2197] | 794 | if ( chanFreqArr[0].get() > chanFreqArr[1].get() ) |
---|
| 795 | incr *= -1.0 ; |
---|
| 796 | } |
---|
| 797 | else { |
---|
| 798 | throw (casa::AipsError( "Either chanFreqArray or chanFreqStep must exist." )) ; |
---|
| 799 | } |
---|
[2301] | 800 | if ( specWinRow_p->isChanFreqStartExists() ) { |
---|
| 801 | refval = specWinRow_p->getChanFreqStart().get() + refpix * incr ; |
---|
[2197] | 802 | } |
---|
[2301] | 803 | else if ( specWinRow_p->isChanFreqArrayExists() ) { |
---|
| 804 | vector<Frequency> freqs = specWinRow_p->getChanFreqArray() ; |
---|
[2197] | 805 | refval = 0.5 * ( freqs[ic-1].get() + freqs[ic].get() ) ; |
---|
| 806 | } |
---|
| 807 | else { |
---|
| 808 | throw (casa::AipsError( "Either chanFreqArray or chanFreqStart must exist." )) ; |
---|
| 809 | } |
---|
| 810 | } |
---|
| 811 | } |
---|
| 812 | |
---|
[2301] | 813 | double ASDMReader::getTime( unsigned int idx ) |
---|
[2197] | 814 | { |
---|
[2301] | 815 | prepareData( idx ) ; |
---|
| 816 | return getTime() ; |
---|
[2197] | 817 | } |
---|
| 818 | |
---|
[2301] | 819 | double ASDMReader::getTime() |
---|
[2197] | 820 | { |
---|
[2301] | 821 | double tsec = vmsData_->v_time[dataIndex_] ; |
---|
[2197] | 822 | return tsec * s2d ; |
---|
| 823 | } |
---|
| 824 | |
---|
| 825 | double ASDMReader::getInterval( unsigned int idx ) |
---|
| 826 | { |
---|
[2301] | 827 | prepareData( idx ) ; |
---|
| 828 | return getInterval() ; |
---|
[2197] | 829 | } |
---|
| 830 | |
---|
[2301] | 831 | double ASDMReader::getInterval() |
---|
[2197] | 832 | { |
---|
[2301] | 833 | return vmsData_->v_interval[dataIndex_] ; |
---|
| 834 | } |
---|
| 835 | |
---|
| 836 | void ASDMReader::getSourceProperty( unsigned int idx, |
---|
| 837 | string &srcname, |
---|
| 838 | string &fieldname, |
---|
| 839 | vector<double> &srcdir, |
---|
| 840 | vector<double> &srcpm, |
---|
| 841 | double &sysvel, |
---|
| 842 | vector<double> &restfreq ) |
---|
| 843 | { |
---|
| 844 | prepareData( idx ) ; |
---|
| 845 | getSourceProperty( srcname, fieldname, srcdir, srcpm, sysvel, restfreq ) ; |
---|
| 846 | } |
---|
| 847 | |
---|
| 848 | void ASDMReader::getSourceProperty( string &srcname, |
---|
| 849 | string &fieldname, |
---|
| 850 | vector<double> &srcdir, |
---|
| 851 | vector<double> &srcpm, |
---|
| 852 | double &sysvel, |
---|
| 853 | vector<double> &restfreq ) |
---|
| 854 | { |
---|
[2355] | 855 | String funcName = "getSourceProperty" ; |
---|
[2301] | 856 | ostringstream oss ; |
---|
| 857 | oss << fieldRow_p->getFieldName() << "__" << vmsData_->v_fieldId[dataIndex_] ; |
---|
| 858 | fieldname = oss.str() ; |
---|
[2355] | 859 | SourceRow *srow = 0 ; |
---|
[2301] | 860 | if ( fieldRow_p->isSourceIdExists() ) { |
---|
| 861 | int sourceId = fieldRow_p->getSourceId() ; |
---|
[2355] | 862 | srow = asdm_->getSource().getRowByKey( sourceId, timeInterval_, specWinTag_ ) ; |
---|
| 863 | } |
---|
| 864 | if ( srow != 0 ) { |
---|
| 865 | //logsink_->postLocally( LogMessage("timeInterval_="+String::toString(timeInterval_.getStart().getMJD()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 866 | //logsink_->postLocally( LogMessage("specWinTag_="+String::toString(specWinTag_.toString()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 867 | //SourceRow *srow = asdm_->getSource().getRowByKey( sourceId, timeInterval_, specWinTag_ ) ; |
---|
| 868 | //logsink_->postLocally( LogMessage("sourceId="+String::toString(sourceId),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 869 | //if ( srow == 0 ) |
---|
| 870 | //logsink_->postLocally( LogMessage("nullpo",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2301] | 871 | |
---|
| 872 | // source name |
---|
[2197] | 873 | srcname = srow->getSourceName() ; |
---|
[2355] | 874 | //logsink_->postLocally( LogMessage("srcname="+String::toString(srcname),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2301] | 875 | |
---|
| 876 | // source direction |
---|
| 877 | vector<Angle> srcdirA = srow->getDirection() ; |
---|
| 878 | srcdir.resize( 2 ) ; |
---|
| 879 | srcdir[0] = limitedAngle( srcdirA[0].get() ) ; |
---|
| 880 | srcdir[1] = limitedAngle( srcdirA[1].get() ) ; |
---|
[2355] | 881 | //logsink_->postLocally( LogMessage("srcdir=["+String::toString(srcdir[0])+","+String::toString(srcdir[1])+"]",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2301] | 882 | if ( srow->isDirectionCodeExists() ) { |
---|
[2305] | 883 | DirectionReferenceCodeMod::DirectionReferenceCode dircode = srow->getDirectionCode() ; |
---|
[2301] | 884 | //logsink_->postLocally( LogMessage("dircode="+CDirectionReferenceCode::toString(dircode),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2305] | 885 | if ( dircode != DirectionReferenceCodeMod::J2000 ) { |
---|
[2301] | 886 | // if not J2000, need direction conversion |
---|
| 887 | String ref( CDirectionReferenceCode::toString( dircode ) ) ; |
---|
| 888 | double mjd = vmsData_->v_time[dataIndex_] * s2d ; |
---|
| 889 | srcdir = toJ2000( srcdir, ref, mjd, antennaPosition_ ) ; |
---|
| 890 | } |
---|
| 891 | } |
---|
| 892 | |
---|
| 893 | // source proper motion |
---|
| 894 | srcpm.resize( 2 ) ; |
---|
| 895 | vector<AngularRate> srcpmA = srow->getProperMotion() ; |
---|
| 896 | srcpm[0] = srcpmA[0].get() ; |
---|
| 897 | srcpm[1] = srcpmA[1].get() ; |
---|
[2355] | 898 | //logsink_->postLocally( LogMessage("srcpm=["+String::toString(srcpm[0])+","+String::toString(srcpm[1])+"]",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2301] | 899 | // systemic velocity |
---|
| 900 | if ( srow->isSysVelExists() ) { |
---|
| 901 | vector<Speed> sysvelV = srow->getSysVel() ; |
---|
| 902 | if ( sysvelV.size() > 0 ) |
---|
| 903 | sysvel = sysvelV[0].get() ; |
---|
| 904 | } |
---|
| 905 | else { |
---|
| 906 | sysvel = 0.0 ; |
---|
| 907 | } |
---|
[2355] | 908 | //logsink_->postLocally( LogMessage("sysvel="+String::toString(sysvel),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2301] | 909 | // rest frequency |
---|
| 910 | if ( srow->isRestFrequencyExists() ) { |
---|
| 911 | //logsink_->postLocally( LogMessage("restFrequency exists",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 912 | vector<Frequency> rf = srow->getRestFrequency() ; |
---|
| 913 | restfreq.resize( rf.size() ) ; |
---|
| 914 | for ( unsigned int i = 0 ; i < restfreq.size() ; i++ ) |
---|
| 915 | restfreq[i] = rf[i].get() ; |
---|
| 916 | } |
---|
| 917 | else { |
---|
| 918 | restfreq.resize( 0 ) ; |
---|
| 919 | } |
---|
[2355] | 920 | //logsink_->postLocally( LogMessage("restfreq.size()="+String::toString(restfreq.size()),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 921 | } |
---|
| 922 | else { |
---|
[2301] | 923 | srcname = fieldRow_p->getFieldName() ; |
---|
| 924 | srcdir.resize( 2 ) ; |
---|
| 925 | srcdir[0] = 0.0 ; |
---|
| 926 | srcdir[1] = 0.0 ; |
---|
| 927 | srcpm = srcdir ; |
---|
| 928 | sysvel = 0.0 ; |
---|
| 929 | restfreq.resize( 0 ) ; |
---|
[2197] | 930 | } |
---|
| 931 | } |
---|
| 932 | |
---|
| 933 | int ASDMReader::getSrcType( unsigned int scan, |
---|
| 934 | unsigned int subscan ) |
---|
| 935 | { |
---|
| 936 | int srctype = SrcType::NOTYPE ; |
---|
[2301] | 937 | ScanRow *scanrow = asdm_->getScan().getRowByKey( execBlockTag_, (int)scan ) ; |
---|
[2305] | 938 | ScanIntentMod::ScanIntent scanIntent = scanrow->getScanIntent()[0] ; |
---|
[2301] | 939 | SubscanRow *subrow = asdm_->getSubscan().getRowByKey( execBlockTag_, (int)scan, (int)subscan ) ; |
---|
[2618] | 940 | if ( subrow == 0 ) { |
---|
| 941 | return srctype ; |
---|
| 942 | } |
---|
[2305] | 943 | SubscanIntentMod::SubscanIntent subIntent = subrow->getSubscanIntent() ; |
---|
| 944 | SwitchingModeMod::SwitchingMode swmode = SwitchingModeMod::NO_SWITCHING ; |
---|
[2299] | 945 | if ( subrow->isSubscanModeExists() ) |
---|
| 946 | swmode = subrow->getSubscanMode() ; |
---|
[2305] | 947 | if ( scanIntent == ScanIntentMod::OBSERVE_TARGET ) { |
---|
[2197] | 948 | // on sky scan |
---|
[2305] | 949 | if ( swmode == SwitchingModeMod::NO_SWITCHING || swmode == SwitchingModeMod::POSITION_SWITCHING ) { |
---|
[2197] | 950 | // position switching |
---|
| 951 | // tentatively set NO_SWITCHING = POSITION_SWITCHING |
---|
[2305] | 952 | if ( subIntent == SubscanIntentMod::ON_SOURCE ) { |
---|
[2197] | 953 | srctype = SrcType::PSON ; |
---|
| 954 | } |
---|
[2305] | 955 | else if ( subIntent == SubscanIntentMod::OFF_SOURCE ) { |
---|
[2197] | 956 | srctype = SrcType::PSOFF ; |
---|
| 957 | } |
---|
| 958 | } |
---|
[2305] | 959 | else if ( swmode == SwitchingModeMod::FREQUENCY_SWITCHING ) { |
---|
[2197] | 960 | // frequency switching |
---|
[2305] | 961 | if ( subIntent == SubscanIntentMod::ON_SOURCE ) { |
---|
[2197] | 962 | srctype = SrcType::FSON ; |
---|
| 963 | } |
---|
[2305] | 964 | else if ( subIntent == SubscanIntentMod::OFF_SOURCE ) { |
---|
[2197] | 965 | srctype = SrcType::FSOFF ; |
---|
| 966 | } |
---|
| 967 | } |
---|
[2305] | 968 | else if ( swmode == SwitchingModeMod::NUTATOR_SWITCHING ) { |
---|
[2197] | 969 | // nutator switching |
---|
[2305] | 970 | if ( subIntent == SubscanIntentMod::ON_SOURCE ) { |
---|
[2197] | 971 | srctype = SrcType::PSON ; |
---|
| 972 | } |
---|
[2305] | 973 | else if ( subIntent == SubscanIntentMod::OFF_SOURCE ) { |
---|
[2197] | 974 | srctype = SrcType::PSOFF ; |
---|
| 975 | } |
---|
| 976 | } |
---|
| 977 | else { |
---|
| 978 | // other switching mode |
---|
[2305] | 979 | if ( subIntent == SubscanIntentMod::ON_SOURCE ) { |
---|
[2197] | 980 | srctype = SrcType::SIG ; |
---|
| 981 | } |
---|
[2305] | 982 | else if ( subIntent == SubscanIntentMod::OFF_SOURCE ) { |
---|
[2197] | 983 | srctype = SrcType::REF ; |
---|
| 984 | } |
---|
| 985 | } |
---|
| 986 | } |
---|
[2305] | 987 | else if ( scanIntent == ScanIntentMod::CALIBRATE_ATMOSPHERE ) { |
---|
| 988 | if ( swmode == SwitchingModeMod::NO_SWITCHING || swmode == SwitchingModeMod::POSITION_SWITCHING ) { |
---|
[2250] | 989 | // position switching |
---|
| 990 | // tentatively set NO_SWITCHING = POSITION_SWITCHING |
---|
[2305] | 991 | if ( subIntent == SubscanIntentMod::ON_SOURCE ) { |
---|
[2250] | 992 | srctype = SrcType::PONCAL ; |
---|
| 993 | } |
---|
[2305] | 994 | else if ( subIntent == SubscanIntentMod::OFF_SOURCE ) { |
---|
[2250] | 995 | srctype = SrcType::POFFCAL ; |
---|
| 996 | } |
---|
| 997 | } |
---|
[2305] | 998 | else if ( swmode == SwitchingModeMod::FREQUENCY_SWITCHING ) { |
---|
[2250] | 999 | // frequency switching |
---|
[2305] | 1000 | if ( subIntent == SubscanIntentMod::ON_SOURCE ) { |
---|
[2250] | 1001 | srctype = SrcType::FONCAL ; |
---|
| 1002 | } |
---|
[2305] | 1003 | else if ( subIntent == SubscanIntentMod::OFF_SOURCE ) { |
---|
[2250] | 1004 | srctype = SrcType::FOFFCAL ; |
---|
| 1005 | } |
---|
| 1006 | } |
---|
[2305] | 1007 | else if ( swmode == SwitchingModeMod::NUTATOR_SWITCHING ) { |
---|
[2250] | 1008 | // nutator switching |
---|
[2305] | 1009 | if ( subIntent == SubscanIntentMod::ON_SOURCE ) { |
---|
[2250] | 1010 | srctype = SrcType::PONCAL ; |
---|
| 1011 | } |
---|
[2305] | 1012 | else if ( subIntent == SubscanIntentMod::OFF_SOURCE ) { |
---|
[2250] | 1013 | srctype = SrcType::POFFCAL ; |
---|
| 1014 | } |
---|
| 1015 | } |
---|
| 1016 | else { |
---|
| 1017 | // other switching mode |
---|
[2305] | 1018 | if ( subIntent == SubscanIntentMod::ON_SOURCE ) { |
---|
[2250] | 1019 | srctype = SrcType::CAL ; |
---|
| 1020 | } |
---|
[2305] | 1021 | else if ( subIntent == SubscanIntentMod::OFF_SOURCE ) { |
---|
[2250] | 1022 | srctype = SrcType::CAL ; |
---|
| 1023 | } |
---|
| 1024 | } |
---|
| 1025 | } |
---|
[2197] | 1026 | else { |
---|
| 1027 | // off sky (e.g. calibrator device) scan |
---|
[2305] | 1028 | if ( subIntent == SubscanIntentMod::ON_SOURCE ) { |
---|
[2197] | 1029 | srctype = SrcType::SIG ; |
---|
| 1030 | } |
---|
[2305] | 1031 | else if ( subIntent == SubscanIntentMod::OFF_SOURCE ) { |
---|
[2197] | 1032 | srctype = SrcType::REF ; |
---|
| 1033 | } |
---|
[2305] | 1034 | else if ( subIntent == SubscanIntentMod::HOT ) { |
---|
[2197] | 1035 | srctype = SrcType::HOT ; |
---|
| 1036 | } |
---|
[2305] | 1037 | else if ( subIntent == SubscanIntentMod::AMBIENT ) { |
---|
[2197] | 1038 | srctype = SrcType::SKY ; |
---|
| 1039 | } |
---|
| 1040 | else { |
---|
| 1041 | srctype = SrcType::CAL ; |
---|
| 1042 | } |
---|
| 1043 | } |
---|
| 1044 | |
---|
| 1045 | return srctype ; |
---|
| 1046 | } |
---|
| 1047 | |
---|
| 1048 | unsigned int ASDMReader::getSubscanNo( unsigned int idx ) |
---|
| 1049 | { |
---|
[2301] | 1050 | prepareData( idx ) ; |
---|
| 1051 | return getSubscanNo() ; |
---|
[2197] | 1052 | } |
---|
| 1053 | |
---|
[2301] | 1054 | unsigned int ASDMReader::getSubscanNo() |
---|
[2197] | 1055 | { |
---|
[2618] | 1056 | return mainRow_[row_]->getSubscanNumber() ; |
---|
[2197] | 1057 | } |
---|
| 1058 | |
---|
[2225] | 1059 | void ASDMReader::getSourceDirection( vector<double> &dir, string &ref ) |
---|
| 1060 | { |
---|
| 1061 | dir.resize( 2 ) ; |
---|
| 1062 | ref = "J2000" ; // default is J2000 |
---|
| 1063 | SourceTable &tab = asdm_->getSource() ; |
---|
| 1064 | SourceRow *row = tab.get()[0] ; |
---|
| 1065 | vector<Angle> dirA = row->getDirection() ; |
---|
| 1066 | dir[0] = dirA[0].get() ; |
---|
| 1067 | dir[1] = dirA[1].get() ; |
---|
| 1068 | if ( row->isDirectionCodeExists() ) { |
---|
| 1069 | ref = CDirectionReferenceCode::toString( row->getDirectionCode() ) ; |
---|
| 1070 | } |
---|
| 1071 | } |
---|
| 1072 | |
---|
[2301] | 1073 | unsigned int ASDMReader::getFlagRow( unsigned int idx ) |
---|
[2197] | 1074 | { |
---|
[2301] | 1075 | prepareData( idx ) ; |
---|
| 1076 | return getFlagRow() ; |
---|
[2197] | 1077 | } |
---|
| 1078 | |
---|
[2301] | 1079 | unsigned int ASDMReader::getFlagRow() |
---|
[2197] | 1080 | { |
---|
[2301] | 1081 | return vmsData_->v_flag[dataIndex_] ; |
---|
[2197] | 1082 | } |
---|
| 1083 | |
---|
[2301] | 1084 | vector<unsigned int> ASDMReader::getDataShape( unsigned int idx ) |
---|
[2197] | 1085 | { |
---|
[2301] | 1086 | prepareData( idx ) ; |
---|
| 1087 | return getDataShape() ; |
---|
[2197] | 1088 | } |
---|
| 1089 | |
---|
[2301] | 1090 | vector<unsigned int> ASDMReader::getDataShape() |
---|
[2197] | 1091 | { |
---|
[2301] | 1092 | return vmsData_->vv_dataShape[dataIndex_] ; |
---|
[2197] | 1093 | } |
---|
| 1094 | |
---|
| 1095 | float * ASDMReader::getSpectrum( unsigned int idx ) |
---|
| 1096 | { |
---|
[2301] | 1097 | prepareData( idx ) ; |
---|
| 1098 | return getSpectrum() ; |
---|
| 1099 | } |
---|
| 1100 | |
---|
| 1101 | float * ASDMReader::getSpectrum() |
---|
| 1102 | { |
---|
| 1103 | map<AtmPhaseCorrection, float*> data = vmsData_->v_m_data[dataIndex_] ; |
---|
[2197] | 1104 | //map<AtmPhaseCorrection, float*>::iterator iter = data.find(AP_UNCORRECTED) ; |
---|
| 1105 | map<AtmPhaseCorrection, float*>::iterator iter = data.find(apc_) ; |
---|
| 1106 | float *autoCorr = iter->second ; |
---|
| 1107 | return autoCorr ; |
---|
| 1108 | } |
---|
| 1109 | |
---|
| 1110 | vector< vector<float> > ASDMReader::getTsys( unsigned int idx ) |
---|
| 1111 | { |
---|
[2301] | 1112 | prepareData( idx ) ; |
---|
| 1113 | return getTsys() ; |
---|
| 1114 | } |
---|
| 1115 | |
---|
| 1116 | vector< vector<float> > ASDMReader::getTsys() |
---|
| 1117 | { |
---|
[2197] | 1118 | vector< vector<float> > defaultTsys( 1, vector<float>( 1, 1.0 ) ) ; |
---|
[2301] | 1119 | SysCalRow *scrow = getSysCalRow() ; |
---|
[2249] | 1120 | if ( scrow != 0 && scrow->isTsysSpectrumExists() ) { |
---|
[2197] | 1121 | vector< vector<Temperature> > tsysSpec = scrow->getTsysSpectrum() ; |
---|
| 1122 | unsigned int numReceptor = tsysSpec.size() ; |
---|
| 1123 | unsigned int numChan = tsysSpec[0].size() ; |
---|
| 1124 | vector< vector<float> > tsys( numReceptor, vector<float>( numChan, 1.0 ) ) ; |
---|
| 1125 | for ( unsigned int ir = 0 ; ir < numReceptor ; ir++ ) { |
---|
| 1126 | for ( unsigned int ic = 0 ; ic < numChan ; ic++ ) { |
---|
| 1127 | tsys[ir][ic] = tsysSpec[ir][ic].get() ; |
---|
| 1128 | } |
---|
| 1129 | } |
---|
| 1130 | return tsys ; |
---|
| 1131 | } |
---|
| 1132 | // else if ( scrow->isTsysExists() ) { |
---|
| 1133 | // vector<Temperature> tsysScalar = scrow->getTsys() ; |
---|
| 1134 | // unsigned int numReceptor = tsysScalar.size() ; |
---|
| 1135 | // vector< vector<float> > tsys( numReceptor ) ; |
---|
| 1136 | // for ( unsigned int ir = 0 ; ir < numReceptor ; ir++ ) |
---|
| 1137 | // tsys[ir] = vector<float>( 1, tsysScalar[ir].get() ) ; |
---|
| 1138 | // return tsys ; |
---|
| 1139 | // } |
---|
| 1140 | else { |
---|
| 1141 | return defaultTsys ; |
---|
| 1142 | } |
---|
| 1143 | } |
---|
| 1144 | |
---|
| 1145 | vector< vector<float> > ASDMReader::getTcal( unsigned int idx ) |
---|
| 1146 | { |
---|
[2301] | 1147 | prepareData( idx ) ; |
---|
| 1148 | return getTcal() ; |
---|
| 1149 | } |
---|
| 1150 | |
---|
| 1151 | vector< vector<float> > ASDMReader::getTcal() |
---|
| 1152 | { |
---|
[2197] | 1153 | vector< vector<float> > defaultTcal( 1, vector<float>( 1, 1.0 ) ) ; |
---|
[2301] | 1154 | SysCalRow *scrow = getSysCalRow() ; |
---|
[2249] | 1155 | if ( scrow != 0 && scrow->isTcalSpectrumExists() ) { |
---|
[2197] | 1156 | vector< vector<Temperature> > tcalSpec = scrow->getTcalSpectrum() ; |
---|
| 1157 | unsigned int numReceptor = tcalSpec.size() ; |
---|
| 1158 | unsigned int numChan = tcalSpec[0].size() ; |
---|
| 1159 | vector< vector<float> > tcal( numReceptor, vector<float>( numChan, 1.0 ) ) ; |
---|
| 1160 | for ( unsigned int ir = 0 ; ir < numReceptor ; ir++ ) { |
---|
| 1161 | for ( unsigned int ic = 0 ; ic < numChan ; ic++ ) { |
---|
| 1162 | tcal[ir][ic] = tcalSpec[ir][ic].get() ; |
---|
| 1163 | } |
---|
| 1164 | } |
---|
| 1165 | return tcal ; |
---|
| 1166 | } |
---|
| 1167 | // else if ( scrow->isTcalExists() ) { |
---|
| 1168 | // vector<Temperature> tcalScalar = scrow->getTcal() ; |
---|
| 1169 | // unsigned int numReceptor = tcalScalar.size() ; |
---|
| 1170 | // vector< vector<float> > tcal( numReceptor, vector<float>( 1, 1.0 ) ) ; |
---|
| 1171 | // for ( unsigned int ir = 0 ; ir < numReceptor ; ir++ ) |
---|
| 1172 | // tcal[ir][0] = tcalScalar[ir][0].get() ; |
---|
| 1173 | // return tcal ; |
---|
| 1174 | // } |
---|
| 1175 | else { |
---|
| 1176 | return defaultTcal ; |
---|
| 1177 | } |
---|
| 1178 | } |
---|
| 1179 | |
---|
[2251] | 1180 | void ASDMReader::getTcalAndTsys( unsigned int idx, |
---|
| 1181 | vector< vector<float> > &tcal, |
---|
| 1182 | vector< vector<float> > &tsys ) |
---|
| 1183 | { |
---|
[2301] | 1184 | prepareData( idx ) ; |
---|
| 1185 | getTcalAndTsys( tcal, tsys ) ; |
---|
| 1186 | } |
---|
| 1187 | |
---|
| 1188 | void ASDMReader::getTcalAndTsys( vector< vector<float> > &tcal, |
---|
| 1189 | vector< vector<float> > &tsys ) |
---|
| 1190 | { |
---|
[2251] | 1191 | String funcName = "getTcalAndTsys" ; |
---|
| 1192 | |
---|
| 1193 | vector< vector<float> > defaultT( 1, vector<float>( 1, 1.0 ) ) ; |
---|
[2301] | 1194 | SysCalRow *scrow = getSysCalRow() ; |
---|
[2355] | 1195 | //logsink_->postLocally( LogMessage("scrow = "+String::toString((long)scrow),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2251] | 1196 | if ( scrow == 0 ) { |
---|
| 1197 | tcal = defaultT ; |
---|
| 1198 | tsys = defaultT ; |
---|
| 1199 | } |
---|
| 1200 | else { |
---|
| 1201 | if ( scrow->isTsysSpectrumExists() ) { |
---|
| 1202 | vector< vector<Temperature> > tsysSpec = scrow->getTsysSpectrum() ; |
---|
| 1203 | unsigned int numReceptor = tsysSpec.size() ; |
---|
| 1204 | unsigned int numChan = tsysSpec[0].size() ; |
---|
[2355] | 1205 | //logsink_->postLocally( LogMessage("TSYS: numReceptor = "+String::toString(numReceptor),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 1206 | //logsink_->postLocally( LogMessage("TSYS:numChan = "+String::toString(numChan),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2251] | 1207 | tsys.resize( numReceptor ) ; |
---|
| 1208 | for ( unsigned int ir = 0 ; ir < numReceptor ; ir++ ) { |
---|
| 1209 | tsys[ir].resize( numChan ) ; |
---|
| 1210 | for ( unsigned int ic = 0 ; ic < numChan ; ic++ ) { |
---|
| 1211 | tsys[ir][ic] = tsysSpec[ir][ic].get() ; |
---|
| 1212 | } |
---|
| 1213 | } |
---|
| 1214 | } |
---|
| 1215 | else { |
---|
| 1216 | tsys = defaultT ; |
---|
| 1217 | } |
---|
| 1218 | if ( scrow->isTcalSpectrumExists() ) { |
---|
| 1219 | vector< vector<Temperature> > tcalSpec = scrow->getTcalSpectrum() ; |
---|
| 1220 | unsigned int numReceptor = tcalSpec.size() ; |
---|
| 1221 | unsigned int numChan = tcalSpec[0].size() ; |
---|
[2355] | 1222 | //logsink_->postLocally( LogMessage("TCAL: numReceptor = "+String::toString(numReceptor),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 1223 | //logsink_->postLocally( LogMessage("TCAL: numChan = "+String::toString(numChan),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2251] | 1224 | tcal.resize( numReceptor ) ; |
---|
| 1225 | for ( unsigned int ir = 0 ; ir < numReceptor ; ir++ ) { |
---|
[2355] | 1226 | tcal[ir].resize( numChan ) ; |
---|
[2251] | 1227 | for ( unsigned int ic = 0 ; ic < numChan ; ic++ ) { |
---|
| 1228 | tcal[ir][ic] = tcalSpec[ir][ic].get() ; |
---|
| 1229 | } |
---|
| 1230 | } |
---|
| 1231 | } |
---|
| 1232 | else { |
---|
| 1233 | tcal = defaultT ; |
---|
| 1234 | } |
---|
| 1235 | } |
---|
| 1236 | } |
---|
| 1237 | |
---|
[2197] | 1238 | vector<float> ASDMReader::getOpacity( unsigned int idx ) |
---|
| 1239 | { |
---|
[2301] | 1240 | prepareData( idx ) ; |
---|
| 1241 | return getOpacity() ; |
---|
| 1242 | } |
---|
| 1243 | |
---|
| 1244 | vector<float> ASDMReader::getOpacity() |
---|
| 1245 | { |
---|
[2197] | 1246 | vector<float> tau(0) ; |
---|
| 1247 | CalAtmosphereTable &atmtab = asdm_->getCalAtmosphere() ; |
---|
| 1248 | unsigned int nrow = atmtab.size() ; |
---|
| 1249 | if ( nrow > 0 ) { |
---|
| 1250 | //int feedid = vmsData_->v_feedId1[index] ; |
---|
| 1251 | //BasebandName bbname = spwrow->getBasebandName() ; |
---|
| 1252 | //FeedRow *frow = asdm_->getFeed().getRowByKey( atag, spwtag, tint, feedid ) ; |
---|
| 1253 | //int nfeed = frow->getNumReceptor() ; |
---|
| 1254 | //vector<ReceiverRow *> rrows = frow->getReceivers() ; |
---|
| 1255 | vector<CalAtmosphereRow *> atmrows = atmtab.get() ; |
---|
| 1256 | //ReceiverBand rb = rrows[0]->getFrequencyBand() ; |
---|
| 1257 | int row0 = -1 ; |
---|
[2307] | 1258 | //double eps = DBL_MAX ; |
---|
| 1259 | double eps = 1.0e10 ; |
---|
[2197] | 1260 | for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { |
---|
| 1261 | CalAtmosphereRow *atmrow = atmrows[irow] ; |
---|
| 1262 | if ( casa::String(atmrow->getAntennaName()) != antennaName_ |
---|
| 1263 | //|| atmrow->getReceiverBand() != rb |
---|
| 1264 | //|| atmrow->getBasebandName() != bbname |
---|
[2305] | 1265 | || atmrow->getCalDataUsingCalDataId()->getCalType() != CalTypeMod::CAL_ATMOSPHERE ) |
---|
[2197] | 1266 | continue ; |
---|
| 1267 | else { |
---|
[2301] | 1268 | double dt = timeInterval_.getStart().getMJD() - atmrow->getEndValidTime().getMJD() ; |
---|
[2197] | 1269 | if ( dt >= 0 && dt < eps ) { |
---|
| 1270 | eps = dt ; |
---|
| 1271 | row0 = (int)irow ; |
---|
| 1272 | } |
---|
| 1273 | } |
---|
| 1274 | } |
---|
| 1275 | if ( row0 != -1 ) { |
---|
| 1276 | CalAtmosphereRow *atmrow = atmrows[row0] ; |
---|
| 1277 | tau = atmrow->getTau() ; |
---|
| 1278 | } |
---|
[2471] | 1279 | else { |
---|
| 1280 | tau.resize( 1 ) ; |
---|
| 1281 | tau[0] = 0.0 ; |
---|
| 1282 | } |
---|
[2197] | 1283 | } |
---|
[2229] | 1284 | else { |
---|
| 1285 | tau.resize( 1 ) ; |
---|
| 1286 | tau[0] = 0.0 ; |
---|
| 1287 | } |
---|
[2197] | 1288 | return tau ; |
---|
| 1289 | } |
---|
| 1290 | |
---|
| 1291 | void ASDMReader::getWeatherInfo( unsigned int idx, |
---|
| 1292 | float &temperature, |
---|
| 1293 | float &pressure, |
---|
| 1294 | float &humidity, |
---|
| 1295 | float &windspeed, |
---|
| 1296 | float &windaz ) |
---|
| 1297 | { |
---|
[2301] | 1298 | prepareData( idx ) ; |
---|
| 1299 | getWeatherInfo( temperature, pressure, humidity, windspeed, windaz ) ; |
---|
| 1300 | } |
---|
| 1301 | |
---|
| 1302 | void ASDMReader::getWeatherInfo( float &temperature, |
---|
| 1303 | float &pressure, |
---|
| 1304 | float &humidity, |
---|
| 1305 | float &windspeed, |
---|
| 1306 | float &windaz ) |
---|
| 1307 | { |
---|
[2235] | 1308 | casa::String funcName = "getWeatherInfo" ; |
---|
| 1309 | |
---|
[2197] | 1310 | temperature = 0.0 ; |
---|
| 1311 | pressure = 0.0 ; |
---|
| 1312 | humidity = 0.0 ; |
---|
| 1313 | windspeed = 0.0 ; |
---|
| 1314 | windaz = 0.0 ; |
---|
| 1315 | |
---|
[2208] | 1316 | //logsink_->postLocally( LogMessage("weatherStationId_ = "+String::toString(weatherStationId_),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 1317 | |
---|
| 1318 | WeatherTable &wtab = asdm_->getWeather() ; |
---|
| 1319 | if ( wtab.size() == 0 || weatherStationId_ == -1 ) |
---|
| 1320 | return ; |
---|
| 1321 | |
---|
| 1322 | Tag sttag( (unsigned int)weatherStationId_, TagType::Station ) ; |
---|
| 1323 | //WeatherRow *wrow = wtab.getRowByKey( sttag, tint ) ; |
---|
| 1324 | vector<WeatherRow *> *wrows = wtab.getByContext( sttag ) ; |
---|
| 1325 | WeatherRow *wrow = (*wrows)[0] ; |
---|
| 1326 | unsigned int nrow = wrows->size() ; |
---|
[2208] | 1327 | //logsink_->postLocally( LogMessage("There are "+String::toString(nrow)+" rows for given context: stationId "+String::toString(weatherStationId_),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2301] | 1328 | ArrayTime startTime = getMidTime( timeInterval_ ) ; |
---|
[2197] | 1329 | if ( startTime < (*wrows)[0]->getTimeInterval().getStart() ) { |
---|
| 1330 | temperature = (*wrows)[0]->getTemperature().get() ; |
---|
[2235] | 1331 | pressure = (*wrows)[0]->getPressure().get() ; |
---|
[2197] | 1332 | humidity = (*wrows)[0]->getRelHumidity().get() ; |
---|
| 1333 | windspeed = (*wrows)[0]->getWindSpeed().get() ; |
---|
| 1334 | windaz = (*wrows)[0]->getWindDirection().get() ; |
---|
| 1335 | } |
---|
[2235] | 1336 | else if ( startTime > getEndTime( (*wrows)[nrow-1]->getTimeInterval() ) ) { |
---|
[2197] | 1337 | temperature = (*wrows)[nrow-1]->getTemperature().get() ; |
---|
| 1338 | pressure = (*wrows)[nrow-1]->getPressure().get() ; |
---|
| 1339 | humidity = (*wrows)[nrow-1]->getRelHumidity().get() ; |
---|
| 1340 | windspeed = (*wrows)[nrow-1]->getWindSpeed().get() ; |
---|
| 1341 | windaz = (*wrows)[nrow-1]->getWindDirection().get() ; |
---|
| 1342 | } |
---|
| 1343 | else { |
---|
| 1344 | for ( unsigned int irow = 1 ; irow < wrows->size() ; irow++ ) { |
---|
| 1345 | wrow = (*wrows)[irow-1] ; |
---|
[2235] | 1346 | ArrayTime tStart = wrow->getTimeInterval().getStart() ; |
---|
| 1347 | ArrayTime tEnd = (*wrows)[irow]->getTimeInterval().getStart() ; |
---|
| 1348 | if ( startTime >= tStart && startTime <= tEnd ) { |
---|
[2197] | 1349 | temperature = wrow->getTemperature().get() ; |
---|
| 1350 | pressure = wrow->getPressure().get() ; |
---|
| 1351 | humidity = wrow->getRelHumidity().get() ; |
---|
| 1352 | windspeed = wrow->getWindSpeed().get() ; |
---|
| 1353 | windaz = wrow->getWindDirection().get() ; |
---|
| 1354 | break ; |
---|
| 1355 | } |
---|
| 1356 | } |
---|
| 1357 | } |
---|
| 1358 | |
---|
[2235] | 1359 | // Pa -> hPa |
---|
| 1360 | pressure /= 100.0 ; |
---|
| 1361 | |
---|
[2197] | 1362 | return ; |
---|
| 1363 | } |
---|
| 1364 | |
---|
| 1365 | void ASDMReader::processStation() |
---|
| 1366 | { |
---|
| 1367 | antennaPad_.resize(0) ; |
---|
| 1368 | weatherStation_.resize(0) ; |
---|
| 1369 | StationTable &stab = asdm_->getStation() ; |
---|
| 1370 | vector<StationRow *> srows = stab.get() ; |
---|
| 1371 | for ( unsigned int irow = 0 ; irow < srows.size() ; irow++ ) { |
---|
[2305] | 1372 | StationTypeMod::StationType stype = srows[irow]->getType() ; |
---|
[2197] | 1373 | Tag stag = srows[irow]->getStationId() ; |
---|
[2305] | 1374 | if ( stype == StationTypeMod::ANTENNA_PAD ) |
---|
[2197] | 1375 | antennaPad_.push_back( stag ) ; |
---|
[2305] | 1376 | else if ( stype == StationTypeMod::WEATHER_STATION ) |
---|
[2197] | 1377 | weatherStation_.push_back( stag ) ; |
---|
| 1378 | } |
---|
| 1379 | |
---|
| 1380 | weatherStationId_ = getClosestWeatherStation() ; |
---|
| 1381 | } |
---|
| 1382 | |
---|
| 1383 | int ASDMReader::getClosestWeatherStation() |
---|
| 1384 | { |
---|
| 1385 | if ( weatherStation_.size() == 0 ) |
---|
| 1386 | return -1 ; |
---|
| 1387 | |
---|
| 1388 | vector<double> apos( 3 ) ; |
---|
| 1389 | StationTable &stab = asdm_->getStation() ; |
---|
[2301] | 1390 | apos[0] = antennaPosition_[0].getValue( Unit("m") ) ; |
---|
| 1391 | apos[1] = antennaPosition_[1].getValue( Unit("m") ) ; |
---|
| 1392 | apos[2] = antennaPosition_[2].getValue( Unit("m") ) ; |
---|
[2197] | 1393 | |
---|
[2307] | 1394 | //double eps = DBL_MAX ; |
---|
| 1395 | double eps = 1.0e10 ; |
---|
[2197] | 1396 | int retval = -1 ; |
---|
| 1397 | for ( unsigned int ir = 0 ; ir < weatherStation_.size() ; ir++ ) { |
---|
[2301] | 1398 | StationRow *srow = stab.getRowByKey( weatherStation_[ir] ) ; |
---|
[2197] | 1399 | vector<Length> wpos = srow->getPosition() ; |
---|
| 1400 | double dist = (apos[0]-wpos[0].get())*(apos[0]-wpos[0].get()) |
---|
| 1401 | + (apos[1]-wpos[1].get())*(apos[1]-wpos[1].get()) |
---|
| 1402 | + (apos[2]-wpos[2].get())*(apos[2]-wpos[2].get()) ; |
---|
| 1403 | if ( dist < eps ) { |
---|
| 1404 | retval = (int)(weatherStation_[ir].getTagValue()) ; |
---|
| 1405 | } |
---|
| 1406 | } |
---|
| 1407 | |
---|
| 1408 | return retval ; |
---|
| 1409 | } |
---|
| 1410 | |
---|
| 1411 | void ASDMReader::getPointingInfo( unsigned int idx, |
---|
| 1412 | vector<double> &dir, |
---|
| 1413 | double &az, |
---|
| 1414 | double &el, |
---|
| 1415 | vector<double> &srate ) |
---|
| 1416 | { |
---|
[2301] | 1417 | prepareData( idx ) ; |
---|
| 1418 | getPointingInfo( dir, az, el, srate ) ; |
---|
| 1419 | } |
---|
| 1420 | |
---|
| 1421 | void ASDMReader::getPointingInfo( vector<double> &dir, |
---|
| 1422 | double &az, |
---|
| 1423 | double &el, |
---|
| 1424 | vector<double> &srate ) |
---|
| 1425 | { |
---|
[2208] | 1426 | String funcName = "getPointingInfo" ; |
---|
| 1427 | |
---|
[2197] | 1428 | dir.resize(0) ; |
---|
| 1429 | az = -1.0 ; |
---|
| 1430 | el = -1.0 ; |
---|
| 1431 | srate.resize(0) ; |
---|
| 1432 | |
---|
[2301] | 1433 | //Tag atag( antennaId_, TagType::Antenna ) ; |
---|
| 1434 | //unsigned int index = dataIdList_[idx] ; |
---|
| 1435 | //vector<PointingRow *> *prows = asdm_->getPointing().getByContext( atag ) ; |
---|
| 1436 | vector<PointingRow *> *prows = asdm_->getPointing().getByContext( antennaTag_ ) ; |
---|
[2254] | 1437 | |
---|
| 1438 | if ( prows == 0 ) |
---|
| 1439 | return ; |
---|
| 1440 | |
---|
[2197] | 1441 | PointingRow *prow ; |
---|
| 1442 | PointingRow *qrow ; |
---|
| 1443 | //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; |
---|
[2301] | 1444 | //double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; |
---|
| 1445 | //ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; |
---|
[2197] | 1446 | |
---|
| 1447 | unsigned int nrow = prows->size() ; |
---|
[2208] | 1448 | //logsink_->postLocally( LogMessage("There are " << nrow << " rows for given context: antennaId "+String::toString(antennaId_),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 1449 | |
---|
| 1450 | // for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { |
---|
| 1451 | // prow = (*prows)[irow] ; |
---|
| 1452 | // ArrayTimeInterval ati = prow->getTimeInterval() ; |
---|
| 1453 | // ArrayTime pst = ati.getStart() ; |
---|
| 1454 | // ArrayTime pet( ati.getStartInMJD()+ati.getDurationInDays() ) ; |
---|
[2208] | 1455 | // logsink_->postLocally( LogMessage("start: "+pst.toFITS(),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 1456 | // logsink_->postLocally( LogMessage("end: "+pet.toFITS(),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 1457 | // } |
---|
| 1458 | |
---|
| 1459 | srate.resize(2) ; |
---|
| 1460 | srate[0] = 0.0 ; |
---|
| 1461 | srate[1] = 0.0 ; |
---|
| 1462 | az = 0.0 ; |
---|
| 1463 | el = 0.0 ; |
---|
[2254] | 1464 | //double tcen = 0.0 ; |
---|
[2301] | 1465 | //double tcen = getMidTime( tint ).getMJD() ; |
---|
| 1466 | double tcen = getMidTime( timeInterval_ ).getMJD() ; |
---|
[2197] | 1467 | |
---|
| 1468 | // |
---|
| 1469 | // shape of pointingDirection is (numSample,2) if usePolynomial = False, while it is |
---|
| 1470 | // (numTerm,2) if usePolynomial = True. |
---|
| 1471 | // |
---|
| 1472 | // In the former case, typical sampled time interval is 48msec, which is very small |
---|
| 1473 | // compared with typical integration time (~a few sec). |
---|
| 1474 | // Scan rate for this case is always [0,0] (or get slope?). |
---|
| 1475 | // |
---|
| 1476 | // In the later case, scan rate is (pointingDirection[1][0],pointingDirection[1][1]) |
---|
| 1477 | // |
---|
| 1478 | // PointingDirection seems to store AZEL |
---|
| 1479 | // |
---|
| 1480 | ArrayTimeInterval pTime0 = (*prows)[0]->getTimeInterval() ; |
---|
| 1481 | ArrayTimeInterval pTime1 = (*prows)[nrow-1]->getTimeInterval() ; |
---|
[2254] | 1482 | //if ( tint.getStartInMJD()+tint.getDurationInDays() < pTime0.getStartInMJD() ) { |
---|
[2301] | 1483 | //if ( getEndTime( tint ) < getStartTime( pTime0 ) ) { |
---|
| 1484 | if ( getEndTime( timeInterval_ ) < getStartTime( pTime0 ) ) { |
---|
[2208] | 1485 | logsink_->postLocally( LogMessage( "ArrayTimeInterval out of bounds: no data for given position (tint < ptime)", LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; |
---|
[2197] | 1486 | prow = (*prows)[0] ; |
---|
[2254] | 1487 | vector< vector<double> > dirA = pointingDir( prow ) ; |
---|
| 1488 | az = dirA[0][0] ; |
---|
| 1489 | el = dirA[0][1] ; |
---|
[2197] | 1490 | if ( prow->getUsePolynomials() && prow->getNumTerm() > 1 ) { |
---|
[2254] | 1491 | srate[0] = dirA[1][0] ; |
---|
| 1492 | srate[1] = dirA[1][1] ; |
---|
[2197] | 1493 | } |
---|
| 1494 | } |
---|
[2254] | 1495 | //else if ( tint.getStartInMJD() > pTime1.getStartInMJD()+pTime1.getDurationInDays() ) { |
---|
[2301] | 1496 | //else if ( getStartTime( tint ) > getEndTime( pTime1 ) ) { |
---|
| 1497 | else if ( getStartTime( timeInterval_ ) > getEndTime( pTime1 ) ) { |
---|
[2208] | 1498 | logsink_->postLocally( LogMessage( "ArrayTimeInterval out of bounds: no data for given position (tint > ptime)", LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; |
---|
[2197] | 1499 | prow = (*prows)[nrow-1] ; |
---|
| 1500 | int numSample = prow->getNumSample() ; |
---|
[2254] | 1501 | vector< vector<double> > dirA = pointingDir( prow ) ; |
---|
[2197] | 1502 | if ( prow->getUsePolynomials() ) { |
---|
[2254] | 1503 | az = dirA[0][0] ; |
---|
| 1504 | el = dirA[0][1] ; |
---|
[2197] | 1505 | if ( prow->getNumTerm() > 1 ) { |
---|
[2254] | 1506 | srate[0] = dirA[1][0] ; |
---|
| 1507 | srate[1] = dirA[1][1] ; |
---|
[2197] | 1508 | } |
---|
| 1509 | } |
---|
| 1510 | else { |
---|
[2254] | 1511 | az = dirA[numSample-1][0] ; |
---|
| 1512 | el = dirA[numSample-1][1] ; |
---|
[2197] | 1513 | } |
---|
| 1514 | } |
---|
| 1515 | else { |
---|
[2301] | 1516 | //ArrayTime startTime = tint.getStart() ; |
---|
| 1517 | //ArrayTime endTime = getEndTime( tint ) ; |
---|
| 1518 | ArrayTime startTime = timeInterval_.getStart() ; |
---|
| 1519 | ArrayTime endTime = getEndTime( timeInterval_ ) ; |
---|
[2197] | 1520 | int row0 = -1 ; |
---|
| 1521 | int row1 = -1 ; |
---|
| 1522 | int row2 = -1 ; |
---|
[2301] | 1523 | //double dt0 = getMidTime( tint ).getMJD() ; |
---|
| 1524 | double dt0 = getMidTime( timeInterval_ ).getMJD() ; |
---|
[2197] | 1525 | for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { |
---|
| 1526 | prow = (*prows)[irow] ; |
---|
[2301] | 1527 | //double dt = getMidTime( tint ).getMJD() - getMidTime( prow->getTimeInterval() ).getMJD() ; |
---|
| 1528 | double dt = getMidTime( timeInterval_ ).getMJD() - getMidTime( prow->getTimeInterval() ).getMJD() ; |
---|
[2197] | 1529 | if ( dt > 0 && dt < dt0 ) { |
---|
| 1530 | dt0 = dt ; |
---|
| 1531 | row2 = irow ; |
---|
| 1532 | } |
---|
| 1533 | if ( prow->getTimeInterval().contains( startTime ) ) |
---|
| 1534 | row0 = irow ; |
---|
| 1535 | else if ( prow->getTimeInterval().contains( endTime ) ) |
---|
| 1536 | row1 = irow ; |
---|
| 1537 | if ( row0 != -1 && row1 != -1 ) |
---|
| 1538 | break ; |
---|
| 1539 | } |
---|
[2208] | 1540 | //logsink_->postLocally( LogMessage("row0 = "+String::toString(row0)+", row1 = "+String::toString(row1)+", row2 = "+String::toString(row2),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 1541 | if ( row0 == -1 && row1 == -1 ) { |
---|
| 1542 | prow = (*prows)[row2] ; |
---|
| 1543 | qrow = (*prows)[row2+1] ; |
---|
| 1544 | double t0 = getEndTime( prow->getTimeInterval() ).getMJD() ; |
---|
| 1545 | double t1 = qrow->getTimeInterval().getStartInMJD() ; |
---|
[2254] | 1546 | vector< vector<double> > dirA = pointingDir( prow ) ; |
---|
| 1547 | vector< vector<double> > dirB = pointingDir( qrow ) ; |
---|
| 1548 | double da0 = dirA[0][0] ; |
---|
| 1549 | double db0 = dirB[0][0] ; |
---|
| 1550 | double da1 = dirA[0][1] ; |
---|
| 1551 | double db1 = dirB[0][1] ; |
---|
[2197] | 1552 | if ( prow->getUsePolynomials() && qrow->getUsePolynomials() ) { |
---|
[2254] | 1553 | double dt = ( tcen - t0 ) / ( t1 - t0 ) ; |
---|
[2197] | 1554 | az = da0 + ( db0 - da0 ) * dt ; |
---|
| 1555 | el = da1 + ( db1 - da1 ) * dt ; |
---|
| 1556 | if ( prow->getNumTerm() > 0 && qrow->getNumTerm() > 1 ) { |
---|
[2254] | 1557 | double ra0 = dirA[1][0] ; |
---|
| 1558 | double rb0 = dirB[1][0] ; |
---|
| 1559 | double ra1 = dirA[1][1] ; |
---|
| 1560 | double rb1 = dirB[1][1] ; |
---|
[2197] | 1561 | srate[0] = ra0 + ( rb0 - ra0 ) * dt ; |
---|
| 1562 | srate[1] = ra1 + ( rb1 - ra1 ) * dt ; |
---|
| 1563 | } |
---|
| 1564 | } |
---|
| 1565 | else if ( !(qrow->getUsePolynomials()) ) { |
---|
[2254] | 1566 | double dt = ( tcen - t0 ) / ( t1 - t0 ) ; |
---|
[2197] | 1567 | az = da0 + ( db0 - da0 ) * dt ; |
---|
| 1568 | el = da1 + ( db1 - da1 ) * dt ; |
---|
| 1569 | } |
---|
| 1570 | //else { |
---|
| 1571 | // nothing to do |
---|
| 1572 | //} |
---|
| 1573 | } |
---|
| 1574 | else { |
---|
| 1575 | int ndir = 0 ; |
---|
| 1576 | if ( row0 == -1 ) { |
---|
| 1577 | row0 = row1 ; |
---|
| 1578 | } |
---|
| 1579 | else if ( row1 == -1 ) { |
---|
| 1580 | row1 = row0 ; |
---|
| 1581 | } |
---|
| 1582 | prow = (*prows)[row0] ; |
---|
| 1583 | qrow = (*prows)[row1] ; |
---|
| 1584 | if ( prow->getUsePolynomials() && qrow->getUsePolynomials() ) { |
---|
[2208] | 1585 | //logsink_->postLocally( LogMessage("usePolynomial = True",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 1586 | if ( row0 == row1 ) { |
---|
| 1587 | prow = (*prows)[row0] ; |
---|
[2254] | 1588 | vector< vector<double> > dirA = pointingDir( prow ) ; |
---|
| 1589 | az = dirA[0][0] ; |
---|
| 1590 | el = dirA[0][1] ; |
---|
[2197] | 1591 | if ( prow->getNumTerm() > 1 ) { |
---|
[2254] | 1592 | srate[0] = dirA[1][0] ; |
---|
| 1593 | srate[1] = dirA[1][1] ; |
---|
[2197] | 1594 | } |
---|
| 1595 | } |
---|
| 1596 | else { |
---|
| 1597 | prow = (*prows)[row0] ; |
---|
| 1598 | qrow = (*prows)[row1] ; |
---|
[2254] | 1599 | vector< vector<double> > dirA = pointingDir( prow ) ; |
---|
| 1600 | vector< vector<double> > dirB = pointingDir( qrow ) ; |
---|
[2197] | 1601 | double t0 = getMidTime( prow->getTimeInterval() ).getMJD() ; |
---|
| 1602 | double t1 = getMidTime( qrow->getTimeInterval() ).getMJD() ; |
---|
[2254] | 1603 | double dt = ( tcen - t0 ) / ( t1 - t0 ) ; |
---|
| 1604 | double da0 = dirA[0][0] ; |
---|
| 1605 | double db0 = dirB[0][0] ; |
---|
| 1606 | double da1 = dirA[0][1] ; |
---|
| 1607 | double db1 = dirB[0][1] ; |
---|
[2197] | 1608 | az = da0 + ( db0 - da0 ) * dt ; |
---|
| 1609 | el = da1 + ( db1 - db0 ) * dt ; |
---|
| 1610 | if ( prow->getNumTerm() > 0 && qrow->getNumTerm() > 1 ) { |
---|
[2254] | 1611 | double ra0 = dirA[1][0] ; |
---|
| 1612 | double rb0 = dirB[1][0] ; |
---|
| 1613 | double ra1 = dirA[1][1] ; |
---|
| 1614 | double rb1 = dirB[1][1] ; |
---|
[2197] | 1615 | srate[0] = ra0 + ( rb0 - ra0 ) * dt ; |
---|
| 1616 | srate[1] = ra1 + ( rb1 - ra1 ) * dt ; |
---|
| 1617 | } |
---|
| 1618 | } |
---|
| 1619 | } |
---|
| 1620 | else if ( prow->getUsePolynomials() == qrow->getUsePolynomials() ) { |
---|
[2208] | 1621 | //logsink_->postLocally( LogMessage("numSample == numTerm",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2254] | 1622 | tcen = 0.0 ; |
---|
[2197] | 1623 | for ( int irow = row0 ; irow <= row1 ; irow++ ) { |
---|
| 1624 | prow = (*prows)[irow] ; |
---|
| 1625 | int numSample = prow->getNumSample() ; |
---|
[2208] | 1626 | //logsink_->postLocally( LogMessage("numSample = "+String::toString(numSample),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2254] | 1627 | vector< vector<double> > dirA = pointingDir( prow ) ; |
---|
[2197] | 1628 | if ( prow->isSampledTimeIntervalExists() ) { |
---|
[2208] | 1629 | //logsink_->postLocally( LogMessage("sampledTimeIntervalExists",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 1630 | vector<ArrayTimeInterval> stime = prow->getSampledTimeInterval() ; |
---|
| 1631 | for ( int isam = 0 ; isam < numSample ; isam++ ) { |
---|
| 1632 | //if ( tint.overlaps( stime[isam] ) ) { |
---|
[2301] | 1633 | //if ( tint.contains( stime[isam] ) ) { |
---|
| 1634 | if ( timeInterval_.contains( stime[isam] ) ) { |
---|
[2254] | 1635 | az += dirA[isam][0] ; |
---|
| 1636 | el += dirA[isam][1] ; |
---|
| 1637 | tcen += getMidTime( stime[isam] ).getMJD() ; |
---|
[2197] | 1638 | ndir++ ; |
---|
| 1639 | } |
---|
| 1640 | } |
---|
| 1641 | } |
---|
| 1642 | else { |
---|
| 1643 | double sampleStart = prow->getTimeInterval().getStartInMJD() ; |
---|
| 1644 | double sampleInterval = prow->getTimeInterval().getDurationInDays() / (double)numSample ; |
---|
[2208] | 1645 | //logsink_->postLocally( LogMessage("sampleStart = "+String::toString(sampleStart),LogOrigin(className_,funcName,WHERE)) ) |
---|
| 1646 | //logsink_->postLocally( LogMessage("sampleInterval = "+String::toString(sampleInterval),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 1647 | //logsink_->postLocally( LogMessage("tint = "+tint.toString(),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2197] | 1648 | for ( int isam = 0 ; isam < numSample ; isam++ ) { |
---|
| 1649 | ArrayTimeInterval stime( sampleStart+isam*sampleInterval, sampleInterval ) ; |
---|
| 1650 | //if ( tint.overlaps( stime ) ) { |
---|
[2301] | 1651 | //if ( tint.contains( stime ) ) { |
---|
| 1652 | if ( timeInterval_.contains( stime ) ) { |
---|
[2254] | 1653 | az += dirA[isam][0] ; |
---|
| 1654 | el += dirA[isam][1] ; |
---|
[2197] | 1655 | tcen += getMidTime( stime ).getMJD() ; |
---|
| 1656 | ndir++ ; |
---|
| 1657 | } |
---|
| 1658 | } |
---|
| 1659 | } |
---|
| 1660 | } |
---|
| 1661 | if ( ndir > 1 ) { |
---|
| 1662 | az /= (double)ndir ; |
---|
| 1663 | el /= (double)ndir ; |
---|
| 1664 | tcen /= (double)ndir ; |
---|
| 1665 | } |
---|
| 1666 | } |
---|
| 1667 | //else { |
---|
| 1668 | // nothing to do |
---|
| 1669 | //} |
---|
| 1670 | } |
---|
| 1671 | |
---|
[2301] | 1672 | toJ2000( dir, az, el, tcen, antennaPosition_ ) ; |
---|
[2197] | 1673 | } |
---|
| 1674 | |
---|
| 1675 | return ; |
---|
| 1676 | } |
---|
| 1677 | |
---|
| 1678 | ArrayTime ASDMReader::getMidTime( const ArrayTimeInterval &t ) |
---|
| 1679 | { |
---|
| 1680 | return ArrayTime( t.getStartInMJD() + 0.5 * t.getDurationInDays() ) ; |
---|
| 1681 | } |
---|
| 1682 | |
---|
| 1683 | ArrayTime ASDMReader::getEndTime( const ArrayTimeInterval &t ) |
---|
| 1684 | { |
---|
| 1685 | return ArrayTime( t.getStartInMJD() + t.getDurationInDays() ) ; |
---|
| 1686 | } |
---|
| 1687 | |
---|
| 1688 | ArrayTime ASDMReader::getStartTime( const ArrayTimeInterval &t ) |
---|
| 1689 | { |
---|
| 1690 | return ArrayTime( t.getStartInMJD() ) ; |
---|
| 1691 | } |
---|
| 1692 | |
---|
| 1693 | void ASDMReader::toJ2000( vector<double> &dir, |
---|
[2301] | 1694 | double &az, |
---|
| 1695 | double &el, |
---|
| 1696 | double &mjd, |
---|
| 1697 | casa::Vector<casa::Quantity> &antpos ) |
---|
| 1698 | // casa::Vector<casa::Double> antpos ) |
---|
[2197] | 1699 | { |
---|
[2208] | 1700 | String funcName = "toJ2000" ; |
---|
| 1701 | |
---|
[2301] | 1702 | String ref = "AZELGEO" ; |
---|
[2225] | 1703 | vector<double> azel( 2 ) ; |
---|
[2197] | 1704 | azel[0] = az ; |
---|
| 1705 | azel[1] = el ; |
---|
[2301] | 1706 | dir = toJ2000( azel, ref, mjd, antpos ) ; |
---|
[2225] | 1707 | } |
---|
[2208] | 1708 | |
---|
[2301] | 1709 | vector<double> ASDMReader::toJ2000( vector<double> &dir, |
---|
| 1710 | casa::String &dirref, |
---|
| 1711 | double &mjd, |
---|
| 1712 | casa::Vector<casa::Quantity> &antpos ) |
---|
| 1713 | // casa::Vector<casa::Double> antpos ) |
---|
[2225] | 1714 | { |
---|
[2227] | 1715 | casa::String funcName = "toJ2000" ; |
---|
[2225] | 1716 | |
---|
| 1717 | vector<double> newd( dir ) ; |
---|
| 1718 | if ( dirref != "J2000" ) { |
---|
| 1719 | casa::MEpoch me( casa::Quantity( (casa::Double)mjd, "d" ), casa::MEpoch::UTC ) ; |
---|
[2301] | 1720 | casa::MPosition mp( casa::MVPosition( antpos ), |
---|
[2225] | 1721 | casa::MPosition::ITRF ) ; |
---|
| 1722 | //ostringstream oss ; |
---|
| 1723 | //mp.print( oss ) ; |
---|
| 1724 | //logsink_->postLocally( LogMessage(oss.str(),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 1725 | |
---|
| 1726 | casa::MeasFrame mf( me, mp ) ; |
---|
| 1727 | casa::MDirection::Types dirtype ; |
---|
| 1728 | casa::Bool b = casa::MDirection::getType( dirtype, dirref ) ; |
---|
| 1729 | if ( b ) { |
---|
| 1730 | casa::MDirection::Convert toj2000( dirtype, |
---|
| 1731 | casa::MDirection::Ref( casa::MDirection::J2000, mf ) ) ; |
---|
| 1732 | casa::Vector<casa::Double> cdir = toj2000( dir ).getAngle( "rad" ).getValue() ; |
---|
| 1733 | //logsink_->postLocally( LogMessage("cdir = "+String::toString(cdir),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 1734 | newd[0] = (double)(cdir[0]) ; |
---|
| 1735 | newd[1] = (double)(cdir[1]) ; |
---|
| 1736 | } |
---|
| 1737 | } |
---|
| 1738 | return newd ; |
---|
[2197] | 1739 | } |
---|
[2208] | 1740 | |
---|
| 1741 | void ASDMReader::setLogger( CountedPtr<LogSinkInterface> &logsink ) |
---|
| 1742 | { |
---|
| 1743 | logsink_ = logsink ; |
---|
| 1744 | } |
---|
[2218] | 1745 | |
---|
| 1746 | string ASDMReader::getFrame() |
---|
| 1747 | { |
---|
[2227] | 1748 | casa::String funcName = "getFrame" ; |
---|
[2218] | 1749 | |
---|
| 1750 | // default is TOPO |
---|
| 1751 | string frame = "TOPO" ; |
---|
| 1752 | |
---|
| 1753 | SpectralWindowTable &spwtab = asdm_->getSpectralWindow() ; |
---|
| 1754 | vector<SpectralWindowRow *> rows = spwtab.get() ; |
---|
[2305] | 1755 | vector<FrequencyReferenceCodeMod::FrequencyReferenceCode> measFreqRef( rows.size() ) ; |
---|
[2218] | 1756 | int nref = 0 ; |
---|
| 1757 | for ( unsigned int irow = 0 ; irow < rows.size() ; irow++ ) { |
---|
| 1758 | int nchan = rows[irow]->getNumChan() ; |
---|
| 1759 | if ( nchan != 4 ) { |
---|
| 1760 | if ( rows[irow]->isMeasFreqRefExists() ) { |
---|
| 1761 | measFreqRef[nref] = rows[irow]->getMeasFreqRef() ; |
---|
| 1762 | nref++ ; |
---|
| 1763 | } |
---|
| 1764 | } |
---|
| 1765 | } |
---|
| 1766 | if ( nref != 0 ) { |
---|
| 1767 | frame = CFrequencyReferenceCode::toString( measFreqRef[0] ) ; |
---|
| 1768 | } |
---|
| 1769 | |
---|
[2220] | 1770 | //logsink_->postLocally( LogMessage("frame = "+String::toString(frame),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2218] | 1771 | |
---|
| 1772 | return frame ; |
---|
| 1773 | } |
---|
[2220] | 1774 | |
---|
| 1775 | int ASDMReader::getNumIFs() |
---|
| 1776 | { |
---|
[2227] | 1777 | casa::String funcName = "getNumIFs" ; |
---|
[2220] | 1778 | |
---|
| 1779 | int nif = 0 ; |
---|
| 1780 | vector<SpectralWindowRow *> rows = asdm_->getSpectralWindow().get() ; |
---|
| 1781 | unsigned int nrow = rows.size() ; |
---|
| 1782 | // check if all rows have freqGroup attribute |
---|
| 1783 | bool freqGroupExists = true ; |
---|
| 1784 | bool countedWvr = false ; |
---|
| 1785 | for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { |
---|
| 1786 | freqGroupExists &= rows[irow]->isFreqGroupExists() ; |
---|
| 1787 | if ( rows[irow]->getNumChan() == 4 ) { |
---|
| 1788 | if ( !countedWvr ) { |
---|
| 1789 | countedWvr = true ; |
---|
| 1790 | nif++ ; |
---|
| 1791 | } |
---|
| 1792 | } |
---|
| 1793 | else { |
---|
| 1794 | nif++ ; |
---|
| 1795 | } |
---|
| 1796 | } |
---|
| 1797 | |
---|
| 1798 | if ( freqGroupExists ) { |
---|
| 1799 | vector<int> freqGroup(0) ; |
---|
| 1800 | for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { |
---|
| 1801 | int fg = rows[irow]->getFreqGroup() ; |
---|
| 1802 | if ( (int)count( freqGroup.begin(), freqGroup.end(), fg ) == 0 ) { |
---|
| 1803 | freqGroup.push_back( fg ) ; |
---|
| 1804 | } |
---|
| 1805 | } |
---|
| 1806 | nif = freqGroup.size() ; |
---|
| 1807 | } |
---|
| 1808 | |
---|
| 1809 | //logsink_->postLocally( LogMessage("nif = "+String::toString(nif),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 1810 | |
---|
| 1811 | return nif ; |
---|
| 1812 | } |
---|
[2251] | 1813 | |
---|
| 1814 | SysCalRow *ASDMReader::getSysCalRow( unsigned int idx ) |
---|
| 1815 | { |
---|
[2301] | 1816 | prepareData( idx ) ; |
---|
| 1817 | return getSysCalRow() ; |
---|
| 1818 | } |
---|
| 1819 | |
---|
| 1820 | SysCalRow *ASDMReader::getSysCalRow() |
---|
| 1821 | { |
---|
[2251] | 1822 | String funcName = "getSysCalRow" ; |
---|
| 1823 | |
---|
| 1824 | SysCalRow *row = 0 ; |
---|
[2301] | 1825 | int feedid = vmsData_->v_feedId1[dataIndex_] ; |
---|
[2251] | 1826 | SysCalTable &sctab = asdm_->getSysCal() ; |
---|
[2301] | 1827 | vector<SysCalRow *> *rows = sctab.getByContext( antennaTag_, specWinTag_, feedid ) ; |
---|
[2251] | 1828 | //if ( nrow == 0 ) { |
---|
| 1829 | if ( rows == 0 ) { |
---|
| 1830 | //logsink_->postLocally( LogMessage("no rows in SysCal table",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 1831 | row = 0 ; |
---|
| 1832 | } |
---|
| 1833 | else { |
---|
| 1834 | unsigned int nrow = rows->size() ; |
---|
| 1835 | //logsink_->postLocally( LogMessage("nrow = "+String::toString(nrow),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 1836 | int scindex = -1 ; |
---|
| 1837 | if ( nrow == 1 ) { |
---|
| 1838 | scindex = 0 ; |
---|
| 1839 | } |
---|
[2301] | 1840 | else if ( getEndTime( timeInterval_ ) <= getStartTime( (*rows)[0]->getTimeInterval() ) ) |
---|
[2251] | 1841 | scindex = 0 ; |
---|
| 1842 | else { |
---|
| 1843 | for ( unsigned int irow = 0 ; irow < nrow-1 ; irow++ ) { |
---|
[2301] | 1844 | ArrayTime t = getMidTime( timeInterval_ ) ; |
---|
[2251] | 1845 | if ( t > getStartTime( (*rows)[irow]->getTimeInterval() ) |
---|
| 1846 | && t <= getStartTime( (*rows)[irow+1]->getTimeInterval() ) ) { |
---|
| 1847 | scindex = irow ; |
---|
| 1848 | break ; |
---|
| 1849 | } |
---|
| 1850 | } |
---|
| 1851 | if ( scindex == -1 ) |
---|
| 1852 | scindex = nrow-1 ; |
---|
| 1853 | } |
---|
| 1854 | //logsink_->postLocally( LogMessage("irow = "+String::toString(scindex),LogOrigin(className_,funcName,WHERE)) ) ; |
---|
| 1855 | row = (*rows)[scindex] ; |
---|
| 1856 | } |
---|
| 1857 | return row ; |
---|
| 1858 | } |
---|
[2252] | 1859 | |
---|
| 1860 | double ASDMReader::limitedAngle( double angle ) |
---|
| 1861 | { |
---|
| 1862 | if ( angle > C::pi ) |
---|
| 1863 | while ( angle > C::pi ) angle -= C::_2pi ; |
---|
| 1864 | else if ( angle < -C::pi ) |
---|
| 1865 | while ( angle < -C::pi ) angle += C::_2pi ; |
---|
| 1866 | return angle ; |
---|
| 1867 | } |
---|
[2254] | 1868 | |
---|
| 1869 | vector< vector<double> > ASDMReader::pointingDir( PointingRow *row ) |
---|
| 1870 | { |
---|
[2273] | 1871 | //String funcName = "pointingDir" ; |
---|
[2256] | 1872 | vector< vector<Angle> > aTar = row->getTarget() ; |
---|
[2254] | 1873 | vector< vector<Angle> > aOff = row->getOffset() ; |
---|
[2256] | 1874 | vector< vector<Angle> > aDir = row->getPointingDirection() ; |
---|
| 1875 | vector< vector<Angle> > aEnc = row->getEncoder() ; |
---|
| 1876 | unsigned int n = aTar.size() ; |
---|
[2254] | 1877 | vector< vector<double> > dir( n ) ; |
---|
[2256] | 1878 | double factor = 1.0 / cos( aTar[0][1].get() ) ; |
---|
[2254] | 1879 | for ( unsigned int i = 0 ; i < n ; i++ ) { |
---|
[2255] | 1880 | dir[i].resize( 2 ) ; |
---|
| 1881 | /** |
---|
[2256] | 1882 | * This is approximate way to add offset taking tracking error |
---|
| 1883 | * into account |
---|
[2255] | 1884 | * |
---|
[2273] | 1885 | * az = dir[0][0] = target[0][0] + offset[0][0] / cos(el) |
---|
[2256] | 1886 | * + encorder[0][0] - direction[0][0] |
---|
[2255] | 1887 | * el = dir[0][1] = target[0][1] + offset[0][1] |
---|
[2256] | 1888 | * + encorder[0][1] - direction[0][1] |
---|
[2255] | 1889 | **/ |
---|
[2273] | 1890 | dir[i][0] = aTar[i][0].get() + factor * aOff[i][0].get() |
---|
[2256] | 1891 | + aEnc[i][0].get() - aDir[i][0].get() ; |
---|
[2273] | 1892 | dir[i][1] = aTar[i][1].get() + aOff[i][1].get() |
---|
[2256] | 1893 | + aEnc[i][1].get() - aDir[i][1].get() ; |
---|
[2273] | 1894 | //logsink_->postLocally( LogMessage("tracking offset: ["+String::toString(aEnc[i][0].get()-aDir[i][0].get())+","+String::toString(aEnc[i][0]-aDir[i][0].get())+"]",LogOrigin(className_,funcName,WHERE)) ) ; |
---|
[2254] | 1895 | } |
---|
| 1896 | return dir ; |
---|
| 1897 | } |
---|