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: 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 :
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 0 : {ANTENNA1, "ANTENNA1"},
50 0 : {ANTENNA2, "ANTENNA2"},
51 0 : { FEED1, "FEED1" },
52 0 : { FEED2, "FEED2" },
53 0 : { PULSAR_BIN, "PULSAR_BIN" },
54 0 : { SCAN_NUMBER, "SCAN_NUMBER" },
55 0 : { TIME, "TIME" },
56 0 : { TIME_EXTRA_PREC, "TIME_EXTRA_PREC" },
57 0 : { INTERVAL, "INTERVAL" },
58 0 : { ARRAY_ID, "ARRAY_ID" },
59 0 : { PROCESSOR_ID, "PROCESSOR_ID" },
60 0 : { FIELD_ID, "FIELD_ID" },
61 0 : { OBSERVATION_ID, "OBSERVATION_ID" },
62 0 : { PULSAR_GATE_ID, "PULSAR_GATE_ID" },
63 0 : { SPECTRAL_WINDOW_ID, "SPECTRAL_WINDOW_ID" },
64 0 : { PHASE_ID, "PHASE_ID" },
65 0 : { STATE_ID, "STATE_ID" },
66 :
67 0 : { FREQ_GROUP, "FREQ_GROUP" },
68 0 : { FREQ_GROUP_NAME, "FREQ_GROUP_NAME" },
69 0 : { FIELD_NAME, "FIELD_NAME" },
70 0 : { FIELD_CODE, "FIELD_CODE" },
71 0 : { SOURCE_NAME, "SOURCE_NAME" },
72 0 : { SOURCE_CODE, "SOURCE_CODE" },
73 0 : { CALIBRATION_GROUP, "CALIBRATION_GROUP" },
74 :
75 0 : { GAIN, "GAIN" },
76 0 : { REF_ANT, "REF_ANT" },
77 0 : { REF_FEED, "REF_FEED" },
78 0 : { REF_RECEPTOR, "REF_RECEPTOR" },
79 0 : { REF_FREQUENCY, "REF_FREQUENCY" },
80 0 : { MEAS_FREQ_REF, "MEAS_FREQ_REF" },
81 0 : { REF_DIRECTION, "REF_DIRECTION" },
82 0 : { MEAS_DIR_REF, "MEAS_DIR_REF" },
83 0 : { POINTING_OFFSET, "POINTING_OFFSET" },
84 0 : { MEAS_POINTING, "MEAS_POINTING" },
85 0 : { CAL_DESC_ID, "CAL_DESC_ID" },
86 0 : { CAL_HISTORY_ID, "CAL_HISTORY_ID" },
87 :
88 0 : { TOTAL_SOLUTION_OK, "TOTAL_SOLUTION_OK" },
89 0 : { TOTAL_FIT, "TOTAL_FIT" },
90 0 : { TOTAL_FIT_WEIGHT, "TOTAL_FIT_WEIGHT" },
91 0 : { SOLUTION_OK, "SOLUTION_OK" },
92 0 : { FIT, "FIT" },
93 0 : { FIT_WEIGHT, "FIT_WEIGHT" },
94 0 : { FLAG, "FLAG" },
95 0 : { SNR, "SNR" },
96 :
97 0 : { NUM_SPW, "NUM_SPW" },
98 0 : { NUM_CHAN, "NUM_CHAN" },
99 0 : { NUM_RECEPTORS, "NUM_RECEPTORS" },
100 0 : { N_JONES, "N_JONES" },
101 0 : { CHAN_FREQ, "CHAN_FREQ" },
102 0 : { CHAN_WIDTH, "CHAN_WIDTH" },
103 0 : { CHAN_RANGE, "CHAN_RANGE" },
104 0 : { JONES_TYPE, "JONES_TYPE" },
105 0 : { POLARIZATION_TYPE, "POLARIZATION_TYPE" },
106 0 : { MS_NAME, "MS_NAME" },
107 :
108 0 : { CAL_PARMS, "CAL_PARMS" },
109 0 : { CAL_TABLES, "CAL_TABLES" },
110 0 : { CAL_SELECT, "CAL_SELECT" },
111 0 : { CAL_NOTES, "CAL_NOTES" },
112 :
113 0 : { CAL_DESC, "CAL_DESC" },
114 0 : { CAL_HISTORY, "CAL_HISTORY" },
115 0 : { OBSERVATION, "OBSERVATION" },
116 :
117 0 : { ROT_MEASURE, "ROT_MEASURE" },
118 0 : { ROT_MEASURE_ERROR, "ROT_MEASURE_ERROR" },
119 0 : { IONOSPH_TEC, "IONOSPH_TEC" },
120 0 : { IONOSPH_TEC_ERROR, "IONOSPH_TEC_ERROR" },
121 :
122 0 : { PHASE_OFFSET, "PHASE_OFFSET" },
123 0 : { SB_DELAY, "SB_DELAY" },
124 0 : { DELAY_RATE, "DELAY_RATE" },
125 :
126 0 : { POLY_TYPE, "POLY_TYPE" },
127 0 : { POLY_MODE, "POLY_MODE" },
128 0 : { SCALE_FACTOR, "SCALE_FACTOR" },
129 0 : { VALID_DOMAIN, "VALID_DOMAIN" },
130 0 : { N_POLY_AMP, "N_POLY_AMP" },
131 0 : { N_POLY_PHASE, "N_POLY_PHASE" },
132 0 : { POLY_COEFF_AMP, "POLY_COEFF_AMP" },
133 0 : { POLY_COEFF_PHASE, "POLY_COEFF_PHASE" },
134 0 : { PHASE_UNITS, "PHASE_UNITS" },
135 :
136 0 : { SIDEBAND_REF, "SIDEBAND_REF" },
137 :
138 0 : { N_KNOTS_AMP, "N_KNOTS_AMP" },
139 0 : { N_KNOTS_PHASE, "N_KNOTS_PHASE" },
140 0 : { SPLINE_KNOTS_AMP, "SPLINE_KNOTS_AMP" },
141 0 : { 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 0 : };
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 :
|