static GtkWidget *rotate_button;
static Radar *radar;
+static Sweep *sweep;
+static int nred, ngreen, nblue;
+static unsigned char red[256], green[256], blue[256];
static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
{
glShadeModel(GL_FLAT);
- glBegin (GL_TRIANGLE_FAN);
- glVertex3f(0., 0., 0.);
- glVertex3f(0., .5, 0.);
-
- int angle;
- for (angle = 1; angle <= 360; angle++) {
- double rad = (angle*M_PI)/180.0;
- double x = sin(rad);
- double y = cos(rad);
- //g_printf("tick.. %d - %5.3f: (%5.2f,%5.2f)\n", angle, rad, x, y);
- glColor3f((float)angle/360.0, 0., 0.);
- glVertex3f(x/2., y/2., 0.);
+ glBegin(GL_QUADS);
+
+ int rayi;
+ for (rayi = 0; rayi < sweep->h.nrays; rayi++) {
+ Ray *ray = sweep->ray[rayi];
+
+ /* right and left with respect to north */
+ double right = ((ray->h.azimuth + ray->h.beam_width)*M_PI)/180.0;
+ double left = ((ray->h.azimuth - ray->h.beam_width)*M_PI)/180.0;
+
+ double rx = sin(right), ry = cos(right);
+ double lx = sin(left), ly = cos(left);
+
+ int nbins = ray->h.nbins;
+ //int nbins = 20;
+ int max_dist = nbins * ray->h.gate_size + ray->h.range_bin1;
+ int bini, dist = ray->h.range_bin1;
+ for (bini = 0; bini < nbins; bini++, dist += ray->h.gate_size) {
+ if (ray->range[bini] == BADVAL) continue;
+
+ /* (find middle of bin) / scale for opengl */
+ double nd = ((double)dist - ((double)ray->h.gate_size)/2.) / (double)max_dist;
+ double fd = ((double)dist + ((double)ray->h.gate_size)/2.) / (double)max_dist;
+
+ glColor3ub(
+ red[(unsigned char)ray->h.f(ray->range[bini])],
+ green[(unsigned char)ray->h.f(ray->range[bini])],
+ blue[(unsigned char)ray->h.f(ray->range[bini])]
+ );
+
+ glVertex3f(lx*nd, ly*nd, 0.); // near left
+ glVertex3f(lx*fd, ly*fd, 0.); // far left
+ glVertex3f(rx*fd, ry*fd, 0.); // far right
+ glVertex3f(rx*nd, ry*nd, 0.); // near right
+
+ }
+
+ g_print("\n");
}
- glEnd ();
+ glEnd();
+
+ /* Print the color table */
+ glBegin(GL_QUADS);
+ int i;
+ for (i = 0; i < nred; i++) {
+ glColor3ub(red[i], green[i], blue[i]);
+ glVertex3f(-1., (float)((i ) - nred/2)/(nred/2), 0.); // bot left
+ glVertex3f(-1., (float)((i+1) - nred/2)/(nred/2), 0.); // top left
+ glVertex3f(-.9, (float)((i+1) - nred/2)/(nred/2), 0.); // top right
+ glVertex3f(-.9, (float)((i ) - nred/2)/(nred/2), 0.); // bot right
+ }
+ glEnd();
glPopMatrix ();
RSL_read_these_sweeps("0", NULL);
radar = RSL_wsr88d_to_radar("/scratch/aweather/src/KABR_20080609_0224", "KABR");
RSL_load_refl_color_table();
- RSL_volume_to_gif(radar->v[DZ_INDEX], "dz_sweep", 400, 400, 200.0);
+ RSL_get_color_table(RSL_RED_TABLE, red, &nred);
+ RSL_get_color_table(RSL_GREEN_TABLE, green, &ngreen);
+ RSL_get_color_table(RSL_BLUE_TABLE, blue, &nblue);
+ if (radar->h.nvolumes < 1 || radar->v[0]->h.nsweeps < 1)
+ g_print("No sweeps found\n");
+ sweep = radar->v[0]->sweep[0];
+ RSL_volume_to_gif(radar->v[DZ_INDEX], "dz_sweep", 1024, 1024, 200.0);
}