Line data Source code
1 : //# MSCalEnums.cc: Implementation of MSCalEnums.h
2 : //# Copyright (C) 1996,1997,1998,2000,2001,2002
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: aips2-request@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 :
29 : #include <msvis/MSVis/MSCalEnums.h>
30 :
31 : using namespace casacore;
32 : namespace casa { //# NAMESPACE CASA - BEGIN
33 :
34 : //----------------------------------------------------------------------------
35 :
36 : // Static data initialization
37 : std::map <Int, String> MSCalEnums::theirFieldMap;
38 : std::map <Int, DataType> MSCalEnums::theirTypeMap;
39 :
40 : //----------------------------------------------------------------------------
41 :
42 0 : void MSCalEnums::initMaps ()
43 : {
44 : // Initialize the static map containing the field names.
45 : // Skip this step if already initialized.
46 : //
47 0 : if ( theirFieldMap.size( ) == 0 ) {
48 0 : theirFieldMap = {
49 : {ANTENNA1, "ANTENNA1"},
50 : {ANTENNA2, "ANTENNA2"},
51 : { FEED1, "FEED1" },
52 : { FEED2, "FEED2" },
53 : { PULSAR_BIN, "PULSAR_BIN" },
54 : { SCAN_NUMBER, "SCAN_NUMBER" },
55 : { TIME, "TIME" },
56 : { TIME_EXTRA_PREC, "TIME_EXTRA_PREC" },
57 : { INTERVAL, "INTERVAL" },
58 : { ARRAY_ID, "ARRAY_ID" },
59 : { PROCESSOR_ID, "PROCESSOR_ID" },
60 : { FIELD_ID, "FIELD_ID" },
61 : { OBSERVATION_ID, "OBSERVATION_ID" },
62 : { PULSAR_GATE_ID, "PULSAR_GATE_ID" },
63 : { SPECTRAL_WINDOW_ID, "SPECTRAL_WINDOW_ID" },
64 : { PHASE_ID, "PHASE_ID" },
65 : { STATE_ID, "STATE_ID" },
66 :
67 : { FREQ_GROUP, "FREQ_GROUP" },
68 : { FREQ_GROUP_NAME, "FREQ_GROUP_NAME" },
69 : { FIELD_NAME, "FIELD_NAME" },
70 : { FIELD_CODE, "FIELD_CODE" },
71 : { SOURCE_NAME, "SOURCE_NAME" },
72 : { SOURCE_CODE, "SOURCE_CODE" },
73 : { CALIBRATION_GROUP, "CALIBRATION_GROUP" },
74 :
75 : { GAIN, "GAIN" },
76 : { REF_ANT, "REF_ANT" },
77 : { REF_FEED, "REF_FEED" },
78 : { REF_RECEPTOR, "REF_RECEPTOR" },
79 : { REF_FREQUENCY, "REF_FREQUENCY" },
80 : { MEAS_FREQ_REF, "MEAS_FREQ_REF" },
81 : { REF_DIRECTION, "REF_DIRECTION" },
82 : { MEAS_DIR_REF, "MEAS_DIR_REF" },
83 : { POINTING_OFFSET, "POINTING_OFFSET" },
84 : { MEAS_POINTING, "MEAS_POINTING" },
85 : { CAL_DESC_ID, "CAL_DESC_ID" },
86 : { CAL_HISTORY_ID, "CAL_HISTORY_ID" },
87 :
88 : { TOTAL_SOLUTION_OK, "TOTAL_SOLUTION_OK" },
89 : { TOTAL_FIT, "TOTAL_FIT" },
90 : { TOTAL_FIT_WEIGHT, "TOTAL_FIT_WEIGHT" },
91 : { SOLUTION_OK, "SOLUTION_OK" },
92 : { FIT, "FIT" },
93 : { FIT_WEIGHT, "FIT_WEIGHT" },
94 : { FLAG, "FLAG" },
95 : { SNR, "SNR" },
96 :
97 : { NUM_SPW, "NUM_SPW" },
98 : { NUM_CHAN, "NUM_CHAN" },
99 : { NUM_RECEPTORS, "NUM_RECEPTORS" },
100 : { N_JONES, "N_JONES" },
101 : { CHAN_FREQ, "CHAN_FREQ" },
102 : { CHAN_WIDTH, "CHAN_WIDTH" },
103 : { CHAN_RANGE, "CHAN_RANGE" },
104 : { JONES_TYPE, "JONES_TYPE" },
105 : { POLARIZATION_TYPE, "POLARIZATION_TYPE" },
106 : { MS_NAME, "MS_NAME" },
107 :
108 : { CAL_PARMS, "CAL_PARMS" },
109 : { CAL_TABLES, "CAL_TABLES" },
110 : { CAL_SELECT, "CAL_SELECT" },
111 : { CAL_NOTES, "CAL_NOTES" },
112 :
113 : { CAL_DESC, "CAL_DESC" },
114 : { CAL_HISTORY, "CAL_HISTORY" },
115 : { OBSERVATION, "OBSERVATION" },
116 :
117 : { ROT_MEASURE, "ROT_MEASURE" },
118 : { ROT_MEASURE_ERROR, "ROT_MEASURE_ERROR" },
119 : { IONOSPH_TEC, "IONOSPH_TEC" },
120 : { IONOSPH_TEC_ERROR, "IONOSPH_TEC_ERROR" },
121 :
122 : { PHASE_OFFSET, "PHASE_OFFSET" },
123 : { SB_DELAY, "SB_DELAY" },
124 : { DELAY_RATE, "DELAY_RATE" },
125 :
126 : { POLY_TYPE, "POLY_TYPE" },
127 : { POLY_MODE, "POLY_MODE" },
128 : { SCALE_FACTOR, "SCALE_FACTOR" },
129 : { VALID_DOMAIN, "VALID_DOMAIN" },
130 : { N_POLY_AMP, "N_POLY_AMP" },
131 : { N_POLY_PHASE, "N_POLY_PHASE" },
132 : { POLY_COEFF_AMP, "POLY_COEFF_AMP" },
133 : { POLY_COEFF_PHASE, "POLY_COEFF_PHASE" },
134 : { PHASE_UNITS, "PHASE_UNITS" },
135 :
136 : { SIDEBAND_REF, "SIDEBAND_REF" },
137 :
138 : { N_KNOTS_AMP, "N_KNOTS_AMP" },
139 : { N_KNOTS_PHASE, "N_KNOTS_PHASE" },
140 : { SPLINE_KNOTS_AMP, "SPLINE_KNOTS_AMP" },
141 : { SPLINE_KNOTS_PHASE, "SPLINE_KNOTS_PHASE" }
142 0 : };
143 : }
144 :
145 : // Initialize the static map containing the basic field data types
146 : // Skip this step if already initialized.
147 : //
148 0 : if ( theirTypeMap.size( ) == 0 ) {
149 0 : theirTypeMap = {
150 : { ANTENNA1, TpInt },
151 : { ANTENNA2, TpInt },
152 : { FEED1, TpInt },
153 : { FEED2, TpInt },
154 : { PULSAR_BIN, TpInt },
155 : { SCAN_NUMBER, TpInt },
156 : { TIME, TpDouble },
157 : { TIME_EXTRA_PREC, TpDouble },
158 : { INTERVAL, TpDouble },
159 : { ARRAY_ID, TpInt },
160 : { PROCESSOR_ID, TpInt },
161 : { FIELD_ID, TpInt },
162 : { OBSERVATION_ID, TpInt },
163 : { PULSAR_GATE_ID, TpInt },
164 : { SPECTRAL_WINDOW_ID, TpInt },
165 : { PHASE_ID, TpInt },
166 : { STATE_ID, TpInt },
167 :
168 : { FREQ_GROUP, TpInt },
169 : { FREQ_GROUP_NAME, TpString },
170 : { FIELD_NAME, TpString },
171 : { FIELD_CODE, TpString },
172 : { SOURCE_NAME, TpString },
173 : { SOURCE_CODE, TpString },
174 : { CALIBRATION_GROUP, TpInt },
175 :
176 : { GAIN, TpComplex },
177 : { REF_ANT, TpInt },
178 : { REF_FEED, TpInt },
179 : { REF_RECEPTOR, TpInt },
180 : { REF_FREQUENCY, TpDouble },
181 : { MEAS_FREQ_REF, TpInt },
182 : { REF_DIRECTION, TpDouble },
183 : { MEAS_DIR_REF, TpInt },
184 : { CAL_DESC_ID, TpInt },
185 : { CAL_HISTORY_ID, TpInt },
186 :
187 : { TOTAL_SOLUTION_OK, TpBool },
188 : { TOTAL_FIT, TpFloat },
189 : { TOTAL_FIT_WEIGHT, TpFloat },
190 : { SOLUTION_OK, TpBool },
191 : { FIT, TpFloat },
192 : { FIT_WEIGHT, TpFloat },
193 : { FLAG, TpBool },
194 : { SNR, TpFloat },
195 :
196 : { NUM_SPW, TpInt },
197 : { NUM_CHAN, TpInt },
198 : { NUM_RECEPTORS, TpInt },
199 : { N_JONES, TpInt },
200 : { CHAN_FREQ, TpDouble },
201 : { CHAN_WIDTH, TpDouble },
202 : { CHAN_RANGE, TpInt },
203 : { JONES_TYPE, TpString },
204 : { POLARIZATION_TYPE, TpString },
205 : { MS_NAME, TpString },
206 :
207 : { CAL_PARMS, TpString },
208 : { CAL_TABLES, TpString },
209 : { CAL_SELECT, TpString },
210 : { CAL_NOTES, TpString },
211 :
212 : { CAL_DESC, TpTable },
213 : { CAL_HISTORY, TpTable },
214 : { OBSERVATION, TpTable },
215 :
216 : { ROT_MEASURE, TpFloat },
217 : { ROT_MEASURE_ERROR, TpFloat },
218 : { IONOSPH_TEC, TpFloat },
219 : { IONOSPH_TEC_ERROR, TpFloat },
220 :
221 : { PHASE_OFFSET, TpFloat },
222 : { SB_DELAY, TpFloat },
223 : { DELAY_RATE, TpFloat },
224 :
225 : { POLY_TYPE, TpString },
226 : { POLY_MODE, TpString },
227 : { SCALE_FACTOR, TpComplex },
228 : { VALID_DOMAIN, TpDouble },
229 : { N_POLY_AMP, TpInt },
230 : { N_POLY_PHASE, TpInt },
231 : { POLY_COEFF_AMP, TpDouble },
232 : { POLY_COEFF_PHASE, TpDouble },
233 : { PHASE_UNITS, TpString },
234 :
235 : { SIDEBAND_REF, TpComplex },
236 :
237 : { N_KNOTS_AMP, TpInt },
238 : { N_KNOTS_PHASE, TpInt },
239 : { SPLINE_KNOTS_AMP, TpDouble },
240 : { SPLINE_KNOTS_PHASE, TpDouble }
241 0 : };
242 : }
243 :
244 0 : }
245 :
246 : //----------------------------------------------------------------------------
247 :
248 0 : String MSCalEnums::fieldName (Int enumField)
249 : {
250 : // Static function to look up the field name:
251 : // Inputs:
252 : // enumField Int Field enumeration.
253 : // Outputs:
254 : // fieldName String Field name.
255 : // Exceptions:
256 : // Exception if invalid field enumeration.
257 : //
258 : // Initialize map if empty
259 0 : if ( theirFieldMap.size( ) == 0 ) initMaps();
260 :
261 : // Return the column name
262 0 : return theirFieldMap[enumField];
263 : };
264 :
265 : //----------------------------------------------------------------------------
266 :
267 0 : Block<String> MSCalEnums::fieldNames (const Vector<Int>& enumFields)
268 : {
269 : // Static function to look up a set of field names:
270 : // Inputs:
271 : // enumFields const Vector<Int>& Field enumerations.
272 : // Outputs:
273 : // fieldNames Block<String> Field names.
274 : // Exceptions:
275 : // Exception if invalid field enumeration.
276 : //
277 : // Return the column names
278 0 : uInt nFields = enumFields.nelements();
279 0 : Block<String> names(nFields);
280 0 : for (uInt i=0; i < nFields; i++) {
281 0 : names[i] = fieldName (enumFields(i));
282 : };
283 0 : return names;
284 : };
285 :
286 : //----------------------------------------------------------------------------
287 :
288 0 : DataType MSCalEnums::basicType (Int enumField)
289 : {
290 : // Static function to look up the basic field data type:
291 : // Inputs:
292 : // enumField Int Field enumeration.
293 : // Outputs:
294 : // basicType DataType Basic data type
295 : // Exceptions:
296 : // Exception if invalid field enumeration.
297 : //
298 : // Initialize map if empty
299 0 : if ( theirTypeMap.size( ) == 0 ) initMaps();
300 :
301 : // Return the column name
302 0 : return theirTypeMap[enumField];
303 : };
304 :
305 : //----------------------------------------------------------------------------
306 :
307 :
308 :
309 :
310 :
311 :
312 :
313 : } //# NAMESPACE CASA - END
314 :
|