Module: Evapotranspiration::Validation
- Defined in:
- lib/evapotranspiration/validation.rb
Constant Summary collapse
- MINLAT_RADIANS =
Latitude
Conversion.deg_to_rad(-90.0)
- MAXLAT_RADIANS =
Conversion.deg_to_rad(90.0)
- MINSOLDEC_RADIANS =
Solar declination
Conversion.deg_to_rad(-23.5)
- MAXSOLDEC_RADIANS =
Conversion.deg_to_rad(23.5)
- MINSHA_RADIANS =
Sunset hour angle
0.0
- MAXSHA_RADIANS =
Conversion.deg_to_rad(180.0)
Class Method Summary collapse
-
.check_day_hours(hours, arg_name) ⇒ Object
Check that hours is in the range 1 to 24.
-
.check_doy(doy) ⇒ Object
Check day of the year is valid.
- .check_latitude_rad(latitude) ⇒ Object
-
.check_sol_dec_rad(sd) ⇒ Object
Solar declination can vary between -23.5 and +23.5 degrees.
-
.check_sunset_hour_angle_rad(sha) ⇒ Object
Sunset hour angle has the range 0 to 180 degrees.
Class Method Details
.check_day_hours(hours, arg_name) ⇒ Object
Check that hours is in the range 1 to 24
19 20 21 22 23 |
# File 'lib/evapotranspiration/validation.rb', line 19 def self.check_day_hours(hours, arg_name) unless hours.between?(0,24) raise ArgumentError.new("#{arg_name} should be in the range 0-24: #{hours}") end end |
.check_doy(doy) ⇒ Object
Check day of the year is valid
26 27 28 29 30 |
# File 'lib/evapotranspiration/validation.rb', line 26 def self.check_doy(doy) unless doy.between?(1,366) raise ArgumentError.new("day of the year (doy) must be in range 1-366: #{doy}") end end |
.check_latitude_rad(latitude) ⇒ Object
32 33 34 35 36 |
# File 'lib/evapotranspiration/validation.rb', line 32 def self.check_latitude_rad(latitude) unless latitude.between?(MINLAT_RADIANS,MAXLAT_RADIANS) raise ArgumentError.new("latitude outside valid range #{MINLAT_RADIANS} to #{MAXLAT_RADIANS} rad: #{latitude}") end end |
.check_sol_dec_rad(sd) ⇒ Object
Solar declination can vary between -23.5 and +23.5 degrees. See mypages.iit.edu/~maslanka/SolarGeo.pdf
40 41 42 43 44 |
# File 'lib/evapotranspiration/validation.rb', line 40 def self.check_sol_dec_rad(sd) unless sd.between?(MINSOLDEC_RADIANS,MAXSOLDEC_RADIANS) raise ArgumentError.new("solar declination outside valid range #{MINSOLDEC_RADIANS} to #{MAXSOLDEC_RADIANS} rad: #{sd}") end end |
.check_sunset_hour_angle_rad(sha) ⇒ Object
Sunset hour angle has the range 0 to 180 degrees. See mypages.iit.edu/~maslanka/SolarGeo.pdf
48 49 50 51 52 |
# File 'lib/evapotranspiration/validation.rb', line 48 def self.check_sunset_hour_angle_rad(sha) unless sha.between?(MINSHA_RADIANS,MAXSHA_RADIANS) raise ArgumentError.new("sunset hour angle outside valid range #{MINSHA_RADIANS} to #{MAXSHA_RADIANS} rad: #{sha}") end end |