Module: ADCalculator
- Defined in:
- lib/ad_calculator.rb
Instance Method Summary collapse
-
#ad_max_inches(mad_frac, taw) ⇒ Object
- Created
- 18May11 Author
-
P Kaarakka This should be recalculated and saved whenever soils, crop, or root zone depth are changed AD is Allowable Depletion (aka RAW - Readily Available Water) madFrac is fractional form of Maximum Allowable Depletion taw is Total Available Water Result is in inches of water.
-
#change_in_daily_storage(daily_rain, daily_irrig, adj_et) ⇒ Object
- Created
- 18May11 Author
-
P Kaarakka daily_Rain is accumulated rainfall for the day in inches daily_Irrigation is accumulated irigation for the day in inches adj_ET is calculated in module EtCalculator Result is in inches of water.
-
#daily_ad(prev_daily_ad, delta_stor, mad_frac, taw) ⇒ Object
- Created
- 18May11 Author
-
P Kaarakka AD is Allowable Depletion (aka RAW - Readily Available Water) prev_Daily_AD is previous day’s daily AD delta_Stor is calculated in Change_In_Daily_Storage Result is in inches of water, the smaller of max_ad_inches and the sum of previous + delta.
-
#daily_ad_and_dd(prev_daily_ad, delta_stor, mad_frac, taw) ⇒ Object
- Created
- 05Dec12 Author
-
R Wayne AD is Allowable Depletion (aka RAW - Readily Available Water) prev_Daily_AD is previous day’s daily AD delta_Stor is calculated in Change_In_Daily_Storage Results are in inches of water: [AD,DD] AD is the smaller of max_ad_inches and the sum of previous + delta Deep Drainage is what’s left over above max_ad_inches.
-
#daily_ad_from_moisture(mad_frac, taw, mrzd, pct_mad_min, obs_pct_moisture) ⇒ Object
- Created
- 15Jun11 Author
-
P Kaarakka & Rick Wayne mad_frac and taw are used to calculate Max AD in inches mrzd, pct_mad_min and obs_pct_moisture are used to calculate the new AD Result is Allowable Depletion in inches of water (aka RAW - Readily Available Water).
-
#daily_deep_drainage_volume(ad_max, prev_daily_ad, delta_stor) ⇒ Object
- Created
- 18May11 Author
-
P Kaarakka ad_Max is calculated in AD_Max_inches prev_Daily_AD is previous day’s daily AD delta_Stor is calculated in Change_In_Daily_Storage Result is in inches/day.
-
#pct_moisture_at_ad_min(fc, ad_max, mrzd) ⇒ Object
- Created
- 18May11 Author
-
P Kaarakka This should be recalculated and saved whenever soils, crop, or root zone depth are changed fc is field capacity mrzd is managed root zone depth adMax is calculated in AD_Max_inches Result is in percent.
-
#pct_moisture_from_ad(pwp, fc, ad_max, ad, mrzd, pct_moisture_obs = nil) ⇒ Object
- Created
- 18May11 Author
-
P Kaarakka pwp is permanent wilting point mrzd is managed root zone depth pct_Moisture_At_AD_Min is calculated in Pct_Moisture_At_AD_Min ad is current day’s AD pct_Moisture_Obs is observed soil moisture for the day if pct_moisture_obs is supplied, just return that Result is in percent.
-
#taw(fc, pwp, mrzd) ⇒ Object
- Created
- 18May11 Author
-
P Kaarakka This should be recalculated and saved whenever soils, crop, or root zone depth are changed TAW is Total Available Water fc is field capacity pwp is permanent wilting point mrzd is managed root zone depth Result is inches of water.
Instance Method Details
#ad_max_inches(mad_frac, taw) ⇒ Object
- Created
-
18May11
- Author
-
P Kaarakka
This should be recalculated and saved whenever soils, crop, or root zone depth are changed AD is Allowable Depletion (aka RAW - Readily Available Water) madFrac is fractional form of Maximum Allowable Depletion taw is Total Available Water Result is in inches of water
30 31 32 |
# File 'lib/ad_calculator.rb', line 30 def ad_max_inches(mad_frac, taw) mad_frac * taw end |
#change_in_daily_storage(daily_rain, daily_irrig, adj_et) ⇒ Object
- Created
-
18May11
- Author
-
P Kaarakka
daily_Rain is accumulated rainfall for the day in inches daily_Irrigation is accumulated irigation for the day in inches adj_ET is calculated in module EtCalculator Result is in inches of water
52 53 54 55 56 |
# File 'lib/ad_calculator.rb', line 52 def change_in_daily_storage(daily_rain, daily_irrig, adj_et) # If any of these are nil, use 0.0 for the calculation instead of blowing up daily_rain ||= 0.0; daily_irrig ||= 0.0; adj_et ||= 0.0 (daily_rain + daily_irrig) - adj_et end |
#daily_ad(prev_daily_ad, delta_stor, mad_frac, taw) ⇒ Object
- Created
-
18May11
- Author
-
P Kaarakka
AD is Allowable Depletion (aka RAW - Readily Available Water) prev_Daily_AD is previous day’s daily AD delta_Stor is calculated in Change_In_Daily_Storage Result is in inches of water, the smaller of max_ad_inches and the sum of previous + delta
65 66 67 68 |
# File 'lib/ad_calculator.rb', line 65 def daily_ad(prev_daily_ad, delta_stor, mad_frac, taw) max_ad_inches = ad_max_inches(mad_frac,taw) [max_ad_inches,prev_daily_ad + delta_stor].min end |
#daily_ad_and_dd(prev_daily_ad, delta_stor, mad_frac, taw) ⇒ Object
- Created
-
05Dec12
- Author
-
R Wayne
AD is Allowable Depletion (aka RAW - Readily Available Water) prev_Daily_AD is previous day’s daily AD delta_Stor is calculated in Change_In_Daily_Storage Results are in inches of water: [AD,DD]
AD is the smaller of max_ad_inches and the sum of previous + delta
Deep Drainage is what's left over above max_ad_inches
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ad_calculator.rb', line 80 def daily_ad_and_dd(prev_daily_ad, delta_stor, mad_frac, taw) max_ad_inches = ad_max_inches(mad_frac,taw) water_inches = prev_daily_ad + delta_stor # For some reason we're getting a rounding error here, where the water is coming up # infinitesmially greater than max_ad_inches. So only look for significant DD. drainage = water_inches - max_ad_inches if drainage > 0.00001 # Return maximum possible AD -- the rest drains out [max_ad_inches,drainage] else # Return actual AD and no drainage [water_inches,0.0] end end |
#daily_ad_from_moisture(mad_frac, taw, mrzd, pct_mad_min, obs_pct_moisture) ⇒ Object
- Created
-
15Jun11
- Author
-
P Kaarakka & Rick Wayne
mad_frac and taw are used to calculate Max AD in inches mrzd, pct_mad_min and obs_pct_moisture are used to calculate the new AD Result is Allowable Depletion in inches of water (aka RAW - Readily Available Water)
101 102 103 104 |
# File 'lib/ad_calculator.rb', line 101 def daily_ad_from_moisture(mad_frac,taw,mrzd,pct_mad_min,obs_pct_moisture) max_ad_inches = ad_max_inches(mad_frac,taw) [max_ad_inches,mrzd * ((obs_pct_moisture - pct_mad_min) / 100)].min end |
#daily_deep_drainage_volume(ad_max, prev_daily_ad, delta_stor) ⇒ Object
- Created
-
18May11
- Author
-
P Kaarakka
ad_Max is calculated in AD_Max_inches prev_Daily_AD is previous day’s daily AD delta_Stor is calculated in Change_In_Daily_Storage Result is in inches/day
128 129 130 131 132 133 134 135 |
# File 'lib/ad_calculator.rb', line 128 def daily_deep_drainage_volume(ad_max, prev_daily_ad, delta_stor) temp_ddv = prev_daily_ad + delta_stor if temp_ddv > ad_max ddv = temp_ddv - ad_max else ddv = 0 end end |
#pct_moisture_at_ad_min(fc, ad_max, mrzd) ⇒ Object
- Created
-
18May11
- Author
-
P Kaarakka
This should be recalculated and saved whenever soils, crop, or root zone depth are changed fc is field capacity mrzd is managed root zone depth adMax is calculated in AD_Max_inches Result is in percent
42 43 44 |
# File 'lib/ad_calculator.rb', line 42 def pct_moisture_at_ad_min(fc, ad_max, mrzd) (fc - (ad_max/mrzd)) * 100 end |
#pct_moisture_from_ad(pwp, fc, ad_max, ad, mrzd, pct_moisture_obs = nil) ⇒ Object
- Created
-
18May11
- Author
-
P Kaarakka
pwp is permanent wilting point mrzd is managed root zone depth pct_Moisture_At_AD_Min is calculated in Pct_Moisture_At_AD_Min ad is current day’s AD pct_Moisture_Obs is observed soil moisture for the day if pct_moisture_obs is supplied, just return that Result is in percent
116 117 118 119 |
# File 'lib/ad_calculator.rb', line 116 def pct_moisture_from_ad(pwp, fc, ad_max, ad, mrzd, pct_moisture_obs=nil) pct_moisture_at_ad_min = pct_moisture_at_ad_min(fc, ad_max, mrzd) pct_moisture_obs || ([(pct_moisture_at_ad_min+((ad/mrzd)*100)),pwp].max) end |
#taw(fc, pwp, mrzd) ⇒ Object
- Created
-
18May11
- Author
-
P Kaarakka
This should be recalculated and saved whenever soils, crop, or root zone depth are changed TAW is Total Available Water fc is field capacity pwp is permanent wilting point mrzd is managed root zone depth Result is inches of water
18 19 20 |
# File 'lib/ad_calculator.rb', line 18 def taw(fc, pwp, mrzd) (fc - pwp)*mrzd end |