Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Fix precipitation amount
Browse files Browse the repository at this point in the history
  • Loading branch information
kejadlen committed Nov 22, 2014
1 parent f194093 commit d66f172
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions forecast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ def to_s

minutely = forecast['minutely']
if minutely
intensity = minutely['data'].map {|m| 1000 * m['precipIntensity'] }
intensity = intensity.select.with_index {|_,i| i % 5 == 0 }
intensity = minutely['data'].map {|m| m['precipIntensity'] }
intensity = intensity.select.with_index {|_,i| i % 4 == 0 }
min, max = intensity.minmax
intensity = intensity.map {|i| 1000 * i }

subtitle = ["#{min.round}\" #{Spark.new(intensity)} #{max.round}\""]
subtitle = ["#{min.round(3)}\" #{Spark.new(intensity)} #{max.round(3)}\""]

probability = minutely['data'].map {|m| (100 * m['precipProbability']).round }
probability = probability.select.with_index {|_,i| i % 5 == 0 }
Expand All @@ -100,11 +101,12 @@ def to_s

hourly = forecast['hourly']

intensity = hourly['data'].map {|m| 1000 * m['precipIntensity'] }
intensity = hourly['data'].map {|m| m['precipIntensity'] }
intensity = intensity.select.with_index {|_,i| i % 4 == 0 }
min, max = intensity.minmax
intensity = intensity.map {|i| 1000 * i }

subtitle = ["#{min.round}\" #{Spark.new(intensity)} #{max.round}\""]
subtitle = ["#{min.round(3)}\" #{Spark.new(intensity)} #{max.round(3)}\""]

probability = hourly['data'].map {|m| (100 * m['precipProbability']).round }
probability = probability.select.with_index {|_,i| i % 4 == 0 }
Expand Down

0 comments on commit d66f172

Please sign in to comment.