Index: wflow/JarvisCoefficients.py =================================================================== diff -u -rfbd077ecd824c16e9e207b542e5ee2f9f9ff92dd -rc427e9b948a7fbad40a1c828b68355cb277dc5e0 --- wflow/JarvisCoefficients.py (.../JarvisCoefficients.py) (revision fbd077ecd824c16e9e207b542e5ee2f9f9ff92dd) +++ wflow/JarvisCoefficients.py (.../JarvisCoefficients.py) (revision c427e9b948a7fbad40a1c828b68355cb277dc5e0) @@ -16,6 +16,7 @@ Calculations based on Zhou et al 2006 and Stewart 1998 """ +import math try: from wflow.wf_DynamicFramework import * @@ -29,7 +30,7 @@ """ # resistenceAeroD(self) # potential_evaporation(self,k) - self.EpDay = ifthenelse( + self.EpDay = pcr.ifthenelse( self.Sw_t[k] > 0, self.EpDaySnow2, self.EpDay2 ) # EpDaySnow added on 18-02-2016 downscale_evaporation(self, k) @@ -42,7 +43,7 @@ """ # resistenceAeroD(self) # potential_evaporation(self,k) - self.EpDaySnow = ifthenelse( + self.EpDaySnow = pcr.ifthenelse( self.Sw_t[k] > 0, self.EpDaySnow2 * self.lamda / self.lamdaS, self.EpDay2 * self.lamda / self.lamdaS, @@ -58,7 +59,7 @@ """ # resistenceAeroD(self) # potential_evaporation(self,k) - self.EpHour = ifthenelse( + self.EpHour = pcr.ifthenelse( self.Sw_t[k] > 0, self.EpDaySnow2 * self.lamda / self.lamdaS, self.EpDay2 * self.lamda / self.lamdaS, @@ -109,16 +110,16 @@ - Topt (optimum temperature for transpiration, based on elevation and latitude (Cui et al, 2012)) """ self.JC_ToptC = self.JC_Topt - 273.15 # changed on 9/4/2015, before Topt in K - JC_temp1 = ifthenelse( + JC_temp1 = pcr.ifthenelse( self.Tmean < 273.15, 0, - ifthenelse( - pcrand(self.Tmean >= self.JC_Topt - 1, self.Tmean <= self.JC_Topt + 1), + pcr.ifthenelse( + pcr.pcrand(self.Tmean >= self.JC_Topt - 1, self.Tmean <= self.JC_Topt + 1), 1, 1 - self.JC_Topt ** -2 * (self.Tmean - self.JC_Topt) ** 2, ), ) - self.JC_temp = ifthenelse(JC_temp1 < 0, 0, JC_temp1) + self.JC_temp = pcr.ifthenelse(JC_temp1 < 0, 0, JC_temp1) self.JC_temp_[k] = self.JC_temp @@ -134,7 +135,7 @@ denom = 1 + (self.vpd / self.JC_D05[k]) ** self.JC_cd1[k] JC_vpd1 = (1 / denom) * (1 - self.JC_cd2[k]) + self.JC_cd2[k] - self.JC_vpd = ifthenelse(JC_vpd1 < 0, 0, JC_vpd1) + self.JC_vpd = pcr.ifthenelse(JC_vpd1 < 0, 0, JC_vpd1) self.JC_vpd_[k] = self.JC_vpd @@ -161,7 +162,7 @@ JC_rad1 = ( rad_si_Wm2 * (1 + self.JC_cr[k] / 1000) * (1 / (self.JC_cr[k] + rad_si_Wm2)) ) - self.JC_rad = ifthenelse(JC_rad1 < 0, 0, JC_rad1) + self.JC_rad = pcr.ifthenelse(JC_rad1 < 0, 0, JC_rad1) self.JC_rad_[k] = self.JC_rad @@ -175,18 +176,18 @@ - SuWP (level of saturation in soil at wilting point) """ SuN = self.Su[k] / self.sumax[k] - JC_sm1 = ifthenelse( + JC_sm1 = pcr.ifthenelse( SuN < self.SuWP[k], 0, - ifthenelse( + pcr.ifthenelse( SuN > self.SuFC[k], 1, (SuN - self.SuWP[k]) * (self.SuFC[k] - self.SuWP[k] + self.JC_cuz[k]) / ((self.SuFC[k] - self.SuWP[k]) * (SuN - self.SuWP[k] + self.JC_cuz[k])), ), ) - self.JC_sm = ifthenelse(JC_sm1 < 0, 0, JC_sm1) + self.JC_sm = pcr.ifthenelse(JC_sm1 < 0, 0, JC_sm1) self.JC_sm_[k] = self.JC_sm @@ -214,8 +215,8 @@ - gamma (psychrometric constant) """ JC_all = self.JC_laiEff * self.JC_rad * self.JC_vpd * self.JC_temp * self.JC_sm - stomRes1 = ifthenelse(JC_all == 0, 50000, self.JC_rstmin[k] / JC_all) - stomRes2 = ifthenelse(stomRes1 > 50000, 50000, stomRes1) + stomRes1 = pcr.ifthenelse(JC_all == 0, 50000, self.JC_rstmin[k] / JC_all) + stomRes2 = pcr.ifthenelse(stomRes1 > 50000, 50000, stomRes1) self.stomRes = stomRes2 / (3600 * 24) self.k = 1 / ( @@ -235,8 +236,8 @@ - gamma (psychrometric constant) """ JC_all = self.JC_rad * self.JC_vpd * self.JC_temp * self.JC_sm - stomRes1 = ifthenelse(JC_all == 0, 50000, self.rst_lai[k] / JC_all) - stomRes2 = ifthenelse(stomRes1 > 50000, 50000, stomRes1) + stomRes1 = pcr.ifthenelse(JC_all == 0, 50000, self.rst_lai[k] / JC_all) + stomRes2 = pcr.ifthenelse(stomRes1 > 50000, 50000, stomRes1) self.stomRes = stomRes2 / (3600 * 24) self.k = 1 / ( @@ -276,22 +277,22 @@ - """ - # teller = numpy.nanmax(pcr2numpy(self.thestep,nan)) - teller = pcr2numpy(self.thestep, nan)[0, 0] - x = teller - floor(teller / 24) * 24 * scalar(self.catchArea) + # teller = numpy.nanmax(pcr.pcr2numpy(self.thestep,np.nan)) + teller = pcr.pcr2numpy(self.thestep, np.nan)[0, 0] + x = teller - math.floor(teller / 24) * 24 * pcr.scalar(self.catchArea) DL = self.DE - self.DS + 1 - P = 2 * pi / (2 * DL) # period + P = 2 * math.pi / (2 * DL) # period SH = DL - 12 # horizontal shift of new signal aN = -1 * self.EpDay * P # nominator of the amplitude - aDN = sin((P * (self.DE + SH)) * 180 / pi) - sin( - (P * (self.DS + SH)) * 180 / pi + aDN = math.sin((P * (self.DE + SH)) * 180 / math.pi) - math.sin( + (P * (self.DS + SH)) * 180 / math.pi ) # denominator of the amplitude ampl = aN / aDN # amplitude of new signal - self.EpHour = max( - ifthenelse( - pcrand(x >= self.DS, x <= self.DE), - -1 * ampl * cos((P * (x + SH)) * 180 / pi), + self.EpHour = math.max( + pcr.ifthenelse( + pcr.pcrand(x >= self.DS, x <= self.DE), + -1 * ampl * math.cos((P * (x + SH)) * 180 / math.pi), 0, ), 0, @@ -309,21 +310,21 @@ - """ - teller = pcr2numpy(self.thestep, nan)[0, 0] - x = teller - floor(teller / 24) * 24 * scalar(self.catchArea) + teller = pcr.pcr2numpy(self.thestep, np.nan)[0, 0] + x = teller - math.floor(teller / 24) * 24 * pcr.scalar(self.catchArea) DL = self.DE - self.DS + 1 - P = 2 * pi / (2 * DL) # period + P = 2 * math.pi / (2 * DL) # period SH = DL - 12 # horizontal shift of new signal aN = -1 * self.EpDaySnow * P # nominator of the amplitude - aDN = sin((P * (self.DE + SH)) * 180 / pi) - sin( - (P * (self.DS + SH)) * 180 / pi + aDN = math.sin((P * (self.DE + SH)) * 180 / math.pi) - math.sin( + (P * (self.DS + SH)) * 180 / math.pi ) # denominator of the amplitude ampl = aN / aDN # amplitude of new signal - self.EpHour = max( - ifthenelse( - pcrand(x >= self.DS, x <= self.DE), - -1 * ampl * cos((P * (x + SH)) * 180 / pi), + self.EpHour = pcr.max( + pcr.ifthenelse( + pcr.pcrand(x >= self.DS, x <= self.DE), + -1 * ampl * math.cos((P * (x + SH)) * 180 / math.pi), 0, ), 0,