function [ra] = get_sh(P,T,relhum)
% function to give specific humidity. 
% first calculate saturation spec. hum.

Rd=287; % gas constant density
Rv=461.5; % gas constant water vapor
epsilon=Rd/Rv; % ratio of gas constants

% saturation water vapor pressure (mb)
e_sat = exp(53.67957-6743.769./T-4.8451*log(T));

% mixing ratio water vapor from partial pressure
r_sat = epsilon*e_sat./(P-e_sat);

% specific humidity from relhum * mixing ratio
ra = r_sat * relhum; 

end
