Module: Usgs::InstantaneousValues
Instance Method Summary collapse
-
#get_iv(sites:, parameter_cd: nil, start_date: nil, end_date: nil) ⇒ Array<Usgs::Models::Reading>
Fetch instantaneous values (IV) from USGS NWIS.
Methods included from Utils
#format_date, #format_datetime, #resolve_parameter_codes
Instance Method Details
#get_iv(sites:, parameter_cd: nil, start_date: nil, end_date: nil) ⇒ Array<Usgs::Models::Reading>
Fetch instantaneous values (IV) from USGS NWIS
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/usgs/instantaneous_values.rb', line 18 def get_iv(sites:, parameter_cd: nil, start_date: nil, end_date: nil) site_list = Array(sites).join(",") param_list = resolve_parameter_codes(parameter_cd) query = { format: "json", sites: site_list, parameterCd: param_list, # Default to the the last 24hrs if not filled out startDT: format_datetime(start_date || (Time.now.utc - (24 * 60 * 60))), endDT: format_datetime(end_date || Time.now.utc) }.compact response = api_get("/iv/", query) Parser.parse_time_series_values(JSON.parse(response.body)) end |