Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
spec.h
Go to the documentation of this file.
1 /* Spec's Global Memory Definition */
2 
3 #ifndef SPEC_H
4 #define SPEC_H
5 
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <string.h>
9 #include <math.h>
10 
11 #include "backends.h"
12 
13 /*#define SUPERCAM 0 */
14 
15 #ifndef TRUE
16 #define TRUE 1
17 #endif
18 
19 #ifndef FALSE
20 #define FALSE 0
21 #endif
22 
23 #define MAX_RXS 6 // put this in rx.h?
24 
25 #define VLIGHT (299792.5)
26 #define D2R (M_PI / 180.0)
27 #define SMT_ELEVATION (3.186) // Kilometers elevation
28 
29 /* define FAKE_DATA to test system in Tucson; Otherwise the system
30  * expect to talk to real hardware backends
31  *
32  */
33 
34 // #define FAKE_DATA 1
35 
36 #ifdef FAKE_DATA
37  #define HARD_ENABLE_1MHZ_FFB 0
38  #define HARD_ENABLE_250KHz_FFB 1
39  #define HARD_ENABLE_AOS_AB 1
40  #define HARD_ENABLE_AOS_C 0
41  #define HARD_ENABLE_CTS_A 0
42 #else
43  #define HARD_ENABLE_1MHZ_FFB 0
44  #define HARD_ENABLE_250KHz_FFB 0
45  #define HARD_ENABLE_AOS_AB 0
46  #define HARD_ENABLE_AOS_C 0
47  #define HARD_ENABLE_CTS_A 0
48 #endif
49 
50 static const int backend_channels[MAX_BACKENDS] = {
56 };
57 
58 
59 //
60 // See file ~cactus/spectral/include/backend_names.h
61 // for a character strings of above defined backends.
62 //
63 
64 #define SIG_BIN 0
65 #define REF_BIN 1
66 #define TRASH_BIN 2
67 #define MAX_BINS 3
68 
69 // these are internal bad bin numbers for diagnostic use
70 #define NOT_ENABLED_BIN 4
71 #define ZERO_TIME_BIN 8
72 #define LOCAL_BLANK_BIN 0x80
73 
74 #define MAX_ATTEN 128
75 
76 #define MAGIC_SIZE 16
77 #define SPEC_CONFIG_MAGIC "SPECCONF"
78 #define SPEC_ATTEN_MAGIC "SPECATTEN"
79 #define SPEC_MUNCH_MAGIC "MUNCHMAGIC"
80 
81 
82 #define MAX_SPEC_PROCESS 25
83 
84 /* Observing Modes */
85 /* See backend_names.h for a string of these */
86 #define OBS_MODE_ANY -1
87 
88 #define OBS_MODE_IDLE 0
89 #define OBS_MODE_HOT 1
90 #define OBS_MODE_SKY 2
91 #define OBS_MODE_COLD 3
92 #define OBS_MODE_ZERO 4
93 #define OBS_MODE_SIG 5
94 #define OBS_MODE_REF 6
95 #define OBS_MODE_BSP 7
96 #define OBS_MODE_OTF 8
97 #define OBS_MODE_TPON 9
98 #define OBS_MODE_TPOFF 10
99 
100 #define OBS_MODE_MAX 11
101 
102 /* Actual Observing types */
103 
104 #define OBS_IDLE 0
105 #define OBS_PS 1
106 #define OBS_APS 2
107 #define OBS_FS 3
108 #define OBS_BSP 4
109 #define OBS_TP_ON 5
110 #define OBS_TP_OFF 6
111 #define OBS_ATP 7
112 #define OBS_PSM 8
113 #define OBS_APM 9
114 #define OBS_FSM 10
115 #define OBS_TPM_ON 11
116 #define OBS_TPM_OFF 12
117 #define OBS_DRIFT 13
118 #define OBS_PS_CAL 14
119 #define OBS_BS_CAL 15
120 #define OBS_BLANKING 16
121 #define OBS_SEQUENCE 17
122 #define OBS_FIVE_PT 18
123 #define OBS_CONT_MAP 19
124 #define OBS_FOCALIZE 20
125 #define OBS_NS_FOCALIZE 21
126 #define OBS_TP_TIP 22
127 #define OBS_SP_TIP 23
128 #define OBS_D_ON 24
129 #define OBS_CALIBRATE 25
130 #define OBS_FS_PS 26
131 #define OBS_EW_FOCALIZE 27
132 #define OBS_ZEROS 28
133 #define OBS_TLPW 29
134 #define OBS_FQSW 30
135 #define OBS_NOCL 31
136 #define OBS_PLCL 32
137 #define OBS_ONOF 33
138 #define OBS_BMSW 34
139 #define OBS_PSSW 35
140 #define OBS_DRFT 36
141 #define OBS_OTF 37
142 #define OBS_S_ON 38
143 #define OBS_S_OF 39
144 #define OBS_QK5 40
145 #define OBS_QK5A 41
146 #define OBS_PSS1 42 /* PS flip or PS-1 mode */
147 #define OBS_VLBI 43
148 #define OBS_PZC 44
149 #define OBS_CPZM 45
150 #define OBS_PSPZ 46
151 #define OBS_CPZ1 47
152 #define OBS_CPZ2 48
153 #define OBS_CCPZ 49
154 #define OBS_CCPM 50
155 #define OBS_TPPZ 51
156 #define OBS_OPT 52
157 #define OBS_COLDCAL 53
158 
159 /* Sideband specifiers */
160 #define LSB 1
161 #define USB 2
162 
163 #define CAL_VANE 0 /* Normal Vane Cal */
164 #define CAL_AVGAINS 1 /* Const Cal fac specified by Tsys */
165 #define CAL_CONST 2 /* Const Cal fac specified by config const value */
166 
167 #define DICKE_SRR 0 /* (Signal-Reference/Reference mode (normal) */
168 #define DICKE_SR 1 /* (Signal-Reference) mode (for Comb test, etc) */
169 
170 #define SIG_BIN 0
171 #define REF_BIN 1
172 #define ANY_BIN -1
173 
174 // ------------------------ configuration -------------------------------
175 
176 // Below are the possible values for each configuration menu field
177 
178 // Sideband code stored in cpr->sb and alt_sb
179 #define SB_NONE 0 // (secondary freq. only) disabled
180 #define SB_LSB 1 // LSB
181 #define SB_USB 2 // USB
182 
183 // Polarization code stored in cpr->pols
184 #define POL_HV 0 // Both - normal
185 #define POL_VH 1 // Both - swap for testing
186 #define POL_H 2 // H Pol only
187 #define POL_V 3 // V Pol only
188 
189 #define IF_A 0 // IF channel wired to filterbank IF input A
190 #define IF_B 1 // IF channel wired to filterbank IF input B
191 #define IF_C 2 // IF channel wired to filterbank IF input C & AOS A & AOS C
192 #define IF_D 3 // IF channel wired to filterbank IF input D & AOS B & CTS
193 
194 
195 // sent from each spectrometer to catcher for each data set
196 //
197 // NOTE: Some items will be filled later in the data pipeline.
198 //
200  char magic[MAGIC_SIZE]; // fill with SPEC_CONFIG_MAGIC (16 bytes)
201  int which_spec; // Which spec this data belongs to.
202  int nparts; // number of spectra for this spectrometer
203  int nchans; // number of channels in each spectrum
204  int depth; // Number of seperate spectra. (for OTF / DBE?)
205  int bin; // bin 0 for sig, 1 for ref, 2 trash
206  int walsh; // walsh function value for this dataset
207  int int_time; // integration time in microseconds
208  int error_bits; // zero for good, error bits defined in header
209  int mode; // Observing modes: SIG, HOT, SKY etc
210  float obsTime; // Mid-Time for observation (OTF Mapping)
211  float raoff; // Right Assension Offset for OTF Mapping;
212  float decoff; // Declination Offset for OTF Mapping;
213  float azoff; // Azinuth Offset for OTF Mapping;
214  float eloff; // Elevation Offset for OTF Mapping;
215  struct timespec start_time; // when integration started (2 longs)
216  struct timespec end_time; // when integration ended (2 longs)
217 }; /* 16 + (14 * 4 ) + (2 * 8) = 88 bytes in size */
218 
221  int data[MAX_SPEC_CHANS]; // raw spectral data array
222 };
223 
224 /* same struct only with floating point data */
225 struct SPEC_CAL_SET {
227  float data[MAX_SPEC_CHANS]; // Processed Cal array
228 };
229 
232  double data[MAX_SPEC_CHANS]; // Accumalation data array
233 };
234 
235 // sent from catcher to each spectrometer as config command
236 struct SPEC_CONFIG {
237  char magic[MAGIC_SIZE]; // fill with SPEC_CONFIG_MAGIC
238  int spec_enable; // This backend is usable.
239  int data_enable; // Data acq enable flags for each backend
240  int which_spec; // Which spec this config belongs to.
241  int nparts; // number of spectra for this spectrometer
242  int valid_mask; // SAMbus blanking mask
243  int valid_bits; // SAMbus blanking valid bits
244  int swap_code; // swapping spectrometer halves
245  int image_offset; // Obsolete!image offset(kHz) for 4-IF backends
246  int doppler_khz[MAX_PARTS]; // doppler shift of alt. sideband per FFB part
247  int offset_khz[MAX_PARTS]; // manual offset added for each FFB part
248  double res; // backend resolutions in MHz
249  double center; // and center channels in MHz from sky LO
250 };
251 
254  int spares[64];
255  struct timespec time_stamp; // when config sent
257 };
258 
259 
260 struct SPEC_ATTEN {
263  int n;
264  struct timespec time_stamp; // when atten sent
266 };
267 
268 
270  char magic[MAGIC_SIZE]; // MUNCHMAGIC
271  int scan_segment; // Sequence number of scan part
272  int walsh; // walsh function value for this dataset
273  int mode; // mode segment; vane, sky, off, on, otf
274  int scanno; // scan number for this observation
275  float secs; // Requested integration time (Secs)
276  int nbufs; // Num of buffers for this obs
277  int counts; // Sizes of each buffer.
278  int depth; // Number of buffers (i.e. OTF)
279  int act_integ[2]; // Actual integration time. (uSec)
280  struct timespec start_time; // when data collection started
281  struct timespec end_time; // when data collection stopped
282 };
283 
284 
285 #endif
struct SPEC_DATA_SUB_SET sdss
Definition: spec.h:231
char magic[MAGIC_SIZE]
Definition: spec.h:270
float azoff
Definition: spec.h:213
#define MAGIC_SIZE
Definition: spec.h:76
int scan_segment
Definition: spec.h:271
int which_spec
Definition: spec.h:201
int n
Definition: spec.h:263
char magic[MAGIC_SIZE]
Definition: spec.h:261
int which_spec
Definition: spec.h:262
int walsh
Definition: spec.h:272
#define MAX_AOS_B_CHANNELS
Definition: backends.h:28
int scanno
Definition: spec.h:274
float eloff
Definition: spec.h:214
int which_spec
Definition: spec.h:240
int swap_code
Definition: spec.h:244
#define MAX_1MHZ_CHANNELS
Definition: backends.h:23
int image_offset
Definition: spec.h:245
int mode
Definition: spec.h:273
int act_integ[2]
Definition: spec.h:279
struct SPEC_DATA_SUB_SET sdss
Definition: spec.h:220
char magic[MAGIC_SIZE]
Definition: spec.h:253
int valid_bits
Definition: spec.h:243
int valid_mask
Definition: spec.h:242
struct timespec end_time
Definition: spec.h:216
struct timespec start_time
Definition: spec.h:215
struct timespec time_stamp
Definition: spec.h:255
int nparts
Definition: spec.h:241
char magic[MAGIC_SIZE]
Definition: spec.h:237
int data_enable
Definition: spec.h:239
int error_bits
Definition: spec.h:208
#define MAX_AOS_C_CHANNELS
Definition: backends.h:29
struct timespec time_stamp
Definition: spec.h:264
int offset_khz[MAX_PARTS]
Definition: spec.h:247
int counts
Definition: spec.h:277
float raoff
Definition: spec.h:211
char magic[MAGIC_SIZE]
Definition: spec.h:200
#define MAX_PARTS
Definition: backends.h:15
#define MAX_BACKENDS
Definition: backends.h:14
struct timespec start_time
Definition: spec.h:280
int spec_enable
Definition: spec.h:238
double center
Definition: spec.h:249
struct timespec end_time
Definition: spec.h:281
#define MAX_250KHZ_CHANNELS
Definition: backends.h:24
float decoff
Definition: spec.h:212
int depth
Definition: spec.h:278
#define MAX_AOS_A_CHANNELS
Definition: backends.h:27
int spares[64]
Definition: spec.h:254
float obsTime
Definition: spec.h:210
#define MAX_SPEC_CHANS
Definition: backends.h:35
float secs
Definition: spec.h:275
struct SPEC_CONFIG configs[MAX_BACKENDS]
Definition: spec.h:256
#define MAX_CTS_CHANNELS
Definition: backends.h:33
double res
Definition: spec.h:248
int doppler_khz[MAX_PARTS]
Definition: spec.h:246
#define MAX_ATTEN
Definition: spec.h:74
struct SPEC_DATA_SUB_SET sdss
Definition: spec.h:226
int nbufs
Definition: spec.h:276