| 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 |
|
|---|
| 38 | using namespace atnf_sd;
|
|---|
| 39 |
|
|---|
| 40 | SDContainer::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 |
|
|---|
| 52 | SDContainer::~SDContainer() {
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | Bool SDContainer::putSpectrum(const Array<Float>& spec) {
|
|---|
| 56 | spectrum_ = spec;
|
|---|
| 57 | }
|
|---|
| 58 | Bool SDContainer::putFlags(const Array<uChar>& flag) {
|
|---|
| 59 | flags_ = flag;
|
|---|
| 60 | }
|
|---|
| 61 | Bool SDContainer::putTsys(const Array<Float>& tsys) {
|
|---|
| 62 | tsys_ = tsys;
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | Bool 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 | //Vector<Float> pols(nPol);
|
|---|
| 74 | ArrayAccessor<Float, Axis<0> > j(spec);
|
|---|
| 75 | IPosition shp0 = spectrum_.shape();
|
|---|
| 76 | IPosition shp1 = spec.shape();
|
|---|
| 77 | if ( (shp0(2) != shp1(0)) || (shp0(3) != shp1(1)) ) {
|
|---|
| 78 | cerr << "Arrays not conformant" << endl;
|
|---|
| 79 | return False;
|
|---|
| 80 | }
|
|---|
| 81 | //uInt chani = 0;
|
|---|
| 82 | //uInt poli = 0;
|
|---|
| 83 | // assert dimensions are the same....
|
|---|
| 84 | for (ArrayAccessor<Float, Axis<2> > i(aa1);i != i.end(); ++i) {
|
|---|
| 85 | //pols = spec.row(chani);
|
|---|
| 86 | ArrayAccessor<Float, Axis<1> > jj(j);
|
|---|
| 87 | for (ArrayAccessor<Float, Axis<3> > ii(i);ii != ii.end(); ++ii) {
|
|---|
| 88 | //(*ii) = pols[poli];
|
|---|
| 89 | (*ii) = (*jj);
|
|---|
| 90 | //poli++;
|
|---|
| 91 | jj++;
|
|---|
| 92 | }
|
|---|
| 93 | //poli = 0;
|
|---|
| 94 | //chani++;
|
|---|
| 95 | j++;
|
|---|
| 96 | }
|
|---|
| 97 | // unset flags for this spectrum, they might be set again by the
|
|---|
| 98 | // setFlags method
|
|---|
| 99 |
|
|---|
| 100 | IPosition shp = flags_.shape();
|
|---|
| 101 | IPosition start(4,whichBeam,whichIF,0,0);
|
|---|
| 102 | IPosition end(4,whichBeam,whichIF,shp(2)-1,shp(3)-1);
|
|---|
| 103 | Array<uChar> arr(flags_(start,end));
|
|---|
| 104 | arr = uChar(0);
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|
| 107 | Bool SDContainer::setFlags(const Matrix<uChar>& flag,
|
|---|
| 108 | uInt whichBeam, uInt whichIF) {
|
|---|
| 109 |
|
|---|
| 110 | ArrayAccessor<uChar, Axis<0> > aa0(flags_);
|
|---|
| 111 | aa0.reset(aa0.begin(whichBeam));
|
|---|
| 112 | ArrayAccessor<uChar, Axis<1> > aa1(aa0);
|
|---|
| 113 | aa1.reset(aa1.begin(whichIF));
|
|---|
| 114 |
|
|---|
| 115 | ArrayAccessor<uChar, Axis<0> > j(flag);
|
|---|
| 116 | IPosition shp0 = flags_.shape();
|
|---|
| 117 | IPosition shp1 = flag.shape();
|
|---|
| 118 | if ( (shp0(2) != shp1(0)) || (shp0(3) != shp1(1)) ) {
|
|---|
| 119 | cerr << "Arrays not conformant" << endl;
|
|---|
| 120 | return False;
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | // assert dimensions are the same....
|
|---|
| 124 | for (ArrayAccessor<uChar, Axis<2> > i(aa1);i != i.end(); ++i) {
|
|---|
| 125 | ArrayAccessor<uChar, Axis<1> > jj(j);
|
|---|
| 126 | for (ArrayAccessor<uChar, Axis<3> > ii(i);ii != ii.end(); ++ii) {
|
|---|
| 127 | (*ii) = (*jj);
|
|---|
| 128 | jj++;
|
|---|
| 129 | }
|
|---|
| 130 | j++;
|
|---|
| 131 | }
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | Bool SDContainer::setTsys(const Vector<Float>& tsys,
|
|---|
| 135 | uInt whichBeam, uInt whichIF) {
|
|---|
| 136 | ArrayAccessor<Float, Axis<0> > aa0(tsys_);
|
|---|
| 137 | aa0.reset(aa0.begin(whichBeam));
|
|---|
| 138 | ArrayAccessor<Float, Axis<1> > aa1(aa0);
|
|---|
| 139 | aa1.reset(aa1.begin(whichIF));
|
|---|
| 140 | // assert dimensions are the same....
|
|---|
| 141 | uInt idx = 0;
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 | for (ArrayAccessor<Float, Axis<2> > i(aa1);i != i.end(); ++i) {
|
|---|
| 145 | idx = 0;
|
|---|
| 146 | ArrayAccessor<Float, Axis<0> > j(tsys);
|
|---|
| 147 | for (ArrayAccessor<Float, Axis<3> > ii(i);ii != ii.end(); ++ii) {
|
|---|
| 148 | (*ii) = (*j);
|
|---|
| 149 | j++;
|
|---|
| 150 | }
|
|---|
| 151 | }
|
|---|
| 152 | }
|
|---|