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