X-Git-Url: http://pileus.org/git/?p=~andy%2Frsl;a=blobdiff_plain;f=nsig_to_radar.c;h=da9a8ef603641715f12d5c513189b9e51b5893e6;hp=88788e46dba3b2ff6ae1e6535ae5cd0686cfadfa;hb=01560cc947c59aa600473158dfe26ea0dfaf0823;hpb=d08a7f8a699a044bc4ac5f93917aa7f6c463923b diff --git a/nsig_to_radar.c b/nsig_to_radar.c index 88788e4..da9a8ef 100644 --- a/nsig_to_radar.c +++ b/nsig_to_radar.c @@ -174,9 +174,10 @@ RSL_nsig_to_radar float max_vel, sweep_rate, azim_rate; float ray_data; float az1, az2; + float elev1, elev2; double tmp; float sqi, log, csr, sig, cal_dbz; - char radar_type[50], state[2], city[15]; + char radar_type[50], state[4], city[15]; char site_name[16]; NSIG_Product_file *prod_file; short id; @@ -190,9 +191,11 @@ RSL_nsig_to_radar twob nsig_twob; Sweep *sweep; int msec; + const unsigned short low10bits = 0x3ff; float azm, elev, pitch, roll, heading, azm_rate, elev_rate, pitch_rate, roll_rate, heading_rate, lat, lon; + float fix_angle; int alt; /* Altitude */ float rvc; /* Radial correction velocity m/s */ float vel_east, vel_north, vel_up; /* Platform velocity vectors m/sec */ @@ -240,17 +243,6 @@ RSL_nsig_to_radar if (radar_verbose_flag) fprintf(stderr, "Read %d bytes for rec2.\n", n); - /** Test for scan mode -- If scan is a RHI will return NULL **/ - /** because RSL can't handle RHI's. In the future, replace **/ - /** NULL will a routine to convert RHI's to RSL Format **/ - ant_scan_mode =NSIG_I2(prod_file->rec2.task_config.scan_info.ant_scan_mode); - if(ant_scan_mode == 2) - { - if (radar_verbose_flag) - fprintf(stderr, "RHI scan detected. Unable to process, returning NULL.\n"); - /* return NULL; */ - } - /* Count the bits set in 'data_mask' to determine the number * of parameters present. */ @@ -487,6 +479,9 @@ RSL_nsig_to_radar radar->h.height = (int)sea_lvl_hgt; radar->h.spulse = (int)(pw*1000); radar->h.lpulse = (int)(pw*1000); + ant_scan_mode = NSIG_I2(prod_file->rec2.task_config.scan_info.ant_scan_mode); + if(ant_scan_mode == 2 || ant_scan_mode == 7) radar->h.scan_mode = RHI; + else radar->h.scan_mode = PPI; if (radar_verbose_flag) { #ifdef NSIG_VER2 @@ -534,7 +529,7 @@ RSL_nsig_to_radar sweep_day = NSIG_I2(nsig_sweep[itype]->idh.time.day); sweep_sec = NSIG_I4(nsig_sweep[itype]->idh.time.sec); #ifdef NSIG_VER2 - msec = NSIG_I2(nsig_sweep[itype]->idh.time.msec); + msec = NSIG_I2(nsig_sweep[itype]->idh.time.msec) & low10bits; /* printf("....... msec == %d\n", msec); */ #endif /* converting seconds since mid to time of day */ @@ -631,6 +626,26 @@ RSL_nsig_to_radar f = HC_F; invf = HC_INVF; break; + case NSIG_DTB_DBZ2: + ifield = CZ_INDEX; + f = CZ_F; + invf = CZ_INVF; + break; + case NSIG_DTB_ZDRC2: + ifield = ZD_INDEX; + f = ZD_F; + invf = ZD_INVF; + break; + case NSIG_DTB_DBTE8: + ifield = ET_INDEX; + f = ZT_F; + invf = ZT_INVF; + break; + case NSIG_DTB_DBZE8: + ifield = EZ_INDEX; + f = DZ_F; + invf = DZ_INVF; + break; default: fprintf(stderr,"Unknown field type: %d Skipping it.\n", data_type); continue; @@ -668,8 +683,9 @@ RSL_nsig_to_radar sweep->h.beam_width = beam_width; sweep->h.vert_half_bw = vert_half_bw; sweep->h.horz_half_bw = horz_half_bw; - elev = nsig_from_bang(nsig_sweep[itype]->idh.fix_ang); - sweep->h.elev = elev; + fix_angle = nsig_from_bang(nsig_sweep[itype]->idh.fix_ang); + if (radar->h.scan_mode == PPI) sweep->h.elev = fix_angle; + else sweep->h.azimuth = fix_angle; for(j = 0; j < num_rays; j++) { @@ -725,7 +741,7 @@ RSL_nsig_to_radar else ray->h.unam_rng = 0.0; ray->h.prf2 = (int) prf2; - ray->h.fix_angle = (float)sweep->h.elev; + ray->h.fix_angle = fix_angle; ray->h.azim_rate = azim_rate; ray->h.pulse_count = num_samples; ray->h.pulse_width = pw; @@ -734,7 +750,7 @@ RSL_nsig_to_radar ray->h.wavelength = wave/100.0; /* meters */ ray->h.nyq_vel = max_vel; /* m/s */ if (elev == 0.) elev = sweep->h.elev; - ray->h.elev = elev; + /* Compute mean azimuth angle for ray. */ az1 = nsig_from_bang(ray_p->h.beg_azm); az2 = nsig_from_bang(ray_p->h.end_azm); @@ -750,6 +766,21 @@ RSL_nsig_to_radar if (az1 > 360) az1 -= 360; ray->h.azimuth = az1; + /* Compute mean elevation angle for ray. */ + elev1 = nsig_from_bang(ray_p->h.beg_elev); + elev2 = nsig_from_bang(ray_p->h.end_elev); + /* printf("elev1, %f, elev2 %f\n", elev1, elev2); */ + if(elev1 > elev2) + if((elev1 - elev2) > 180.0) elev2 += 360.0; + else + ; + else + if((elev2 - elev1) > 180.0) elev2 -= 360.0; + + elev1 = (elev1 + elev2) / 2.0; + if (elev1 > 360) elev1 -= 360; + ray->h.elev = elev1; + /* From the extended header information, we learn the following. */ ray->h.pitch = pitch; ray->h.roll = roll; @@ -780,6 +811,8 @@ RSL_nsig_to_radar switch(data_type) { case NSIG_DTB_UCR: case NSIG_DTB_CR: + case NSIG_DTB_DBTE8: + case NSIG_DTB_DBZE8: if (ray_p->range[k] == 0) ray_data = NSIG_NO_ECHO; else ray_data = (float)((ray_p->range[k]-64.0)/2.0); break;