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)
46 if (s == NULL) return;
47 sweep_index = SWEEP_INDEX(s);
48 res = 360.0/RSL_sweep_list[sweep_index].hash->nindexes;
49 printf("Azimuth resolution = %f for %d bins.\n", res, RSL_sweep_list[sweep_index].hash->nindexes);
50 for (i=0; i<RSL_sweep_list[sweep_index].hash->nindexes; i++) {
51 index = RSL_sweep_list[sweep_index].hash->indexes[i];
53 printf("RSL_sweep_list[%d].hash->indexes[%d] = ", sweep_index, i);
58 print_link_list(index);
62 void poke_about_sweep(Sweep *s)
64 /* This routine demonstrates that the azimuth we want is the azimuth
70 ray = RSL_get_first_ray_of_sweep(s);
71 res = 360.0/s->h.nrays;
72 for (azim=0; azim<360; azim+=res) {
73 ray = RSL_get_ray_from_sweep(s, azim);
75 printf("Azimuth %f matched in ray # %d, h.azimuth= %f, diff=%f\n",
76 azim, ray->h.ray_num, ray->h.azimuth,
79 printf("Azimuth %f NOT FOUND within 1/2 beamwidth; 1/2beam=%f\n",
80 azim, s->h.horz_half_bw);
84 float random_azim(void)
91 Sweep *permute_sweep(Sweep *sweep)
95 if (sweep == NULL) return NULL;
96 for (i=0; i<sweep->h.nrays; i++) {
98 if (ray == NULL) continue;
99 ray->h.azimuth = random_azim();
103 Volume *permute_volume(Volume *volume)
106 if (volume == NULL) return NULL;
107 for (i=0; i<volume->h.nsweeps; i++)
108 volume->sweep[i] = permute_sweep(volume->sweep[i]);
111 Radar *permute_radar(Radar *radar)
114 if (radar == NULL) return NULL;
115 for (i=0; i<radar->h.nvolumes; i++)
116 radar->v[i] = permute_volume(radar->v[i]);
117 printf("Radar permuted. Now, redo the ray_indexes.\n");
121 void chase_hi_links(Sweep *sweep)
125 Hash_table *hash_table;
129 if (sweep == NULL) return;
130 hash_table = hash_table_for_sweep(sweep);
131 table = hash_table->indexes[0];
133 printf("Printing HI links. This has better be a sorted output.\n");
134 printf("ELEVATION angle = %f\n", sweep->h.elev);
135 for (i=0, last_azimuth=-1;i<sweep->h.nrays; i++) {
136 if (table == NULL) continue;
137 printf(" ray# %3d azim %8.6f hi# %3d lo# %3d\n",
138 table->ray->h.ray_num,
139 table->ray->h.azimuth,
140 table->ray_high->ray->h.ray_num,
141 table->ray_low->ray->h.ray_num);
142 azimuth = table->ray->h.azimuth;
143 if (azimuth < last_azimuth) printf("AZIMUTH OUT OF ORDER\n");
144 last_azimuth = azimuth;
145 table = table->ray_high;
149 int main(int argc, char **argv)
155 if (argc < 2 || argc > 3) {fprintf(stderr, "Usage: %s infile [callid_or_firstfile]\n", argv[0]); exit(-1);}
156 RSL_radar_verbose_on();
157 radar = RSL_anyformat_to_radar(argv[1], argv[2]);
159 printf("RADAR IS NULL.\n");
163 printf("permute_radar\n");
164 radar = permute_radar(radar);
166 for (i=0; i<radar->v[DZ_INDEX]->h.nsweeps; i++) {
167 sweep = radar->v[DZ_INDEX]->sweep[i];
168 chase_hi_links(sweep);
171 print_hash_table(sweep);
173 poke_about_sweep(sweep);