casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SysCalRecord.h
Go to the documentation of this file.
1 /*
2  * SysCalRecord.h
3  *
4  * Created on: Jan 27, 2016
5  * Author: nakazato
6  */
7 
8 #ifndef SINGLEDISH_FILLER_SYSCALRECORD_H_
9 #define SINGLEDISH_FILLER_SYSCALRECORD_H_
10 
12 #include <casacore/casa/OS/Path.h>
17 
18 namespace casa { //# NAMESPACE CASA - BEGIN
19 namespace sdfiller { //# NAMESPACE SDFILLER - BEGIN
20 
21 struct SysCalRecord {
24 
25  // mandatory
31 
32  // optional
37 
38  // method
39  void clear() {
40  antenna_id = -1;
41  feed_id = -1;
42  spw_id = -1;
43  time = 0.0;
44  interval = 0.0;
45  tcal.resize();
47  tsys.resize();
49  }
50 
52  antenna_id = other.antenna_id;
53  feed_id = other.feed_id;
54  spw_id = other.spw_id;
55  time = other.time;
56  interval = other.interval;
57  tcal = other.tcal;
59  tsys = other.tsys;
61  return *this;
62  }
63 
64  void add(AssociatingTable &table, AssociatingColumns &/*columns*/) {
65  table.addRow(1, true);
66  }
67 
69  if (columns.nrow() <= irow) {
70  return false;
71  }
72 
73  columns.antennaId().put(irow, antenna_id);
74  columns.feedId().put(irow, feed_id);
75  columns.spectralWindowId().put(irow, spw_id);
76  columns.time().put(irow, time);
77  columns.interval().put(irow, interval);
78  if (tcal.size() > 0) {
79  columns.tcal().put(irow, tcal);
80  }
81  if (tcal_spectrum.size() > 0) {
82  columns.tcalSpectrum().put(irow, tcal_spectrum);
83  }
84  if (tsys.size() > 0) {
85  columns.tsys().put(irow, tsys);
86  }
87  if (tsys_spectrum.size() > 0) {
88  columns.tsysSpectrum().put(irow, tsys_spectrum);
89  }
90  return true;
91  }
92 };
93 
95  enum Status {
97  };
99  ms_(ms), columns_(ms->sysCal()), irow_(irow) {
100  antenna_id = record.antenna_id;
101  feed_id = record.feed_id;
102  spw_id = record.spw_id;
103  casacore::ScalarColumn<casacore::Int> num_chan_column(ms_->spectralWindow(), "NUM_CHAN");
104  num_chan = num_chan_column(spw_id);
105  if (record.tsys_spectrum.empty()) {
106  num_corr = record.tsys.size();
107  tsys_status = Status::Scalar;
108  if (record.tsys.empty()) {
109  tsys_nominal = -1.0f;
110  tsys_status = Status::NotDefined;
111  } else {
112  tsys_nominal = record.tsys[0];
113  }
114  } else {
115  num_corr = record.tsys_spectrum.shape()[0];
116  tsys_status = Status::Spectral;
117  tsys_nominal = record.tsys_spectrum(0, 0);
118  }
119  if (record.tcal_spectrum.empty()) {
120  tcal_status = Status::Scalar;
121  if (record.tcal.empty()) {
122  tcal_nominal = -1.0f;
123  tcal_status = Status::NotDefined;
124  } else {
125  tcal_nominal = record.tcal[0];
126  }
127  } else {
128  tcal_status = Status::Spectral;
129  tcal_nominal = record.tcal_spectrum(0, 0);
130  }
131  }
133  ms_(other.ms_), columns_(ms_->sysCal()), irow_(other.irow_) {
134  antenna_id = other.antenna_id;
135  feed_id = other.feed_id;
136  spw_id = other.spw_id;
137  num_chan = other.num_chan;
138  num_corr = other.num_corr;
139  tsys_status = other.tsys_status;
140  tcal_status = other.tcal_status;
141  tsys_nominal = other.tsys_nominal;
142  tcal_nominal = other.tcal_nominal;
143  }
153 
154  // returns true if two SysCalTableRecord objects are exactly same
155  bool operator==(SysCalTableRecord const &record) {
156  casacore::String ms_name = casacore::Path(ms_->tableName()).resolvedName();
157  casacore::String ms_name_record = casacore::Path(record.ms_->tableName()).resolvedName();
158  return ms_name == ms_name_record && irow_ == record.irow_
159  && antenna_id == record.antenna_id && feed_id == record.feed_id
160  && spw_id == record.spw_id && num_chan == record.num_chan
161  && num_corr == record.num_corr && tsys_status == record.tsys_status
162  && tcal_status == record.tcal_status
163  && tsys_nominal == record.tsys_nominal
164  && tcal_nominal == record.tcal_nominal;
165  }
166 
167  // returns true if given SysCalRecord is effectively the same
168  bool operator==(SysCalRecord const &record) {
169  bool is_meta_equal = antenna_id == record.antenna_id
170  && feed_id == record.feed_id && spw_id == record.spw_id;
171  if (!is_meta_equal) {
172  return false;
173  }
174 
175  bool is_tsys_same;
176  if (tsys_status == Status::Spectral) {
177  is_tsys_same = num_chan > 0
178  && (casacore::uInt) num_chan == record.tsys_spectrum.ncolumn() && num_corr > 0
179  && (casacore::uInt) num_corr == record.tsys_spectrum.nrow()
180  && tsys_nominal == record.tsys_spectrum(0, 0)
181  && allEQ(columns_.tsysSpectrum()(irow_), record.tsys_spectrum);
182  } else if (tsys_status == Status::Scalar) {
183  is_tsys_same = num_corr > 0 && (casacore::uInt) num_corr == record.tsys.size()
184  && tsys_nominal == record.tsys[0]
185  && allEQ(columns_.tsys()(irow_), record.tsys);
186  } else {
187  is_tsys_same = record.tsys_spectrum.empty() && record.tsys.empty();
188  }
189 
190  if (!is_tsys_same) {
191  return false;
192  }
193 
194  bool is_tcal_same;
195  if (tcal_status == Status::Spectral) {
196  is_tcal_same = num_chan > 0
197  && (casacore::uInt) num_chan == record.tcal_spectrum.ncolumn() && num_corr > 0
198  && (casacore::uInt) num_corr == record.tcal_spectrum.nrow()
199  && tcal_nominal == record.tcal_spectrum(0, 0)
200  && allEQ(columns_.tcalSpectrum()(irow_), record.tcal_spectrum);
201  } else if (tcal_status == Status::Scalar) {
202  is_tcal_same = num_corr > 0 && (casacore::uInt) num_corr == record.tcal.size()
203  && tcal_nominal == record.tcal[0]
204  && allEQ(columns_.tcal()(irow_), record.tcal);
205  } else {
206  is_tcal_same = record.tcal_spectrum.empty() && record.tcal.empty();
207  }
208 
209  if (!is_tcal_same) {
210  return false;
211  }
212 
213  return true;
214  }
215 
216 private:
220 };
221 
222 } //# NAMESPACE SDFILLER - END
223 } //# NAMESPACE CASA - END
224 
225 #endif /* SINGLEDISH_FILLER_SYSCALRECORD_H_ */
ArrayColumn< Float > & tcal()
ScalarColumn< Int > & antennaId()
Read-write access to required columns.
casacore::Double interval
Definition: SysCalRecord.h:30
casacore::MeasurementSet * ms_
Definition: SysCalRecord.h:217
void addRow(uInt nrrow=1, Bool initialize=False)
Add one or more rows at the end of the table.
Definition: Table.h:1235
int Int
Definition: aipstype.h:50
casacore::Matrix< casacore::Float > tcal_spectrum
Definition: SysCalRecord.h:34
size_t nrow() const
The number of rows in the Matrix, i.e.
Definition: Matrix.h:301
casacore::Vector< casacore::Float > tsys
Definition: SysCalRecord.h:35
const IPosition & shape() const
The length of each axis of the Matrix.
Definition: Matrix.h:295
casacore::Int antenna_id
mandatory
Definition: SysCalRecord.h:26
MSSpectralWindow & spectralWindow()
ScalarColumn< Int > & spectralWindowId()
bool operator==(SysCalTableRecord const &record)
returns true if two SysCalTableRecord objects are exactly same
Definition: SysCalRecord.h:155
casacore::Bool fill(casacore::uInt irow, AssociatingColumns &columns)
Definition: SysCalRecord.h:68
void put(uInt rownr, const Array< T > &array)
Put the array in a particular cell (i.e.
ArrayColumn< Float > & tcalSpectrum()
ScalarColumn< Int > & feedId()
SysCalTableRecord(casacore::MeasurementSet *ms, casacore::uInt irow, SysCalRecord const &record)
Definition: SysCalRecord.h:98
Bool empty() const
Is the array empty (i.e.
Definition: ArrayBase.h:106
Path name of a file.
Definition: Path.h:126
A Table intended to hold a MeasurementSet SYSCAL table.
Definition: MSSysCal.h:78
SysCalRecord & operator=(SysCalRecord const &other)
Definition: SysCalRecord.h:51
const String & tableName() const
Get the table name.
Definition: Table.h:1219
casacore::MSSysCalColumns columns_
Definition: SysCalRecord.h:218
SysCalTableRecord(SysCalTableRecord const &other)
Definition: SysCalRecord.h:132
ArrayColumn< Float > & tsys()
ScalarColumn< Double > & time()
double Double
Definition: aipstype.h:55
A class to provide easy read-write access to MSSysCal columns.
casacore::Vector< casacore::Float > tcal
optional
Definition: SysCalRecord.h:33
casacore::Matrix< casacore::Float > tsys_spectrum
Definition: SysCalRecord.h:36
ArrayColumn< Float > & tsysSpectrum()
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
size_t ncolumn() const
The number of columns in the Matrix, i.e.
Definition: Matrix.h:305
float Float
Definition: aipstype.h:54
A Table intended to hold astronomical data (a set of Measurements).
bool operator==(SysCalRecord const &record)
returns true if given SysCalRecord is effectively the same
Definition: SysCalRecord.h:168
casacore::MSSysCal AssociatingTable
Definition: SysCalRecord.h:22
void put(uInt rownr, const T &value)
Put the value in a particular cell (i.e.
Definition: ScalarColumn.h:198
casacore::MSSysCalColumns AssociatingColumns
Definition: SysCalRecord.h:23
void add(AssociatingTable &table, AssociatingColumns &)
Definition: SysCalRecord.h:64
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void resize(size_t nx, size_t ny, Bool copyValues=False)
Definition: Matrix.h:154
size_t size() const
Definition: ArrayBase.h:101
uInt nrow() const
Convenience function that returns the number of rows in any of the columns.
void resize(size_t len, Bool copyValues=False)
Definition: Vector.h:167
ScalarColumn< Double > & interval()
unsigned int uInt
Definition: aipstype.h:51