Jan 31, 2017 class: Precipitation


In [1]:
# Import numerical tools
import numpy as np

Here I will enter the weather data I downloaded for today.


In [2]:
TnoonF = 61 #Temperature at noon (really 1pm) in Farenheit
TnightF = 54 #Temperature at 4am in Farenheit
RHnoon = 0.62 #Relative humidity at noon (really 1pm)
RHnight = 0.96 #Relative humidity at 4 am
Tdp_noonF = 48 #Dew point at noon (really 1pm) in Farenheit
Tdp_nightF = 40 #Dew point at 4 am, Farenheit

Let's convert all of the Farenheit data to Celsius by creating a module (i.e., a function).


In [3]:
def FtoC(TF):
    """
    Takes the temperature in Farenheit (TF) as input and returns it in Celsius (TC)
    """
    TC = (TF-32)*5/9
    return TC

Now we'll apply that function to our temperature data in Farenheit


In [4]:
TnoonC = FtoC(TnoonF)
TnightC = FtoC(TnightF)
Tdp_noonC = FtoC(Tdp_noonF)
Tdp_nightC = FtoC(Tdp_nightF)
print(TnoonC) #Just checking to make sure it looks reasonable--always a good idea!


16.11111111111111

What is today's pressure in Pa?


In [5]:
Pinches = 30.12 #pressure in inches
Pmm = 30.12*25.4 #There are 25.4 mm in an inch
PPa = Pmm*133.322
print(PPa)


101997.729456

Now let's make a module for the Clausius-Clapeyron approximation.


In [6]:
def CC_esat(TC):
    """
    Takes the temperature in Celsius (TC) as input and returns the 
    saturation vapor pressure in kPa
    """
    esat = 0.61078*np.exp(17.27*TC/(TC+237.3)) #the "e" function comes from the numpy library
    return esat

Now we can feed this equation today's temperatures to calculate the saturation vapor pressure.


In [7]:
esat_noon = CC_esat(TnoonC) #saturation vapor pressure at noon
esat_night = CC_esat(TnightC) #saturation vapor pressure at 4 am
print(esat_noon)
print(esat_night)


1.83117137191
1.42320208583

Let's now figure out actual vapor pressure from the relative humidity.


In [8]:
ed_noon = esat_noon*RHnoon #in kPa
ed_night = esat_night*RHnight #in kPa
print(ed_noon)
print(ed_night)


1.13532625058
1.3662740024

Finally, let us convert the vapor pressures to mass in grams. Humidity in g/m3 is called the absolute humidity. We will do this using the ideal gas law, p=$\rho$RT. We need to solve this for the molar density and then convert it to a mass density.


In [9]:
#First, let's enter some constants.
R = 8.314 #m3 Pa K−1 mol−1 We're going to need to do some more units conversions!
rho_noon = (ed_noon*1000)/(R*(TnoonC+273.15)) #now this is in moles/m^3
rho_night = (ed_night*1000)/(R*(TnightC+273.15))

#Now we will convert the molar densities to mass densities
MW_H2O = 18.01528 #grams of water per mole
m_noon = rho_noon*MW_H2O #grams per m^3
m_night = rho_night*MW_H2O
print(m_noon)
print(m_night)


8.50475144674
10.3742594189

Is the atmosphere at equilibrium with respect to water vapor content? Let's find out by solving for the actual vapor pressure from the dewpoint. Note that we can do this by plugging the dewpoint in to our saturation vapor pressure approximator above.


In [10]:
ed_act_noon = CC_esat(Tdp_noonC) #in kPa
ed_act_night = CC_esat(Tdp_nightC) #in kPa
print(ed_act_noon)
print(ed_act_night)


1.13943402461
0.839027797904

What might be some causes of the discrepancy? Hint: Think about water balances.


In [ ]: