evapotranspiration 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -7
- data/evapotranspiration.gemspec +1 -1
- data/lib/evapotranspiration/fao.rb +44 -44
- data/lib/evapotranspiration/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d42faca68854dee08ce74daf91aade4b2b3d053a
|
4
|
+
data.tar.gz: fdbd328a397870e26c8281bfa95fe1e12c57cfc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23cc8b262d93fd46c61082db9c80e61458679b2ebbd40980d3d5e7c253ced745908c6a60e84118ceaa1359824718a790985ad67c1d58f153afbed285a7e0c15a
|
7
|
+
data.tar.gz: 85283c747e3dcb20db5c6b36a9abeff6b2bc7cd8eef3a0794d2d093964d12eb94170628930419ded53016c4fc07c298960479c7644f2f71ceb55f17f2b1a613e
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
[gem]: https://rubygems.org/gems/evapotranspiration
|
7
7
|
[travis]: http://travis-ci.org/AgRuby/evapotranspiration
|
8
8
|
|
9
|
-
Ruby library for calculating reference crop evapotranspiration (ETo), also referred to as potential evapotranspiration (PET), using the FAO-56 Penman-Monteith method. This
|
9
|
+
Ruby library for calculating reference crop evapotranspiration (ETo), also referred to as potential evapotranspiration (PET), using the FAO-56 Penman-Monteith method. This was originally ported into Ruby from [Mark Richard's PyETo Python package](https://github.com/woodcrafty/PyETo). The library provides numerous methods for estimating missing meteorological data.
|
10
10
|
|
11
11
|
Three methods for estimating ETo/PET are implemented:
|
12
12
|
|
@@ -30,21 +30,27 @@ Or install it yourself as:
|
|
30
30
|
|
31
31
|
$ gem install evapotranspiration
|
32
32
|
|
33
|
-
##
|
33
|
+
## Information
|
34
34
|
|
35
|
-
|
35
|
+
### Documentation
|
36
36
|
|
37
|
-
|
37
|
+
You can view the evapotranspiration documentation here:
|
38
38
|
|
39
|
-
|
39
|
+
http://www.rubydoc.info/gems/evapotranspiration
|
40
|
+
|
41
|
+
### Wiki
|
42
|
+
|
43
|
+
The Evapotranspiration wiki provides some usage examples and "how-to" articles:
|
44
|
+
|
45
|
+
https://github.com/AgRuby/evapotranspiration/wiki
|
40
46
|
|
41
47
|
## Contributing
|
42
48
|
|
43
49
|
Bug reports and pull requests are welcome on GitHub at https://github.com/AgRuby/evapotranspiration.
|
44
50
|
|
45
|
-
|
51
|
+
### Development
|
46
52
|
|
47
|
-
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`.
|
48
54
|
|
49
55
|
## License
|
50
56
|
|
data/evapotranspiration.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Bryce Johnston"]
|
10
10
|
spec.email = ["johnstonbrc@gmail.com"]
|
11
11
|
spec.summary = %q{Ruby library for calculating reference crop evapotranspiration (ETo)}
|
12
|
-
spec.description = %q{Ruby library for calculating reference crop evapotranspiration (ETo), also referred to as potential evapotranspiration (PET), using the FAO-56 Penman-Monteith method.
|
12
|
+
spec.description = %q{Ruby library for calculating reference crop evapotranspiration (ETo), also referred to as potential evapotranspiration (PET), using the FAO-56 Penman-Monteith method.}
|
13
13
|
spec.homepage = "https://github.com/AgRuby/evapotranspiration"
|
14
14
|
spec.license = "BSD 3-Clause"
|
15
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -4,7 +4,7 @@ module Evapotranspiration
|
|
4
4
|
|
5
5
|
# Methods for estimating reference evapotransporation (ETo) for
|
6
6
|
# a grass reference crop using the FAO-56 Penman-Monteith and Hargreaves
|
7
|
-
# equations. The library includes numerous
|
7
|
+
# equations. The library includes numerous methods for estimating missing
|
8
8
|
# meteorological data.
|
9
9
|
module FAO
|
10
10
|
include Enumerable
|
@@ -53,9 +53,9 @@ module Evapotranspiration
|
|
53
53
|
# Based on FAO equation 17 in Allen et al (1998).
|
54
54
|
#
|
55
55
|
# @param svp_tmin [Float] Saturation vapour pressure at daily minimum
|
56
|
-
# temperature (kPa). Can be estimated using svp_from_t
|
56
|
+
# temperature (kPa). Can be estimated using svp_from_t
|
57
57
|
# @param svp_tmax [Float] Saturation vapour pressure at daily maximum
|
58
|
-
# temperature (kPa). Can be estimated using svp_from_t
|
58
|
+
# temperature (kPa). Can be estimated using svp_from_t
|
59
59
|
# @param rh_min [Float] Minimum relative humidity (%)
|
60
60
|
# @param rh_max [Float] Maximum relative humidity (%)
|
61
61
|
# @return [Float] Actual vapour pressure (kPa)
|
@@ -71,7 +71,7 @@ module Evapotranspiration
|
|
71
71
|
# Based on FAO equation 19 in Allen et al (1998).
|
72
72
|
#
|
73
73
|
# @param svp_tmin [Float] Saturation vapour pressure at daily minimum
|
74
|
-
# temperature (kPa). Can be estimated using svp_from_t
|
74
|
+
# temperature (kPa). Can be estimated using svp_from_t
|
75
75
|
# @param rh_max [Float] Maximum relative humidity (%)
|
76
76
|
# @return [Float] Actual vapour pressure (kPa)
|
77
77
|
def self.avp_from_rhmax(svp_tmin, rh_max)
|
@@ -84,9 +84,9 @@ module Evapotranspiration
|
|
84
84
|
# Based on FAO equation 18 in Allen et al (1998).
|
85
85
|
#
|
86
86
|
# @param svp_tmin [Float] Saturation vapour pressure at daily minimum
|
87
|
-
# temperature (kPa). Can be estimated using svp_from_t
|
87
|
+
# temperature (kPa). Can be estimated using svp_from_t
|
88
88
|
# @param svp_tmax [Float] Saturation vapour pressure at daily maximum
|
89
|
-
# temperature (kPa). Can be estimated using svp_from_t
|
89
|
+
# temperature (kPa). Can be estimated using svp_from_t
|
90
90
|
# @param rh_mean [Float] Mean relative humidity (%) (average of RH min and RH max).
|
91
91
|
# @return [Float] Actual vapour pressure (kPa)
|
92
92
|
def self.avp_from_rhmean(svp_tmin, svp_tmax, rh_mean)
|
@@ -120,15 +120,15 @@ module Evapotranspiration
|
|
120
120
|
# minimum temperature.
|
121
121
|
#
|
122
122
|
# Values for the psychrometric constant of the psychrometer (*psy_const*)
|
123
|
-
# can be calculated using psyc_const_of_psychrometer
|
123
|
+
# can be calculated using psyc_const_of_psychrometer.
|
124
124
|
#
|
125
125
|
# @param twet [Float] Wet bulb temperature (deg C)
|
126
126
|
# @param tdry [Float] Dry bulb temperature (deg C)
|
127
127
|
# @param svp_twet [Float] Saturated vapour pressure at the wet bulb
|
128
|
-
# temperature (kPa). Can be estimated using svp_from_t
|
128
|
+
# temperature (kPa). Can be estimated using svp_from_t
|
129
129
|
# @param psy_const [Float] Psychrometric constant of the pyschrometer
|
130
|
-
# (kPa deg C-1). Can be estimated using psy_const
|
131
|
-
# psy_const_of_psychrometer
|
130
|
+
# (kPa deg C-1). Can be estimated using psy_const or
|
131
|
+
# psy_const_of_psychrometer
|
132
132
|
# @return [Float] Actual vapour pressure (kPa)
|
133
133
|
def self.avp_from_twet_tdry(twet, tdry, svp_twet, psy_const)
|
134
134
|
return svp_twet.to_f - (psy_const.to_f * (tdry.to_f - twet.to_f))
|
@@ -141,7 +141,7 @@ module Evapotranspiration
|
|
141
141
|
#
|
142
142
|
# @param altitude [Float] Elevation above sea level (m)
|
143
143
|
# @param et_rad [Float] Extraterrestrial radiation (MJ m-2 day-1). Can be
|
144
|
-
# estimated using et_rad
|
144
|
+
# estimated using et_rad
|
145
145
|
# @return [Float] Clear sky radiation (MJ m-2 day-1)
|
146
146
|
def self.cs_rad(altitude, et_rad)
|
147
147
|
return (0.00002 * altitude.to_f + 0.75) * et_rad.to_f
|
@@ -162,7 +162,7 @@ module Evapotranspiration
|
|
162
162
|
# Based on FAO equation 34 in Allen et al (1998).
|
163
163
|
#
|
164
164
|
# @param sha [Float] Sunset hour angle (rad). Can be calculated using
|
165
|
-
# sunset_hour_angle
|
165
|
+
# sunset_hour_angle
|
166
166
|
# @return [Float] Daylight hours
|
167
167
|
def self.daylight_hours(sha)
|
168
168
|
Validation.check_sunset_hour_angle_rad(sha)
|
@@ -194,7 +194,7 @@ module Evapotranspiration
|
|
194
194
|
#
|
195
195
|
# @param energy [Float] Energy e.g. radiation or heat flux (MJ m-2 day-1)
|
196
196
|
# @return [Float] Equivalent evaporation (mm day-1)
|
197
|
-
def self.
|
197
|
+
def self.energy_to_evap(energy)
|
198
198
|
return 0.408 * energy.to_f
|
199
199
|
end
|
200
200
|
|
@@ -212,11 +212,11 @@ module Evapotranspiration
|
|
212
212
|
#
|
213
213
|
# @param latitude [Float] Latitude (radians)
|
214
214
|
# @param sol_dec [Float] Solar declination (radians). Can be calculated
|
215
|
-
# using sol_dec
|
215
|
+
# using sol_dec
|
216
216
|
# @param sha [Float] Sunset hour angle (radians). Can be calculated using
|
217
|
-
# sunset_hour_angle
|
217
|
+
# sunset_hour_angle
|
218
218
|
# @param ird [Float] Inverse relative distance earth-sun (dimensionless).
|
219
|
-
# Can be calculated using inv_rel_dist_earth_sun
|
219
|
+
# Can be calculated using inv_rel_dist_earth_sun
|
220
220
|
# @return [Float] Daily extraterrestrial radiation (MJ m-2 day-1)
|
221
221
|
def self.et_rad(latitude, sol_dec, sha, ird)
|
222
222
|
Validation.check_latitude_rad(latitude)
|
@@ -235,22 +235,22 @@ module Evapotranspiration
|
|
235
235
|
# Based on equation 6 in Allen et al (1998).
|
236
236
|
#
|
237
237
|
# @param net_rad [Float] Net radiation at crop surface (MJ m-2 day-1). If
|
238
|
-
# necessary this can be estimated using net_rad
|
238
|
+
# necessary this can be estimated using net_rad
|
239
239
|
# @param t [Float] Air temperature at 2 m height (deg Kelvin)
|
240
240
|
# @param ws [Float] Wind speed at 2 m height (m s-1). If not measured at 2m,
|
241
|
-
# convert using wind_speed_at_2m
|
241
|
+
# convert using wind_speed_at_2m
|
242
242
|
# @param svp [Float] Saturation vapour pressure (kPa). Can be estimated
|
243
|
-
# using svp_from_t
|
243
|
+
# using svp_from_t
|
244
244
|
# @param avp [Float] Actual vapour pressure (kPa). Can be estimated using a
|
245
|
-
# range of
|
245
|
+
# range of methods with names beginning with avp_from
|
246
246
|
# @param delta_svp [Float] Slope of saturation vapour pressure curve
|
247
|
-
# (kPa degC-1). Can be estimated using delta_svp
|
247
|
+
# (kPa degC-1). Can be estimated using delta_svp
|
248
248
|
# @param psy [Float] Psychrometric constant (kPa deg C). Can be estimatred
|
249
|
-
# using psy_const_of_psychrometer
|
249
|
+
# using psy_const_of_psychrometer or psy_const
|
250
250
|
# @param shf [Float] Soil heat flux (G) (MJ m-2 day-1) (default is 0.0,
|
251
251
|
# which is reasonable for a daily or 10-day time steps). For monthly time
|
252
|
-
# steps *shf* can be estimated using monthly_soil_heat_flux
|
253
|
-
# monthly_soil_heat_flux2
|
252
|
+
# steps *shf* can be estimated using monthly_soil_heat_flux or
|
253
|
+
# monthly_soil_heat_flux2
|
254
254
|
# @return [Float] Reference evapotranspiration (ETo) from a hypothetical
|
255
255
|
# grass reference surface (mm day-1)
|
256
256
|
def self.fao56_penman_monteith(net_rad, t, ws, svp, avp, delta_svp, psy, shf=0.0)
|
@@ -264,7 +264,7 @@ module Evapotranspiration
|
|
264
264
|
#
|
265
265
|
# Generally, when solar radiation data, relative humidity data
|
266
266
|
# and/or wind speed data are missing, it is better to estimate them using
|
267
|
-
# the
|
267
|
+
# the methods available in this module, and then calculate ETo
|
268
268
|
# the FAO Penman-Monteith equation. However, as an alternative, ETo can be
|
269
269
|
# estimated using the Hargreaves ETo equation.
|
270
270
|
#
|
@@ -275,7 +275,7 @@ module Evapotranspiration
|
|
275
275
|
# @param tmean [Float] Mean daily temperature (deg C). If measurements not
|
276
276
|
# available it can be estimated as (*tmin* + *tmax*) / 2
|
277
277
|
# @param et_rad [Float] Extraterrestrial radiation (Ra) (MJ m-2 day-1).
|
278
|
-
# Can be estimated using et_rad
|
278
|
+
# Can be estimated using et_rad
|
279
279
|
# @return [Float] Reference evapotranspiration over grass (ETo) (mm day-1)
|
280
280
|
def self.hargreaves(tmin, tmax, tmean, et_rad)
|
281
281
|
# Note, multiplied by 0.408 to convert extraterrestrial radiation could
|
@@ -318,7 +318,7 @@ module Evapotranspiration
|
|
318
318
|
# Based on equation 43 in Allen et al (1998). If the air temperature of the
|
319
319
|
# next month is not known use monthly_soil_heat_flux2 instead. The
|
320
320
|
# resulting heat flux can be converted to equivalent evaporation [mm day-1]
|
321
|
-
# using
|
321
|
+
# using energy_to_evap.
|
322
322
|
#
|
323
323
|
# @param t_month_prev [Float] Mean air temperature of the previous month
|
324
324
|
# (deg Celsius)
|
@@ -335,7 +335,7 @@ module Evapotranspiration
|
|
335
335
|
# Based on equation 44 in Allen et al (1998). If the air temperature of the
|
336
336
|
# next month is available, use monthly_soil_heat_flux instead. The
|
337
337
|
# resulting heat flux can be converted to equivalent evaporation [mm day-1]
|
338
|
-
# using
|
338
|
+
# using energy_to_evap.
|
339
339
|
#
|
340
340
|
# @param t_month_prev [Float] Mean air temperature of the previous month
|
341
341
|
# (deg Celsius)
|
@@ -352,13 +352,13 @@ module Evapotranspiration
|
|
352
352
|
# Net incoming solar radiation is the net shortwave radiation resulting
|
353
353
|
# from the balance between incoming and reflected solar radiation. The
|
354
354
|
# output can be converted to equivalent evaporation [mm day-1] using
|
355
|
-
#
|
355
|
+
# energy_to_evap.
|
356
356
|
#
|
357
357
|
# Based on FAO equation 38 in Allen et al (1998).
|
358
358
|
#
|
359
359
|
# @param sol_rad [Float] Gross incoming solar radiation (MJ m-2 day-1).
|
360
|
-
# If necessary this can be estimated using
|
361
|
-
# with
|
360
|
+
# If necessary this can be estimated using methods whose name begins
|
361
|
+
# with sol_rad_from
|
362
362
|
# @param albedo [Float] Albedo of the crop as the proportion of gross
|
363
363
|
# incoming solar radiation that is reflected by the surface. Default value
|
364
364
|
# is 0.23, which is the value used by the FAO for a short grass reference
|
@@ -376,23 +376,23 @@ module Evapotranspiration
|
|
376
376
|
# earth's surface. It is proportional to the absolute temperature of
|
377
377
|
# the surface raised to the fourth power according to the Stefan-Boltzmann
|
378
378
|
# law. However, water vapour, clouds, carbon dioxide and dust are absorbers
|
379
|
-
# and emitters of longwave radiation. This
|
379
|
+
# and emitters of longwave radiation. This method corrects the Stefan-
|
380
380
|
# Boltzmann law for humidity (using actual vapor pressure) and cloudiness
|
381
381
|
# (using solar radiation and clear sky radiation). The concentrations of all
|
382
382
|
# other absorbers are assumed to be constant.
|
383
383
|
#
|
384
|
-
# The output can be converted to equivalent evaporation [mm day-1] using
|
384
|
+
# The output can be converted to equivalent evaporation [mm day-1] using energy_to_evap.
|
385
385
|
#
|
386
386
|
# Based on FAO equation 39 in Allen et al (1998).
|
387
387
|
#
|
388
388
|
# @param tmin [Float] Absolute daily minimum temperature (degrees Kelvin)
|
389
389
|
# @param albedo [Float] Absolute daily maximum temperature (degrees Kelvin)
|
390
390
|
# @param sol_rad [Float] Solar radiation (MJ m-2 day-1). If necessary this
|
391
|
-
# can be estimated using
|
391
|
+
# can be estimated using methods with names beginning with sol_rad
|
392
392
|
# @param cs_rad [Float] Clear sky radiation (MJ m-2 day-1). Can be estimated
|
393
|
-
# using cs_rad
|
393
|
+
# using cs_rad
|
394
394
|
# @param avp [Float] Actual vapour pressure (kPa). Can be estimated using
|
395
|
-
#
|
395
|
+
# methods with names beginning with avp_from
|
396
396
|
# @return [Float] Net outgoing longwave radiation (MJ m-2 day-1)
|
397
397
|
def self.net_out_lw_rad(tmin, tmax, sol_rad, cs_rad, avp)
|
398
398
|
tmp1 = (STEFAN_BOLTZMANN_CONSTANT * (((tmax.to_f ** 4) + (tmin.to_f ** 4)) / 2))
|
@@ -406,14 +406,14 @@ module Evapotranspiration
|
|
406
406
|
#
|
407
407
|
# Net radiation is the difference between the incoming net shortwave (or
|
408
408
|
# solar) radiation and the outgoing net longwave radiation. Output can be
|
409
|
-
# converted to equivalent evaporation [mm day-1] using
|
409
|
+
# converted to equivalent evaporation [mm day-1] using energy_to_evap.
|
410
410
|
#
|
411
411
|
# Based on equation 40 in Allen et al (1998).
|
412
412
|
#
|
413
413
|
# @param ni_sw_rad [Float] Net incoming shortwave radiation (MJ m-2 day-1).
|
414
|
-
# Can be estimated using net_in_sol_rad
|
414
|
+
# Can be estimated using net_in_sol_rad
|
415
415
|
# @param no_lw_rad [Float] Net outgoing longwave radiation (MJ m-2 day-1).
|
416
|
-
# Can be estimated using net_out_lw_rad
|
416
|
+
# Can be estimated using net_out_lw_rad
|
417
417
|
# @return [Float] Daily net radiation (MJ m-2 day-1)
|
418
418
|
def self.net_rad(ni_sw_rad, no_lw_rad)
|
419
419
|
return ni_sw_rad.to_f - no_lw_rad.to_f
|
@@ -427,7 +427,7 @@ module Evapotranspiration
|
|
427
427
|
# Based on equation 8, page 95 in Allen et al (1998).
|
428
428
|
#
|
429
429
|
# @param atmos_pres [Float] Atmospheric pressure (kPa). Can be estimated
|
430
|
-
# using atm_pressure
|
430
|
+
# using atm_pressure
|
431
431
|
# @return [Float] Psychrometric constant (kPa degC-1)
|
432
432
|
def self.psy_const(atmos_pres)
|
433
433
|
return 0.000665 * atmos_pres.to_f
|
@@ -446,7 +446,7 @@ module Evapotranspiration
|
|
446
446
|
# @param psychrometer [Float] Integer between 1 and 3 which denotes type of
|
447
447
|
# psychrometer
|
448
448
|
# @param atmos_pres [Float] Atmospheric pressure [kPa]. Can be estimated
|
449
|
-
# using atm_pressure
|
449
|
+
# using atm_pressure
|
450
450
|
# @return [Float] Psychrometric constant (kPa degC-1)
|
451
451
|
def self.psy_const_of_psychrometer(psychrometer, atmos_pres)
|
452
452
|
# Select coefficient based on type of ventilation of the wet bulb
|
@@ -470,10 +470,10 @@ module Evapotranspiration
|
|
470
470
|
# See Allen et al (1998), page 67 for details.
|
471
471
|
#
|
472
472
|
# @param avp [Float] Actual vapour pressure (units do not matter so long as
|
473
|
-
# they are the same as for *svp*). Can be estimated using
|
474
|
-
# name begins with
|
473
|
+
# they are the same as for *svp*). Can be estimated using methods whose
|
474
|
+
# name begins with avp_from
|
475
475
|
# @param svp [Float] Saturated vapour pressure (units do not matter so long
|
476
|
-
# as they are the same as for *avp*). Can be estimated using svp_from_t
|
476
|
+
# as they are the same as for *avp*). Can be estimated using svp_from_t
|
477
477
|
# @return [Float] Relative humidity (%)
|
478
478
|
def self.rh_from_avp_svp(avp, svp)
|
479
479
|
return 100.0 * avp.to_f / svp.to_f
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evapotranspiration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryce Johnston
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '3.0'
|
55
55
|
description: Ruby library for calculating reference crop evapotranspiration (ETo),
|
56
56
|
also referred to as potential evapotranspiration (PET), using the FAO-56 Penman-Monteith
|
57
|
-
method.
|
57
|
+
method.
|
58
58
|
email:
|
59
59
|
- johnstonbrc@gmail.com
|
60
60
|
executables: []
|