Changeset 2782 for trunk/external-alma/atnf/PKSIO/NRODataset.cc
- Timestamp:
- 03/07/13 18:45:58 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external-alma/atnf/PKSIO/NRODataset.cc
r2781 r2782 57 57 58 58 // constructor 59 NRODataset::NRODataset( string name ) 60 { 61 // memory allocation 62 initialize() ; 63 64 filename_ = name ; 65 fp_ = NULL ; 66 scanNum_ = 0 ; 67 rowNum_ = 0 ; 68 scanLen_ = 0 ; 69 dataLen_ = 0 ; 70 dataid_ = -1 ; 71 72 // endian matches 73 same_ = -1 ; 74 75 // Record for frequency setting 76 frec_ = Record() ; 77 } 59 NRODataset::NRODataset( string name ) 60 : scanNum_(0), 61 rowNum_(0), 62 scanLen_(0), 63 dataLen_(0), 64 dataid_(-1), 65 filename_(name), 66 fp_(NULL), 67 same_(-1), 68 frec_() 69 {} 78 70 79 71 // destructor … … 90 82 void NRODataset::initialize() 91 83 { 84 LogIO os( LogOrigin( "NRODataset", "initialize()", WHERE ) ) ; 85 86 int arymax = arrayMax() ; 87 88 // check endian 89 open() ; 90 fseek( fp_, 144, SEEK_SET ) ; 91 int tmp ; 92 if( fread( &tmp, 1, sizeof(int), fp_ ) != sizeof(int) ) { 93 os << LogIO::SEVERE << "Error while checking endian of the file. " << LogIO::EXCEPTION ; 94 return ; 95 } 96 if ( ( 0 < tmp ) && ( tmp <= arymax ) ) { 97 same_ = 1 ; 98 os << LogIO::NORMAL << "same endian " << LogIO::POST ; 99 } 100 else { 101 same_ = 0 ; 102 os << LogIO::NORMAL << "different endian " << LogIO::POST ; 103 } 104 fseek( fp_, 0, SEEK_SET ) ; 105 106 // common part of calculation of data size and memory allocation 107 RX.resize( arymax ) ; 108 HPBW.resize( arymax ) ; 109 EFFA.resize( arymax ) ; 110 EFFB.resize( arymax ) ; 111 EFFL.resize( arymax ) ; 112 EFSS.resize( arymax ) ; 113 GAIN.resize( arymax ) ; 114 HORN.resize( arymax ) ; 115 POLTP.resize( arymax ) ; 116 POLDR.resize( arymax ) ; 117 POLAN.resize( arymax ) ; 118 DFRQ.resize( arymax ) ; 119 SIDBD.resize( arymax ) ; 120 REFN.resize( arymax ) ; 121 IPINT.resize( arymax ) ; 122 MULTN.resize( arymax ) ; 123 MLTSCF.resize( arymax ) ; 124 LAGWIND.resize( arymax ) ; 125 BEBW.resize( arymax ) ; 126 BERES.resize( arymax ) ; 127 CHWID.resize( arymax ) ; 128 ARRY.resize( arymax ) ; 129 NFCAL.resize( arymax ) ; 130 F0CAL.resize( arymax ) ; 131 FQCAL.resize( arymax ) ; 132 CHCAL.resize( arymax ) ; 133 CWCAL.resize( arymax ) ; 134 DSBFC.resize( arymax ) ; 135 136 for ( int i = 0 ; i < arymax ; i++ ) { 137 FQCAL[i].resize( 10 ) ; 138 CHCAL[i].resize( 10 ) ; 139 CWCAL[i].resize( 10 ) ; 140 } 141 92 142 datasize_ = sizeof( char ) * 8 // LOFIL 93 143 + sizeof( char ) * 8 // VER … … 120 170 record_ = new NRODataRecord() ; 121 171 record_->LDATA = NULL ; 172 173 // reference frequency 174 refFreq_.resize( arymax, 0.0 ) ; 175 } 176 177 // fill data header 178 int NRODataset::fillHeader() 179 { 180 LogIO os( LogOrigin( "NRODataset", "fillHeader()", WHERE ) ) ; 181 182 // open file 183 if ( open() ) { 184 os << LogIO::SEVERE << "Error opening file " << filename_ << "." << LogIO::EXCEPTION ; 185 return -1 ; 186 } 187 188 // fill 189 int status = fillHeader( same_ ) ; 190 191 if ( status != 0 ) { 192 os << LogIO::SEVERE << "Error while reading header " << filename_ << "." << LogIO::EXCEPTION ; 193 return status ; 194 } 195 196 //scanNum_ = NSCAN + 1 ; // includes ZERO scan 197 scanLen_ = SCNLEN ; 198 dataLen_ = scanLen_ - SCAN_HEADER_SIZE ; 199 scanNum_ = getScanNum(); 200 rowNum_ = scanNum_ * ARYNM ; 201 chmax_ = (int) ( dataLen_ * 8 / IBIT ) ; 202 record_->LDATA = new char[dataLen_] ; 203 204 initArray(); 205 206 show() ; 207 208 return status ; 122 209 } 123 210
Note: See TracChangeset
for help on using the changeset viewer.