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