Changeset 2263
- Timestamp:
- 08/04/11 15:42:43 (13 years ago)
- Location:
- branches/parallel
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/parallel/external-alma/atnf/PKSIO/NROReader.cc
r2262 r2263 531 531 String &srcname, 532 532 String &fieldname, 533 Array<Float> &spectra,534 Array<uChar> &flagtra,535 Array<Float> &tsys,536 Array<Double> &direction,533 Vector<Float> &spectra, 534 Vector<uChar> &flagtra, 535 Vector<Float> &tsys, 536 Vector<Double> &direction, 537 537 Float &azimuth, 538 538 Float &elevation, … … 548 548 Float &winddir, 549 549 Double &srcvel, 550 Array<Double> &propermotion,550 Vector<Double> &propermotion, 551 551 Vector<Double> &srcdir, 552 Array<Double> &scanrate )552 Vector<Double> &scanrate ) 553 553 { 554 554 // DEBUG … … 589 589 590 590 // restfreq (for MOLECULE_ID) 591 Vector<Double> rf( IPosition( 1, 1 ) ) ;592 rf( 0 ) = record->FREQ0;593 restfreq = rf;591 if ( restfreq.size() != 1 ) 592 restfreq.resize( 1 ) ; 593 restfreq[0] = record->FREQ0 ; 594 594 //cout << "restfreq = " << rf << endl ; 595 595 … … 617 617 // spectra 618 618 vector<double> spec = dataset_->getSpectrum( irow ) ; 619 Array<Float> sp( IPosition( 1, spec.size() ) ) ; 619 if ( spectra.size() != spec.size() ) 620 spectra.resize( spec.size() ) ; 620 621 int index = 0 ; 621 for ( Array<Float>::iterator itr = sp.begin() ; itr != sp.end() ; itr++ ) {622 for ( Vector<Float>::iterator itr = spectra.begin() ; itr != spectra.end() ; itr++ ) { 622 623 *itr = spec[index++] ; 623 624 } 624 spectra = sp ;625 625 //cout << "spec.size() = " << spec.size() << endl ; 626 626 627 627 // flagtra 628 Array<uChar> flag( spectra.shape() ) ;629 flag.set( 0) ;630 flagtra = flag;628 if ( flagtra.size() != spectra.size() ) 629 flagtra.resize( spectra.nelements() ) ; 630 flagtra.set( 0 ) ; 631 631 //cout << "flag.size() = " << flag.size() << endl ; 632 632 633 633 // tsys 634 Array<Float> tmp( IPosition( 1, 1 ), record->TSYS ) ; 635 tsys = tmp ; 634 if ( tsys.size() != 1 ) 635 tsys.resize( 1 ) ; 636 tsys[0] = record->TSYS ; 636 637 //cout << "tsys[0] = " << tsys[0] << endl ; 637 638 … … 693 694 694 695 // propermotion 695 Array<Double> srcarr( IPosition( 1, 2 ) ) ; 696 srcarr = 0.0 ; 697 propermotion = srcarr ; 698 //cout << "propermotion = [" << propermotion[0] << ", " << propermotion[1] << "]" << endl ; 696 // do nothing 699 697 700 698 // srcdir … … 703 701 704 702 // scanrate 705 Array<Double> sr( IPosition( 1, 1 ) ) ; 706 sr = 0.0 ; 707 scanrate = sr ; 708 //cout << "scanrate = " << scanrate[0] << endl ; 703 // do nothing 709 704 710 705 return 0 ; -
branches/parallel/external-alma/atnf/PKSIO/NROReader.h
r2262 r2263 139 139 String &srcname, 140 140 String &fieldname, 141 Array<Float> &spectra,142 Array<uChar> &flagtra,143 Array<Float> &tsys,144 Array<Double> &direction,141 Vector<Float> &spectra, 142 Vector<uChar> &flagtra, 143 Vector<Float> &tsys, 144 Vector<Double> &direction, 145 145 Float &azimuth, 146 146 Float &elevation, … … 156 156 Float &winddir, 157 157 Double &srcvel, 158 Array<Double> &propermotion,158 Vector<Double> &propermotion, 159 159 Vector<Double> &srcdir, 160 Array<Double> &scanrate ) ;160 Vector<Double> &scanrate ) ; 161 161 162 162 // Get scan type -
branches/parallel/src/FillerBase.cpp
r2247 r2263 24 24 { 25 25 row_ = TableRow(table_->table()); 26 27 mEntry_.resize( 0 ) ; 28 mIdx_.resize( 0 ) ; 29 fEntry_.resize( 0 ) ; 30 fIdx_.resize( 0 ) ; 31 wEntry_.resize( 0 ) ; 32 wIdx_.resize( 0 ) ; 26 33 } 27 34 … … 78 85 { 79 86 /// @todo this has to change when nchan isn't global anymore 80 uInt id= table_->frequencies().addEntry(refpix, refval, incr); 87 uInt nEntry = fEntry_.size() ; 88 Int idx = -1 ; 89 Vector<Double> entry( 3 ) ; 90 entry[0] = refpix ; 91 entry[1] = refval ; 92 entry[2] = incr ; 93 for ( uInt i = 0 ; i < nEntry ; i++ ) { 94 if ( allEQ( entry, fEntry_[i] ) ) { 95 idx = i ; 96 break ; 97 } 98 } 99 uInt id ; 100 if ( idx != -1 ) 101 id = fIdx_[idx] ; 102 else { 103 id= table_->frequencies().addEntry(refpix, refval, incr); 104 RecordFieldPtr<uInt> mfreqidCol(row_.record(), "FREQ_ID"); 105 fEntry_.push_back( entry ) ; 106 fIdx_.push_back( id ) ; 107 } 81 108 RecordFieldPtr<uInt> mfreqidCol(row_.record(), "FREQ_ID"); 82 109 *mfreqidCol = id; … … 87 114 void FillerBase::setMolecule(const Vector<Double>& restfreq) 88 115 { 89 Vector<String> tmp; 90 uInt id = table_->molecules().addEntry(restfreq, tmp, tmp); 116 uInt nEntry = mEntry_.size() ; 117 Int idx = -1 ; 118 for ( uInt i = 0 ; i < nEntry ; i++ ) { 119 if ( restfreq.conform( mEntry_[i] ) ) { 120 if ( allEQ( restfreq, mEntry_[i] ) ) { 121 idx = i ; 122 break ; 123 } 124 } 125 } 126 uInt id ; 127 if ( idx != -1 ) 128 id = mIdx_[idx] ; 129 else { 130 Vector<String> tmp ; 131 id = table_->molecules().addEntry(restfreq,tmp,tmp) ; 132 mEntry_.push_back( restfreq ) ; 133 mIdx_.push_back( id ) ; 134 } 91 135 RecordFieldPtr<uInt> molidCol(row_.record(), "MOLECULE_ID"); 92 136 *molidCol = id; … … 125 169 Float windspeed, Float windaz) 126 170 { 127 uInt id = table_->weather().addEntry(temperature, pressure, 128 humidity, windspeed, windaz); 129 RecordFieldPtr<uInt> mweatheridCol(row_.record(), "WEATHER_ID"); 130 *mweatheridCol = id; 171 uInt nEntry = wEntry_.size() ; 172 Int idx = -1 ; 173 Vector<Float> entry( 5 ) ; 174 entry[0] = temperature ; 175 entry[1] = pressure ; 176 entry[2] = humidity ; 177 entry[3] = windspeed ; 178 entry[4] = windaz ; 179 for ( uInt i = 0 ; i < nEntry ; i++ ) { 180 if ( allEQ( entry, wEntry_[i] ) ) { 181 idx = i ; 182 break ; 183 } 184 } 185 uInt id ; 186 if ( idx != -1 ) 187 id = wIdx_[idx] ; 188 else { 189 id = table_->weather().addEntry(temperature, pressure, 190 humidity, windspeed, windaz); 191 wEntry_.push_back( entry ) ; 192 wIdx_.push_back( id ) ; 193 } 194 RecordFieldPtr<uInt> mweatheridCol(row_.record(), "WEATHER_ID"); 195 *mweatheridCol = id; 131 196 } 132 197 … … 183 248 Float windaz) 184 249 { 250 uInt nEntry = wEntry_.size() ; 251 Int idx = -1 ; 252 Vector<Float> entry( 5 ) ; 253 entry[0] = temperature ; 254 entry[1] = pressure ; 255 entry[2] = humidity ; 256 entry[3] = windspeed ; 257 entry[4] = windaz ; 258 for ( uInt i = 0 ; i < nEntry ; i++ ) { 259 if ( allEQ( entry, wEntry_[i] ) ) { 260 idx = i ; 261 break ; 262 } 263 } 185 264 uInt id ; 186 Table tab = table_->weather().table() ; 187 Table subt = tab( tab.col("TEMPERATURE") == temperature \ 188 && tab.col("PRESSURE") == pressure \ 189 && tab.col("HUMIDITY") == humidity \ 190 && tab.col("WINDSPEED") == windspeed \ 191 && tab.col("WINDAZ") == windaz, 1 ) ; 192 Int nrow = tab.nrow() ; 193 Int nrowSel = subt.nrow() ; 194 if ( nrowSel == 0 ) { 195 tab.addRow( 1, True ) ; 196 TableRow row( tab ) ; 197 TableRecord &rec = row.record() ; 198 RecordFieldPtr<casa::uInt> rfpi ; 199 rfpi.attachToRecord( rec, "ID" ) ; 200 *rfpi = (uInt)nrow ; 201 RecordFieldPtr<casa::Float> rfp ; 202 rfp.attachToRecord( rec, "TEMPERATURE" ) ; 203 *rfp = temperature ; 204 rfp.attachToRecord( rec, "PRESSURE" ) ; 205 *rfp = pressure ; 206 rfp.attachToRecord( rec, "HUMIDITY" ) ; 207 *rfp = humidity ; 208 rfp.attachToRecord( rec, "WINDSPEED" ) ; 209 *rfp = windspeed ; 210 rfp.attachToRecord( rec, "WINDAZ" ) ; 211 *rfp = windaz ; 212 row.put( nrow, rec ) ; 213 id = (uInt)nrow ; 214 } 215 else { 216 ROTableColumn tc( subt, "ID" ) ; 217 id = tc.asuInt( 0 ) ; 265 if ( idx != -1 ) 266 id = wIdx_[idx] ; 267 else { 268 Table tab = table_->weather().table() ; 269 Table subt = tab( tab.col("TEMPERATURE") == temperature \ 270 && tab.col("PRESSURE") == pressure \ 271 && tab.col("HUMIDITY") == humidity \ 272 && tab.col("WINDSPEED") == windspeed \ 273 && tab.col("WINDAZ") == windaz, 1 ) ; 274 Int nrow = tab.nrow() ; 275 Int nrowSel = subt.nrow() ; 276 if ( nrowSel == 0 ) { 277 tab.addRow( 1, True ) ; 278 TableRow row( tab ) ; 279 TableRecord &rec = row.record() ; 280 RecordFieldPtr<casa::uInt> rfpi ; 281 rfpi.attachToRecord( rec, "ID" ) ; 282 *rfpi = (uInt)nrow ; 283 RecordFieldPtr<casa::Float> rfp ; 284 rfp.attachToRecord( rec, "TEMPERATURE" ) ; 285 *rfp = temperature ; 286 rfp.attachToRecord( rec, "PRESSURE" ) ; 287 *rfp = pressure ; 288 rfp.attachToRecord( rec, "HUMIDITY" ) ; 289 *rfp = humidity ; 290 rfp.attachToRecord( rec, "WINDSPEED" ) ; 291 *rfp = windspeed ; 292 rfp.attachToRecord( rec, "WINDAZ" ) ; 293 *rfp = windaz ; 294 row.put( nrow, rec ) ; 295 id = (uInt)nrow ; 296 } 297 else { 298 ROTableColumn tc( subt, "ID" ) ; 299 id = tc.asuInt( 0 ) ; 300 } 301 wEntry_.push_back( entry ) ; 302 wIdx_.push_back( id ) ; 218 303 } 219 304 RecordFieldPtr<uInt> mweatheridCol(row_.record(), "WEATHER_ID"); -
branches/parallel/src/FillerBase.h
r2247 r2263 27 27 // STL 28 28 #include <string> 29 #include <vector> 29 30 // AIPS++ 30 31 #include <casa/aips.h> … … 103 104 casa::String referenceRx_; 104 105 casa::TableRow row_; 106 107 std::vector< casa::Vector<casa::Double> > mEntry_ ; 108 std::vector<casa::uInt> mIdx_ ; 109 std::vector< casa::Vector<casa::Double> > fEntry_ ; 110 std::vector<casa::uInt> fIdx_ ; 111 std::vector< casa::Vector<casa::Float> > wEntry_ ; 112 std::vector<casa::uInt> wIdx_ ; 105 113 }; 106 114 -
branches/parallel/src/FillerWrapper.h
r1904 r2263 45 45 throw(AipsError("File does not exist")); 46 46 } 47 filler_ = new PKSFiller(stable_); 48 if (filler_->open(filename, rec)) { 49 // if (filler_->open(filename)) { 50 attached_ = true; 51 return; 47 int fileType = dataType( filename ) ; 48 if ( fileType == 0 ) { 49 filler_ = new PKSFiller(stable_); 50 if (filler_->open(filename, rec)) { 51 attached_ = true; 52 return; 53 } 52 54 } 53 filler_ = new NROFiller(stable_); 54 if (filler_->open(filename, rec)) { 55 // if (filler_->open(filename)) { 56 attached_ = true; 57 return; 55 else if ( fileType == 1 ) { 56 filler_ = new NROFiller(stable_); 57 if (filler_->open(filename, rec)) { 58 attached_ = true; 59 return; 60 } 58 61 } 59 62 filler_ = 0; … … 81 84 private: 82 85 86 int dataType( const std::string &filename ) { 87 int ret = -1 ; 88 int pks = 0 ; 89 int nro = 1 ; 90 casa::File file( filename ) ; 91 if ( file.isDirectory() ) 92 ret = pks ; 93 else if ( file.isReadable() ) { 94 FILE *f = fopen( filename.c_str(), "r") ; 95 char buf[8] ; 96 fread( buf, 6, 1, f ) ; 97 fclose( f ) ; 98 buf[7]='\0' ; 99 // NRO data has two types: 100 // 1) specific binary data for OTF observation 101 // 2) (pseudo-)FITS data that doesn't have primary HDU 102 // So, one can distinguish NRO and non-NRO data by examining 103 // first keyword name. 104 if ( casa::String( buf ) == "SIMPLE" ) { 105 ret = pks ; 106 } 107 else { 108 ret = nro ; 109 } 110 } 111 return ret ; 112 } 113 83 114 FillerWrapper(); 84 115 FillerWrapper(const FillerWrapper&); -
branches/parallel/src/NROFiller.cpp
r2262 r2263 100 100 String srcname ; 101 101 String fieldname ; 102 Array<Float> spectra ;103 Array<uChar> flagtra ;104 Array<Float> tsys ;105 Array<Double> direction ;102 Vector<Float> spectra ; 103 Vector<uChar> flagtra ; 104 Vector<Float> tsys ; 105 Vector<Double> direction ; 106 106 Float azimuth ; 107 107 Float elevation ; 108 Float parangle ;108 Float parangle = 0.0 ; 109 109 Float opacity ; 110 110 uInt tcalid ; … … 117 117 Float winddir ; 118 118 Double srcvel ; 119 Array<Double> propermotion;119 Vector<Double> propermotion( 2, 0.0 ) ; 120 120 Vector<Double> srcdir ; 121 Array<Double> scanrate;121 Vector<Double> scanrate( 2, 0.0 ) ; 122 122 Int rowCount = 0 ; 123 123 … … 126 126 Vector<Float> defaultTcal( 1, 1.0 ) ; 127 127 String tcalTime = MVTime( header.utc ).string( MVTime::YMD ) ; 128 129 // TCAL subtable rows 130 setTcal( tcalTime, defaultTcal ) ; 131 132 // FOCUS subtable rows 133 setFocus( parangle ) ; 134 128 135 for ( Int irow = 0 ; irow < (Int)nRow ; irow++ ) { 129 136 // check scan intent … … 195 202 setMolecule( restfreq ) ; 196 203 197 // FOCUS subtable row198 setFocus( parangle ) ;199 200 204 // WEATHER subtable row 201 setWeather( temperature, pressure, humidity, windvel, winddir ) ; 202 203 // TCAL subtable row 204 // use default since NRO input is calibrated data 205 setTcal( tcalTime, defaultTcal ) ; 206 205 setWeather2( temperature, pressure, humidity, windvel, winddir ) ; 207 206 208 207 // set row attributes 209 208 // SPECTRA, FLAGTRA, and TSYS 210 Vector<Float> spectrum( spectra ); 211 Vector<uChar> flags( flagtra ) ; 212 Vector<Float> Tsys( tsys ) ; 213 setSpectrum( spectrum, flags, Tsys ) ; 209 setSpectrum( spectra, flagtra, tsys ) ; 214 210 215 211 // SCANNO, CYCLENO, IFNO, POLNO, and BEAMNO 216 //uInt ifno = table_->frequencies().addEntry( (Double)fqs[0], (Double)fqs[1], (Double)fqs[2] ) ;217 212 setIndex( scanno, cycleno, ifno, polno, beamno ) ; 218 213 … … 221 216 222 217 // DIRECTION 223 Vector<Double> dir( direction ) ; 224 setDirection(dir, azimuth, elevation ) ; 218 setDirection( direction, azimuth, elevation ) ; 225 219 226 220 // TIME and INTERVAL … … 228 222 229 223 // SRCNAME, SRCTYPE, FIELDNAME, SRCDIRECTION, SRCPROPERMOTION, and SRCVELOCITY 230 Vector<Double> propermot( propermotion ) ; 231 setSource( srcname, srcType, fieldname, srcdir, propermot, srcvel ) ; 224 setSource( srcname, srcType, fieldname, srcdir, propermotion, srcvel ) ; 232 225 233 226 // SCANRATE 234 Vector<Double> srate( scanrate ) ; 235 setScanRate( srate ) ; 227 setScanRate( scanrate ) ; 236 228 237 229 // OPACITY -
branches/parallel/src/STFiller.cpp
r2262 r2263 644 644 String srcname ; 645 645 String fieldname ; 646 Array<Float> spectra ;647 Array<uChar> flagtra ;648 Array<Float> tsys ;649 Array<Double> direction ;646 Vector<Float> spectra ; 647 Vector<uChar> flagtra ; 648 Vector<Float> tsys ; 649 Vector<Double> direction ; 650 650 Float azimuth ; 651 651 Float elevation ; … … 661 661 Float winddir ; 662 662 Double srcvel ; 663 Array<Double> propermotion;663 Vector<Double> propermotion( 2, 0.0 ) ; 664 664 Vector<Double> srcdir ; 665 Array<Double> scanrate;665 Vector<Double> scanrate( 2, 0.0 ) ; 666 666 for ( i = 0 ; i < imax ; i++ ) { 667 667 string scanType = nreader_->getScanType( i ) ;
Note:
See TracChangeset
for help on using the changeset viewer.