Changeset 2889 in Sophya for trunk/SophyaExt/FitsIOServer/swfitsdtable.cc
- Timestamp:
- Jan 9, 2006, 6:32:37 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/swfitsdtable.cc
r2865 r2889 1 1 #include "swfitsdtable.h" 2 #include "fitshdtable.h" 2 3 #include "sopnamsp.h" 3 4 #include "pexceptions.h" … … 19 20 - It is not possible to make a complete (deep) copy of a SwFitsDataTable 20 21 Copy constructor and equal operator shares the data. 22 - The min/max values for column data are not updated when reading from a fits file. 23 In this case, the Show() method (or ostream& << operator) will compute min/max 24 values. This operation will take some time for large tables. 21 25 22 26 \sa SOPHYA::MuTyV … … 26 30 27 31 \code 28 #include "sw ppfdtable.h"32 #include "swfitsdtable.h" 29 33 // ... 30 34 { 31 35 // ---- Creation of the table 32 36 // Create the swap stream 33 POutPersist so("myswtable.ppf");34 SwFitsDataTable dt(so, 64);37 FitsInOutFile so("myswtable.fits", FitsInOutFile::Fits_Create); 38 SwFitsDataTable dt(so, 16); 35 39 // define table columns 36 40 dt.AddFloatColumn("X0_f"); … … 38 42 dt.AddDoubleColumn("X0X0pX1X1_d"); 39 43 // Fill the table 40 MuTyVx[5];44 r_8 x[5]; 41 45 for(int i=0; i<63; i++) { 42 46 x[0] = (i%9)-4.; x[1] = (i/9)-3.; x[2] = x[0]*x[0]+x[1]*x[1]; … … 45 49 // Printing table info 46 50 cout << dt ; 47 // Swap out all data and write the table structure to the PPF stream 48 so << dt ; 49 // .... 51 // The destructor will Swap out data still in memory 50 52 } 51 53 { 52 54 // ---- Accessing information from a previously created table 53 55 SwFitsDataTable dt; 54 PInPersist si("myswtable.ppf"); 56 FitsInOutFile si("myswtable.fits", FitsInOutFile::Fits_ReadOnly); 57 // Position the fits file on the first extension (BinTable) 58 si.MoveAbsToHDU(2); 59 // Reading in the table (initialisation) 55 60 si >> dt; 56 // Printing table info 61 // Printing table info 57 62 cout << dt ; 58 63 } … … 72 77 mSwF(os) , mFgCreate(fgcreate) 73 78 { 79 if (!fgcreate) { // Lecture de la table 80 FitsHandler<BaseDataTable> fio(*this); 81 fio.Read(os); 82 } 74 83 } 75 84 //! copy constructor - shares the data … … 83 92 SwFitsDataTable::~SwFitsDataTable() 84 93 { 85 if (mFgCreate) SwapOutAll(); 94 if (mFgCreate) { 95 SwapOutAll(); 96 // Ecriture de SegmentSize et autre elements de DVList 97 mSwF.WriteHeaderRecords(Info()); 98 MuTyV mtv = SegmentSize(); 99 mSwF.WriteKey("SEGMSIZE",mtv," SOPHYA::DataTable SegmentSize"); 100 mtv = "SOPHYA::SwFitsDataTable"; 101 mSwF.WriteKey("SOPCLSNM",mtv," Object class name "); 102 } 86 103 } 87 104 … … 213 230 mSCols.clear(); 214 231 215 /*216 mISwapper.clear();217 mLSwapper.clear();218 mFSwapper.clear();219 mDSwapper.clear();220 mYSwapper.clear();221 mZSwapper.clear();222 mSSwapper.clear();223 */224 232 } 225 233 … … 232 240 sa_size_t SwFitsDataTable::AddColumn(FieldType ft, string const & cnom) 233 241 { 234 return AddColRd(ft, cnom, NULL);242 return AddColRd(ft, cnom, -1, NULL); 235 243 } 236 244 /*! … … 240 248 */ 241 249 sa_size_t SwFitsDataTable::AddColRd(FieldType ft, string const & cnom, 242 vector<int_8> const * swpos)250 int colidx, vector<int_8> const * swpos) 243 251 { 244 252 if (NEntry() > 0) … … 247 255 sa_size_t ser; 248 256 sa_size_t idx = NVar(); 257 if (colidx < 1) colidx = idx+1; 258 249 259 switch (ft) { 250 260 case IntegerField : 251 261 { 252 262 ser = mICols.size(); 253 FITSDataSwapper<int_4> ISwapper(mSwF, idx+1);263 FITSDataSwapper<int_4> ISwapper(mSwF, colidx); 254 264 if (swpos) 255 265 mICols.push_back(SwSegDataBlock<int_4>(ISwapper, *swpos, mSegSz)); … … 265 275 { 266 276 ser = mLCols.size(); 267 FITSDataSwapper<int_8> LSwapper(mSwF, idx+1);277 FITSDataSwapper<int_8> LSwapper(mSwF, colidx); 268 278 if (swpos) 269 279 mLCols.push_back(SwSegDataBlock<int_8>(LSwapper, *swpos, mSegSz)); … … 279 289 { 280 290 ser = mFCols.size(); 281 FITSDataSwapper<r_4> FSwapper(mSwF, idx+1);291 FITSDataSwapper<r_4> FSwapper(mSwF, colidx); 282 292 if (swpos) 283 293 mFCols.push_back(SwSegDataBlock<r_4>(FSwapper, *swpos, mSegSz)); … … 294 304 { 295 305 ser = mDCols.size(); 296 FITSDataSwapper<r_8> DSwapper(mSwF, idx+1);306 FITSDataSwapper<r_8> DSwapper(mSwF, colidx); 297 307 if (swpos) 298 308 mDCols.push_back(SwSegDataBlock<r_8>(DSwapper, *swpos, mSegSz)); … … 308 318 { 309 319 ser = mYCols.size(); 310 FITSDataSwapper< complex<r_4> > YSwapper(mSwF, idx+1);320 FITSDataSwapper< complex<r_4> > YSwapper(mSwF, colidx); 311 321 if (swpos) 312 322 mYCols.push_back(SwSegDataBlock< complex<r_4> >(YSwapper, *swpos, mSegSz)); … … 322 332 { 323 333 ser = mZCols.size(); 324 FITSDataSwapper< complex<r_8> > ZSwapper(mSwF, idx+1);334 FITSDataSwapper< complex<r_8> > ZSwapper(mSwF, colidx); 325 335 if (swpos) 326 336 mZCols.push_back(SwSegDataBlock< complex<r_8> >(ZSwapper, *swpos, mSegSz)); … … 336 346 { 337 347 ser = mSCols.size(); 338 FITSDataSwapper< string > SSwapper(mSwF, idx+1);348 FITSDataSwapper< string > SSwapper(mSwF, colidx); 339 349 if (swpos) 340 350 mSCols.push_back(SwSegDataBlock< string >(SSwapper, *swpos, mSegSz)); … … 368 378 /*! 369 379 The min/max values for each column is updated, in addition 370 to the actions performed by the base class AddLine() 371 */ 372 sa_size_t SwFitsDataTable::AddLine(const r_8* data) 373 { 380 to the actions performed by the base class AddRow() 381 */ 382 sa_size_t SwFitsDataTable::AddRow(const r_8* data) 383 { 384 if (NRows() == 0) { // On cree la definition de la table FITS au premier appel 385 FitsHandler<BaseDataTable> fio(*this); 386 fio.Write(mSwF); 387 } 374 388 // On est oblige de calculer les min-max lors du remplissage 375 389 // On ne peut pas en effet 'relire' le swap pendant l'ecriture … … 380 394 mMinMaxNEnt[k]++; 381 395 } 382 return BaseDataTable::Add Line(data);383 } 384 385 //! Adds a line (or rowto the table) with input data as an array of MuTyV396 return BaseDataTable::AddRow(data); 397 } 398 399 //! Adds a row (or line to the table) with input data as an array of MuTyV 386 400 /*! 387 401 The min/max values for each column is updated, in addition 388 to the actions performed by the base class AddLine() 389 */ 390 sa_size_t SwFitsDataTable::AddLine(const MuTyV * data) 391 { 402 to the actions performed by the base class AddRow() 403 */ 404 sa_size_t SwFitsDataTable::AddRow(const MuTyV * data) 405 { 406 if (NRows() == 0) { // On cree la definition de la table FITS au premier appel 407 FitsHandler<BaseDataTable> fio(*this); 408 fio.Write(mSwF); 409 } 392 410 // On est oblige de calculer les min-max lors du remplissage 393 411 // On ne peut pas en effet 'relire' le swap pendant l'ecriture … … 398 416 mMinMaxNEnt[k]++; 399 417 } 400 return BaseDataTable::Add Line(data);401 } 402 418 return BaseDataTable::AddRow(data); 419 } 420
Note:
See TracChangeset
for help on using the changeset viewer.