Changeset 2209
- Timestamp:
- 07/06/11 17:03:30 (13 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/FillerBase.cpp
r1876 r2209 12 12 13 13 #include <casa/Containers/RecordField.h> 14 #include <tables/Tables/ExprNode.h> 14 15 15 16 #include "FillerBase.h" … … 176 177 } 177 178 179 void FillerBase::setWeather2(Float temperature, 180 Float pressure, 181 Float humidity, 182 Float windspeed, 183 Float windaz) 184 { 185 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 ) ; 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 ) ; 218 } 219 RecordFieldPtr<uInt> mweatheridCol(row_.record(), "WEATHER_ID"); 220 *mweatheridCol = id; 221 } 222 223 void FillerBase::setTcal2(const String& tcaltime, 224 const Vector<Float>& tcal) 225 { 226 uInt id ; 227 Table tab = table_->tcal().table() ; 228 Int nrow = tab.nrow() ; 229 Vector<uInt> rowList( 0 ) ; 230 ArrayColumn<Float> tcalCol( tab, "TCAL" ) ; 231 TableColumn timeCol( tab, "TIME" ) ; 232 TableColumn idCol( tab, "ID" ) ; 233 uInt nelem = tcal.nelements() ; 234 for ( Int irow = 0 ; irow < nrow ; irow++ ) { 235 if ( tcalCol.shape(irow)[0] == nelem ) { 236 rowList.resize( rowList.nelements()+1, True ) ; 237 rowList[rowList.nelements()-1] = irow ; 238 } 239 } 240 241 //cout << "rowList = " << rowList << endl ; 242 243 if ( rowList.nelements() == 0 ) { 244 // add new row 245 tab.addRow( 1 ) ; 246 //cout << "tab.nrow() = " << tab.nrow() << endl ; 247 tcalCol.put( nrow, tcal ) ; 248 timeCol.putScalar( nrow, tcaltime ) ; 249 id = (uInt)nrow ; 250 idCol.putScalar( nrow, id ) ; 251 } 252 else { 253 uInt ichan = 0 ; 254 while ( rowList.nelements() > 1 && ichan < nelem ) { 255 Vector<uInt> tmp = rowList.copy() ; 256 rowList.resize( 0 ) ; 257 for ( uInt irow = 0 ; irow < tmp.nelements() ; irow++ ) { 258 Vector<Float> t = tcalCol( tmp[irow] ) ; 259 if ( t[ichan] == tcal[ichan] ) { 260 rowList.resize( rowList.nelements()+1, True ) ; 261 rowList[rowList.nelements()-1] = irow ; 262 } 263 } 264 ichan++ ; 265 } 266 267 //cout << "updated rowList = " << rowList << endl ; 268 269 if ( rowList.nelements() == 0 ) { 270 // add new row 271 tab.addRow( 1, True ) ; 272 //cout << "tab.nrow() = " << tab.nrow() << endl ; 273 tcalCol.put( nrow, tcal ) ; 274 timeCol.putScalar( nrow, tcaltime ) ; 275 id = (uInt)nrow ; 276 idCol.putScalar( nrow, id ) ; 277 } 278 else { 279 Vector<Float> t = tcalCol( rowList[0] ) ; 280 if ( allEQ( t, tcal ) ) { 281 ROTableColumn tc( tab, "ID" ) ; 282 id = tc.asuInt( rowList[0] ) ; 283 } 284 else { 285 // add new row 286 tab.addRow( 1, True ) ; 287 //cout << "tab.nrow() = " << tab.nrow() << endl ; 288 tcalCol.put( nrow, tcal ) ; 289 timeCol.putScalar( nrow, tcaltime ) ; 290 id = (uInt)nrow ; 291 idCol.putScalar( nrow, id ) ; 292 } 293 } 294 } 295 296 RecordFieldPtr<uInt> mcalidCol(row_.record(), "TCAL_ID"); 297 *mcalidCol = id; 298 } 299 178 300 }; -
trunk/src/FillerBase.h
r1904 r2209 77 77 casa::Float windspeed=0.0f, 78 78 casa::Float windaz=0.0f); 79 void setWeather2(casa::Float temperature=0.0f, 80 casa::Float pressure=0.0f, 81 casa::Float humidity=0.0f, 82 casa::Float windspeed=0.0f, 83 casa::Float windaz=0.0f); 79 84 void setTcal(const casa::String& caltime="", 85 const casa::Vector<casa::Float>& tcal=casa::Vector<casa::Float>()); 86 void setTcal2(const casa::String& caltime="", 80 87 const casa::Vector<casa::Float>& tcal=casa::Vector<casa::Float>()); 81 88 void setScanRate(const casa::Vector<casa::Double>& srate=casa::Vector<casa::Double>());
Note:
See TracChangeset
for help on using the changeset viewer.