Line data Source code
1 : #include <sstream>
2 : #include <iostream>
3 : #include <stdlib.h> // for atoi()
4 : #include <stdint.h>
5 :
6 : #include <alma/ASDMBinaries/Integration.h>
7 : #include <alma/ASDMBinaries/Error.h>
8 :
9 : using namespace sdmbin;
10 : using namespace std;
11 :
12 : using namespace AxisNameMod;
13 : using namespace CorrelationModeMod;
14 : using namespace NetSidebandMod;
15 :
16 : namespace sdmbin{
17 : // ============================================================================================
18 : // DataStructure: the base
19 : // ============================================================================================
20 :
21 0 : DataStructure::DataStructure()
22 : {
23 0 : }
24 :
25 0 : DataStructure::DataStructure( uint32_t numPolProduct,
26 : uint32_t numBin,
27 : Enum<NetSideband> e_sideband,
28 : uint32_t numBaseband,
29 : uint32_t numAnt,
30 : CorrelationMode correlationMode
31 0 : )
32 : {
33 0 : v_numSpectralWindow_.resize(0);
34 0 : vv_numAutoPolProduct_.resize(numBaseband);
35 0 : vv_numSpectralPoint_.resize(numBaseband);
36 0 : vv_numBin_.resize(numBaseband);
37 0 : vv_e_sideband_.resize(numBaseband);
38 0 : for(uint32_t nbb=0; nbb<numBaseband; nbb++){
39 0 : v_numSpectralWindow_.push_back(1);
40 0 : for(uint32_t nspw=0; nspw<numBaseband; nspw++){
41 0 : vv_numAutoPolProduct_[nbb].push_back(numPolProduct);
42 0 : vv_numSpectralPoint_[nbb].push_back(1);
43 0 : vv_numBin_[nbb].push_back(numBin);
44 0 : vv_e_sideband_[nbb].push_back(e_sideband);
45 : }
46 : }
47 0 : numApc_ = 1;
48 0 : numBaseband_ = numBaseband;
49 0 : numAnt_ = numAnt;
50 0 : correlationMode_ = correlationMode;
51 0 : axisSequence_ = setStructureProperties();
52 0 : }
53 :
54 0 : DataStructure::DataStructure( uint32_t numPolProduct,
55 : uint32_t numSpectralPoint,
56 : uint32_t numBin,
57 : Enum<NetSideband> e_sideband,
58 : uint32_t numBaseband,
59 : uint32_t numAnt,
60 0 : CorrelationMode correlationMode)
61 : {
62 0 : v_numSpectralWindow_.resize(0);
63 0 : vv_numAutoPolProduct_.resize(numBaseband);
64 0 : vv_numSpectralPoint_.resize(numSpectralPoint);
65 0 : vv_numBin_.resize(numBaseband);
66 0 : vv_e_sideband_.resize(numBaseband);
67 0 : for(uint32_t nbb=0; nbb<numBaseband; nbb++){
68 0 : v_numSpectralWindow_.push_back(1);
69 0 : for(uint32_t nspw=0; nspw<numBaseband; nspw++){
70 0 : vv_numAutoPolProduct_[nbb].push_back(numPolProduct);
71 0 : vv_numSpectralPoint_[nbb].push_back(1);
72 0 : vv_numBin_[nbb].push_back(numBin);
73 0 : vv_e_sideband_[nbb].push_back(e_sideband);
74 : }
75 : }
76 0 : numAnt_ = numAnt;
77 0 : numApc_ = 1;
78 0 : numBaseband_ = numBaseband;
79 0 : correlationMode_ = correlationMode;
80 0 : axisSequence_ = setStructureProperties();
81 0 : }
82 :
83 0 : DataStructure::DataStructure( vector<vector<uint32_t> > vv_numCrossPolProduct,// /bb/spw
84 : vector<vector<uint32_t> > vv_numAutoPolProduct, // /bb/spw
85 : vector<vector<uint32_t> > vv_numSpectralPoint, // /bb/spw
86 : vector<vector<uint32_t> > vv_numBin, // /bb/spw
87 : vector<vector<Enum<NetSideband> > > vv_e_sideband, // /bb/spw
88 : uint32_t numApc,
89 : vector<uint32_t> v_numSpectralWindow, // /bb
90 : uint32_t numBaseband,
91 : uint32_t numAnt,
92 0 : CorrelationMode correlationMode):
93 0 : vv_numCrossPolProduct_(vv_numCrossPolProduct),
94 0 : vv_numAutoPolProduct_(vv_numAutoPolProduct),
95 0 : vv_numSpectralPoint_(vv_numSpectralPoint),
96 0 : vv_numBin_(vv_numBin),
97 0 : vv_e_sideband_(vv_e_sideband),
98 0 : numApc_(numApc),
99 0 : v_numSpectralWindow_(v_numSpectralWindow),
100 0 : numBaseband_(numBaseband),
101 0 : numAnt_(numAnt),
102 0 : correlationMode_(correlationMode)
103 : {
104 0 : axisSequence_ = setStructureProperties();
105 0 : }
106 :
107 0 : DataStructure::DataStructure( vector<vector<uint32_t> > vv_numAutoPolProduct, // /bb/spw
108 : vector<vector<uint32_t> > vv_numSpectralPoint, // /bb/spw
109 : vector<vector<uint32_t> > vv_numBin, // /bb/spw
110 : vector<vector<Enum<NetSideband> > > vv_e_sideband, // /bb/spw
111 : uint32_t numApc,
112 : vector<uint32_t> v_numSpectralWindow, // /bb
113 : uint32_t numBaseband,
114 : uint32_t numAnt,
115 0 : CorrelationMode correlationMode):
116 0 : vv_numAutoPolProduct_(vv_numAutoPolProduct),
117 0 : vv_numSpectralPoint_(vv_numSpectralPoint),
118 0 : vv_numBin_(vv_numBin),
119 0 : vv_e_sideband_(vv_e_sideband),
120 0 : numApc_(numApc),
121 0 : v_numSpectralWindow_(v_numSpectralWindow),
122 0 : numBaseband_(numBaseband),
123 0 : numAnt_(numAnt),
124 0 : correlationMode_(correlationMode)
125 : {
126 0 : vv_numCrossPolProduct_.clear();
127 0 : axisSequence_ = setStructureProperties();
128 0 : }
129 :
130 0 : DataStructure::DataStructure( const DataStructure & a)
131 : {
132 0 : vv_numCrossPolProduct_ = a.vv_numCrossPolProduct_;
133 0 : vv_numAutoPolProduct_ = a.vv_numAutoPolProduct_;
134 0 : vv_numSpectralPoint_ = a.vv_numSpectralPoint_;
135 0 : vv_numBin_ = a.vv_numBin_;
136 0 : vv_e_sideband_ = a.vv_e_sideband_;
137 0 : numApc_ = a.numApc_;
138 0 : v_numSpectralWindow_ = a.v_numSpectralWindow_;
139 0 : numBaseband_ = a.numBaseband_;
140 0 : numAnt_ = a.numAnt_;
141 0 : correlationMode_ = a.correlationMode_;
142 0 : axisSequence_ = a.axisSequence_;
143 0 : v_minSize_ = a.v_minSize_;
144 0 : v_maxSize_ = a.v_maxSize_;
145 0 : }
146 :
147 0 : DataStructure::~DataStructure()
148 : {
149 0 : }
150 :
151 0 : string DataStructure::setStructureProperties()
152 : {
153 : uint32_t minSize,maxSize;
154 : bool newLevel;
155 0 : ostringstream axisSequence;
156 :
157 0 : newLevel = false;
158 0 : minSize = 100000;
159 0 : maxSize = 0;
160 0 : if(vv_numAutoPolProduct_.size()){
161 0 : for(uint32_t nbb=0; nbb<numBaseband_; nbb++){
162 0 : for(uint32_t nspw=0; nspw<v_numSpectralWindow_[nbb]; nspw++){
163 0 : if(vv_numAutoPolProduct_[nbb][nspw]<minSize)minSize=vv_numAutoPolProduct_[nbb][nspw];
164 0 : if(vv_numAutoPolProduct_[nbb][nspw]>maxSize)maxSize=vv_numAutoPolProduct_[nbb][nspw];
165 0 : if(vv_numAutoPolProduct_[nbb][nspw]>1)newLevel=true;
166 : }
167 : }
168 : }
169 0 : if(vv_numCrossPolProduct_.size()){
170 0 : for(uint32_t nbb=0; nbb<numBaseband_; nbb++){
171 0 : for(uint32_t nspw=0; nspw<v_numSpectralWindow_[nbb]; nspw++){
172 0 : if(vv_numCrossPolProduct_[nbb][nspw]<minSize)minSize=vv_numCrossPolProduct_[nbb][nspw];
173 0 : if(vv_numCrossPolProduct_[nbb][nspw]>maxSize)maxSize=vv_numCrossPolProduct_[nbb][nspw];
174 0 : if(vv_numCrossPolProduct_[nbb][nspw]>1)newLevel=true;
175 : }
176 : }
177 : }
178 0 : if( newLevel ){
179 0 : v_minSize_.push_back(minSize);
180 0 : v_maxSize_.push_back(maxSize);
181 0 : axisSequence << "1";
182 : }
183 :
184 0 : newLevel=false;
185 0 : minSize = 1000000;
186 0 : maxSize = 0;
187 0 : for(uint32_t nbb=0; nbb<numBaseband_; nbb++){
188 0 : for(uint32_t nspw=0; nspw<v_numSpectralWindow_[nbb]; nspw++){
189 0 : if(vv_numSpectralPoint_[nbb][nspw]<minSize)minSize=vv_numSpectralPoint_[nbb][nspw];
190 0 : if(vv_numSpectralPoint_[nbb][nspw]>maxSize)maxSize=vv_numSpectralPoint_[nbb][nspw];
191 0 : if(vv_numSpectralPoint_[nbb][nspw]>1)newLevel=true;
192 : }
193 : }
194 0 : if( newLevel ){
195 0 : v_minSize_.push_back(minSize);
196 0 : v_maxSize_.push_back(maxSize);
197 0 : axisSequence << "2";
198 : }
199 :
200 0 : if( numApc_>1 ){
201 0 : v_minSize_.push_back(numApc_);
202 0 : v_maxSize_.push_back(numApc_);
203 0 : axisSequence << "3";
204 : }
205 :
206 0 : newLevel=false;
207 0 : minSize = 100000;
208 0 : maxSize = 0;
209 0 : for(uint32_t nbb=0; nbb<numBaseband_; nbb++){
210 0 : for(uint32_t nspw=0; nspw<v_numSpectralWindow_[nbb]; nspw++){
211 0 : if(vv_numBin_[nbb][nspw]<minSize)minSize=vv_numBin_[nbb][nspw];
212 0 : if(vv_numBin_[nbb][nspw]>maxSize)maxSize=vv_numBin_[nbb][nspw];
213 0 : if(vv_numBin_[nbb][nspw]>1)newLevel=true;
214 : }
215 : }
216 0 : if( newLevel ){
217 0 : v_minSize_.push_back(minSize);
218 0 : v_maxSize_.push_back(maxSize);
219 0 : axisSequence << "4";
220 : }
221 :
222 0 : newLevel=false;
223 0 : minSize = 100000;
224 0 : maxSize = 0;
225 0 : for(uint32_t nbb=0; nbb<numBaseband_; nbb++){
226 0 : if(v_numSpectralWindow_[nbb]<minSize)minSize=v_numSpectralWindow_[nbb];
227 0 : if(v_numSpectralWindow_[nbb]>maxSize)maxSize=v_numSpectralWindow_[nbb];
228 0 : if(v_numSpectralWindow_[nbb]>1)newLevel=true;
229 : }
230 0 : if( newLevel ){
231 0 : v_minSize_.push_back(minSize);
232 0 : v_maxSize_.push_back(maxSize);
233 0 : axisSequence << "5";
234 : }
235 :
236 0 : if( numBaseband_>1 ){
237 0 : v_minSize_.push_back(numBaseband_);
238 0 : v_maxSize_.push_back(numBaseband_);
239 0 : axisSequence << "6";
240 : }
241 :
242 0 : if(correlationMode_!=AUTO_ONLY){
243 0 : v_minSize_.push_back(numAnt_);
244 0 : v_maxSize_.push_back(numAnt_);
245 0 : axisSequence << "7";
246 : }
247 :
248 0 : if(correlationMode_!=CROSS_ONLY){
249 0 : v_minSize_.push_back(numAnt_);
250 0 : v_maxSize_.push_back(numAnt_);
251 0 : axisSequence << "8";
252 : }
253 :
254 0 : return axisSequence.str();
255 :
256 0 : }
257 :
258 0 : vector<vector<uint32_t> > DataStructure::numCrossPolProducts(){ return vv_numCrossPolProduct_; }
259 :
260 0 : vector<vector<uint32_t> > DataStructure::numAutoPolProducts() { return vv_numAutoPolProduct_; }
261 :
262 0 : vector<vector<uint32_t> > DataStructure::numSpectralPoints() { return vv_numSpectralPoint_; }
263 :
264 0 : vector<vector<uint32_t> > DataStructure::numBins() { return vv_numBin_; }
265 :
266 0 : vector<vector<Enum<NetSideband> > > DataStructure::sidebands() { return vv_e_sideband_; }
267 :
268 0 : uint32_t DataStructure::numApc() { return numApc_; }
269 :
270 0 : vector<uint32_t> DataStructure::numSpectralWindows() { return v_numSpectralWindow_; }
271 :
272 0 : uint32_t DataStructure::numBaseband() { return numBaseband_; }
273 :
274 0 : uint32_t DataStructure::numAnt() { return numAnt_; }
275 :
276 0 : CorrelationMode DataStructure::correlationMode() { return correlationMode_; }
277 :
278 :
279 0 : vector<uint32_t> DataStructure::leafAxisSizes(){
280 0 : if(!isIndexible()){
281 0 : vector<uint32_t> las;
282 0 : return las;
283 0 : }
284 0 : return leafAxisSizes(0,0);
285 : }
286 :
287 0 : vector<uint32_t> DataStructure::leafAxisSizes(uint32_t basebandIndex, uint32_t spectralWindowIndex){
288 0 : vector<uint32_t> las;
289 0 : if(vv_numBin_[basebandIndex][spectralWindowIndex]!=1)
290 0 : las.push_back(vv_numBin_[basebandIndex][spectralWindowIndex]);
291 0 : if(numApc_!=1)
292 0 : las.push_back(numApc_);
293 0 : if(vv_numSpectralPoint_[basebandIndex][spectralWindowIndex]!=1)
294 0 : las.push_back(vv_numSpectralPoint_[basebandIndex][spectralWindowIndex]);
295 0 : if(vv_numAutoPolProduct_[basebandIndex][spectralWindowIndex]!=1)
296 0 : las.push_back(vv_numAutoPolProduct_[basebandIndex][spectralWindowIndex]);
297 0 : return las;
298 0 : }
299 :
300 0 : vector<uint32_t> DataStructure::leafAxisSizes(uint32_t ndd){
301 0 : vector<uint32_t> las;
302 0 : if(ndd==0){
303 0 : return leafAxisSizes(0,0);
304 : }else{
305 0 : uint32_t k=0;
306 : uint32_t nb;
307 0 : uint32_t nspw=0;
308 0 : for(nb=0; nb<numBaseband_; nb++){
309 0 : for(nspw=0; nspw<v_numSpectralWindow_[nb]; nspw++){
310 0 : if(k==ndd)break;
311 0 : k++;
312 : }
313 : }
314 0 : return leafAxisSizes(nb,nspw);
315 : }
316 0 : }
317 :
318 :
319 0 : uint32_t DataStructure::isIndexible() const
320 : {
321 0 : uint32_t multidim=0;
322 0 : for(uint32_t n=0; n<v_minSize_.size(); n++)
323 0 : if(v_minSize_[n]==v_maxSize_[n])multidim++;
324 0 : if(multidim==v_minSize_.size())return multidim;
325 0 : return 0;
326 : }
327 :
328 : // todo
329 0 : vector<uint32_t> DataStructure::eAxisSizes() const
330 : {
331 0 : vector<uint32_t> v_size;
332 0 : if(!isIndexible())return v_size; //
333 : // 12345678
334 : //v_size.push_back(vv_numCrossPolProduct_[0][0]);
335 0 : v_size.push_back(vv_numAutoPolProduct_[0][0]);
336 0 : v_size.push_back(vv_numSpectralPoint_[0][0]);
337 0 : v_size.push_back(numApc_);
338 0 : v_size.push_back(vv_numBin_[0][0]);
339 0 : v_size.push_back(v_numSpectralWindow_[0]);
340 0 : v_size.push_back(numBaseband_);
341 0 : if(correlationMode_!=AUTO_ONLY) v_size.push_back((numAnt_*(numAnt_-1))/2);
342 0 : if(correlationMode_!=CROSS_ONLY)v_size.push_back(numAnt_);
343 0 : return v_size;
344 0 : }
345 :
346 : // todo
347 0 : vector<uint32_t> DataStructure::axisSizes() const
348 : {
349 0 : vector<uint32_t> v_size;
350 0 : for(uint32_t n=0; n<v_minSize_.size(); n++)
351 0 : if(v_minSize_[n]==v_maxSize_[n])v_size.push_back(v_minSize_[n]);
352 0 : return v_size;
353 0 : }
354 :
355 0 : uint32_t DataStructure::dimension() const
356 : {
357 0 : return (uint32_t)axisSequence_.length();
358 : }
359 :
360 0 : vector<uint32_t> DataStructure::minAxSize() const
361 : {
362 0 : return v_minSize_;
363 : }
364 :
365 0 : vector<uint32_t> DataStructure::maxAxSize() const
366 : {
367 0 : return v_maxSize_;
368 : }
369 :
370 0 : uint32_t DataStructure::numCrossData() const
371 : {
372 0 : uint32_t numCrossData = 1;
373 0 : for(uint32_t nbb=0; nbb<numBaseband_; nbb++){
374 0 : for(uint32_t nspw=0; nspw<v_numSpectralWindow_[nbb]; nspw++){
375 0 : numCrossData *=
376 0 : vv_numBin_[nbb][nspw] *
377 0 : vv_numSpectralPoint_[nbb][nspw] *
378 0 : vv_numCrossPolProduct_[nbb][nspw];
379 : }
380 : }
381 0 : return numCrossData;
382 : }
383 :
384 0 : uint32_t DataStructure::numAutoData() const
385 : {
386 0 : uint32_t numAutoData = 1;
387 0 : for(uint32_t nbb=0; nbb<numBaseband_; nbb++){
388 0 : for(uint32_t nspw=0; nspw<v_numSpectralWindow_[nbb]; nspw++){
389 0 : numAutoData *=
390 0 : vv_numBin_[nbb][nspw] *
391 0 : vv_numSpectralPoint_[nbb][nspw] *
392 0 : vv_numAutoPolProduct_[nbb][nspw];
393 : }
394 : }
395 :
396 : // if( numBaseline_>1 ){
397 : // v_minSize_.push_back(numBaseline_);
398 : // v_maxSize_.push_back(numBaseline_);
399 : // axisSequence << "7";
400 : // }
401 : // numData *= numApc_*numAnt_; // for total power only!
402 :
403 0 : return numAutoData;
404 : }
405 :
406 0 : string DataStructure::axisSequence() const
407 : {
408 0 : return axisSequence_;
409 : }
410 :
411 0 : void DataStructure::summary() const
412 : {
413 0 : cout<<"Data for "<<numAnt_<<" antenna."<<endl;
414 0 : for(uint32_t nbb=0; nbb<numBaseband_; nbb++){
415 0 : cout<<" Baseband "<<nbb+1
416 0 : <<" has "<<v_numSpectralWindow_[nbb]
417 0 : <<" spectral windows."<<endl;
418 0 : for(uint32_t nspw=0; nspw<v_numSpectralWindow_[nbb]; nspw++){
419 0 : cout<<" Spectral window "<<nspw+1
420 0 : <<" num spectral points: "<<vv_numSpectralPoint_[nbb][nspw]
421 0 : <<" num bins: "<<vv_numBin_[nbb][nspw];
422 0 : if(vv_numAutoPolProduct_.size())
423 0 : if(vv_numAutoPolProduct_[nbb].size())
424 0 : cout<<" num sd pol.: "<<vv_numAutoPolProduct_[nbb][nspw];
425 0 : if(vv_numCrossPolProduct_.size())
426 0 : if(vv_numCrossPolProduct_[nbb].size())
427 0 : cout<<" num cross pol.: "<<vv_numCrossPolProduct_[nbb][nspw];
428 0 : cout<<endl;
429 : }
430 : }
431 0 : uint32_t multidim = isIndexible();
432 0 : if( multidim ){
433 0 : cout<<"The data structure is multi-dimensional with the dimensionality "
434 0 : <<multidim<<endl;
435 0 : cout<<" axis order: "<<axisSequence_<<endl;
436 0 : vector<uint32_t>v_size=axisSizes();
437 0 : ostringstream os;
438 0 : for(uint32_t n=0; n<v_size.size()-1; n++)os<<v_size[n]<<",";
439 0 : os<<v_size[v_size.size()-1];
440 0 : cout<<" axis sizes: "<<os.str()<<endl;;
441 0 : }
442 0 : }
443 :
444 : // ============================================================================================
445 : // DataDump -> DataStructure
446 : // ============================================================================================
447 :
448 0 : DataDump::DataDump()
449 : {
450 : //cout<<"Default constructor DataDump"<<endl;
451 0 : }
452 :
453 0 : DataDump::DataDump( uint32_t numPolProduct,
454 : uint32_t numBin,
455 : Enum<NetSideband> e_sideband,
456 : uint32_t numBaseband,
457 : uint32_t numAnt,
458 : CorrelationMode correlationMode,
459 : uint64_t time,
460 : uint64_t timeCentroid,
461 : uint64_t interval,
462 : uint64_t exposure,
463 0 : const float* floatData):
464 : DataStructure( numPolProduct,
465 : numBin,
466 : e_sideband,
467 : numBaseband,
468 : numAnt,
469 : correlationMode),
470 0 : cuintFlagsPtr_(NULL),
471 0 : clonlonActualTimesPtr_(NULL),
472 0 : clonlonActualDurationsPtr_(NULL),
473 0 : cfloatWeightsPtr_(NULL),
474 0 : cfloatZeroLagsPtr_(NULL),
475 0 : cfloatAutoDataPtr_(floatData),
476 0 : cshortCrossDataPtr_(NULL),
477 0 : cintCrossDataPtr_(NULL),
478 0 : cfloatCrossDataPtr_(NULL)
479 : {
480 0 : integrationNum_ = 0;
481 0 : subintegrationNum_ = 0;
482 0 : time_ = time;
483 0 : timeCentroid_ = timeCentroid;
484 0 : interval_ = interval;
485 0 : exposure_ = exposure;
486 :
487 0 : uintFlagsPtr_ = NULL;
488 0 : lonlonActualTimesPtr_ = NULL;
489 0 : lonlonActualDurationsPtr_ = NULL;
490 0 : floatWeightsPtr_ = NULL;
491 0 : floatZeroLagsPtr_ = NULL;
492 0 : floatAutoDataPtr_ = NULL;
493 0 : shortCrossDataPtr_ = NULL;
494 0 : intCrossDataPtr_ = NULL;
495 0 : floatCrossDataPtr_ = NULL;
496 :
497 0 : }
498 :
499 :
500 0 : DataDump::DataDump( uint32_t numPolProduct,
501 : uint32_t numSpectralPoint,
502 : uint32_t numBin,
503 : Enum<NetSideband> e_sideband,
504 : uint32_t numBaseband,
505 : uint32_t numAnt,
506 : CorrelationMode correlationMode,
507 : uint64_t time,
508 : uint64_t timeCentroid,
509 : uint64_t interval,
510 : uint64_t exposure,
511 : const float* floatData,
512 0 : const uint32_t* dataFlags):
513 : DataStructure( numPolProduct,
514 : numSpectralPoint,
515 : numBin,
516 : e_sideband,
517 : numBaseband,
518 : numAnt,
519 : correlationMode),
520 0 : cuintFlagsPtr_(dataFlags),
521 0 : clonlonActualTimesPtr_(NULL),
522 0 : clonlonActualDurationsPtr_(NULL),
523 0 : cfloatWeightsPtr_(NULL),
524 0 : cfloatZeroLagsPtr_(NULL),
525 0 : cfloatAutoDataPtr_(floatData),
526 0 : cshortCrossDataPtr_(NULL),
527 0 : cintCrossDataPtr_(NULL),
528 0 : cfloatCrossDataPtr_(NULL)
529 : {
530 0 : integrationNum_ = 0;
531 0 : subintegrationNum_ = 0;
532 0 : time_ = time;
533 0 : timeCentroid_ = timeCentroid; cout<<"timeCentroid="<<timeCentroid<<endl;
534 0 : interval_ = interval;
535 0 : exposure_ = exposure;
536 :
537 0 : uintFlagsPtr_ = NULL;
538 0 : lonlonActualTimesPtr_ = NULL;
539 0 : lonlonActualDurationsPtr_ = NULL;
540 0 : floatWeightsPtr_ = NULL;
541 0 : floatZeroLagsPtr_ = NULL;
542 0 : floatAutoDataPtr_ = NULL;
543 0 : shortCrossDataPtr_ = NULL;
544 0 : intCrossDataPtr_ = NULL;
545 0 : floatCrossDataPtr_ = NULL;
546 0 : }
547 :
548 0 : DataDump::DataDump( vector<vector<uint32_t> > vv_numAutoPolProduct, // /bb/spw
549 : vector<vector<uint32_t> > vv_numSpectralPoint, // /bb/spw
550 : vector<vector<uint32_t> > vv_numBin, // /bb/spw
551 : vector<vector<Enum<NetSideband> > > vv_e_sideband, // /bb/spw
552 : uint32_t numApc,
553 : vector<uint32_t> v_numSpectralWindow, // /bb
554 : uint32_t numBaseband,
555 : uint32_t numAnt,
556 : CorrelationMode correlationMode,
557 : uint64_t time,
558 : uint64_t timeCentroid,
559 : uint64_t interval,
560 : uint64_t exposure,
561 : const float* floatData,
562 0 : const uint32_t* dataFlags):
563 : DataStructure( vv_numAutoPolProduct,
564 : vv_numSpectralPoint,
565 : vv_numBin,
566 : vv_e_sideband,
567 : numApc,
568 : v_numSpectralWindow,
569 : numBaseband,
570 : numAnt,
571 : correlationMode),
572 0 : integrationNum_(0),
573 0 : subintegrationNum_(0),
574 0 : time_(time),
575 0 : timeCentroid_(timeCentroid),
576 0 : interval_(interval),
577 0 : exposure_(exposure),
578 0 : cuintFlagsPtr_(dataFlags),
579 0 : clonlonActualTimesPtr_(NULL),
580 0 : clonlonActualDurationsPtr_(NULL),
581 0 : cfloatWeightsPtr_(NULL),
582 0 : cfloatZeroLagsPtr_(NULL),
583 0 : cfloatAutoDataPtr_(floatData),
584 0 : cshortCrossDataPtr_(NULL),
585 0 : cintCrossDataPtr_(NULL),
586 0 : cfloatCrossDataPtr_(NULL)
587 : {
588 0 : uintFlagsPtr_ = NULL;
589 0 : lonlonActualTimesPtr_ = NULL;
590 0 : lonlonActualDurationsPtr_ = NULL;
591 0 : floatWeightsPtr_ = NULL;
592 0 : floatZeroLagsPtr_ = NULL;
593 0 : floatAutoDataPtr_ = NULL;
594 0 : shortCrossDataPtr_ = NULL;
595 0 : intCrossDataPtr_ = NULL;
596 0 : floatCrossDataPtr_ = NULL;
597 0 : }
598 :
599 0 : DataDump::DataDump( vector<vector<uint32_t> > vv_numAutoPolProduct, // /bb/spw
600 : vector<vector<uint32_t> > vv_numSpectralPoint, // /bb/spw
601 : vector<vector<uint32_t> > vv_numBin, // /bb/spw
602 : vector<vector<Enum<NetSideband> > > vv_e_sideband, // /bb/spw
603 : uint32_t numApc,
604 : vector<uint32_t> v_numSpectralWindow, // /bb
605 : uint32_t numBaseband,
606 : uint32_t numAnt,
607 : CorrelationMode correlationMode,
608 : uint64_t time,
609 : uint64_t timeCentroid,
610 : uint64_t interval,
611 : uint64_t exposure,
612 0 : const float* floatData):
613 : DataStructure( vv_numAutoPolProduct,
614 : vv_numSpectralPoint,
615 : vv_numBin,
616 : vv_e_sideband,
617 : numApc,
618 : v_numSpectralWindow,
619 : numBaseband,
620 : numAnt,
621 : correlationMode),
622 0 : integrationNum_(0),
623 0 : subintegrationNum_(0),
624 0 : time_(time),
625 0 : timeCentroid_(timeCentroid),
626 0 : interval_(interval),
627 0 : exposure_(exposure),
628 0 : cuintFlagsPtr_(NULL),
629 0 : clonlonActualTimesPtr_(NULL),
630 0 : clonlonActualDurationsPtr_(NULL),
631 0 : cfloatWeightsPtr_(NULL),
632 0 : cfloatZeroLagsPtr_(NULL),
633 0 : cfloatAutoDataPtr_(floatData),
634 0 : cshortCrossDataPtr_(NULL),
635 0 : cintCrossDataPtr_(NULL),
636 0 : cfloatCrossDataPtr_(NULL)
637 : {
638 0 : uintFlagsPtr_ = NULL;
639 0 : lonlonActualTimesPtr_ = NULL;
640 0 : lonlonActualDurationsPtr_ = NULL;
641 0 : floatWeightsPtr_ = NULL;
642 0 : floatZeroLagsPtr_ = NULL;
643 0 : floatAutoDataPtr_ = NULL;
644 0 : shortCrossDataPtr_ = NULL;
645 0 : intCrossDataPtr_ = NULL;
646 0 : floatCrossDataPtr_ = NULL;
647 0 : }
648 :
649 0 : DataDump::DataDump( vector<vector<uint32_t> > vv_numCrossPolProduct,// /bb/spw
650 : vector<vector<uint32_t> > vv_numAutoPolProduct, // /bb/spw
651 : vector<vector<uint32_t> > vv_numSpectralPoint, // /bb/spw
652 : vector<vector<uint32_t> > vv_numBin, // /bb/spw
653 : vector<vector<Enum<NetSideband> > > vv_e_sideband, // /bb/spw
654 : uint32_t numApc,
655 : vector<uint32_t> v_numSpectralWindow, // /bb
656 : uint32_t numBaseband,
657 : uint32_t numAnt,
658 : CorrelationMode correlationMode,
659 : uint64_t time,
660 : uint64_t timeCentroid,
661 : uint64_t interval,
662 0 : uint64_t exposure):
663 : DataStructure( vv_numCrossPolProduct,
664 : vv_numAutoPolProduct,
665 : vv_numSpectralPoint,
666 : vv_numBin,
667 : vv_e_sideband,
668 : numApc,
669 : v_numSpectralWindow,
670 : numBaseband,
671 : numAnt,
672 : correlationMode),
673 0 : integrationNum_(0),
674 0 : subintegrationNum_(0),
675 0 : time_(time),
676 0 : timeCentroid_(timeCentroid),
677 0 : interval_(interval),
678 0 : exposure_(exposure),
679 0 : es_flagsAxes_(),
680 0 : es_actualTimesAxes_(),
681 0 : es_actualDurationsAxes_(),
682 0 : es_weightsAxes_(),
683 0 : es_zeroLagsAxes_(),
684 0 : es_autoDataAxes_(),
685 0 : es_crossDataAxes_(),
686 0 : numFlags_(0),
687 0 : numActualTimes_(0),
688 0 : numActualDurations_(0),
689 0 : numWeights_(0),
690 0 : numZeroLags_(0),
691 0 : numAutoData_(0),
692 0 : numCrossData_(0),
693 0 : cuintFlagsPtr_(NULL),
694 0 : clonlonActualTimesPtr_(NULL),
695 0 : clonlonActualDurationsPtr_(NULL),
696 0 : cfloatWeightsPtr_(NULL),
697 0 : cfloatZeroLagsPtr_(NULL),
698 0 : cfloatAutoDataPtr_(NULL),
699 0 : cshortCrossDataPtr_(NULL),
700 0 : cintCrossDataPtr_(NULL),
701 0 : cfloatCrossDataPtr_(NULL)
702 : {
703 :
704 : // By default the scale factor is set to 1 for all spw. It must be updated subsequently if required
705 : // using the method setScaleFactor().
706 0 : if(vv_numCrossPolProduct.size()){
707 0 : for(uint32_t nbb=0; nbb<numBaseband; nbb++){
708 0 : vector<float> v_f;
709 0 : for(uint32_t nspw=0; nspw<vv_numCrossPolProduct[nbb].size(); nspw++)v_f.push_back(1.0);
710 0 : vv_scaleFactor_.push_back(v_f);
711 0 : }
712 : }
713 :
714 0 : uintFlagsPtr_ = NULL;
715 0 : lonlonActualTimesPtr_ = NULL;
716 0 : lonlonActualDurationsPtr_ = NULL;
717 0 : floatWeightsPtr_ = NULL;
718 0 : floatZeroLagsPtr_ = NULL;
719 0 : floatAutoDataPtr_ = NULL;
720 0 : shortCrossDataPtr_ = NULL;
721 0 : intCrossDataPtr_ = NULL;
722 0 : floatCrossDataPtr_ = NULL;
723 :
724 0 : }
725 :
726 :
727 0 : DataDump::DataDump( vector<vector<uint32_t> > vv_numCrossPolProduct, // /bb/spw
728 : vector<vector<uint32_t> > vv_numAutoPolProduct, // /bb/spw
729 : vector<vector<uint32_t> > vv_numSpectralPoint, // /bb/spw
730 : vector<vector<uint32_t> > vv_numBin, // /bb/spw
731 : vector<vector<Enum<NetSideband> > > vv_e_sideband, // /bb/spw
732 : uint32_t numApc,
733 : vector<uint32_t> v_numSpectralWindow, // /bb
734 : uint32_t numBaseband,
735 : uint32_t numAnt,
736 : CorrelationMode correlationMode,
737 : uint64_t time,
738 : uint64_t timeCentroid,
739 : uint64_t interval,
740 : uint64_t exposure,
741 : uint32_t /*numVal*/, // comment to avoid the unused parameter warning
742 : const int* /*crossData*/, // comment to avoid the unused parameter warning
743 : uint32_t numAutoData,
744 : const float* autoData,
745 : uint32_t numFlags,
746 0 : const uint32_t* flags):
747 : DataStructure( vv_numCrossPolProduct,
748 : vv_numAutoPolProduct,
749 : vv_numSpectralPoint,
750 : vv_numBin,
751 : vv_e_sideband,
752 : numApc,
753 : v_numSpectralWindow,
754 : numBaseband,
755 : numAnt,
756 : correlationMode),
757 0 : integrationNum_(0),
758 0 : subintegrationNum_(0),
759 0 : time_(time),
760 0 : timeCentroid_(timeCentroid),
761 0 : interval_(interval),
762 0 : exposure_(exposure),
763 0 : cuintFlagsPtr_(NULL),
764 0 : clonlonActualTimesPtr_(NULL),
765 0 : clonlonActualDurationsPtr_(NULL),
766 0 : cfloatWeightsPtr_(NULL),
767 0 : cfloatZeroLagsPtr_(NULL),
768 0 : cfloatAutoDataPtr_(NULL),
769 0 : cshortCrossDataPtr_(NULL),
770 0 : cintCrossDataPtr_(NULL),
771 0 : cfloatCrossDataPtr_(NULL)
772 : {
773 0 : uintFlagsPtr_ = new uint32_t[numFlags]; for(uint32_t n=0; n<numFlags; n++)uintFlagsPtr_[n] = flags[n];
774 0 : lonlonActualTimesPtr_ = NULL;
775 0 : lonlonActualDurationsPtr_ = NULL;
776 0 : floatWeightsPtr_ = NULL;
777 :
778 0 : floatZeroLagsPtr_ = NULL;
779 :
780 0 : floatAutoDataPtr_ = new float[numAutoData]; for(uint32_t n=0; n<numAutoData; n++)floatAutoDataPtr_[n] = autoData[n];
781 :
782 0 : shortCrossDataPtr_ = NULL;
783 0 : intCrossDataPtr_ = NULL;
784 0 : floatCrossDataPtr_ = NULL;
785 :
786 0 : }
787 :
788 :
789 0 : DataDump::~DataDump()
790 : {
791 0 : bool coutest=false;
792 0 : if(coutest){
793 0 : cout<<"Destructor DataDump"<<endl;
794 0 : if(uintFlagsPtr_ ) cout<<"delete uintFlagsPtr_"<<endl;
795 0 : if(lonlonActualTimesPtr_ ) cout<<"delete lonlonActualTimesPtr_"<<endl;
796 0 : if(lonlonActualDurationsPtr_ ) cout<<"delete lonlonActualDurationsPtr_"<<endl;
797 0 : if(floatWeightsPtr_ ) cout<<"delete floatWeightsPtr_"<<endl;
798 0 : if(floatZeroLagsPtr_ ) cout<<"delete floatZeroLagsPtr_"<<endl;
799 0 : if(floatAutoDataPtr_ ) cout<<"delete floatAutoDataPtr_"<<endl;
800 0 : if(shortCrossDataPtr_ ) cout<<"delete shortCrossDataPtr_"<<endl;
801 0 : if(intCrossDataPtr_ ) cout<<"delete intCrossDataPtr_"<<endl;
802 0 : if(floatCrossDataPtr_ ) cout<<"delete floatCrossDataPtr_"<<endl;
803 : }
804 0 : if(uintFlagsPtr_ ) delete uintFlagsPtr_;
805 0 : if(lonlonActualTimesPtr_ ) delete lonlonActualTimesPtr_;
806 0 : if(lonlonActualDurationsPtr_ ) delete lonlonActualDurationsPtr_;
807 0 : if(floatWeightsPtr_ ) delete floatWeightsPtr_;
808 0 : if(floatZeroLagsPtr_ ) delete floatZeroLagsPtr_;
809 0 : if(floatAutoDataPtr_ ) delete floatAutoDataPtr_;
810 0 : if(shortCrossDataPtr_ ) delete shortCrossDataPtr_;
811 0 : if(intCrossDataPtr_ ) delete intCrossDataPtr_;
812 0 : if(floatCrossDataPtr_ ) delete floatCrossDataPtr_;
813 0 : }
814 :
815 0 : DataDump::DataDump(const DataDump& a) : DataStructure(a)
816 : {
817 0 : cout<<"Copy constructor DataDump (deep copy)"<<endl;
818 0 : cout<<"ici a.uintFlagsPtr_="<<a.uintFlagsPtr_<<endl;
819 0 : vv_numCrossPolProduct_= a.vv_numCrossPolProduct_;
820 0 : vv_numAutoPolProduct_ = a.vv_numAutoPolProduct_;
821 0 : vv_numSpectralPoint_ = a.vv_numSpectralPoint_;
822 0 : vv_numBin_ = a.vv_numBin_;
823 0 : vv_e_sideband_ = a.vv_e_sideband_;
824 0 : numApc_ = a.numApc_;
825 0 : v_numSpectralWindow_ = a.v_numSpectralWindow_;
826 0 : numBaseband_ = a.numBaseband_;
827 0 : numAnt_ = a.numAnt_;
828 0 : correlationMode_ = a.correlationMode_;
829 0 : axisSequence_ = a.axisSequence_;
830 0 : v_minSize_ = a.v_minSize_;
831 0 : v_maxSize_ = a.v_maxSize_;
832 :
833 0 : integrationNum_ = a.integrationNum_;
834 0 : subintegrationNum_ = a.subintegrationNum_;
835 0 : time_ = a.time_;
836 0 : timeCentroid_ = a.timeCentroid_;
837 0 : interval_ = a.interval_;
838 0 : exposure_ = a.exposure_;
839 :
840 0 : vv_scaleFactor_ = a.vv_scaleFactor_;
841 :
842 0 : es_flagsAxes_ = a.es_flagsAxes_;
843 0 : es_actualTimesAxes_ = a.es_actualTimesAxes_;
844 0 : es_actualDurationsAxes_ = a.es_actualDurationsAxes_;
845 0 : es_weightsAxes_ = a.es_weightsAxes_;
846 :
847 0 : es_zeroLagsAxes_ = a.es_zeroLagsAxes_;
848 :
849 0 : es_autoDataAxes_ = a.es_autoDataAxes_;
850 0 : es_crossDataAxes_ = a.es_crossDataAxes_;
851 :
852 :
853 0 : numFlags_ = a.numFlags_;
854 0 : numActualTimes_ = a.numActualTimes_;
855 0 : numActualDurations_ = a.numActualDurations_;
856 0 : numWeights_ = a.numWeights_;
857 :
858 0 : numZeroLags_ = a.numZeroLags_;
859 :
860 0 : numAutoData_ = a.numAutoData_;
861 0 : numCrossData_ = a.numCrossData_;
862 0 : cout<<"A"<<endl;
863 0 : cout<<"a.cuintFlagsPtr_"<<a.cuintFlagsPtr_<<endl;
864 0 : cout<<"a.flags()="<<a.flags()<<endl;
865 0 : cuintFlagsPtr_ = a.cuintFlagsPtr_;
866 0 : cout<<"B"<<endl;
867 0 : clonlonActualTimesPtr_ = a.clonlonActualTimesPtr_;
868 0 : clonlonActualDurationsPtr_ = a.clonlonActualDurationsPtr_;
869 0 : cfloatWeightsPtr_ = a.cfloatWeightsPtr_;
870 :
871 0 : cfloatZeroLagsPtr_ = a.cfloatZeroLagsPtr_;
872 :
873 0 : cfloatAutoDataPtr_ = a.cfloatAutoDataPtr_;
874 0 : cshortCrossDataPtr_ = a.cshortCrossDataPtr_;
875 0 : cintCrossDataPtr_ = a.cintCrossDataPtr_;
876 0 : cout<<"C"<<endl;
877 0 : cout<<"a.uintFlagsPtr_"<<a.uintFlagsPtr_<<endl;
878 0 : if(a.uintFlagsPtr_){
879 0 : cout<<"a.numFlags_="<<a.numFlags_<<endl;
880 0 : uintFlagsPtr_ = new uint32_t[a.numFlags_];
881 0 : for(uint32_t n=0; n<a.numFlags_; n++) uintFlagsPtr_[n] = a.uintFlagsPtr_[n]; }
882 0 : cout<<"D"<<endl;
883 0 : if(a.lonlonActualTimesPtr_){
884 0 : cout<<"a.numActualTimes_="<<a.numActualTimes_<<endl;
885 0 : lonlonActualTimesPtr_ = new int64_t[numActualTimes_];
886 0 : for(uint32_t n=0; n<numActualTimes_; n++)lonlonActualTimesPtr_[n] = a.lonlonActualTimesPtr_[n]; }
887 0 : if(a.lonlonActualDurationsPtr_){
888 0 : lonlonActualDurationsPtr_ = new int64_t[numActualDurations_];
889 0 : for(uint32_t n=0; n<numActualDurations_; n++)lonlonActualDurationsPtr_[n] = a.lonlonActualDurationsPtr_[n]; }
890 0 : if(a.floatWeightsPtr_){
891 0 : floatWeightsPtr_ = new float[numWeights_];
892 0 : for(uint32_t n=0; n<numWeights_; n++)floatWeightsPtr_[n] = a.floatWeightsPtr_[n]; }
893 :
894 0 : if(a.floatZeroLagsPtr_){
895 0 : floatZeroLagsPtr_ = new float[numZeroLags_];
896 0 : for(uint32_t n=0; n<numZeroLags_; n++)floatZeroLagsPtr_[n] = a.floatZeroLagsPtr_[n]; }
897 0 : if(a.shortCrossDataPtr_){
898 0 : cout<<"a.numCrossData_="<<a.numCrossData_<<endl;
899 0 : cout<<"numCrossData_="<<numCrossData_<<endl;
900 0 : shortCrossDataPtr_ = new short int[numCrossData_];
901 0 : for(uint32_t n=0; n<numCrossData_; n++)shortCrossDataPtr_[n] = a.shortCrossDataPtr_[n]; }
902 0 : if(a.intCrossDataPtr_){
903 0 : intCrossDataPtr_ = new int[numCrossData_];
904 0 : for(uint32_t n=0; n<numCrossData_; n++)intCrossDataPtr_[n] = a.intCrossDataPtr_[n]; }
905 0 : if(a.floatCrossDataPtr_){
906 0 : floatCrossDataPtr_ = new float[numCrossData_];
907 0 : for(uint32_t n=0; n<numCrossData_; n++)floatCrossDataPtr_[n] = a.floatCrossDataPtr_[n]; }
908 0 : cout<<"E"<<endl;
909 0 : cout<<"floatAutoDataPtr_ ="<<floatAutoDataPtr_<<endl;
910 0 : cout<<"a.floatAutoDataPtr_ ="<<a.floatAutoDataPtr_<<endl;
911 0 : if(a.floatAutoDataPtr_){
912 0 : cout<<"a.numAutoData_="<<a.numAutoData_<<endl;
913 0 : cout<<"numAutoData_="<<numAutoData_<<endl;
914 0 : floatAutoDataPtr_ = new float[numAutoData_];
915 0 : for(uint32_t n=0; n<numAutoData_; n++)floatAutoDataPtr_[n] = a.floatAutoDataPtr_[n]; }
916 :
917 0 : cout<<"F"<<endl;
918 :
919 0 : }
920 :
921 0 : DataDump& DataDump::operator = (const DataDump & a)
922 : {
923 0 : if(this == &a)return *this;
924 0 : vv_numCrossPolProduct_= a.vv_numCrossPolProduct_;
925 0 : vv_numAutoPolProduct_ = a.vv_numAutoPolProduct_;
926 0 : vv_numSpectralPoint_ = a.vv_numSpectralPoint_;
927 0 : vv_numBin_ = a.vv_numBin_;
928 0 : vv_e_sideband_ = a.vv_e_sideband_;
929 0 : numApc_ = a.numApc_;
930 0 : v_numSpectralWindow_ = a.v_numSpectralWindow_;
931 0 : numBaseband_ = a.numBaseband_;
932 0 : numAnt_ = a.numAnt_;
933 0 : correlationMode_ = a.correlationMode_;
934 0 : axisSequence_ = a.axisSequence_;
935 0 : v_minSize_ = a.v_minSize_;
936 0 : v_maxSize_ = a.v_maxSize_;
937 :
938 0 : integrationNum_ = a.integrationNum_;
939 0 : subintegrationNum_ = a.subintegrationNum_;
940 0 : time_ = a.time_;
941 0 : timeCentroid_ = a.timeCentroid_;
942 0 : interval_ = a.interval_;
943 0 : exposure_ = a.exposure_;
944 :
945 0 : return *this;
946 : }
947 :
948 : // shape unchanged
949 0 : DataDump DataDump::operator - (const DataDump &rhs)
950 : {
951 0 : uint32_t numD=numAutoData();
952 0 : if(rhs.numAutoData()!=numD){
953 0 : ostringstream os;
954 0 : os << "Cannot subtract a data dump which has " << rhs.numAutoData()
955 0 : <<" data from an other which has "<<numD
956 0 : <<" data";
957 0 : Error( FATAL, os.str());
958 0 : }
959 0 : uint64_t st1 = (time_-interval_)/(uint64_t)2;
960 0 : uint64_t et1 = (time_+interval_)/(uint64_t)2;
961 0 : uint64_t st2 = (rhs.time()-rhs.interval())/(uint64_t)2;
962 0 : uint64_t et2 = (rhs.time()+rhs.interval())/(uint64_t)2;
963 0 : if( st1>et2 || et1<st2)
964 0 : Error( WARNING, (char *) "data difference of dumps overlaping in time");
965 : uint64_t st,et;
966 0 : if(st1<st2)
967 0 : st = st1;
968 : else
969 0 : st = st2;
970 0 : if(et1<et2)
971 0 : et = et2;
972 : else
973 0 : et = et1;
974 :
975 : uint64_t timeCentroid;
976 0 : if(interval_==rhs.interval())
977 0 : timeCentroid = (time_+rhs.time())/(uint64_t)2;
978 : else{
979 0 : double w=interval_/rhs.interval();
980 0 : timeCentroid = (uint64_t) ( (w*time_ + rhs.time())/(w+1.) );
981 : }
982 :
983 0 : uint32_t numF = numD; // TODO (more complex than that!)
984 0 : float* diffFloatData = new float[numD];
985 0 : uint32_t* sumUintFlags = new uint32_t[numF];
986 :
987 0 : if(floatAutoDataPtr_){
988 0 : if(rhs.floatAutoDataPtr_){
989 0 : for(uint32_t nd=0; nd<numD; nd++)
990 0 : diffFloatData[nd] = floatAutoDataPtr_[nd]-rhs.floatAutoDataPtr_[nd];
991 0 : for(uint32_t nf=0; nf<numF; nf++){
992 0 : if(uintFlagsPtr_[nf]!=rhs.uintFlagsPtr_[nf])
993 0 : sumUintFlags[nf]=uintFlagsPtr_[nf]+rhs.uintFlagsPtr_[nf]; // TODO (more complex than that!)
994 : else
995 0 : sumUintFlags[nf]=uintFlagsPtr_[nf];
996 : }
997 : }else{
998 0 : for(uint32_t nd=0; nd<numD; nd++)
999 0 : diffFloatData[nd] = floatAutoDataPtr_[nd]-rhs.cfloatAutoDataPtr_[nd];
1000 0 : for(uint32_t nf=0; nf<numF; nf++){
1001 0 : if(uintFlagsPtr_[nf]!=rhs.cuintFlagsPtr_[nf])
1002 0 : sumUintFlags[nf]=uintFlagsPtr_[nf]+rhs.cuintFlagsPtr_[nf]; // TODO (more complex than that!)
1003 : else
1004 0 : sumUintFlags[nf]=uintFlagsPtr_[nf];
1005 : }
1006 : }
1007 : }else{
1008 0 : if(rhs.floatAutoDataPtr_){
1009 0 : for(uint32_t nd=0; nd<numD; nd++)
1010 0 : diffFloatData[nd] = cfloatAutoDataPtr_[nd]-rhs.floatAutoDataPtr_[nd];
1011 0 : for(uint32_t nf=0; nf<numF; nf++){
1012 0 : if(cuintFlagsPtr_[nf]!=rhs.uintFlagsPtr_[nf])
1013 0 : sumUintFlags[nf]=cuintFlagsPtr_[nf]+rhs.uintFlagsPtr_[nf]; // TODO (more complex than that!)
1014 : else
1015 0 : sumUintFlags[nf]=cuintFlagsPtr_[nf];
1016 : }
1017 : }else{
1018 0 : for(uint32_t nd=0; nd<numD; nd++)
1019 0 : diffFloatData[nd] = cfloatAutoDataPtr_[nd]-rhs.cfloatAutoDataPtr_[nd];
1020 0 : for(uint32_t nf=0; nf<numF; nf++){
1021 0 : if(cuintFlagsPtr_[nf]!=rhs.cuintFlagsPtr_[nf])
1022 0 : sumUintFlags[nf]=cuintFlagsPtr_[nf]+rhs.cuintFlagsPtr_[nf]; // TODO (more complex than that!)
1023 : else
1024 0 : sumUintFlags[nf]=cuintFlagsPtr_[nf];
1025 : }
1026 : }
1027 : }
1028 0 : uint32_t numV=0; // TODO
1029 0 : int* diffCorrData=NULL;
1030 0 : return DataDump( vv_numCrossPolProduct_,
1031 0 : vv_numAutoPolProduct_,
1032 0 : vv_numSpectralPoint_,
1033 0 : vv_numBin_,
1034 0 : vv_e_sideband_,
1035 : numApc_,
1036 0 : v_numSpectralWindow_,
1037 : numBaseband_,
1038 : numAnt_,
1039 : correlationMode_,
1040 0 : (time_+rhs.time())/(uint64_t) 2,
1041 : timeCentroid,
1042 : et-st,
1043 0 : exposure_+rhs.exposure(),
1044 : numV, diffCorrData,
1045 : numD, diffFloatData,
1046 : numF, sumUintFlags
1047 0 : );
1048 : }
1049 :
1050 0 : DataDump DataDump::operator + (const DataDump &rhs)
1051 : {
1052 0 : uint32_t numD=numAutoData();
1053 0 : if(rhs.numAutoData()!=numD){
1054 0 : ostringstream os;
1055 0 : os << "Cannot add a data dump which has " << numD
1056 0 : <<" data with an other which has "<<rhs.numAutoData()
1057 0 : <<" data";
1058 0 : Error( FATAL, os.str());
1059 0 : }
1060 0 : uint64_t st1 = (time_-interval_)/(uint64_t)2;
1061 0 : uint64_t et1 = (time_+interval_)/(uint64_t)2;
1062 0 : uint64_t st2 = (rhs.time()-rhs.interval())/(uint64_t)2;
1063 0 : uint64_t et2 = (rhs.time()+rhs.interval())/(uint64_t)2;
1064 0 : if( st1>et2 || et1<st2)
1065 0 : Error( WARNING, (char *) "sum of data dumps which overlap in time");
1066 : uint64_t st,et;
1067 0 : if(st1<st2)
1068 0 : st = st1;
1069 : else
1070 0 : st = st2;
1071 0 : if(et1<et2)
1072 0 : et = et2;
1073 : else
1074 0 : et = et1;
1075 :
1076 : uint64_t timeCentroid;
1077 0 : if(interval_==rhs.interval())
1078 0 : timeCentroid = (time_+rhs.time())/(uint64_t)2;
1079 : else{
1080 0 : double w=interval_/rhs.interval();
1081 0 : timeCentroid = (uint64_t) ( (w*time_ + rhs.time())/(w+1.) );
1082 : }
1083 0 : uint32_t numF = numD; // TODO (more complex than that!)
1084 0 : float* sumFloatData = new float[numD];
1085 0 : uint32_t* sumUintFlags = new uint32_t[numF];
1086 :
1087 0 : if(floatAutoDataPtr_){
1088 0 : if(rhs.floatAutoDataPtr_){
1089 0 : for(uint32_t nd=0; nd<numD; nd++)
1090 0 : sumFloatData[nd] = 0.5*(floatAutoDataPtr_[nd]+rhs.floatAutoDataPtr_[nd]);
1091 0 : for(uint32_t nf=0; nf<numF; nf++){
1092 0 : if(uintFlagsPtr_[nf]!=rhs.uintFlagsPtr_[nf])
1093 0 : sumUintFlags[nf]=uintFlagsPtr_[nf]+rhs.uintFlagsPtr_[nf]; // TODO (more complex than that!)
1094 : else
1095 0 : sumUintFlags[nf]=uintFlagsPtr_[nf];
1096 : }
1097 : }else{
1098 0 : for(uint32_t nd=0; nd<numD; nd++)
1099 0 : sumFloatData[nd] = 0.5*(floatAutoDataPtr_[nd]+rhs.cfloatAutoDataPtr_[nd]);
1100 0 : for(uint32_t nf=0; nf<numF; nf++){
1101 0 : if(uintFlagsPtr_[nf]!=rhs.cuintFlagsPtr_[nf])
1102 0 : sumUintFlags[nf]=uintFlagsPtr_[nf]+rhs.cuintFlagsPtr_[nf]; // TODO (more complex than that!)
1103 : else
1104 0 : sumUintFlags[nf]=uintFlagsPtr_[nf];
1105 : }
1106 : }
1107 : }else{
1108 0 : if(rhs.floatAutoDataPtr_){
1109 0 : for(uint32_t nd=0; nd<numD; nd++)
1110 0 : sumFloatData[nd] = 0.5*(cfloatAutoDataPtr_[nd]+rhs.floatAutoDataPtr_[nd]);
1111 0 : for(uint32_t nf=0; nf<numF; nf++){
1112 0 : if(cuintFlagsPtr_[nf]!=rhs.uintFlagsPtr_[nf])
1113 0 : sumUintFlags[nf]=cuintFlagsPtr_[nf]+rhs.uintFlagsPtr_[nf]; // TODO (more complex than that!)
1114 : else
1115 0 : sumUintFlags[nf]=cuintFlagsPtr_[nf];
1116 : }
1117 : }else{
1118 0 : for(uint32_t nd=0; nd<numD; nd++)
1119 0 : sumFloatData[nd] = 0.5*(cfloatAutoDataPtr_[nd]+rhs.cfloatAutoDataPtr_[nd]);
1120 0 : for(uint32_t nf=0; nf<numF; nf++){
1121 0 : if(cuintFlagsPtr_[nf]!=rhs.cuintFlagsPtr_[nf])
1122 0 : sumUintFlags[nf]=cuintFlagsPtr_[nf]+rhs.cuintFlagsPtr_[nf]; // TODO (more complex than that!)
1123 : else
1124 0 : sumUintFlags[nf]=cuintFlagsPtr_[nf];
1125 : }
1126 : }
1127 : }
1128 0 : uint32_t numVal=0; // TODO
1129 0 : int* sumVisData=NULL;
1130 0 : return DataDump (vv_numCrossPolProduct_,
1131 0 : vv_numAutoPolProduct_,
1132 0 : vv_numSpectralPoint_,
1133 0 : vv_numBin_,
1134 0 : vv_e_sideband_,
1135 : numApc_,
1136 0 : v_numSpectralWindow_,
1137 : numBaseband_,
1138 : numAnt_,
1139 : correlationMode_,
1140 0 : (time_+rhs.time())/(uint64_t) 2,
1141 : timeCentroid,
1142 : et-st,
1143 0 : exposure_+rhs.exposure(),
1144 : numVal, sumVisData,
1145 : numD, sumFloatData,
1146 : numF, sumUintFlags
1147 0 : );
1148 : }
1149 :
1150 :
1151 : // operations modifying the structure
1152 : // DataDump DataDump::spectralAverage()
1153 : // {
1154 :
1155 : // }
1156 :
1157 : // Attachers and importers
1158 :
1159 0 : void DataDump::attachFlags( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an, // comment to avoid the unused parameter warning
1160 : uint32_t numData, const uint32_t* flagsPtr){
1161 0 : cuintFlagsPtr_ = flagsPtr;
1162 0 : es_flagsAxes_ = es_an;
1163 0 : numFlags_ = numData;
1164 0 : }
1165 0 : void DataDump::importFlags( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an, // comment to avoid the unused parameter warning
1166 : uint32_t numData, const uint32_t* flagsPtr){
1167 0 : cuintFlagsPtr_ = NULL;
1168 0 : if(uintFlagsPtr_){
1169 0 : if(numFlags_!=numData){
1170 0 : delete uintFlagsPtr_;
1171 0 : uintFlagsPtr_ = new uint32_t[numData];
1172 : }
1173 : }else{
1174 0 : uintFlagsPtr_ = new uint32_t[numData];
1175 : }
1176 0 : for(uint32_t n=0; n<numData; n++)uintFlagsPtr_[n] = flagsPtr[n];
1177 0 : es_flagsAxes_ = es_an;
1178 0 : numFlags_ = numData;
1179 0 : }
1180 :
1181 0 : void DataDump::attachActualTimes( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an, // comment to avoid the unused parameter warning
1182 : uint32_t numData, const int64_t * actualTimesPtr){
1183 0 : clonlonActualTimesPtr_ = actualTimesPtr;
1184 0 : es_actualTimesAxes_ = es_an;
1185 0 : numActualTimes_ = numData;
1186 0 : }
1187 0 : void DataDump::importActualTimes( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an, // comment to avoid the unused parameter warning
1188 : uint32_t numData, const int64_t * actualTimesPtr){
1189 0 : clonlonActualTimesPtr_ = NULL;
1190 0 : if(lonlonActualTimesPtr_){
1191 0 : if(numActualTimes_!=numData){
1192 0 : delete lonlonActualTimesPtr_;
1193 0 : lonlonActualTimesPtr_ = new int64_t[numData];
1194 : }
1195 : }else{
1196 0 : lonlonActualTimesPtr_ = new int64_t[numData];
1197 : }
1198 0 : for(uint32_t n=0; n<numData; n++)lonlonActualTimesPtr_[n] = actualTimesPtr[n];
1199 0 : es_actualTimesAxes_ = es_an;
1200 0 : numActualTimes_ = numData;
1201 0 : }
1202 :
1203 :
1204 0 : void DataDump::attachActualDurations( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an, // comment to avoid the unused parameter warning
1205 : uint32_t numData, const int64_t * actualDurationsPtr){
1206 0 : clonlonActualDurationsPtr_ = actualDurationsPtr;
1207 0 : es_actualDurationsAxes_ = es_an;
1208 0 : numActualDurations_ = numData;
1209 0 : }
1210 0 : void DataDump::importActualDurations( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an, // comment to avoid the unused parameter warning
1211 : uint32_t numData, const int64_t * actualDurationsPtr){
1212 0 : clonlonActualDurationsPtr_ = NULL;
1213 0 : if(lonlonActualDurationsPtr_){
1214 0 : if(numActualDurations_!=numData){
1215 0 : delete lonlonActualDurationsPtr_;
1216 0 : lonlonActualDurationsPtr_ = new int64_t[numData];
1217 : }
1218 : }else{
1219 0 : lonlonActualDurationsPtr_ = new int64_t[numData];
1220 : }
1221 0 : for(uint32_t n=0; n<numData; n++)lonlonActualDurationsPtr_[n] = actualDurationsPtr[n];
1222 0 : es_actualDurationsAxes_ = es_an;
1223 0 : numActualDurations_ = numData;
1224 0 : }
1225 :
1226 0 : void DataDump::attachZeroLags( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an, // comment to avoid the unused parameter warning
1227 : uint32_t numData, const float* zeroLagsPtr){
1228 0 : cfloatZeroLagsPtr_ = zeroLagsPtr;
1229 0 : es_zeroLagsAxes_ = es_an;
1230 0 : numZeroLags_ = numData;
1231 0 : }
1232 0 : void DataDump::importZeroLags( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an, // comment to avoid the unused parameter warning
1233 : uint32_t numData, const float* zeroLagsPtr){
1234 0 : cfloatZeroLagsPtr_ = NULL;
1235 0 : if(floatZeroLagsPtr_){
1236 0 : if(numZeroLags_!=numData){
1237 0 : delete floatZeroLagsPtr_;
1238 0 : floatZeroLagsPtr_ = new float[numData];
1239 : }
1240 : }else{
1241 0 : floatZeroLagsPtr_ = new float[numData];
1242 : }
1243 0 : for(uint32_t n=0; n<numData; n++)floatZeroLagsPtr_[n] = zeroLagsPtr[n];
1244 0 : es_zeroLagsAxes_ = es_an;
1245 0 : numZeroLags_ = numData;
1246 0 : }
1247 :
1248 0 : void DataDump::attachAutoData( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an,
1249 : uint32_t numData, const float* autoDataPtr){
1250 0 : cfloatAutoDataPtr_ = autoDataPtr;
1251 0 : es_autoDataAxes_ = es_an;
1252 0 : numAutoData_ = numData;
1253 :
1254 0 : if(uintFlagsPtr_)cout<<"there are imported flags"<<endl;
1255 : //cout<<"uintFlagsPtr_="<< uintFlagsPtr_<<endl;
1256 :
1257 0 : }
1258 0 : void DataDump::importAutoData( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an,
1259 : uint32_t numData, const float* autoDataPtr){
1260 0 : cfloatAutoDataPtr_ = NULL;
1261 0 : if(floatAutoDataPtr_){
1262 0 : if(numAutoData_!=numData){
1263 0 : delete floatAutoDataPtr_;
1264 0 : floatAutoDataPtr_ = new float[numData];
1265 : }
1266 : }else{
1267 0 : floatAutoDataPtr_ = new float[numData];
1268 : }
1269 0 : for(uint32_t n=0; n<numData; n++)floatAutoDataPtr_[n] = autoDataPtr[n];
1270 0 : es_autoDataAxes_ = es_an;
1271 0 : numAutoData_ = numData;
1272 0 : }
1273 :
1274 0 : void DataDump::attachCrossData( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an,
1275 : uint32_t numData, const short int* crossDataPtr){
1276 0 : cintCrossDataPtr_ = NULL;
1277 0 : cfloatCrossDataPtr_ = NULL;
1278 0 : cshortCrossDataPtr_ = crossDataPtr;
1279 0 : es_crossDataAxes_ = es_an;
1280 0 : numCrossData_ = numData;
1281 0 : }
1282 0 : void DataDump::importCrossData( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an,
1283 : uint32_t numData, const short int* crossDataPtr){
1284 0 : cintCrossDataPtr_ = NULL;
1285 0 : cfloatCrossDataPtr_ = NULL;
1286 0 : cshortCrossDataPtr_ = NULL;
1287 0 : if(shortCrossDataPtr_){
1288 0 : if(numCrossData_!=numData){
1289 0 : delete shortCrossDataPtr_;
1290 0 : shortCrossDataPtr_ = new short int[numData];
1291 : }
1292 : }else{
1293 0 : shortCrossDataPtr_ = new short int[numData];
1294 : }
1295 0 : for(uint32_t n=0; n<numData; n++)shortCrossDataPtr_[n] = crossDataPtr[n];
1296 0 : es_crossDataAxes_ = es_an;
1297 0 : numCrossData_ = numData;
1298 0 : }
1299 :
1300 0 : void DataDump::attachCrossData( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an,
1301 : uint32_t numData, const int* crossDataPtr){
1302 0 : cshortCrossDataPtr_ = NULL;
1303 0 : cintCrossDataPtr_ = crossDataPtr;
1304 0 : cfloatCrossDataPtr_ = NULL;
1305 0 : es_crossDataAxes_ = es_an;
1306 0 : numCrossData_ = numData;
1307 0 : }
1308 0 : void DataDump::importCrossData( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an,
1309 : uint32_t numData, const int* crossDataPtr){
1310 0 : cshortCrossDataPtr_ = NULL;
1311 0 : cintCrossDataPtr_ = NULL;
1312 0 : cfloatCrossDataPtr_ = NULL;
1313 0 : if(intCrossDataPtr_){
1314 0 : if(numCrossData_!=numData){
1315 0 : delete intCrossDataPtr_;
1316 0 : intCrossDataPtr_ = new int[numData];
1317 : }
1318 : }else{
1319 0 : intCrossDataPtr_ = new int[numData];
1320 : }
1321 0 : for(uint32_t n=0; n<numData; n++)intCrossDataPtr_[n] = crossDataPtr[n];
1322 0 : es_crossDataAxes_ = es_an;
1323 0 : numCrossData_ = numData;
1324 0 : }
1325 :
1326 :
1327 0 : void DataDump::attachCrossData( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an,
1328 : uint32_t numData, const float* crossDataPtr){
1329 0 : cshortCrossDataPtr_ = NULL;
1330 0 : cintCrossDataPtr_ = NULL;
1331 0 : cfloatCrossDataPtr_ = crossDataPtr;
1332 0 : es_crossDataAxes_ = es_an;
1333 0 : numCrossData_ = numData;
1334 0 : }
1335 0 : void DataDump::importCrossData( uint32_t /*declaredSize*/, EnumSet<AxisName> es_an,
1336 : uint32_t numData, const float* crossDataPtr){
1337 0 : cshortCrossDataPtr_ = NULL;
1338 0 : cintCrossDataPtr_ = NULL;
1339 0 : cfloatCrossDataPtr_ = NULL;
1340 0 : if(floatCrossDataPtr_){
1341 0 : if(numCrossData_!=numData){
1342 0 : delete floatCrossDataPtr_;
1343 0 : floatCrossDataPtr_ = new float[numData];
1344 : }
1345 : }else{
1346 0 : floatCrossDataPtr_ = new float[numData];
1347 : }
1348 0 : for(uint32_t n=0; n<numData; n++)floatCrossDataPtr_[n] = crossDataPtr[n];
1349 0 : es_crossDataAxes_ = es_an;
1350 0 : numCrossData_ = numData;
1351 0 : }
1352 :
1353 0 : void DataDump::setScaleFactor(vector<vector<float> > vv_scaleFactor){
1354 0 : if(vv_scaleFactor.size()!=vv_numCrossPolProduct_.size())
1355 0 : Error(FATAL,
1356 : (char *) "vv_scaleFactor, of size %d, does not have a size equal to %d (i.e. numBaseband)",
1357 : vv_numCrossPolProduct_.size(),numBaseband_);
1358 0 : for(uint32_t nbb=0; nbb<vv_numCrossPolProduct_.size(); nbb++)
1359 0 : if(vv_scaleFactor[nbb].size()!=vv_numCrossPolProduct_[nbb].size())
1360 0 : Error(FATAL,
1361 : (char *) "vv_scaleFactor[%d], of size %d, does not have a size equal to the nb on spw for that baseband",
1362 0 : nbb,vv_numCrossPolProduct_[nbb].size());
1363 0 : vv_scaleFactor_ = vv_scaleFactor;
1364 : // linearization for fast access:
1365 0 : for(uint32_t nbb=0; nbb<vv_scaleFactor.size(); nbb++){
1366 0 : for(uint32_t nspw=0; nspw<vv_scaleFactor[nbb].size(); nspw++){
1367 0 : v_scaleFactor_.push_back(vv_scaleFactor[nbb][nspw]);
1368 : }
1369 : }
1370 0 : return;
1371 : }
1372 :
1373 : // Setters to identify the project structure context:
1374 0 : uint32_t DataDump::setIntegration(uint32_t integNum){
1375 0 : if(integrationNum_){
1376 0 : if(integNum==integrationNum_)return integrationNum_;
1377 0 : Error(WARNING,
1378 : (char *) "This dump has already been identified with the integration number %d;\n it is not allowed to tag it again",
1379 : integrationNum_);
1380 0 : return 0;
1381 : }
1382 0 : integrationNum_=integNum;
1383 0 : return integrationNum_;
1384 : }
1385 :
1386 0 : uint32_t DataDump::setSubintegration(uint32_t integNum, uint32_t subintegNum){
1387 0 : if(setIntegration(integNum)){
1388 0 : if(subintegNum==subintegrationNum_)return integrationNum_;
1389 0 : if(subintegrationNum_)
1390 0 : Error(WARNING,
1391 : (char *) "This dump has already been identified with the subintegration number %d;\n it is not allowed to tag it again",
1392 : subintegrationNum_);
1393 0 : subintegrationNum_=subintegNum;
1394 0 : return subintegNum;
1395 : }
1396 0 : return 0;
1397 : }
1398 :
1399 0 : uint32_t DataDump::setContextUsingProjectPath(string projectPathUri){
1400 0 : string::size_type i=0, p=0 ;
1401 : // uint32_t i=0, p=0;
1402 0 : vector<uint32_t> v_node;
1403 0 : while(p!=string::npos){
1404 0 : p = projectPathUri.find("/",i);
1405 0 : if(p!=string::npos){
1406 0 : v_node.push_back((uint32_t)atoi(projectPathUri.substr(i,p-i).c_str()));
1407 0 : i = p+1;
1408 : }else{
1409 0 : v_node.push_back((uint32_t)atoi(projectPathUri.substr(i,projectPathUri.length()).c_str()));
1410 : }
1411 : }
1412 0 : if(v_node.size()==5)
1413 : //return setSubintegration(v_node[4],v_node[5]);
1414 0 : return setSubintegration(v_node[3],v_node[4]);
1415 0 : else if(v_node.size()==4)
1416 : // return setIntegration(v_node[4]);
1417 0 : return setIntegration(v_node[3]);
1418 0 : return 0;
1419 0 : }
1420 :
1421 :
1422 : // Accessors
1423 0 : uint64_t DataDump::time() const
1424 : {
1425 0 : return time_;
1426 : }
1427 :
1428 0 : uint64_t DataDump::timeCentroid() const
1429 : {
1430 0 : return timeCentroid_;
1431 : }
1432 :
1433 0 : uint64_t DataDump::interval() const
1434 : {
1435 0 : return interval_;
1436 : }
1437 :
1438 0 : uint64_t DataDump::exposure() const
1439 : {
1440 0 : return exposure_;
1441 : }
1442 :
1443 :
1444 0 : uint32_t DataDump::integrationNum()
1445 : {
1446 0 : return integrationNum_;
1447 : }
1448 :
1449 0 : uint32_t DataDump::subintegrationNum()
1450 : {
1451 0 : return subintegrationNum_;
1452 : }
1453 :
1454 0 : float DataDump::scaleFactor(uint32_t nbb, uint32_t nspw){
1455 0 : if(nbb<vv_scaleFactor_.size()){
1456 0 : if(nspw<vv_scaleFactor_[nbb].size()){
1457 0 : return vv_scaleFactor_[nbb][nspw];
1458 : }else{
1459 0 : Error(FATAL,(char *) "spectral window index %d too large for %d spectral windows for baseband index %d",
1460 0 : nspw,vv_scaleFactor_[nbb].size(),nbb);
1461 : }
1462 : }else{
1463 0 : Error(FATAL,(char *) "baseband index %d too large for %d basebands",
1464 : nbb,vv_scaleFactor_.size());
1465 : }
1466 0 : return 0;
1467 : }
1468 :
1469 0 : float DataDump::scaleFactor(uint32_t ndd){
1470 0 : bool coutest=false;
1471 0 : if (coutest) cout << "size of v_scaleFactor_ = " << v_scaleFactor_.size() << ", ndd = " << ndd << endl;
1472 0 : return v_scaleFactor_.at(ndd);
1473 : }
1474 :
1475 :
1476 0 : const float* DataDump::autoData() const{
1477 0 : if(floatAutoDataPtr_) // imported data made available read-only
1478 0 : return floatAutoDataPtr_;
1479 : else
1480 0 : return cfloatAutoDataPtr_; // attached data made available read-only
1481 : }
1482 :
1483 0 : const short* DataDump::crossDataShort() const{
1484 0 : if(shortCrossDataPtr_)
1485 0 : return shortCrossDataPtr_;
1486 : else
1487 0 : return cshortCrossDataPtr_;
1488 : }
1489 :
1490 0 : const int* DataDump::crossDataLong() const{
1491 0 : if(intCrossDataPtr_)
1492 0 : return intCrossDataPtr_;
1493 : else
1494 0 : return cintCrossDataPtr_;
1495 : }
1496 :
1497 0 : const float* DataDump::crossDataFloat() const{
1498 0 : if(floatCrossDataPtr_)
1499 0 : return floatCrossDataPtr_;
1500 : else
1501 0 : return cfloatCrossDataPtr_;
1502 : }
1503 :
1504 :
1505 0 : const uint32_t* DataDump::flags() const
1506 : {
1507 0 : bool coutest=false;
1508 0 : if(coutest){
1509 0 : if(uintFlagsPtr_)
1510 0 : cout<<"return flags owned by datadump"<<endl;
1511 0 : if(cuintFlagsPtr_)
1512 0 : cout<<"return flags which have been attached to datadump"<<endl;
1513 : }
1514 0 : if(uintFlagsPtr_)
1515 0 : return uintFlagsPtr_;
1516 : else
1517 0 : return cuintFlagsPtr_;
1518 : return NULL;
1519 : }
1520 :
1521 :
1522 0 : const int64_t* DataDump::actualTimes() const
1523 : {
1524 0 : if(lonlonActualTimesPtr_)
1525 0 : return lonlonActualTimesPtr_;
1526 : else
1527 0 : return clonlonActualTimesPtr_;
1528 : return NULL;
1529 : }
1530 :
1531 0 : const int64_t* DataDump::actualDurations() const
1532 : {
1533 0 : bool coutest=false;
1534 0 : if(coutest){
1535 0 : if(lonlonActualDurationsPtr_)
1536 0 : cout<<"return actualDurations owned by datadump"<<endl;
1537 0 : if(clonlonActualDurationsPtr_)
1538 0 : cout<<"return actualDurations which have been attached to datadump"<<endl;
1539 : }
1540 0 : if(lonlonActualDurationsPtr_)
1541 0 : return lonlonActualDurationsPtr_;
1542 : else
1543 0 : return clonlonActualDurationsPtr_;
1544 : return NULL;
1545 : }
1546 :
1547 0 : const float* DataDump::zeroLags() const
1548 : {
1549 0 : if(floatZeroLagsPtr_)
1550 0 : return floatZeroLagsPtr_;
1551 : else
1552 0 : return cfloatZeroLagsPtr_;
1553 : return NULL;
1554 : }
1555 :
1556 0 : uint32_t DataDump::floatData(vector<vector<vector<float> > >&)
1557 : {
1558 :
1559 : // for(uint32_t nbb=0; nbb<numBaseband_; nbb++){
1560 : // v_sizes[nbb].push_back(numSpectralWindow[nbb]);
1561 : // }
1562 : // if(numPolProduct>1) v_sizes.push_back(numPolProduct);
1563 : // if(numSpectralPoint>1) v_sizes.push_back(numSpectralPoint);
1564 : // if(numBin>1) v_sizes.push_back(numBin);
1565 : // if(numApc>1) v_sizes.push_back(numApc);
1566 : // if(numSpectralWindow>1) v_sizes.push_back(numSpectralWindow);
1567 : // if(numBaseband>1) v_sizes.push_back(numBaseband);
1568 : // if(numAnt>1) v_sizes.push_back(numAnt);
1569 0 : uint32_t dim=0;
1570 0 : return dim;
1571 : }
1572 0 : uint32_t DataDump::floatData(vector<vector<vector<float*> > >& /*vvv*/) // comment to avoid the unused parameter warning
1573 : {
1574 0 : uint32_t dim=0;
1575 0 : return dim;
1576 : }
1577 :
1578 0 : uint32_t DataDump::floatData(vector<vector<vector<vector<float> > > >& /*vvvv*/) // comment to avoid the unused parameter warning
1579 : {
1580 0 : uint32_t dim=0;
1581 0 : return dim;
1582 : }
1583 :
1584 :
1585 0 : uint32_t DataDump::floatData(vector<vector<vector<vector<vector<float> > > > >& /*vvvvv*/)
1586 : {
1587 : // uint32_t nd;
1588 : // vvvvvvv.resize(numAnt_);
1589 : // for(uint32_t na=0; na<numAnt_; na++){
1590 : // vvvvvvv[na].resize(numBaseband_);
1591 :
1592 : // for(uint32_t nbb=0; nbb<numBaseband_; nbb){
1593 : // vvvvvvv[na][nbb].resize(v_numSpectralWindow_[nbb]);
1594 :
1595 : // for(uint32_t nspw=0; nspw<v_numSpectralWindow_[nbb]; nspw++){
1596 : // vvvvvvv[na][nbb][nspw].resize(vv_numBin_[nbb][nspw]);
1597 :
1598 : // for(uint32_t nb=0; nb<vv_numBin_[nbb][nspw]; nb++){
1599 : // vvvvvvv[na][nbb][nspw][nb].resize(vv_numBin_[nbb][nspw]);
1600 :
1601 : // for(uint32_t napc=0; napc<numApc_; napc++){
1602 : // vvvvvvv[na][nbb][nb][nspw][nb].resize(numApc_);
1603 :
1604 :
1605 : // for(uint32_t nsp=0; nsp<vv_numSpectralPoint_[nbb][nspw] nsp++){
1606 : // vvvvvvv[na][nbb][nb][nspw][nb][nsp].resize(vv_numPolProduct_[nbb][nspw]);
1607 :
1608 : // for(uint32_t np=0; np<vv_numPolProduct_[nbb][nspw]; np++)
1609 : // vvvvvvv[na][nbb][nb][nspw][nb][nsp].push-back(*floatDataPtr_[nd++]);
1610 :
1611 : // }
1612 : // }
1613 : // }
1614 : // }
1615 : // }
1616 : // }
1617 :
1618 0 : uint32_t dim=0;
1619 0 : return dim;
1620 :
1621 : }
1622 :
1623 :
1624 : // ============================================================================================
1625 : // Integration -> DataDump -> DataStructure
1626 : // ============================================================================================
1627 :
1628 : // Integration::Integration()
1629 : // {
1630 : // }
1631 :
1632 0 : Integration::Integration( vector<vector<uint32_t> > vv_numPolProduct, // /bb/spw
1633 : vector<vector<uint32_t> > vv_numSpectralPoint, // /bb/spw
1634 : vector<vector<uint32_t> > vv_numBin, // /bb/spw
1635 : vector<vector<Enum<NetSideband> > > vv_e_sideband, // /bb/spw
1636 : uint32_t numApc,
1637 : vector<uint32_t> v_numSpectralWindow, // /bb
1638 : uint32_t numBaseband,
1639 : uint32_t numAnt,
1640 : CorrelationMode correlationMode,
1641 : uint64_t time,
1642 : uint64_t timeCentroid,
1643 : uint64_t interval,
1644 : uint64_t exposure,
1645 : float* floatData,
1646 0 : uint32_t integrationNum):
1647 : DataDump( vv_numPolProduct,
1648 : vv_numSpectralPoint,
1649 : vv_numBin,
1650 : vv_e_sideband,
1651 : numApc,
1652 : v_numSpectralWindow,
1653 : numBaseband,
1654 : numAnt,
1655 : correlationMode,
1656 : time,
1657 : timeCentroid,
1658 : interval,
1659 : exposure,
1660 0 : floatData)
1661 : {
1662 0 : integrationNum_ = integrationNum;
1663 0 : subintegrationNum_ = 0;
1664 0 : }
1665 :
1666 0 : Integration::Integration( vector<vector<uint32_t> > vv_numPolProduct, // /bb/spw
1667 : vector<vector<uint32_t> > vv_numSpectralPoint, // /bb/spw
1668 : vector<vector<uint32_t> > vv_numBin, // /bb/spw
1669 : vector<vector<Enum<NetSideband> > > vv_e_sideband, // /bb/spw
1670 : uint32_t numApc,
1671 : vector<uint32_t> v_numSpectralWindow, // /bb
1672 : uint32_t numBaseband,
1673 : uint32_t numAnt,
1674 : CorrelationMode correlationMode,
1675 : uint64_t time,
1676 : uint64_t timeCentroid,
1677 : uint64_t interval,
1678 : uint64_t exposure,
1679 : float* floatData,
1680 : uint32_t* dataFlags,
1681 0 : uint32_t integrationNum):
1682 : DataDump( vv_numPolProduct,
1683 : vv_numSpectralPoint,
1684 : vv_numBin,
1685 : vv_e_sideband,
1686 : numApc,
1687 : v_numSpectralWindow,
1688 : numBaseband,
1689 : numAnt,
1690 : correlationMode,
1691 : time,
1692 : timeCentroid,
1693 : interval,
1694 : exposure,
1695 : floatData,
1696 0 : dataFlags)
1697 : {
1698 0 : integrationNum_ = integrationNum;
1699 0 : subintegrationNum_ = 0;
1700 0 : }
1701 :
1702 0 : Integration::~Integration()
1703 : {
1704 0 : }
1705 :
1706 0 : Integration::Integration( const Integration & a) : DataDump(a)
1707 : {
1708 0 : cout<<"Copy constructor Integration"<<endl;
1709 0 : vv_numCrossPolProduct_= a.vv_numCrossPolProduct_;
1710 0 : vv_numAutoPolProduct_ = a.vv_numAutoPolProduct_;
1711 0 : vv_numSpectralPoint_ = a.vv_numSpectralPoint_;
1712 0 : vv_numBin_ = a.vv_numBin_;
1713 0 : vv_e_sideband_ = a.vv_e_sideband_;
1714 0 : numApc_ = a.numApc_;
1715 0 : v_numSpectralWindow_ = a.v_numSpectralWindow_;
1716 0 : numBaseband_ = a.numBaseband_;
1717 0 : numAnt_ = a.numAnt_;
1718 0 : correlationMode_ = a.correlationMode_;
1719 0 : axisSequence_ = a.axisSequence_;
1720 0 : v_minSize_ = a.v_minSize_;
1721 0 : v_maxSize_ = a.v_maxSize_;
1722 :
1723 0 : integrationNum_ = a.integrationNum_;
1724 0 : subintegrationNum_ = a.subintegrationNum_;
1725 0 : time_ = a.time_;
1726 0 : timeCentroid_ = a.timeCentroid_;
1727 0 : interval_ = a.interval_;
1728 0 : exposure_ = a.exposure_;
1729 :
1730 :
1731 : // int nd=a.numData();
1732 : // if(a.floatDataPtr_){
1733 : // floatDataPtr_ = new float[nd]; for(int n=0; n<nd; n++)floatDataPtr_[n] = a.floatDataPtr_[n];
1734 : // }else{
1735 : // floatDataPtr_=a.floatDataPtr_;
1736 : // }
1737 : // if(a.dataFlagsPtr_){
1738 : // dataFlagsPtr_ = new uint32_t[nd]; for(int n=0; n<nd; n++)dataFlagsPtr_[n] = a.dataFlagsPtr_[n];
1739 : // }else{
1740 : // dataFlagsPtr_=a.dataFlagsPtr_;
1741 : // }
1742 :
1743 0 : integrationNum_ = a.integrationNum_;
1744 0 : }
1745 :
1746 :
1747 :
1748 : }
|