Skip to content

Commit

Permalink
Merge pull request #1 from EliTayrien/eli/AirTemperature
Browse files Browse the repository at this point in the history
Add air temperature
  • Loading branch information
bobbymarko committed Jan 16, 2016
2 parents 55607dd + 74197ce commit 99d6ebe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion snotel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,20 @@ def get_data(id, days, start_date = false, end_date = false)
# http://wcc.sc.egov.usda.gov/reportGenerator/view_csv/customSingleStationReport/daily/549:NV:SNTL%7Cid=%22%22%7Cname/2013-01-15,2013-01-18/SNWD::value
# http://wcc.sc.egov.usda.gov/reportGenerator/view_csv/customSingleStationReport/daily/#{id}%7Cid%3D%22%22%7Cname/-#{days}%2C0/WTEQ%3A%3Avalue%2CWTEQ%3A%3Adelta%2CSNWD%3A%3Avalue%2CSNWD%3A%3Adelta

# Each parameter on the end adds a new data field to the report:
# WTEQ::value (snow water equivalent)
# WTEQ::delta (change in snow water equivalent)
# SNWD::value (snow depth)
# SNWD::delta (change in snow depth)
# TOBS::value (observed air temperature)

if start_date
date = "#{start_date},#{end_date}"
else
date = "-#{days}"
end

uri = URI("http://wcc.sc.egov.usda.gov/reportGenerator/view_csv/customSingleStationReport/daily/#{id}%7Cid%3D%22%22%7Cname/#{date}%2C0/WTEQ%3A%3Avalue%2CWTEQ%3A%3Adelta%2CSNWD%3A%3Avalue%2CSNWD%3A%3Adelta")
uri = URI("http://wcc.sc.egov.usda.gov/reportGenerator/view_csv/customSingleStationReport/daily/#{id}%7Cid%3D%22%22%7Cname/#{date}%2C0/WTEQ%3A%3Avalue%2CWTEQ%3A%3Adelta%2CSNWD%3A%3Avalue%2CSNWD%3A%3Adelta%2CTOBS%3A%3Avalue")
json = Net::HTTP.get(uri)

json_filtered = json.gsub(/(^#.+|#)/, '').gsub(/^\s+/, "") # remove comments at top of file
Expand Down

0 comments on commit 99d6ebe

Please sign in to comment.