Line data Source code
1 : //# VLALogicalRecord.cc: This class reads and reconstructs VLA archive records
2 : //# Copyright (C) 1995,1999,2000
3 : //# Associated Universities, Inc. Washington DC, USA.
4 : //#
5 : //# This library is free software; you can redistribute it and/or modify it
6 : //# under the terms of the GNU Library General Public License as published by
7 : //# the Free Software Foundation; either version 2 of the License, or (at your
8 : //# option) any later version.
9 : //#
10 : //# This library is distributed in the hope that it will be useful, but WITHOUT
11 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 : //# License for more details.
14 : //#
15 : //# You should have received a copy of the GNU Library General Public License
16 : //# along with this library; if not, write to the Free Software Foundation,
17 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 : //#
19 : //# Correspondence concerning AIPS++ should be addressed as follows:
20 : //# Internet email: casa-feedback@nrao.edu.
21 : //# Postal address: AIPS++ Project Office
22 : //# National Radio Astronomy Observatory
23 : //# 520 Edgemont Road
24 : //# Charlottesville, VA 22903-2475 USA
25 : //#
26 : //# $Id$
27 :
28 : #include <nrao/VLA/VLALogicalRecord.h>
29 : #include <casacore/casa/Utilities/Assert.h>
30 : #include <casacore/casa/Exceptions/Error.h>
31 : #include <casacore/measures/Measures/Stokes.h>
32 : #include <casacore/casa/Arrays/Vector.h>
33 : #include <casacore/casa/Arrays/Matrix.h>
34 :
35 0 : VLALogicalRecord::VLALogicalRecord()
36 0 : :itsRecordPtr( ),
37 0 : itsRCA(),
38 0 : itsSDA(),
39 0 : itsADA(0),
40 0 : itsCDA(4)
41 : {
42 0 : }
43 :
44 16 : VLALogicalRecord::VLALogicalRecord(VLAArchiveInput* input)
45 16 : :itsRecordPtr(input),
46 16 : itsRCA(),
47 16 : itsSDA(),
48 16 : itsADA(0),
49 16 : itsCDA(4)
50 : {
51 16 : }
52 :
53 16 : VLALogicalRecord::VLALogicalRecord(const VLALogicalRecord& other)
54 16 : :itsRecordPtr(other.itsRecordPtr),
55 16 : itsRCA(other.itsRCA),
56 16 : itsSDA(other.itsSDA),
57 16 : itsADA(other.itsADA),
58 16 : itsCDA(other.itsCDA)
59 : {
60 16 : }
61 :
62 32 : VLALogicalRecord::~VLALogicalRecord() {
63 32 : }
64 :
65 0 : VLALogicalRecord& VLALogicalRecord::operator=(const VLALogicalRecord& other) {
66 0 : if (this != &other) {
67 0 : itsRecordPtr = other.itsRecordPtr;
68 0 : itsRCA = other.itsRCA;
69 0 : itsSDA = other.itsSDA;
70 0 : itsADA = other.itsADA;
71 0 : itsCDA = other.itsCDA;
72 : }
73 0 : return *this;
74 : }
75 :
76 0 : ByteSource& VLALogicalRecord::logicalRecord() {
77 0 : DebugAssert(isValid(), AipsError);
78 0 : return itsRecordPtr->logicalRecord();
79 : }
80 :
81 20585 : Bool VLALogicalRecord::read() {
82 20585 : DebugAssert(isValid(), AipsError);
83 20585 : if (itsRecordPtr->read() == false) return false;
84 20569 : ByteSource& itsRecord = itsRecordPtr->logicalRecord();
85 20569 : itsRCA.attach(itsRecord);
86 20569 : itsSDA.attach(itsRecord, itsRCA.SDAOffset());
87 20569 : const uInt nant = itsRCA.nAntennas();
88 20569 : itsADA.resize(nant, false, false);
89 574500 : for (uInt i = 0; i < nant; i++) {
90 553931 : itsADA[i].attach(itsRecord, itsRCA.ADAOffset(i));
91 : }
92 102845 : for (uInt i = 0; i < 4; i++) {
93 82276 : const uInt nchan = itsSDA.trueChannels(VLAEnum::CDA(i));
94 82276 : const uInt size = itsRCA.CDABaselineBytes(i);
95 82276 : itsCDA[i].attach(itsRecord, itsRCA.CDAOffset(i), size, nant, nchan);
96 : }
97 20569 : return true;
98 : }
99 :
100 3410416 : Bool VLALogicalRecord::isValid() const {
101 3410416 : return !itsRecordPtr.null();
102 : }
103 :
104 24710 : const VLARCA& VLALogicalRecord::RCA() const {
105 24710 : DebugAssert(isValid(), AipsError);
106 24710 : return itsRCA;
107 : }
108 :
109 118870 : const VLASDA& VLALogicalRecord::SDA() const {
110 118870 : DebugAssert(isValid(), AipsError);
111 118870 : return itsSDA;
112 : }
113 :
114 2676673 : const VLACDA& VLALogicalRecord::CDA(uInt which) const {
115 2676673 : DebugAssert(isValid(), AipsError);
116 2676673 : DebugAssert(which < 4, AipsError);
117 2676673 : return itsCDA[which];
118 : }
119 :
120 569578 : const VLAADA& VLALogicalRecord::ADA(uInt which) const {
121 569578 : DebugAssert(isValid(), AipsError);
122 569578 : DebugAssert(which < itsRCA.nAntennas(), AipsError);
123 569578 : return itsADA[which];
124 : }
125 :
126 :
127 : Vector<Stokes::StokesTypes>
128 15124 : VLALogicalRecord::polarisations(VLAEnum::CDA cda, uInt ant1, uInt ant2) const {
129 15124 : const Matrix<VLAEnum::IF> ifs = itsSDA.ifUsage(cda);
130 15124 : const uInt nPol = ifs.ncolumn();
131 15124 : Vector<Stokes::StokesTypes> retVal(nPol);
132 66152 : for (uInt p = 0; p < nPol; p++) {
133 51028 : const Stokes::StokesTypes if1= itsADA[ant1].ifPol(ifs(0,p));
134 51028 : const Stokes::StokesTypes if2= itsADA[ant2].ifPol(ifs(1,p));
135 51028 : if ((if1 == Stokes::RCircular) && (if2 == Stokes::RCircular)) {
136 15124 : retVal(p) = Stokes::RR;
137 35904 : } else if ((if1 == Stokes::LCircular) && (if2 == Stokes::LCircular)) {
138 11968 : retVal(p) = Stokes::LL;
139 23936 : } else if ((if1 == Stokes::RCircular) && (if2 == Stokes::LCircular)) {
140 11968 : retVal(p) = Stokes::RL;
141 11968 : } else if ((if1 == Stokes::LCircular) && (if2 == Stokes::RCircular)) {
142 11968 : retVal(p) = Stokes::LR;
143 : }
144 : }
145 30248 : return retVal;
146 15124 : }
147 :
148 : // Local Variables:
149 : // compile-command: "gmake VLALogicalRecord; cd test; gmake OPTLIB=1 tVLALogicalRecord"
150 : // End:
|