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 | #include <aips/Quanta/MVTime.h>
|
---|
36 |
|
---|
37 | #include "SDContainer.h"
|
---|
38 |
|
---|
39 | using namespace atnf_sd;
|
---|
40 |
|
---|
41 | void SDHeader::print() const {
|
---|
42 | MVTime mvt(this->utc);
|
---|
43 |
|
---|
44 | cout << "Observer: " << this->observer << endl
|
---|
45 | << "Project: " << this->project << endl
|
---|
46 | << "Obstype: " << this->obstype << endl
|
---|
47 | << "Antenna: " << this->antennaname << endl
|
---|
48 | << "Ant. Position: " << this->antennaposition << endl
|
---|
49 | << "Equinox: " << this->equinox << endl
|
---|
50 | << "Freq. ref.: " << this->freqref << endl
|
---|
51 | << "Ref. frequency: " << this->reffreq << endl
|
---|
52 | << "Bandwidth: " << this->bandwidth << endl
|
---|
53 | << "Time (utc): "
|
---|
54 | << mvt.string()
|
---|
55 | << endl;
|
---|
56 | //setprecision(10) << this->utc << endl;
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|
60 | SDContainer::SDContainer(uInt nBeam, uInt nIF, uInt nPol, uInt nChan)
|
---|
61 | : nBeam_(nBeam),
|
---|
62 | nIF_(nIF),
|
---|
63 | nPol_(nPol),
|
---|
64 | nChan_(nChan),
|
---|
65 | spectrum_(IPosition(4,nBeam,nIF,nPol,nChan)),
|
---|
66 | flags_(IPosition(4,nBeam,nIF,nPol,nChan)),
|
---|
67 | tsys_(IPosition(4,nBeam,nIF,nPol,nChan)) {
|
---|
68 | uChar x = 0;
|
---|
69 | flags_ = ~x;
|
---|
70 | }
|
---|
71 |
|
---|
72 | SDContainer::SDContainer(IPosition shp)
|
---|
73 | : nBeam_(shp(0)),
|
---|
74 | nIF_(shp(1)),
|
---|
75 | nPol_(shp(2)),
|
---|
76 | nChan_(shp(3)),
|
---|
77 | spectrum_(shp),
|
---|
78 | flags_(shp),
|
---|
79 | tsys_(shp) {
|
---|
80 | uChar x = 0;
|
---|
81 | flags_ = ~x;
|
---|
82 | }
|
---|
83 |
|
---|
84 | SDContainer::~SDContainer() {
|
---|
85 | }
|
---|
86 |
|
---|
87 | Bool SDContainer::putSpectrum(const Array<Float>& spec) {
|
---|
88 | spectrum_ = spec;
|
---|
89 | }
|
---|
90 | Bool SDContainer::putFlags(const Array<uChar>& flag) {
|
---|
91 | flags_ = flag;
|
---|
92 | }
|
---|
93 | Bool SDContainer::putTsys(const Array<Float>& tsys) {
|
---|
94 | tsys_ = tsys;
|
---|
95 | }
|
---|
96 |
|
---|
97 | Bool SDContainer::setSpectrum(const Matrix<Float>& spec,
|
---|
98 | uInt whichBeam, uInt whichIF) {
|
---|
99 |
|
---|
100 | ArrayAccessor<Float, Axis<0> > aa0(spectrum_);
|
---|
101 | aa0.reset(aa0.begin(whichBeam));
|
---|
102 | ArrayAccessor<Float, Axis<1> > aa1(aa0);
|
---|
103 | aa1.reset(aa1.begin(whichIF));
|
---|
104 |
|
---|
105 | //Vector<Float> pols(nPol);
|
---|
106 | ArrayAccessor<Float, Axis<1> > j(spec);
|
---|
107 | IPosition shp0 = spectrum_.shape();
|
---|
108 | IPosition shp1 = spec.shape();
|
---|
109 | if ( (shp0(2) != shp1(1)) || (shp0(3) != shp1(0)) ) {
|
---|
110 | cerr << "Arrays not conformant" << endl;
|
---|
111 | return False;
|
---|
112 | }
|
---|
113 | // assert dimensions are the same....
|
---|
114 | for (ArrayAccessor<Float, Axis<2> > i(aa1);i != i.end(); ++i) {
|
---|
115 | ArrayAccessor<Float, Axis<0> > jj(j);
|
---|
116 | for (ArrayAccessor<Float, Axis<3> > ii(i);ii != ii.end(); ++ii) {
|
---|
117 | (*ii) = (*jj);
|
---|
118 | jj++;
|
---|
119 | }
|
---|
120 | j++;
|
---|
121 | }
|
---|
122 | // unset flags for this spectrum, they might be set again by the
|
---|
123 | // setFlags method
|
---|
124 |
|
---|
125 | IPosition shp = flags_.shape();
|
---|
126 | IPosition start(4,whichBeam,whichIF,0,0);
|
---|
127 | IPosition end(4,whichBeam,whichIF,shp(2)-1,shp(3)-1);
|
---|
128 | Array<uChar> arr(flags_(start,end));
|
---|
129 | arr = uChar(0);
|
---|
130 | }
|
---|
131 |
|
---|
132 | Bool SDContainer::setFlags(const Matrix<uChar>& flag,
|
---|
133 | uInt whichBeam, uInt whichIF) {
|
---|
134 |
|
---|
135 | ArrayAccessor<uChar, Axis<0> > aa0(flags_);
|
---|
136 | aa0.reset(aa0.begin(whichBeam));
|
---|
137 | ArrayAccessor<uChar, Axis<1> > aa1(aa0);
|
---|
138 | aa1.reset(aa1.begin(whichIF));
|
---|
139 |
|
---|
140 | ArrayAccessor<uChar, Axis<1> > j(flag);
|
---|
141 | IPosition shp0 = flags_.shape();
|
---|
142 | IPosition shp1 = flag.shape();
|
---|
143 | if ( (shp0(2) != shp1(1)) || (shp0(3) != shp1(0)) ) {
|
---|
144 | cerr << "Arrays not conformant" << endl;
|
---|
145 | return False;
|
---|
146 | }
|
---|
147 |
|
---|
148 | // assert dimensions are the same....
|
---|
149 | for (ArrayAccessor<uChar, Axis<2> > i(aa1);i != i.end(); ++i) {
|
---|
150 | ArrayAccessor<uChar, Axis<0> > jj(j);
|
---|
151 | for (ArrayAccessor<uChar, Axis<3> > ii(i);ii != ii.end(); ++ii) {
|
---|
152 | (*ii) = (*jj);
|
---|
153 | jj++;
|
---|
154 | }
|
---|
155 | j++;
|
---|
156 | }
|
---|
157 | return True;
|
---|
158 | }
|
---|
159 |
|
---|
160 | Bool SDContainer::setTsys(const Vector<Float>& tsys,
|
---|
161 | uInt whichBeam, uInt whichIF) {
|
---|
162 | ArrayAccessor<Float, Axis<0> > aa0(tsys_);
|
---|
163 | aa0.reset(aa0.begin(whichBeam));
|
---|
164 | ArrayAccessor<Float, Axis<1> > aa1(aa0);
|
---|
165 | aa1.reset(aa1.begin(whichIF));
|
---|
166 | // assert dimensions are the same....
|
---|
167 | for (ArrayAccessor<Float, Axis<3> > i(aa1);i != i.end(); ++i) {
|
---|
168 | ArrayAccessor<Float, Axis<0> > j(tsys);
|
---|
169 | for (ArrayAccessor<Float, Axis<2> > ii(i);ii != ii.end(); ++ii) {
|
---|
170 | (*ii) = (*j);
|
---|
171 | j++;
|
---|
172 | }
|
---|
173 | }
|
---|
174 | }
|
---|