pro get_merged_sounding, fname, start_hr, end_hr, start_z, end_z common merged_sounding_data, num_times2, hrfrac2, jday2, temp, $ height2, num_heights2, press, rh, theta, mxrat, svp, smxrat common mmcr_merged_data, num_times, hrfrac, jday, dbz, $ height, num_heights, vel, width common merged_sounding_data2, sflag cdfid=ncdf_open(fname, /nowrite) ; open the netcdf file time_did=ncdf_dimid(cdfid,'time') height_did=ncdf_dimid(cdfid,'height') ncdf_diminq, cdfid, time_did, char_strng, num_times ncdf_diminq, cdfid, height_did, char_strng, num_heights ; get the id's of the variables to be read num_sec_id=ncdf_varid(cdfid,'base_time') time_offset_id=ncdf_varid(cdfid,'time_offset') height_id=ncdf_varid(cdfid,'height') temp_id=ncdf_varid(cdfid,'temp') mxrat_id=ncdf_varid(cdfid,'mxrat') sflag_id=ncdf_varid(cdfid,'sndg_flag') press_id=ncdf_varid(cdfid,'pressure') ; get the data ncdf_varget, cdfid, num_sec_id, num_sec ncdf_varget, cdfid, time_offset_id, time_offset ncdf_varget, cdfid, height_id, height i=1 while (height(i) le end_z) do i=i+1 num_heights=i-1 ijday_ihrfrac_fm_numsec, num_sec, time_offset, hrfrac, jday, yy, mm, dd, hh, mi, ss ;i=1 ;while (hrfrac[i-1] ne 0 and i le (num_times-1)) do begin ;print, hrfrac[i], (i) ;i=i+1 ;endwhile ;num_times=i-1 ; determine the start and end time index i=1 while (hrfrac[i] lt start_hr) do i=i+1 start_time_index=i-1 ii=1 while (hrfrac[i] lt end_hr and hrfrac[i] lt hrfrac[num_times-1]) do begin i=i+1 endwhile end_time_index=i ; determine the start and end height index i=1 while (height[i] lt start_z) do i=i+1 start_height_index=i-1 while (height[i] lt end_z and height[i] lt height[num_heights-1]) do begin i=i+1 endwhile end_height_index=i start=indgen(1,1) count=indgen(1,1) temp=findgen(end_time_index-start_time_index+1,end_height_index-start_height_index+1) press=findgen(end_time_index-start_time_index+1,end_height_index-start_height_index+1) rh=findgen(end_time_index-start_time_index+1,end_height_index-start_height_index+1) theta=findgen(end_time_index-start_time_index+1,end_height_index-start_height_index+1) mxrat=findgen(end_time_index-start_time_index+1,end_height_index-start_height_index+1) svp=findgen(end_time_index-start_time_index+1,end_height_index-start_height_index+1) smxrat=findgen(end_time_index-start_time_index+1,end_height_index-start_height_index+1) temp1=findgen(end_height_index-start_height_index+1) sflag=intarr(end_time_index-start_time_index+1) ii=start_time_index for i=0,end_time_index-start_time_index do begin start=[start_height_index,ii] count=[end_height_index-start_height_index+1,1] ncdf_varget, cdfid, temp_id, temp1, offset=start, count=count temp[i,*]=temp1[*] ncdf_varget, cdfid, mxrat_id, temp1, offset=start, count=count mxrat[i,*]=temp1[*] ncdf_varget, cdfid, press_id, temp1, offset=start, count=count press[i,*]=temp1[*] ncdf_varget, cdfid, sflag_id, sflag, offset=start_time_index, count=end_time_index-start_time_index+1 ii=ii+1 endfor calc_rh_theta, start_time_index, end_time_index, $ end_height_index, start_height_index ncdf_close, cdfid hrfrac2=findgen(end_time_index-start_time_index+1) jday2=findgen(end_time_index-start_time_index+1) height2=findgen(end_height_index-start_height_index+1) ii=0 for i=start_time_index,end_time_index do begin hrfrac2[ii]=hrfrac[i] jday2[ii]=jday[i] ii=ii+1 endfor num_times2=ii ii=0 for i=start_height_index,end_height_index do begin height2[ii]=height[i] ii=ii+1 endfor num_heights2=ii return end