pro calc_rh_theta, start_time_index, end_time_index, $ end_height_index, start_height_index common merged_sounding_data, num_times2, hrfrac2, jday2, temp, $ height2, num_heights2, press, rh, theta, mxrat, svp, smxrat ; This script will calculate the rh and potential temperature ; from pressure, temperature, and the mixing ratio. for j=0,(end_time_index-start_time_index) do begin for k=0,(end_height_index-start_height_index) do begin ;******* Calculate RH *************** svp[j,k]=6.112*exp((17.67*(temp[j,k]-273.15))/((temp[j,k]-273.15)+243.5)) smxrat[j,k]=1000.*(0.622*(svp[j,k]/((press[j,k]/100.)-svp[j,k]))) ;smxrat[j,k]=0.622*(6.112*exp((17.67*(temp[j,k]-273.15))/((temp[j,k]-273.15)+243.5))/((press[j,k]/100.)-6.112*exp((17.67*(temp[j,k]-273.15))/((temp[j,k]-273.15)+243.5)))) rh[j,k]=100.*(mxrat[j,k]/smxrat[j,k]) if (rh[j,k] gt 100.) then rh[j,k]=100. ;******* Calculate potential temperature ************** theta[j,k]=temp[j,k]*((press[j,k]/100000.)^(-287.04/1004.)) endfor endfor end