Exemplo n.º 1
0
float RSL_get_value_from_cappi(Cappi *cappi, float rng, float azm)
   {
   return RSL_get_value_from_sweep(cappi->sweep, azm, rng);
   }
Exemplo n.º 2
0
unsigned char *RSL_rhi_sweep_to_cart(Sweep *s, int xdim, int ydim,
                                     float range, int vert_scale)
{
    int x, y, xx, yy, i, j;
    float angle, r;
    float val;
    int the_index;

    static unsigned char *rhi_cart_image = NULL;
    static unsigned char *buffer = NULL;

    if (s == NULL) return NULL;
    if (buffer == NULL)
        buffer = (unsigned char *)calloc(xdim*ydim, sizeof(unsigned char));
    if (rhi_cart_image == NULL)
        rhi_cart_image = (unsigned char *)calloc(xdim*ydim, sizeof(unsigned char));
    memset(buffer, (unsigned char)0, xdim*ydim);
    memset(rhi_cart_image, (unsigned char)0, xdim*ydim);

    for (y=0; y<xdim; y++)
        for (x=0; x<ydim; x++) {
            if (x != 0)
                angle = (float)atan((double)y/(double)x)*180.0/3.14159;
            else
                angle = 90.0;

            angle = 90.0 - angle;
            r = (float)sqrt((double)x*x + (double)y*y);
            if (r > range)
                val = BADVAL;
            else
                val = RSL_get_value_from_sweep(s, angle, r);

            /* A vertical sweep extends from 0 deg to perhaps 25 deg in
             elevation. For proper orientation of a displayed rhi
             vertical sweep:
             1. reflect image about the line y=x .
             2. translate image downward so that radar site is located
                at the bottom left corner of the image. The sweep will
            	then extend upward from the bottom of the image.
            */
            xx = y;    /* reflection about line y=x */
            yy = x;    /* reflection about line y=x */
            the_index =  (ydim - 1 - yy)*xdim + xx;
            if (val == BADVAL || val == NOTFOUND_V || val == NOTFOUND_H)
                buffer[the_index] = (unsigned char) 0;
            else if (val >= 0)
                buffer[the_index] = (unsigned char) val;
            else
                buffer[the_index] = (unsigned char) (256+val);
        }

    /* To see details in the sweep, it is customary to scale the image
     so that the scale of the vertical axis is 5 or 10 times the scale
     of the horizontal axis.
     Copy each row of pixel values from buffer[] a constant multiple
     number of times into rhi_cart_image[], in order to vertically
     expand the image.
    */
    for (j=0; j<ydim/vert_scale; j++)
        for (i=1; i<=vert_scale; i++)
            memcpy(&rhi_cart_image[(ydim - i - vert_scale*j)*xdim],
                   &buffer[(ydim - 1 - j)*xdim], xdim);

    return rhi_cart_image;
}