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