source: trunk/src/SDContainer.cc @ 13

Last change on this file since 13 was 7, checked in by mmarquar, 20 years ago

Changed Tsys vector to be of the same dimensionality as the spectrum. This makes it easier to use.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1//#---------------------------------------------------------------------------
2//# SDContainer.cc: A container class for single dish integrations
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# Malte Marquarding, ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//#        Internet email: Malte.Marquarding@csiro.au
23//#        Postal address: Malte Marquarding,
24//#                        Australia Telescope National Facility,
25//#                        P.O. Box 76,
26//#                        Epping, NSW, 2121,
27//#                        AUSTRALIA
28//#
29//# $Id:
30//#---------------------------------------------------------------------------
31#include <aips/Tables/Table.h>
32#include <aips/Arrays/IPosition.h>
33#include <aips/Arrays/ArrayAccessor.h>
34#include <aips/Arrays/Matrix.h>
35
36#include "SDContainer.h"
37
38using namespace atnf_sd;
39
40SDContainer::SDContainer(uInt nBeam, uInt nIF, uInt nChan, uInt nPol)
41  : nBeam_(nBeam),
42  nIF_(nIF),
43  nChan_(nChan),
44  nPol_(nPol),
45  spectrum_(IPosition(4,nBeam,nIF,nChan,nPol)),
46  flags_(IPosition(4,nBeam,nIF,nChan,nPol)),
47  tsys_(IPosition(4,nBeam,nIF,nChan,nPol)) {
48  uChar x = 0;
49  flags_ = ~x;
50}
51
52SDContainer::~SDContainer() {
53}
54
55Bool SDContainer::putSpectrum(const Array<Float>& spec) {
56  spectrum_ = spec;
57}
58Bool SDContainer::putFlags(const Array<uChar>& flag) {
59  flags_ = flag;
60}
61Bool SDContainer::putTsys(const Array<Float>& tsys) {
62  tsys_ = tsys;
63}
64
65Bool SDContainer::setSpectrum(const Matrix<Float>& spec,
66                              uInt whichBeam, uInt whichIF) {
67
68  ArrayAccessor<Float, Axis<0> > aa0(spectrum_);
69  aa0.reset(aa0.begin(whichBeam));
70  ArrayAccessor<Float, Axis<1> > aa1(aa0);
71  aa1.reset(aa1.begin(whichIF));
72 
73  uInt nChan = spec.nrow();
74  uInt nPol  = spec.ncolumn();
75  Vector<Float> pols(nPol);
76  uInt chani = 0;
77  uInt poli = 0;
78  // assert dimensions are the same....
79  for (ArrayAccessor<Float, Axis<2> > i(aa1);i != i.end(); ++i) {
80    pols = spec.row(chani);
81    for (ArrayAccessor<Float, Axis<3> > ii(i);ii != ii.end(); ++ii) {
82      (*ii) = pols[poli];
83      poli++;
84    }
85    poli = 0;
86    chani++;
87  }
88  // unset flags for this spectrum, they might be set again by the
89  // setFlags method
90  IPosition shp = flags_.shape();
91  IPosition start(4,whichBeam,whichIF,0,0);
92  IPosition end(4,whichBeam,whichIF,shp(2)-1,shp(3)-1);
93  Array<uChar> arr(flags_(start,end));
94  arr = uChar(0);
95}
96
97Bool SDContainer::setFlags(const Matrix<uChar>& flag,
98                           uInt whichBeam, uInt whichIF) {
99
100  ArrayAccessor<uChar, Axis<0> > aa0(flags_);
101  aa0.reset(aa0.begin(whichBeam));
102  ArrayAccessor<uChar, Axis<1> > aa1(aa0);
103  aa1.reset(aa1.begin(whichIF));
104 
105  uInt nChan = flag.nrow();
106  uInt nPol  = flag.ncolumn();
107  Vector<uChar> pols(nPol);
108  uInt chani = 0;
109  uInt poli = 0;
110  // assert dimensions are the same....
111  for (ArrayAccessor<uChar, Axis<2> > i(aa1);i != i.end(); ++i) {
112    pols = flag.row(chani);
113    for (ArrayAccessor<uChar, Axis<3> > ii(i);ii != ii.end(); ++ii) {
114      (*ii) = uChar(pols[poli]);
115      poli++;
116    }
117    poli = 0;
118    chani++;
119  }
120}
121
122Bool SDContainer::setTsys(const Vector<Float>& tsys,
123                          uInt whichBeam, uInt whichIF) {
124  ArrayAccessor<Float, Axis<0> > aa0(tsys_);
125  aa0.reset(aa0.begin(whichBeam));
126  ArrayAccessor<Float, Axis<1> > aa1(aa0);
127  aa1.reset(aa1.begin(whichIF));
128  // assert dimensions are the same....
129  uInt idx = 0;
130 
131  for (ArrayAccessor<Float, Axis<2> > i(aa1);i != i.end(); ++i) {   
132    idx = 0;
133    for (ArrayAccessor<Float, Axis<3> > ii(i);ii != ii.end(); ++ii) {
134      (*ii) = tsys[idx];
135      idx++;
136    }
137  }
138}
Note: See TracBrowser for help on using the repository browser.