casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FieldRecord.h
Go to the documentation of this file.
1 /*
2  * FieldRecord.h
3  *
4  * Created on: Jan 27, 2016
5  * Author: nakazato
6  */
7 
8 #ifndef SINGLEDISH_FILLER_FIELDRECORD_H_
9 #define SINGLEDISH_FILLER_FIELDRECORD_H_
10 
16 
17 namespace casa { //# NAMESPACE CASA - BEGIN
18 
19 // forward decleration
20 template<class Reader>
22 
23 namespace sdfiller { //# NAMESPACE SDFILLER - BEGIN
24 
25 struct FieldRecord {
28 
29 private:
30  // external resource
33 
34 public:
35  // meta
39 
40  // mandatory
44 
45  // optional
47 
48  // for dummy entry
52  casacore::Double const d_time = 0.0;
54 
55  // method
56  void clear() {
57  field_id = -1;
58  source_name = "";
59  name = "";
60  time = -1.0;
61  direction.resize();
63  code = "";
64  }
65 
67  source_map = other.source_map;
68  table = other.table;
69  field_id = other.field_id;
70  source_name = other.source_name;
71  frame = other.frame;
72  name = other.name;
73  time = other.time;
74  direction = other.direction;
75  code = other.code;
76  return *this;
77  }
78 
81  casacore::uInt nrow = table.nrow();
82  if (nrow == 0) {
83  // set direction frame information
84  setFrame(columns);
85  }
86  if (nrow <= ufield_id) {
87  table.addRow(ufield_id - nrow + 1);
88  casacore::uInt new_nrow = table.nrow();
89  for (casacore::uInt i = nrow; i < new_nrow - 1; ++i) {
90  columns.sourceId().put(i, d_source_id);
91  columns.name().put(i, d_name);
92  columns.time().put(i, d_time);
93  columns.numPoly().put(i, d_num_poly);
94  columns.delayDir().put(i, d_direction);
95  columns.phaseDir().put(i, d_direction);
96  columns.referenceDir().put(i, d_direction);
97  }
98  }
99  }
100 
102  if (field_id < 0) {
103  return false;
104  }
105 
106  casacore::uInt nrow = columns.nrow();
107  if (nrow == 0) {
108  // set direction frame information
109  setFrame(columns);
110  }
111 
112  if (table.nrow() <= (casacore::uInt) field_id) {
113  return false;
114  }
115 
116  columns.name().put(field_id, name);
117  columns.time().put(field_id, time);
118  casacore::Int source_id = -1;
120  source_id = source_map.asInt(source_name);
121  }
122  columns.sourceId().put(field_id, source_id);
123  columns.delayDir().put(field_id, direction);
124  columns.phaseDir().put(field_id, direction);
125  columns.referenceDir().put(field_id, direction);
126  casacore::Int num_poly = direction.shape()[1] - 1;
127  columns.numPoly().put(field_id, num_poly);
128  if (code.size() > 0) {
129  columns.code().put(field_id, code);
130  }
131  return true;
132  }
133 
134 private:
135  void setFrame(AssociatingColumns &columns) {
136  casacore::TableRecord &record = columns.delayDir().rwKeywordSet();
137  casacore::Record meas_info = record.asRecord("MEASINFO");
139  meas_info.define("Ref", direction_frame);
140  record.defineRecord("MEASINFO", meas_info);
141  columns.phaseDir().rwKeywordSet().defineRecord("MEASINFO", meas_info);
142  columns.referenceDir().rwKeywordSet().defineRecord("MEASINFO", meas_info);
143  }
144 
145  template<class Reader>
147 };
148 
149 } //# NAMESPACE SDFILLER - END
150 } //# NAMESPACE CASA - END
151 
152 #endif /* SINGLEDISH_FILLER_FIELDRECORD_H_ */
void addRow(uInt nrrow=1, Bool initialize=False)
Add one or more rows at the end of the table.
Definition: Table.h:1235
casacore::Double const d_time
Definition: FieldRecord.h:52
int Int
Definition: aipstype.h:50
ScalarColumn< String > & code()
Read-write access to required columns.
const IPosition & shape() const
The length of each axis of the Matrix.
Definition: Matrix.h:295
AssociatingTable table
Definition: FieldRecord.h:32
casacore::Matrix< casacore::Double > direction
Definition: FieldRecord.h:43
void put(uInt rownr, const Array< T > &array)
Put the array in a particular cell (i.e.
ArrayColumn< Double > & referenceDir()
FieldRecord & operator=(FieldRecord const &other)
Definition: FieldRecord.h:66
size_type size() const
Capacity, size.
Definition: String.h:342
void defineRecord(const RecordFieldId &, const TableRecord &value, RecordType type=Variable)
Define a value for the given field.
casacore::String source_name
Definition: FieldRecord.h:37
casacore::Record source_map
external resource
Definition: FieldRecord.h:31
casacore::MSFieldColumns AssociatingColumns
Definition: FieldRecord.h:27
casacore::Bool fill(casacore::uInt, AssociatingColumns &columns)
Definition: FieldRecord.h:101
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition: MDirection.h:188
A class to provide easy read-write access to MSField columns.
ScalarColumn< Int > & numPoly()
casacore::String code
optional
Definition: FieldRecord.h:46
ArrayColumn< Double > & phaseDir()
void add(AssociatingTable &table, AssociatingColumns &columns)
Definition: FieldRecord.h:79
casacore::Int field_id
meta
Definition: FieldRecord.h:36
ScalarColumn< String > & name()
ScalarColumn< Int > & sourceId()
double Double
Definition: aipstype.h:55
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
uInt nrow() const
Convenience function that returns the number of rows in any of the columns.
casacore::Int const d_source_id
for dummy entry
Definition: FieldRecord.h:49
Bool isDefined(const String &fieldName) const
Test if a field name exists.
uInt nrow() const
Get the number of rows.
Definition: Table.h:1201
casacore::Double time
Definition: FieldRecord.h:42
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
static const String & showType(MDirection::Types tp)
A Table intended to hold a MeasurementSet FIELD table.
Definition: MSField.h:78
casacore::MSField AssociatingTable
Definition: FieldRecord.h:26
TableRecord & rwKeywordSet()
Get read/write access to the column keyword set.
virtual const RecordInterface & asRecord(const RecordFieldId &) const
void setFrame(AssociatingColumns &columns)
Definition: FieldRecord.h:135
casacore::Matrix< casacore::Double > const d_direction
Definition: FieldRecord.h:53
casacore::String name
mandatory
Definition: FieldRecord.h:41
Int asInt(const RecordFieldId &) const
casacore::String const d_name
Definition: FieldRecord.h:50
casacore::MDirection::Types frame
Definition: FieldRecord.h:38
void put(uInt rownr, const T &value)
Put the value in a particular cell (i.e.
Definition: ScalarColumn.h:198
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
ArrayColumn< Double > & delayDir()
forward decleration
Definition: FieldRecord.h:21
void define(const RecordFieldId &, Bool value)
Define a value for the given field.
casacore::Int const d_num_poly
Definition: FieldRecord.h:51
ScalarColumn< Double > & time()
unsigned int uInt
Definition: aipstype.h:51