<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Try to write temperature-based potential evaporation (PET) model
Step1:  Source
Step2:  Kharrufa method. Kharrufa (1985) derived an equation through correlation of ET/p and T in the form of
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
data = pd.read_csv('../data/hbv_s_data.csv', index_col=0, parse_dates=True)
Explanation: Try to write temperature-based potential evaporation (PET) model
End of explanation
evap_true = np.array([0.6,1.9,2.4,1.8,1.4,1.3,1.0,0.8,0.6,0.4,0.2,0.3])*1.2 #evapo for jan-dec
def romanenko(data):
    Ta = np.array([data.ix[data.index.month == x, 'Temp'].mean() for x in range(1, 13)])
    Td = 2
    
    def et(T):
        return 33.8679*( ((0.00738*T + 0.8072)**8) - 0.000019*(np.abs(1.8*T + 48)) + 0.001316)
    
    Rh = et(Td)*100/et(Ta)
    # best results with manual evap setup
    # Rh = np.array([60, 0, 0, 45, 70, 80, 85, 90, 90, 90, 90, 76])
    return (0.0018*((25+Ta)**2))*(100-Rh)/30
Ta = np.array([data.ix[data.index.month == x, 'Temp'].mean() for x in range(1, 13)])
Td = np.array([0, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10])
et(Td)*100/et(Ta)
Ta
plt.plot(range(1,13), romanenko(data), 'b',
         range(1,13), evap_true, 'r')
Explanation: Source: Xu and Singh, 2001
Romanenko (1961) derived an evaporation equation based on the relationship using
mean temperature and relative humidity:
$$ET = 0.0018(25 + T_a)^2(100-Rh)$$
where Ta is the mean air temperature (in °C), Rh is the mean monthly relative humidity, which is calculated
by:
$$Rh = \frac{e^o(T_d)}{e^o(T_a)}$$
in which e°(T) is the saturated vapour pressure calculated by (see Bosen, 1960):
$$ e^o(T) = 33.8679[(0.00738T + 0.8072)^8 - 0.000019|1.8T + 48| + 0.001316]  $$
End of explanation
def kharufa(data):
    Ta = np.array([data.ix[data.index.month == x, 'Temp'].mean() for x in range(1, 13)])
    p = 0.85
    return 0.34*p*(Ta**1.3)
plt.plot(range(1,13), kharufa(data), 'b', 
         range(1,13), romanenko(data), 'g',
         range(1,13), evap_true, 'r')
print(kharufa(data))
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import sys
sys.path.append('../models/')
import hbv_s
swe_riv = pd.read_csv('../data/hbv_s_data.csv', index_col=0, parse_dates=True)
Qobs = swe_riv.Qobs
Qsim = hbv_s.simulation(swe_riv)
pd.DataFrame({'obs':Qobs, 'sim':Qsim}, index=swe_riv.index).plot()
swe_riv2 = swe_riv.drop('Evap', 1)
swe_riv2['Evap'] = swe_riv2.index.map(lambda x: romanenko(swe_riv2)[x.month-1])
Qsim = hbv_s.simulation(swe_riv2)
pd.DataFrame({'obs':Qobs, 'sim':Qsim}, index=swe_riv2.index).plot()
swe_riv2['Evap'].plot();
swe_riv['Evap'].plot()
evap_true
a = np.array([0.6,1.9,2.4,1.8,1.4,1.3,1.0,0.8,0.6,0.4,0.2,0.3])
np.savetxt('../data/Evap_monthly_constants.txt', a)
np.loadtxt('../data/Evap_monthly_constants.txt')
swe_riv2['Evap2'] = swe_riv2.index.map(lambda x: np.loadtxt('../data/Evap_monthly_constants.txt')[x.month-1])
swe_riv2[['Evap', 'Evap2']].plot()
Explanation: Kharrufa method. Kharrufa (1985) derived an equation through correlation of ET/p and T in the form of:
$$ ET = 0.34pT_a^{1.3}$$
where ET is the Kharrufa potential evapotranspiration (in mm/month) and Ta and p have the same definitions
as given earlier.
End of explanation
<END_TASK>