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