function byte_text, input_text, num_bytes ; create a character array with a fixed length in bytes out_arr = bytarr(max([strlen(input_text),num_bytes])) + 32B ; fill with blanks out_arr(0:(strlen(input_text)-1)) = byte(input_text) ; include text out_arr = out_arr(0:(num_bytes-1)) ; truncate to required number of bytes return, out_arr end pro correction_block, fid cr_ident = 'CFAC' cr_length = long(72) cr_az = float(0.0) ; correction added to azimuth (deg) cr_el = float(0.0) ; correction added to elevation (deg) cr_rng = float(0.0) ; correction added to the range (m) cr_lon = float(0.0) ; correction added to radar longitude cr_lat = float(0.0) ; correction added to radar latitude cr_palt = float(0.0) ; correction added to pressure altitude (km) cr_alt = float(0.0) ; correction added to the radar altitude above ground (km) cr_vx = float(0.0) ; correction added to the ground velocity E-W (m/s) cr_vy = float(0.0) ; correction added to the ground velocity N-S (m/s) cr_vz = float(0.0) ; correction added to the vertical velocity (m/s) cr_hd = float(0.0) ; correction added to the radar platform heading (deg) cr_roll = float(0.0) ; correction added to the radar platform roll (deg) cr_pitch = float(0.0) ; correction added to the radar platform pitch (deg) cr_drift = float(0.0) ; correction added to the platform drift (deg) cr_rot = float(0.0) ; correction added to the platform rotation angle (deg) cr_tilt = float(0.0) ; correction added to the radar tilt angle (deg) writeu, fid, cr_ident, cr_length, cr_az, cr_el, cr_rng, cr_lon, cr_lat, cr_palt, cr_alt writeu, fid, cr_vx, cr_vy, cr_vz, cr_hd, cr_roll, cr_pitch, cr_drift, cr_rot, cr_tilt end pro sweep_block, fid, comment, sweep_num, number_rays, th_start, th_end, th_fixed s_ident = 'SWIB' s_length = long(40) s_comm = byte_text(comment,8) s_num = long(sweep_num) s_nrays = long(number_rays) s_th1 = float(th_start) ; start angle (deg) s_th2 = float(th_end) ; end angle (deg) s_th0 = float(th_fixed) ; fixed angle (???? deg) s_ff = long(0) ; filtering flag writeu, fid, s_ident, s_length, s_comm, s_num, s_nrays, s_th1, s_th2, s_th0, s_ff end pro platform_block, fid, lat, lon, alt, el_angle, az_angle p_ident = 'ASIB' p_length = long(80) p_alon = float(lon) p_alat = float(lat) p_palt = float(alt) p_alt = float(alt) p_vx = float(0.0) p_vy = float(0.0) p_vz = float(0.0) p_head = float(0.0) p_roll = float(0.0) p_pitch = float(0.0) p_drift = float(0.0) p_el = float(el_angle) p_az = float(az_angle) p_wvx = float(0.0) p_wvy = float(0.0) p_wvz = float(0.0) p_dhead = float(0.0) p_dpitch = float(0.0) writeu, fid, p_ident, p_length, p_alon, p_alt, p_palt, p_alt, p_vx, p_vy, p_vz writeu, fid, p_head, p_roll, p_pitch, p_drift, p_el, p_az, p_wvx, p_wvy, p_wvz, p_dhead, p_dpitch end pro comment_block, fid, c_intext c_ident = 'COMM' c_length = long(508) c_dor = 'DORADE: ' c_all = c_dor + c_intext c_comm = byte_text(c_all,500) writeu, fid, c_ident, c_length, c_comm end pro volume_block, fid, proj_name, yr, mo, day ; Volume descriptor v_ident = 'VOLD' v_length = long(72) v_format = fix(-999) v_volnum = fix(1) v_maxbyt = long(-999) v_proj = byte_text(proj_name,20) v_year = fix(yr) v_month = fix(mo) v_day = fix(day) v_hour = fix(-999) v_min = fix(-999) v_sec = fix(-999) v_flight = byte_text(' ',8) v_facil = byte_text('AMFR',8) v_recyr = fix(yr) v_recmo = fix(mo) v_recday = fix(day) v_numsens = fix(3) ; number of radar sensors writeu, fid, v_ident, v_length, v_format, v_volnum, v_maxbyt, v_proj writeu, fid, v_year, v_month, v_day, v_hour, v_min, v_sec, v_flight, v_facil writeu, fid, v_recyr, v_recmo, v_recday, v_numsens end pro radar_block, fid, name, pow, noise, Gant, HPBW, PRF, Freq, lat, lon, alt c = float(3e8) r_ident = 'RADD' r_len = long(144) r_name = byte_text(name,8) r_const = float(-999) ; radar/lidar constant r_ppow = float(pow) ; peak power in kW r_noise = float(noise) ; noise power in dBm r_grec = float(-999) ; receiver gain in dB r_gant = float(Gant) ; antenna gain in dB r_gsys = float(-999) ; system gain in dB r_Hbeam = float(HPBW) ; horizontal beamwidth in degrees r_Vbeam = float(HPBW) ; vertical beamwidth in degrees r_typ = fix(0) ; radar type r_scan = fix(4) ; pointing method r_omega = float(0) ; requested rotational velocity r_scanparam0 = float(-999) ; scan mode specific parameter # 0 r_scanparam1 = float(-999) ; scan mode specific parameter # 1 r_nparam = fix(3) ; number of parameter descriptor blocks r_ndesc = fix(0) ; number of additional descriptor blocks r_comp = fix(0) ; data compression flag r_red = fix(1) ; data reduction algorithm specifier r_thmin = float(-999) ; minimum positive angle r_thmax = float(-999) ; maximum positive angle r_lon = float(lat) ; radar longtitude r_lat = float(lon) ; radar lattitude r_alt = float(alt) ; radar altitude r_vambig = float(c/freq*PRF/4.0) ; max unambiguous velocity (m/s) r_rambig = float(c/PRF/2.0/1000.0) ; max unambiguous range (km) r_nfreq = fix(1) ; number of frequencies r_nIPP = fix(1) ; number of interpulse periods r_freq = fltarr(5) ; frequency array r_freq(1) = float(freq) ; frequency number one r_IPP = fltarr(5) ; IPP array r_IPP(1) = float(1.0/PRF) writeu, fid, r_ident,r_len,r_name,r_const,r_ppow,r_noise,r_grec,r_gant,r_gsys,r_Hbeam,r_Vbeam,r_typ,r_scan writeu, fid, r_omega,r_scanparam0, r_scanparam1, r_nparam,r_ndesc,r_comp,r_red,r_thmin,r_thmax writeu, fid, r_lon,r_lat,r_alt,r_vambig,r_rambig,r_nfreq,r_nIPP,r_freq,r_IPP end pro parameter_block, fid, name, desc, units, BW, dr, nsamp p1_ident = 'PARM' p1_len = long(104) p1_name = byte_text(name,8) p1_detail = byte_text(desc,40) p1_units = byte_text(units,8) p1_ipp = fix(1) ; which IPP to use p1_freq = fix(1) ; which frequency to use p1_BW = float(BW/1.0e6) ; bandwidth in MHz p1_taup = fix(dr) ; effective pulse width in meters p1_pol = fix(1) ; polarization (0-H, 1-V, 2-C, 3-Ellip) p1_nsamp = fix(nsamp) ; number of samples used for estimating parameter p1_form = fix(4) ; binary format of data (1:8 bit, 2:16 bit, 3:24 bit, 4:32 bit FP, 5:16 bit FP) p1_thresh_name = byte_text('NONE',8) ; name of parameter for thresholding p1_thresh = float(-999) p1_scale = float(1) ; scale factor for parameter p1_bias = float(0) ; bias factor for parameter p1_bad_data = long(-999) ; bad data flag writeu, fid, p1_ident, p1_len, p1_name, p1_detail, p1_units, p1_ipp, p1_freq, p1_BW, p1_taup, p1_pol writeu, fid, p1_nsamp, p1_form, p1_thresh_name, p1_thresh, p1_scale, p1_bias, p1_bad_data end pro cell_block, fid, offset, dr ; cell range vector description c_ident = 'CELV' c_len = long(12 + 1024*4) c_nvol = long(1024) c_off = float(offset) ; distance to cell 1 in meters c_vec = indgen(1024,/float)*float(dr) + c_off ; range cells writeu, fid, c_ident, c_len, c_nvol, c_vec end pro ray_block, fid, ray_number, jday, hr, minute, sec, msec, az, el, status r_ident = 'RYIB' r_len = long(44) r_sweepnum = long(ray_number) ; sweep number (???) r_day = long(jday) ; julian day r_hour = fix(hr) ; hour r_min = fix(minute) ; minutes r_sec = fix(sec) ; seconds r_msec = fix(msec) ; millisecond r_az = float(az) ; azimuth in degrees r_el = float(el) ; elevation in degrees r_tpow = float(-999) ; transmit power in kW r_scanrate = float(-999) ; actual scan rate (deg/sec) r_status = long(status) ; status (0-normal, 1-transition, 2-bad) writeu, fid, r_ident, r_len, r_sweepnum, r_day, r_hour, r_min, r_sec, r_msec, r_az, r_el, r_tpow, r_scanrate, r_status end pro data_block, fid, name, data p1_ident = 'RDAT' ; identifier p1_length = long(16+1024*4) ; length of parameter data block p1_name = byte_text(name,8) ; parameter name writeu, fid, p1_ident, p1_length, p1_name, data end pro amfr2dorade, dataCVP0, dataCVR1, dataCVI1 ; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; ; pro amfr2dorade ; ; convert amfr data format intot the DORADE format ; ; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; convert AMFR data to DORADE format. See the following web page for further details: ; ; http://www.eol.ucar.edu/rsf/UserGuides/ELDORA/DoradeFormat/Descriptors.html#COMM ; Ku_infile = '/Users/siqueira/Desktop/TruckTest/Ku_PPP_Long.bin' Ka_infile = '/Users/siqueira/Desktop/TruckTest/Ka_PPP_Long.bin' W_infile = '/Users/siqueira/Desktop/TruckTest/W_PPP_Long.bin' out_file = 'amfr1.dor' mo = fix(12) day = fix(13) yr = fix(2006) hr = fix(14) jday = julday(mo,day,yr,0,0,0) nsamp = float(400) ; number of samples per ray BW = float(5.0e6); ; system bandwidth in Hz dr = float(3.0e8/(2.0*BW)) ; range resolution of system offset = float(0) ; range offset in meters gmt_adj = float(-4) ; time to adjust from GMT for the local standard time nbin = 1024 ; number of range bins nray = 3000 ; number of rays lat = float(42.39314) ; latitude of platform lon = float(-72.529325) alt = float(200.0) c = float(3.0e8) ; the speed of light orient = float(180.0 + 45.0) ; truck orientation az = float(0.0) ; nominal azimuth pointing el = float(0.0) ; nominal elevation pointing PRF01 = float(4000) ; PRF for 1 usec pulses PRF10 = float(2800) ; PRF for 10 usec pulses PRF40 = float(2800) ; PRF for 40 usec pulses Kufreq = float(13.4e9) ; frequency for Kuband KuHPBW = float(0.75) ; Half Power Beamwidth for Ku-band KuG = float(48) ; Gain for Ku-band KuPow = float(5) ; Peak transmit power for Ku-band Kafreq = float(35.6e9) KaHPBW = float(0.7) KaG = float(48) KaPow = float(1.5) Wfreq = float(94.92e9) WHPBW = float(0.7) WG = float(48) WPow = float(2) ;openw, out_fid, out_file, /SWAP_IF_BIG_ENDIAN, /GET_LUN ;openw, out_fid, out_file, /SWAP_ENDIAN, /GET_LUN openw, out_fid, out_file, /GET_LUN ; ; Comment block ; c_text = 'AMFR Data collected during December 13, 2006 during moderate to heavy rains. ' c_more1 = 'Only the 1 microsecond pulse width data is included in the data set.' c_all = c_text + c_more1 comment_block, out_fid, c_all ; ; Volume descriptor ; volume_block, out_fid, 'AMFR_Test1', yr, mo, day ; ; Radar descriptor for Ku-, Ka-, and W-band ; noise = float(-100) radar_block, out_fid, 'AMFR-Ku',KuPow,noise,KuG,KuHPBW,PRF01,Kufreq,lat,lon,alt radar_block, out_fid, 'AMFR-Ka',KaPow,noise,KaG,KaHPBW,PRF01,Kafreq,lat,lon,alt radar_block, out_fid, 'AMFR-W', WPow,noise, WG, WHPBW,PRF01, Wfreq,lat,lon,alt ; ; parameter descriptors for Ku band ; parameter_block, out_fid, 'KUVVP0',' zero lag corr mag of co-pol EV-field','dB(rel)',BW,dr,nsamp parameter_block, out_fid, 'KUVVP1','single lag corr mag of co-pol EV-field','dB(rel)',BW,dr,nsamp parameter_block, out_fid, 'KUVVA1','single lag corr ang of co-pol EV-field','radians',BW,dr,nsamp parameter_block, out_fid, 'KUVHP0',' zero lag corr mag of x-pol EV-field','dB(rel)',BW,dr,nsamp parameter_block, out_fid, 'KUVHP1','single lag corr mag of x-pol EV-field','dB(rel)',BW,dr,nsamp parameter_block, out_fid, 'KUVHA1','single lag corr ang of x-pol EV-field','radians',BW,dr,nsamp parameter_block, out_fid, 'KUHHP0',' zero lag corr mag of co-pol EH-field','dB(rel)',BW,dr,nsamp parameter_block, out_fid, 'KUHHP1','single lag corr mag of co-pol EH-field','dB(rel)',BW,dr,nsamp parameter_block, out_fid, 'KUHHA1','single lag corr ang of co-pol EH-field','radians',BW,dr,nsamp parameter_block, out_fid, 'KUHVP0',' zero lag corr mag of x-pol EH-field','dB(rel)',BW,dr,nsamp parameter_block, out_fid, 'KUHVP1','single lag corr mag of x-pol EH-field','dB(rel)',BW,dr,nsamp parameter_block, out_fid, 'KUHVA1','single lag corr ang of x-pol EH-field','radians',BW,dr,nsamp ; ; cell range vector block and correction factor block ; cell_block, out_fid, offset, dr correction_block, out_fid stars = bytarr(3) header = lonarr(4) dataCVP0 = fltarr(1024) dataCVR1 = fltarr(1024) dataCVI1 = fltarr(1024) dataXVP0 = fltarr(1024) dataXVR1 = fltarr(1024) dataXVI1 = fltarr(1024) dataCHP0 = fltarr(1024) dataCHR1 = fltarr(1024) dataCHI1 = fltarr(1024) dataXHP0 = fltarr(1024) dataXHR1 = fltarr(1024) dataXHI1 = fltarr(1024) openr, Kufid, Ku_infile, /GET_LUN, /SWAP_IF_BIG_ENDIAN openr, Kafid, Ka_infile, /GET_LUN, /SWAP_IF_BIG_ENDIAN openr, Wfid, W_infile, /GET_LUN, /SWAP_IF_BIG_ENDIAN ;openr, Kufid, Ku_infile, /GET_LUN ;openr, Kafid, Ka_infile, /GET_LUN ;openr, Wfid, W_infile, /GET_LUN nray = 30 sweep_num = 1 th_start = 0.0 th_end = 0.0 th_fixed = 0.0 sweep_block, out_fid, 'trial 1', sweep_num, nray, th_start, th_end, th_fixed iray = 0 while (iray le (nray-1)) do begin ; read the v-pol co and cross data readu, Kufid, stars,header,dataCHP0,dataCHR1,dataCHI1,dataXHP0,dataXHR1,dataXHI1 ddataCHP0 = double(dataCHP0) ddataCHR1 = double(dataCHR1) ddataCHI1 = double(dataCHI1) ddataXHP0 = double(dataXHP0) ddataXHR1 = double(dataXHR1) ddataXHI1 = double(dataXHI1) ; read the h-pol co and cross data readu, Kufid, stars,header,dataCVP0,dataCVR1,dataCVI1,dataXVP0,dataXVR1,dataXVI1 ddataCVP0 = double(dataCVP0) ddataCVR1 = double(dataCVR1) ddataCVI1 = double(dataCVI1) ddataXVP0 = double(dataXVP0) ddataXVR1 = double(dataXVR1) ddataXVI1 = double(dataXVI1) sec1 = (double(header(2)) + double(header(3))/1.0e6) ; linux time in seconds since beginning sec2 = sec1 - double(jday - julday(1,1,1970,0,0,0))*24.0*60.0*60.0 + double(gmt_adj*60.0*60.0) ; seconds from the beginning of the day hr = fix(sec2/60.0/60.0) ; actual hour of the day (local time) minute = fix((sec2 - hr*60.0*60.0)/60.0) ; minute of the day after hours removed sec = fix(sec2 - hr*60.0*60.0 - minute*60.0) ; second of the day after hours and minutes removed msec = long((sec2-hr*60.0*60.0 - minute*60.0 - sec)*1000.0) ; millisecond of the day after all above are removed if( (iray mod 10) eq 1)then begin print, 'Local time of data collection (iray,hr,min,sec,msec): ',iray,hr, minute, sec, msec endif if(header(0) lt 2)then begin ; only for 1 usec pulse iray = iray + 1 status = fix(0) ray_block, out_fid, iray, jday, hr, minute, sec, msec, az, el, status el_angle = el az_angle = az platform_block, out_fid, lat, lon, alt, el_angle, az_angle ; ; write parameter data blocks for Ku-band ; plot, float(10*alog10(ddataCVP0)) xyouts, 100,0, 'iray = ' + string(iray) wait, 0.3 data_block, out_fid, 'KUVVP0', float(10*alog10(ddataCVP0)) data_block, out_fid, 'KUVVP1', float(5*alog10(ddataCVR1^2 + ddataCVI1^2)) data_block, out_fid, 'KUVVA1', float(atan(ddataCVI1,ddataCVR1)) data_block, out_fid, 'KUVHP0', float(10*alog10(ddataXVP0)) data_block, out_fid, 'KUVHP1', float(5*alog10(ddataXVR1^2 + ddataXVI1^2)) data_block, out_fid, 'KUVHA1', float(atan(ddataXVI1,ddataXVR1)) data_block, out_fid, 'KUHHP0', float(10*alog10(ddataCHP0)) data_block, out_fid, 'KUHHP1', float(5*alog10(ddataCHR1^2 + ddataCHI1^2)) data_block, out_fid, 'KUHHA1', float(atan(ddataCHI1,ddataCHR1)) data_block, out_fid, 'KUHVP0', float(10*alog10(ddataXHP0)) data_block, out_fid, 'KUHVP1', float(5*alog10(ddataXHR1^2 + ddataXHI1^2)) data_block, out_fid, 'KUHVA1', float(atan(ddataXHI1,ddataXHR1)) endif endwhile ; ; Volume descriptor ; ;volume_block, out_fid, 'AMFR_Test1', yr, mo, day close, out_fid close, Kufid close, Kafid close, Wfid print, 'DORADE FORMAT SUCCESSFULLY WRITTEN!' end