]> Pileus Git - ~andy/rsl/blob - nsig.h
RSL v1.41
[~andy/rsl] / nsig.h
1 /* For SIGMET version 1 and version 2 files.
2  *
3  * John H. Merritt
4  * Applied Research Corp.
5  * NASA GSFC Code 910.1
6  *
7  *
8  * The structures exactly match the SIGMET documentation.
9  */
10
11 #ifndef NSIG2_H
12 #define NSIG2_H
13
14 /*Structure identifier, byte 0 of structure_header, III-18 */
15 #define NSIG_INGEST_SUM 3
16 #define NSIG_PROD       7
17
18 /* Data type, value for byte 22 in ingest data header, III-29 */
19 #define NSIG_DTB_EXH       0
20 #define NSIG_DTB_UCR       1
21 #define NSIG_DTB_CR        2
22 #define NSIG_DTB_VEL       3 
23 #define NSIG_DTB_WID       4
24 #define NSIG_DTB_ZDR       5
25 #define NSIG_DTB_UCR2      8
26 #define NSIG_DTB_CR2       9
27 #define NSIG_DTB_VEL2     10
28 #define NSIG_DTB_WID2     11
29 #define NSIG_DTB_ZDR2     12
30 #define NSIG_DTB_KDP      14
31 #define NSIG_DTB_KDP2     15
32 #define NSIG_DTB_PHIDP    16
33 #define NSIG_DTB_VELC     17 
34 #define NSIG_DTB_SQI      18
35 #define NSIG_DTB_RHOHV    19
36 #define NSIG_DTB_RHOHV2   20
37 #define NSIG_DTB_DBZ2     21
38 #define NSIG_DTB_VELC2    22
39 #define NSIG_DTB_SQI2     23
40 #define NSIG_DTB_PHIDP2   24
41 #define NSIG_DTB_HCLASS   55
42 #define NSIG_DTB_HCLASS2  56
43 #define NSIG_DTB_ZDRC     57
44 #define NSIG_DTB_ZDRC2    58
45
46 /* Product type code ,value for byte 12 in product configuration 
47  * struct, III-35
48  */
49 #define NSIG_PROD_PPI        1             /*  PPI */
50 #define NSIG_PROD_RHI        2             /*  RHI */
51 #define NSIG_PROD_CAPPI      3             /*  CAPPI */
52 #define NSIG_PROD_CROSS      4             /*  Cross section */
53 #define NSIG_PROD_TOPS       5             /*  Echo tops */
54 #define NSIG_PROD_RAIN1      7             /*  Precipitation 1 hour */
55 #define NSIG_PROD_TRACK      6             /*  Storm track */
56 #define NSIG_PROD_RAINN      8             /*  Precipitation n hour */
57 #define NSIG_PROD_VVP        9             /*  Velocity Volume processing */
58 #define NSIG_PROD_VIL        10            /*  Vertically Integrated Liquid */
59 #define NSIG_PROD_SHEAR      11            /*  Wind shear */
60 #define NSIG_PROD_WARN       12            /*  Warning (overlay) */
61 #define NSIG_PROD_RTPPI      13            /*  Real time PPI */
62 #define NSIG_PROD_RTRHI      14            /*  Real time RHI */
63 #define NSIG_PROD_RAW        15            /*  Raw data set (no display)*/
64 #define NSIG_PROD_MAX        16            /*  Maximum with side panels */
65 #define NSIG_PROD_USER       17            /*  Earth projection user product */
66 #define NSIG_PROD_USERV      18            /*  Section projection user product */
67 #define NSIG_PROD_OTHER      19            /*  Other user product (no display) */
68 #define NSIG_PROD_STATUS     20            /*  Status product (no display) */
69 #define NSIG_PROD_SLINE      21            /*  Shear Line Product */
70 #define NSIG_PROD_WIND       22            /*  Horizontal wind field */
71
72 #define NSIG_SCAN_PPI 1
73 #define NSIG_SCAN_RHI 2
74 #define NSIG_SCAN_MAN 3
75 #define NSIG_SCAN_CON 4
76 #define NSIG_SCAN_FIL 5
77
78 #define NSIG_BLOCK   6144
79 #define NSIG_MAX_BIN 1536
80
81 /* Two byte binary angle is unsigned short */
82 /* Using these typedefs forces non-word alignment.  This is because
83  * we don't want any space between members of a structure.
84  * -- A coding trick --
85  */
86 typedef unsigned char bang[2];
87 typedef unsigned char twob[2];
88 typedef unsigned char fourb[4];
89
90 /* Ray header 3.4.2, page III-29 */
91 /* No change for NSIG_VER2 */
92 typedef struct {
93   bang beg_azm;  /* Azimuth   at beginning of ray (binary angle). */
94   bang beg_elev; /* Elevation at beginning of ray (binary angle). */
95   bang end_azm;  /* Azimuth   at end of ray (binary angle). */
96   bang end_elev; /* Elevation at end of ray (binary angle). */
97   twob num_bins; /* Actual number of bins in the ray. */
98   twob sec;      /* Time in seconds from start of sweep (unsigned). */
99 } NSIG_Ray_header;
100 /*============================================================*/
101 /*============================================================*/
102
103 /* Extended Header version 0, section 3.4.3, page III-29 */
104 /* No change for NSIG_VER2 */
105 typedef struct {
106   fourb   msec;
107   twob  cal_sig;
108   twob  spare[7];
109 } NSIG_Ext_header_ver0;
110 /*============================================================*/
111 /*============================================================*/
112
113 /* Extended Header version 1, section 3.4.3, page III-29 */
114 typedef struct {
115   fourb msec;       /* Time in milliseconds from the sweep starting time. */
116   twob  cal_sig;    /* Calibration Signal level. */
117   bang  azm;        /* Azimuth (binary angle) */
118   bang  elev;       /* Elevation (binary angle) */
119   bang  train_ord;  /* Train order (binary angle) */
120   bang  elev_ord;   /* Elevation order (binary angle) */
121   bang  pitch;      /* Pitch   (binary angle) */
122   bang  roll;       /* Roll    (binary angle) */
123   bang  heading;    /* Heading (binary angle) */
124   bang  azm_rate;   /* Azimuth Rate (binary angle/sec) */
125   bang  elev_rate;  /* Elevation Rate (binary angle/sec) */
126   bang  pitch_rate; /* Pitch Rate (binary angle/sec) */
127   bang  roll_rate;  /* Roll Rate (binary angle/sec) */
128 #ifdef NSIG_VER2
129
130 #else
131   bang  heading_rate; /* Heading Rate (binary angle/sec) */
132 #endif
133   fourb   lat; /* Latitude (binary angle) */
134   fourb   lon; /* Longitude (binary angle) */
135   twob  alt;   /* Altitude (meters) */
136   twob  vel_e; /* Velocity East (cm/sec) */
137   twob  vel_n; /* Velocity North (cm/sec) */
138   twob  vel_u; /* Velocity Up (cm/sec) */
139 #ifdef NSIG_VER2
140
141 #else
142   fourb   time_update; /* Time since last update (milliseconds) */
143 #endif
144   twob  nav_sys_flag;  /* Navigation system OK flag */
145   twob  rad_vel_cor;   /* Radial velocity correction (velocity units) */
146 } NSIG_Ext_header_ver1;
147 /*============================================================*/
148 /*============================================================*/
149
150
151
152
153 /*-----------------------------------------------------------------*/
154 /* Note:
155  *   All structure names are prefixed with NSIG_ and have the
156  *   first letter of the remainder capitalized.
157  */
158 /*-----------------------------------------------------------------*/
159
160 /* Structure header 3.2.35, page III-18 */
161 typedef struct {
162   twob  id;
163 #ifdef NSIG_VER2
164   twob  version;
165   fourb num_bytes;
166 #else
167   fourb num_bytes;
168   twob  version;
169 #endif
170   twob  spare;
171   twob  flags;
172 } NSIG_Structure_header;
173 /*============================================================*/
174 /*============================================================*/
175
176 /* Time sturcture 3.2.36, page III-18 */
177 typedef struct {
178 #ifdef NSIG_VER2
179   fourb sec;  
180   twob  msec;  /* Fractions of seconds in milliseconds. */
181   twob  year;
182   twob  month;
183   twob  day;
184 #else
185   twob  year;
186   twob  month;
187   twob  day;
188   fourb sec;
189 #endif
190 } NSIG_Ymds_time;
191 /*============================================================*/
192 /*============================================================*/
193
194 /* ingest data header 3.4.1, page III-28 */
195 typedef struct {
196    NSIG_Structure_header struct_head;
197    NSIG_Ymds_time        time;
198 #ifdef NSIG_VER2
199 #else
200    twob  data_type;
201 #endif
202    twob  sweep_num;
203    twob  num_rays_swp;
204    twob  ind_ray_one;
205    twob  num_rays_exp;
206    twob  num_rays_act;
207    bang  fix_ang;
208    twob  bits_bin;
209 #ifdef NSIG_VER2
210   twob data_type;  /* Data code (See Task_DSP_Info.IDATA) */
211   char  spare[36];
212 #else
213   char  spare[38];
214 #endif
215 } NSIG_Ingest_data_header;
216 /*============================================================*/
217 /*============================================================*/
218
219 /* No change for NSIG_VER2 */
220 typedef struct {
221   twob    rec_num;
222   twob    sweep_num;
223   twob    ray_loc;
224   twob    ray_num;
225   twob    flags;
226   twob    spare;
227 } NSIG_Raw_prod_bhdr;
228 /*============================================================*/
229 /*============================================================*/
230 #ifdef NSIG_VER2
231 /* Define the color scale conversion */
232 typedef struct {
233 #define COLOR_SCALE_OVERRIDE (0x0200)
234 #define COLOR_SCALE_VARIABLE (0x0100)
235 #define COLOR_LABEL_MASK     (0x00ff)
236   fourb iflags;
237   fourb istart;
238   fourb istep;
239   twob  icolcnt;
240   twob  ipalette_num;
241   twob  ilevel_seams[16];
242 } NSIG_Color_scale_def;
243 #endif
244 /*============================================================*/
245 /*============================================================*/
246
247 /* Product configuration structure 3.5.1.1, page III-35 */
248 typedef struct {
249    NSIG_Structure_header st_head;
250    twob                  prod_code;
251 #ifdef NSIG_VER2
252   twob  isch;                    /*  Scheduling */
253 #define PSC_HOLD_P    0           /*   Do not run at all. */
254 #define PSC_NEXT_P    1           /*   Run once on next available data */
255 #define PSC_ALL_P     2           /*   Run as data becomes available */
256 #define PSC_AGAIN_P   3           /*   Run again on data last used */
257
258   fourb isch_skip;                /*  # seconds between runs */
259
260 #else
261
262 #endif
263    NSIG_Ymds_time        prod_time;
264    NSIG_Ymds_time        file_time;
265    NSIG_Ymds_time        schd_time;
266    twob   schd_code;    /* Not used in Ver 2. */
267    fourb    sec_skip;   /* Not used in Ver 2. */
268    char   user_name[12];
269 #ifdef NSIG_VER2
270
271 #else
272    char   file_name[12];
273 #endif
274    char   task_name[12];
275 #ifdef NSIG_VER2
276
277 #else
278    char   spare_name[12];
279 #endif
280    twob   flag;
281 #ifdef NSIG_VER2
282   fourb ixscale, iyscale, izscale; /*  Scale in cm/pixel  */
283 #else
284
285 #endif
286    fourb    x_size;
287    fourb    y_size;
288    fourb    z_size;
289    fourb    x_loc;
290    fourb    y_loc;
291    fourb    z_loc;
292    fourb    max_rng;
293 #ifdef NSIG_VER2
294   fourb irange_last_v20;       /* Range of last bin in cm (raw only) */
295   char ipad128x2[2];
296   twob idata_out;             /* Data type of data generated by product gen */
297
298   /* This section for version 2.1+ products: */
299   char ipad132x12[12];
300   twob idata_in;                 /*  Data type used by the generator */
301   char ipad146x2[2];
302   twob iradial_smooth;           /*  Range in km*100 over which radial  */
303                                   /*  smoothing should be done.  0:none. */
304   twob iruns;                    /*  # of times this pcf has been run   */
305   fourb izr_const;                /*  Z-R or Z-W constant and exponent   */
306   fourb izr_exp;                  /*   in 1/1000 of integers             */
307   twob ix_smooth;                /*  X-Y Smoothing parameters for 2D */
308   twob iy_smooth;                /*   products.  km*100,  0:none */
309
310   /* ---- Product Specific Parameters ---- */
311   /*The following area conveys information needed for each specific product.*/
312
313   char psi[80];  /* Do we need these??  -John 8/14/96 */
314
315   char ipad244x28[28];
316   NSIG_Color_scale_def colors;
317
318 #else
319
320    twob   bits_item;
321    twob   data_type;
322    fourb    data_start;
323    fourb    data_step;
324    twob   num_col;
325   /* The following depends on version 2.0, 2.1 etc check III-34,35 */
326   /* Currently, though, this is not used. */
327   char spare[178];
328 #endif
329 } NSIG_Product_config;
330 /*============================================================*/
331 /*============================================================*/
332
333
334 /* product end 3.5.1.2 ,page III-36 */
335 typedef struct {
336 #ifdef NSIG_VER2
337   char sprod_sitename[16];  /* Name of product generator site, space padded */
338   char sprod_version[8];    /* Product IRIS version, null terminated */
339   char sing_version[8];     /* Ingest IRIS version, null terminated */
340   NSIG_Ymds_time data_time; /* Oldest data in this file */
341   char ipad44x46[42];
342 #else
343   char  part_name[80];     /* Path name of file on disk. */
344   NSIG_Ymds_time data_time; /* Date/time structure. */
345 #endif
346   char  site_name[16];     /* Site name.  Eg. mit, tog, kwa (upper-case?). */
347   twob  ahead_gms;         /* # minutes ahead of GMT. */
348   fourb lat;               /* Latitude (binary angle format). */
349   fourb lon;               /* Longitude (binary angle format). */
350   twob  grnd_sea_ht;       /* Signed ground height (meters). */
351   twob  rad_grnd_ht;       /* Radar height above ground (meters). */
352 #ifdef NSIG_VER2
353
354 #else
355   twob  sig_proc;          /* Type of signal processor used. */
356 #endif
357   fourb prf;               /* PRF (hz). */
358   fourb pulse_wd;          /* sample width in microsec/100*/
359 #ifdef NSIG_VER2
360   twob  sig_proc;          /* Type of signal processor used. */
361 #else
362
363 #endif
364   twob  trg_rate;          /* Trigger rate scheme. */
365   twob  num_samp;          /* number of samples (per ray). */
366   char  clutter_file[12];  /* Clutter filter file name. */
367   twob  num_filter;        /* Number of filter used for the first range bin. */
368   fourb wavelen;           /* Wavelength in 1/100 of centimeters. */
369   fourb trunc_ht;          /* Truncation height in cm. */
370   fourb rng_f_bin;         /* Range of the first bin in cm. */
371   fourb rng_l_bin;         /* Range of the last  bin in cm. */
372   fourb num_bin;           /* Number of output bins. */
373   twob  flag;              /* Flag word. */
374 #define PH_OVERLAY_P   (0x0001)     /*  Has an overlay \ For picture */
375 #define PH_RINGS_P     (0x0002)     /*  Has range rings/ products only */
376
377   twob  file_up;           /* Number of updates to the file. */
378   char  label[16][4];      /* Array of labels for color parameter legend. */
379 #ifdef NSIG_VER2
380   twob ilog_filter_first;             /* Log filter used on first bin */
381   char ipad238x10[10];
382 #else
383   char  label_unit[12];    /* Text holding units of the labels. (Ver 2 only) */
384 #endif
385   twob  prod_seq;          /* Product sequence number. */
386   twob  color_num[16];     /* Color numbers for the up to 16 steps. */
387   char  color_reject;      /* Color used for rejected data. */
388 #ifdef NSIG_VER2
389  char ipad283x2[3];
390
391   /* The number of results elements at the end of the file.
392    * Used for warning, shearline, and track only */
393   twob iresults_count;
394
395 #define PROD_END_PAD 20
396   char ipad_end[PROD_END_PAD];
397 #else
398   char  color_unscan;      /* Color used for unscanned area. */
399   char  color_over;        /* Color used for overlays. */
400   char  spare;
401   fourb prod_max_rng;      /* Max range of the first product used as input. */
402   char  spare2[18];
403 #endif
404 } NSIG_Product_end;
405 /*============================================================*/
406 /*============================================================*/
407
408 /* Ingest Summary Header 3.3.1 , page III-19 */
409 typedef struct {
410   char   file_name[80];         /* Name of file on disk. */
411   twob   num_file;              /* Number of associated data files extant. */
412 #ifdef NSIG_VER2
413     twob isweeps_done ;     /* # of sweeps that have been completed */
414 #endif
415   fourb  sum_size;              /* Total size of all files in bytes. */
416   NSIG_Ymds_time start_time;    
417 #ifdef NSIG_VER2
418   char ipad100x12[12];
419 #else
420   char   drive_name[16];        /* Name of tape drive written to. */
421 #endif
422   twob   size_ray_headers;      /* Number of bytes in the ray headers. */
423   twob   size_ext_ray_headers;  /* Number of bytes in extended ray headers. */
424 #ifdef NSIG_VER2
425  twob ib_task;                     /* # bytes in task config table */
426   char ipad_118x6[6];
427   char siris_version[8];             /* Null terminated */
428   char ipad_132x18[18];
429 #else
430   twob   num_task_conf_tab;     /* Number of task configuration table. */
431   twob   size_device_status_tab; /* Number of bytes in device status table. */
432   twob   gparam_size;         /* Number of bytes in each gparam. */
433   char   spare[28];
434 #endif
435   char   site_name[16];       /* Name of site from setup program. */
436   twob   time_zone;           /* Time zione of recorded time, +min of GMT */
437   fourb  lat_rad;             /* Latitude of radar. */
438   fourb  lon_rad;             /* Longitude of radar. */
439   twob   grd_height;          /* Height of ground at site (meters) */
440   twob   ant_height;          /* Height of radar above ground (meters) */
441   twob   azm_res;             /* Resolution of delta azimuth in sweep. */
442   twob   ray_ind;             /* Index of first rays from above set of rays.
443                                                            *  Or the angle of the first ray.
444                                                            */
445   twob   num_rays;            /* Number of rays in a sweep. */
446   fourb  ant_alt;             /* Altitude of radar above sea level in cm */
447   fourb  vel[3];              /* [0]=east, [1]=north, [2]=up */
448   fourb  ant_offset[3];       /* [0]=starboard, [1]=bow, [2]=up */
449 #ifdef NSIG_VER2
450   char spare2[264];
451 #else
452   char spare2[266];
453 #endif
454 } NSIG_Ingest_summary;
455 /*============================================================*/
456 /*============================================================*/
457
458 /* rvp5_gparam structure 3.3.4.1, page III-26 */
459 typedef struct {
460   twob  revision;               /* Revision                 */
461   twob  num_bins;               /* Number of range bins     */
462   twob  cur_trig_p;             /* Current trigger period   */
463   twob  cur_tag1;               /* Current TAG00 - TAG15    */
464   twob  cur_tag2;               /* Current TAG16 - TAG31    */
465   twob  l_chan_noise;   /* Log channel noise level  */
466   twob  i_chan_noise;   /* I Channel noise level    */
467   twob  q_chan_noise;   /* Q Channel noise level    */
468   twob  lat_proc_status;/* Latched processor status */
469   twob  imm_proc_status;/* Immdiate processor status */
470   twob  diag_reg_a;     /* Diagnostic register A    */
471   twob  diag_reg_b;     /* Diagnostic register B    */
472   twob  num_pulses;     /* Number of pulses per ray */
473   twob  trig_c_low;     /* Trigger count (low 16 bits)  */
474   twob  trig_c_high;    /* Trigger count (high 8 bits)  */
475   twob  num_acq_bins;   /* # of properly acquired bins  */
476   twob  num_pro_bins;   /* # of properly processed bins */
477   twob  rng_off;        /* 25-meter range offset        */
478   twob  noise_rng;      /* Noise range in KM            */
479   twob  noise_trg;      /* Noise trigger period         */
480   twob  pulse_w_0;      /* Pulse width 0 min trig period */
481   twob  pulse_w_1;      /* Pulse width 1 min trig period */
482   twob  pulse_w_2;      /* Pulse width 2 min trig period */
483   twob  pulse_w_3;      /* Pulse width 3 min trig period */
484   twob  pulse_w_pat;    /* Pulse width bit patterns      */
485   twob  cur_wave_pw;    /* Current waveform/pulsewidth   */
486   twob  cur_trig_gen;   /* Current trigger gen period    */
487   twob  des_trig_gen;   /* Desired trigger gen period    */
488   twob  prt_start;      /* PRT at start of last ray      */
489   twob  prt_end;        /* PRT at end   of last ray      */
490   twob  proc_thr_flag;  /* Processing/threshold flags    */
491   twob  log_con_slope;  /* LOG conversion slope          */
492   twob  log_noise_thr;  /* LOG noise threshold           */
493   twob  clu_cor_thr;    /* Clutter correction threshold  */
494   twob  sqi_thr;        /* SQI threshold                 */
495   twob  log_thr_w;      /* LOG threshold for width       */
496   twob  cal_ref;        /* Calibration reflectivity      */
497   twob  q_i_cur_samp;   /* Q and I current sample        */
498   twob  l_cur_samp;     /* Log current sample            */
499   twob  rng_avr_cho;    /* Range averaging choice        */
500   twob  spare1[3];
501   twob  i_sqr_low;
502   twob  i_sqr_high;
503   twob  q_sqr_low;
504   twob  q_sqr_high;
505   twob  noise_mean;
506   twob  noise_std;
507   twob  spare2[15];
508 } NSIG_Rpv5_gparam;
509 /*============================================================*/
510 /*============================================================*/
511
512 typedef struct {
513   NSIG_Structure_header struct_head;
514   NSIG_Rpv5_gparam rpv5;
515 } NSIG_Gparam;
516 /*============================================================*/
517 /*============================================================*/
518
519 /* One_device_structure.  Sect: 3.3.3.1 */
520 #ifdef NSIG_VER2
521 typedef struct {
522   fourb status;
523 #define DEV_NULL_P   (0)         /*Not applicable*/
524 #define DEV_OK_P     (1)         /*OK*/
525 #define DEV_ERROR_P  (2)         /*Error has occured*/
526 /* The following are only valid for network devices */
527 #define DEV_REMOTE_P (5)         /*Remote computer unavailable*/
528 #define DEV_IRIS_P   (6)         /*Remote IRIS unavailable*/
529
530 /* This number indicates which process is using the device. */
531   fourb process;
532 #define PROC_NONE_P    (0)       /*Noone is using it*/
533 #define PROC_RTDISP_P  (1)       /*Real time display*/
534 #define PROC_INGEST_P  (2)       /*Ingest*/
535 #define PROC_INGFIO_P  (3)       /*Ingest file output*/
536 #define PROC_REINGEST_P (4)       /*Reingest !!!tom */
537 #define PROC_OUTFMT_P  (5)       /*Output Formatter*/
538 #define PROC_PRODUCT_P (6)       /*Product generator*/
539 #define PROC_NETWORK_P (7)       /*Network  !!!tom */
540 #define PROC_QUICK_P   (8)       /*Quick look menu(part of out)*/
541 #define PROC_TAPE_P    (9)       /*Tape process*/
542 #define PROC_NORDRAD_P (10)       /*NORDRAD process*/
543
544   /* Node name or user name */
545   char  nuser_name[16];
546   /* Number of characters in the name */
547   char  nchar;
548   /* Process mode, see process_status structure */
549   fourb imode;
550 #define MODE_NULL    (0)
551 #define MODE_STOPPED (1)
552 #define MODE_IDLE    (2)
553 #define MODE_RUNNING (3)
554 #define MODE_EXIT    (4)
555 #define MODE_QUICK   (5)
556 #define MODE_INIT    (6)
557 #define MODE_HOLD    (7)
558
559 /* Used only for antenna device */
560 #define MODE_ANT_NULL  (0)
561 #define MODE_ANT_IRIS  (1)
562 #define MODE_ANT_LOCAL (2)
563 #define MODE_ANT_MAIN  (3)
564 #define MODE_ANT_COMP  (4)
565 #define MODE_ANT_SHUT  (5)
566   char spare[8];
567 } NSIG_One_device;
568 #else
569 typedef struct {
570   twob status;
571   twob process;
572   char user_name[15];
573   char nchar;
574   char spare[10];
575 } NSIG_One_device;
576 /*============================================================*/
577 /*============================================================*/
578 #endif
579
580 typedef struct {
581 #ifdef NSIG_VER2
582 /* THIS IS WRONG.... but, does it matter for RSL ???? */
583   NSIG_Structure_header struct_head;
584   NSIG_One_device       dsp_stat[4];
585   NSIG_One_device       ant_stat[4];
586   NSIG_One_device       outdev_stat[12];
587   char spare[120];
588 #else
589   NSIG_Structure_header struct_head;
590   NSIG_One_device       dsp_stat[4];
591   NSIG_One_device       ant_stat[4];
592   NSIG_One_device       outdev_stat[12];
593   char spare[120];
594 #endif
595 } NSIG_Device_status;
596 /*============================================================*/
597 /*============================================================*/
598   
599 /* No change for NSIG_VER2 */
600 typedef struct {
601   fourb startt; /* Start time (seconds within a day) */
602   fourb stopt;  /* Stop  time (seconds within a day) */
603   fourb skipt;  /* Desired skip time (seconds) */
604   fourb time_last; /* Time last run (seconds w/in a day) */
605   fourb time_used; /* Time used on last run (seconds) */
606   fourb day_last;  /* Relative day of last run. */
607   twob  iflag;     /* bit 0=ASAP, bit 1= Mandatory,
608                                         * bit 2=Late skip, bit 3= Time used has been measured,
609                                         * bit 4=Stop after running.
610                                         */
611   char spare[94];
612 } NSIG_Task_sched_info;
613 /*============================================================*/
614 /*============================================================*/
615
616 #ifdef NSIG_VER2
617 typedef struct {
618   twob low_prf; /* Hertz */
619   twob low_prf_frac; /* Fraction part, scaled by 2**-16 */
620   twob low_prf_sample_size;
621   twob low_prf_range_averaging; /* In bins */
622   twob thresh_refl_unfolding; /* Threshold for reflectivity unfolding in 1/100 dB */
623   twob thresh_vel_unfolding; /* Threshold for velocity unfolding in 1/100 dB */
624   twob thresh_sw_unfolding; /* Threshold for width unfolding in 1/100 dB */
625   char spare[18];
626 } NSIG_Task_dsp_mode_batch;
627 #endif
628 /*============================================================*/
629 /*============================================================*/
630
631 #ifdef NSIG_VER2
632 typedef struct {
633   fourb mask_word_0;
634   fourb ext_hdr_type;
635   fourb mask_word_1;
636   fourb mask_word_2;
637   fourb mask_word_3;
638   fourb mask_word_4;
639 } NSIG_Dsp_data_mask;
640 #endif
641 /*============================================================*/
642 /*============================================================*/
643
644
645 /* Task dsp info 3.3.2.2, page III-22 */
646 typedef struct {
647 #ifdef NSIG_VER2
648   twob   dsp_num;
649   fourb   dsp_type;
650   NSIG_Dsp_data_mask  data_mask_cur;
651   NSIG_Dsp_data_mask  data_mask_orig;
652   NSIG_Task_dsp_mode_batch task_dsp_mode;
653   char spare[52];
654 #else
655   twob   dsp_num;
656   twob   dsp_type;
657   fourb  data_mask;
658   fourb  aux_data_def[32];
659 #endif
660   fourb  prf;
661   fourb  pwid;
662   twob   prf_mode;
663   twob   prf_delay;
664   twob   agc_code;
665   twob   samp_size;
666   twob   gain_con_flag;
667   char   filter_name[12];
668 #ifdef NSIG_VER2
669   char idop_filter_first;       /* Doppler based filter used on first bin */
670   char ilog_filter_first;       /* Z based filter used on first bin */
671 #else
672   twob   f_num;
673 #endif
674   twob   atten_gain;
675 #ifdef NSIG_VER2
676   twob  igas_atten;             /* 100000 * db/km */
677   twob  clutter_map_flag;
678   twob  xmt_phase_seq;
679   fourb ray_hdr_mask;
680   twob  time_series_playback;
681   twob  spare2;
682   char  custom_ray_hdr_name[16];
683 #define TASK_DSP_INFO_PAD 120
684   char ipad_end[TASK_DSP_INFO_PAD];
685 #else
686   char   spare[150];
687 #endif
688 } NSIG_Task_dsp_info;
689 /*============================================================*/
690 /*============================================================*/
691
692 /* task cal info struct: 3.3.2.3, page III-22, rec 2 offset 944 */
693 /* No change for NSIG_VER2 */
694 typedef struct {
695   twob slope;             /* 00: Reflectivity slope (4096*dB/ A/D Count) */
696   twob noise;             /* 02: Noise threshold (1/16 dB above noise)   */
697   twob clutr_corr;        /* 04: Clutter correction threshold (1/16 dB)  */
698   twob sqi;                       /* 06: (0-1)*256                               */
699   twob power;             /* 08: (1/16 dBZ)                              */
700   char spare1[8];         /* 10: <spare>  8                              */
701   twob cal_ref;           /* 18: Calibration reflectivity                */
702   twob z_flag_unc;        /* 20: Threshold flags for Unc. reflectivity   */
703   twob z_flag_cor;        /* 22: Threshold flags for Cor. reflectivity   */
704   twob v_flag;            /* 24: Threshold flags for velocity            */
705   twob w_flag;            /* 26: Threshold flags for width               */
706   char spare2[8];         /* 28: <spare> 8                               */
707   twob speckle;           /* 36: Speckle remover flag. See III-22        */
708   twob slope_2;           /* 38: Refl. slope for second processor        */
709   twob cal_ref_2;         /* 40: Calibration reflectivity for 2nd proc   */
710   twob zdr_bias;          /* 42: ZDR bias in signed 1/16 dB              */
711   char spare3[276];       /* 44: <spare> 276                             */
712 } NSIG_Task_calib_info;
713 /*============================================================*/
714 /*============================================================*/
715
716
717 /* Task_range_info Structure 3.3.2.4,  page III-23                    */
718 typedef struct { 
719   fourb   rng_first;            /* 00: Range to first bin [cm]          */
720   fourb   rng_last;                     /* 04: Range to last bin [cm]           */
721 #ifdef NSIG_VER2
722   fourb ibin_last;              /* Range of last (input) bin in cm */
723 #else
724 #endif
725   twob    num_bins;                     /* 08: Number of input bins             */
726   twob    num_rngbins;          /* 10: Number of output range bins      */
727   twob    var_bin_spacing;      /* 12: Variable range bin spacing (0,1) */
728   fourb   binstep_in;           /* 14: Step between input bins          */
729   fourb   binstep_out;          /* 18: Step between output bins         */
730   twob    bin_avg_flag;         /* 22: Range bin averaging flag  */
731                             /* 0:No Avg,  1:Avg Pairs, ... */
732 #ifdef NSIG_VER2
733   char    spare[132];       /* 24: <spare> 132                      */
734 #else
735   char    spare[136];       /* 24: <spare> 136                      */
736 #endif
737 } NSIG_Task_range_info;
738 /*============================================================*/
739 /*============================================================*/
740
741
742 /* Task scan info structure 3.3.2.5, page III-23 */
743 typedef struct {
744   twob  ant_scan_mode; /* 1:PPI, 2:RHI, 3:manual, 4:file */
745   twob  ang_res;       /* Desired angular resolution in 1/100 degree. */
746 #ifdef NSIG_VER2
747  bang iscan_speed ;
748 #else
749   twob  spare1;
750 #endif
751   twob  num_swp;       /* Number of sweeps to perform. */
752   bang  beg_ang;       /* Starting elevation(RHI)/azimuth(PPI) */
753   bang  end_ang;       /* Ending   elevation(RHI)/azimuth(PPI) */
754   bang  list[40];      /* List of azimuths(RSI)/elevations(PPI) */
755 #ifdef NSIG_VER2
756   /*
757 union serv_task_scan_info_u
758 {
759   struct serv_task_rhi_scan_info rhi;
760   struct serv_task_ppi_scan_info ppi;
761   struct serv_task_file_scan_info fil;
762   struct serv_task_manual_scan_info man;
763 } ;
764 */
765   char  spare2[116];
766 #else
767   char  spare3[112];
768 #endif
769 } NSIG_Task_scan_info;
770 /*============================================================*/
771 /*============================================================*/
772
773 typedef struct {
774   fourb wavelength;       /* Wavelength in 1/100 of cm */
775   char  serial_num[16];   /* T/R Serial Number */
776   fourb xmit_pwr;         /* Transmit Power in watts. */
777   twob  flag;             /* bit 0: Digital signal simulator in use.
778                                                    * bit 4: Keep bit.
779                                                    */
780 #ifdef NSIG_VER2
781   twob ipolar;                  /* Type of polarization, see dsp_lib.h */
782   fourb itrunc;                 /* Truncation height in cm */
783   char  ipad32x18[18];          /* Reserved for polarization description */
784
785 #else
786   char  spare1[24];       
787 #endif
788   twob  display_parm1;    /* Real time display parameter #1 */
789   twob  display_parm2;    /* Real time display parameter #2 */
790   /* The following 3 members are not used in Ver 2. */
791   twob  product_flag;     /* Real time product flag         */
792   char  spare2[2];
793   fourb truncation_height;/* Truncation height (cm) */
794   twob  nbytes_comments;  /* Number of bytes of comments entered. */
795   char  spare3[256];
796 } NSIG_Task_misc_info;
797
798 typedef struct {
799   twob major; /* Task major number */
800   twob minor; /* Task minor number */
801   char name[12];  /* Name of task configuration file. */
802   char desc[80];  /* Task description. */
803 #ifdef NSIG_VER2
804   fourb ihybrid_count;          /* Number of tasks in this hybrid set */
805 #else
806
807 #endif
808   twob state; /* Task state: 0=no task, 1=task being modified,
809                            *             2=inactive, 3=scheduled, 4=running
810                            */
811 #ifdef NSIG_VER2
812  char spare[218];
813 #else
814   char spare[222];
815 #endif
816 } NSIG_Task_end_data;
817 /*============================================================*/
818 /*============================================================*/
819
820
821 typedef struct {
822   NSIG_Structure_header struct_head;
823   NSIG_Task_sched_info  sched_info;
824   NSIG_Task_dsp_info    dsp_info;
825   NSIG_Task_calib_info  calib_info;
826   NSIG_Task_range_info  range_info;
827   NSIG_Task_scan_info   scan_info;
828   NSIG_Task_misc_info   misc_info;
829   NSIG_Task_end_data    end_data;
830 #ifdef NSIG_VER2
831 char comments[720];
832 #else
833
834 #endif
835 } NSIG_Task_config;
836 /*============================================================*/
837 /*============================================================*/
838
839
840 typedef struct {
841   NSIG_Structure_header struct_head;
842   NSIG_Product_config   prod_config;
843   NSIG_Product_end      prod_end;
844   char                  spare[5504];
845 } NSIG_Record1;
846 /*============================================================*/
847 /*============================================================*/
848
849 typedef struct {
850   NSIG_Structure_header struct_head; 
851   NSIG_Ingest_summary   ingest_head;
852   NSIG_Task_config      task_config;
853   NSIG_Device_status    device_stat;
854   NSIG_Gparam           dsp1;
855   NSIG_Gparam           dsp2;
856   char                  spare[1260];
857 } NSIG_Record2;
858 /*============================================================*/
859 /*============================================================*/
860
861
862 /* This is the organization of the 2'nd to n'th file on the tape.
863  * This structure is incomplete in that only one data record is
864  * listed.  Record 1, Record 2, a data record.  As each data record
865  * is ingested, the data replaces the data record part and keeps
866  * the information in Record 1 and 2 unchanged.
867  */
868 typedef unsigned char NSIG_Data_record[NSIG_BLOCK];
869
870 typedef struct {
871   NSIG_Record1     rec1;
872   NSIG_Record2     rec2;
873   NSIG_Data_record data;
874 } NSIG_Product_file;
875 /*============================================================*/
876 /*============================================================*/
877
878
879 /* This is the first physical file on the TAPE. It is the only
880  * file on the tape that has this organization.  All other files
881  * are PRODUCT FILES (NSIG_Product_file).  Normally, this is ignored
882  * when reading disk files; there you're only reading PRODUCT FILES.
883  */
884 typedef struct {
885   NSIG_Structure_header struct_head;
886   char                  tape_id_name[16];
887   char                  site_name[16];
888   NSIG_Ymds_time        ymds;
889   twob                  drive_num;
890   twob                  tape_type;
891   char                  spare[262];
892 } NSIG_Tape_header_file;
893 /*============================================================*/
894 /*============================================================*/
895
896 /* FUNCTION PROTOTYPES */
897 FILE *nsig_open(char *file_name);
898 void swap_nsig_record1(NSIG_Record1 *rec1);
899 void swap_nsig_record2(NSIG_Record2 *rec2);
900 void swap_nsig_raw_prod_bhdr(NSIG_Raw_prod_bhdr *rp);
901 void swap_nsig_ingest_data_header(NSIG_Ingest_data_header *ih);
902
903 /* Sweep reading structure */
904 typedef struct {
905   NSIG_Ray_header h;
906   unsigned char *range;  /* 0..h.num_bins-1 */
907 } NSIG_Ray;
908 /*============================================================*/
909 /*============================================================*/
910
911 typedef struct {
912   NSIG_Raw_prod_bhdr bhdr;
913   NSIG_Ingest_data_header idh;
914   NSIG_Ray **ray;
915   int nparams;  /* For freeing. */
916 } NSIG_Sweep;
917 /*============================================================*/
918 /*============================================================*/
919
920 /* Each routine in nsig.c is renamed when compiling Ver2 code.
921  * The rename is simple: change nsig_ to nsig2_
922  */
923 #ifdef NSIG_VER2
924   #define nsig_open        nsig2_open
925   #define nsig_read_record nsig2_read_record
926   #define nsig_close       nsig2_close
927   #define nsig_endianess   nsig2_endianess
928   #define NSIG_I2          NSIG2_I2 
929   #define NSIG_I4          NSIG2_I4 
930   #define nsig_free_ray             nsig2_free_ray
931   #define nsig_free_sweep           nsig2_free_sweep
932   #define nsig_read_chunk           nsig2_read_chunk
933   #define nsig_read_ext_header_ver0 nsig2_read_ext_header_ver0
934   #define nsig_read_ext_header_ver1 nsig2_read_ext_header_ver1
935   #define nsig_read_ray             nsig2_read_ray
936   #define nsig_read_sweep           nsig2_read_sweep
937   #define nsig_from_bang            nsig2_from_bang
938   #define nsig_from_fourb_ang       nsig2_from_fourb_ang
939   #define swap_nsig_structure_header swap_nsig2_structure_header
940   #define swap_nsig_ymds_time        swap_nsig2_ymds_time
941   #define swap_nsig_color_scale_def  swap_nsig2_color_scale_def
942   #define swap_nsig_product_config   swap_nsig2_product_config
943   #define swap_nsig_product_end      swap_nsig2_product_end
944   #define swap_nsig_ingest_summary   swap_nsig2_ingest_summary
945   #define swap_nsig_task_sched_info  swap_nsig2_task_sched_info 
946   #define swap_nsig_task_dsp_info    swap_nsig2_task_dsp_info   
947   #define swap_nsig_task_calib_info  swap_nsig2_task_calib_info 
948   #define swap_nsig_task_range_info  swap_nsig2_task_range_info 
949   #define swap_nsig_task_scan_info   swap_nsig2_task_scan_info  
950   #define swap_nsig_task_misc_info   swap_nsig2_task_misc_info  
951   #define swap_nsig_task_end_data    swap_nsig2_task_end_data   
952   #define swap_nsig_task_config      swap_nsig2_task_config
953   #define swap_nsig_one_device       swap_nsig2_one_device
954   #define swap_nsig_device_status    swap_nsig2_device_status
955   #define swap_nsig_gparam           swap_nsig2_gparam
956   #define swap_nsig_record1          swap_nsig2_record1
957   #define swap_nsig_record2          swap_nsig2_record2
958   #define swap_nsig_raw_prod_bhdr      swap_nsig2_raw_prod_bhdr
959   #define swap_nsig_ingest_data_header swap_nsig2_ingest_data_header
960   #define get_extended_header_info     get2_extended_header_info
961 #endif
962
963 void nsig_free_ray(NSIG_Ray *r);
964 void nsig_free_sweep(NSIG_Sweep **s);
965 NSIG_Sweep **nsig_read_sweep(FILE *fp, NSIG_Product_file *prod_file);
966 int nsig_read_record(FILE *fp, char *nsig_rec);
967 int nsig_endianess(NSIG_Record1 *rec1);
968 short NSIG_I2 (twob x);
969 int NSIG_I4 (fourb x);
970 void nsig_close(FILE *fp);
971
972 float nsig_from_fourb_ang(fourb ang);
973 float nsig_from_bang(bang in);
974
975 #endif