2 * This app tests what happens when a sweep has just one azimuth bin for
3 * all the rays. I will first read real data then permute the sweeps.
4 * Then, I'll check how the hash table were built. Based on print_hash_table.
9 void print_link_list(Azimuth_hash *list)
15 printf("\n ray# %d azim %f, hi# %d lo# %d", list->ray->h.ray_num, list->ray->h.azimuth, list->ray_high->ray->h.ray_num, list->ray_low->ray->h.ray_num);
16 print_link_list(list->next);
21 * Cannot compile if the hash table is static in volume.c. For
22 * testing we make it globally known.
30 extern int RSL_max_sweeps; /* Initial allocation for sweep_list.
31 * RSL_new_sweep will allocate the space first
34 extern int RSL_nsweep_addr; /* A count of sweeps in the table. */
35 extern Sweep_list *RSL_sweep_list;
36 extern int RSL_nextents;
38 void print_hash_table (Sweep *s)
45 int SWEEP_INDEX(Sweep *s); // From Volume.c
47 if (s == NULL) return;
48 sweep_index = SWEEP_INDEX(s);
49 res = 360.0/RSL_sweep_list[sweep_index].hash->nindexes;
50 printf("Azimuth resolution = %f for %d bins.\n", res, RSL_sweep_list[sweep_index].hash->nindexes);
51 for (i=0; i<RSL_sweep_list[sweep_index].hash->nindexes; i++) {
52 index = RSL_sweep_list[sweep_index].hash->indexes[i];
54 printf("RSL_sweep_list[%d].hash->indexes[%d] = ", sweep_index, i);
59 print_link_list(index);
63 void poke_about_sweep(Sweep *s)
65 /* This routine demonstrates that the azimuth we want is the azimuth
71 ray = RSL_get_first_ray_of_sweep(s);
72 res = 360.0/s->h.nrays;
73 for (azim=0; azim<360; azim+=res) {
74 ray = RSL_get_ray_from_sweep(s, azim);
76 printf("Azimuth %f matched in ray # %d, h.azimuth= %f, diff=%f\n",
77 azim, ray->h.ray_num, ray->h.azimuth,
80 printf("Azimuth %f NOT FOUND within 1/2 beamwidth; 1/2beam=%f\n",
81 azim, s->h.horz_half_bw);
85 float random_azim(void)
92 Sweep *permute_sweep(Sweep *sweep)
96 if (sweep == NULL) return NULL;
97 for (i=0; i<sweep->h.nrays; i++) {
99 if (ray == NULL) continue;
100 ray->h.azimuth = random_azim();
104 Volume *permute_volume(Volume *volume)
107 if (volume == NULL) return NULL;
108 for (i=0; i<volume->h.nsweeps; i++)
109 volume->sweep[i] = permute_sweep(volume->sweep[i]);
112 Radar *permute_radar(Radar *radar)
115 if (radar == NULL) return NULL;
116 for (i=0; i<radar->h.nvolumes; i++)
117 radar->v[i] = permute_volume(radar->v[i]);
118 printf("Radar permuted. Now, redo the ray_indexes.\n");
122 void chase_hi_links(Sweep *sweep)
126 Hash_table *hash_table;
130 if (sweep == NULL) return;
131 hash_table = hash_table_for_sweep(sweep);
132 table = hash_table->indexes[0];
134 printf("Printing HI links. This has better be a sorted output.\n");
135 printf("ELEVATION angle = %f\n", sweep->h.elev);
136 for (i=0, last_azimuth=-1;i<sweep->h.nrays; i++) {
137 if (table == NULL) continue;
138 printf(" ray# %3d azim %8.6f hi# %3d lo# %3d\n",
139 table->ray->h.ray_num,
140 table->ray->h.azimuth,
141 table->ray_high->ray->h.ray_num,
142 table->ray_low->ray->h.ray_num);
143 azimuth = table->ray->h.azimuth;
144 if (azimuth < last_azimuth) printf("AZIMUTH OUT OF ORDER\n");
145 last_azimuth = azimuth;
146 table = table->ray_high;
150 int main(int argc, char **argv)
156 if (argc < 2 || argc > 3) {fprintf(stderr, "Usage: %s infile [callid_or_firstfile]\n", argv[0]); exit(-1);}
157 RSL_radar_verbose_on();
158 radar = RSL_anyformat_to_radar(argv[1], argv[2]);
160 printf("RADAR IS NULL.\n");
164 printf("permute_radar\n");
165 radar = permute_radar(radar);
167 for (i=0; i<radar->v[DZ_INDEX]->h.nsweeps; i++) {
168 sweep = radar->v[DZ_INDEX]->sweep[i];
169 chase_hi_links(sweep);
172 print_hash_table(sweep);
174 poke_about_sweep(sweep);