sunny/api/forecast/data

A module containing useful functions to handle API results.

Types

Data at a specific time.

pub type CurrentData(data_type) {
  CurrentData(
    time: birl.Time,
    data: dict.Dict(data_type, measurement.Measurement),
  )
}

Constructors

  • CurrentData(
      time: birl.Time,
      data: dict.Dict(data_type, measurement.Measurement),
    )

A measurement at a specific time.

Similar to CurrentData but with only one Measurement.

pub type Data {
  Data(time: birl.Time, data: measurement.Measurement)
}

Constructors

  • Data(time: birl.Time, data: measurement.Measurement)

Data over a time range.

pub type TimeRangedData(data_type) {
  TimeRangedData(
    time: List(birl.Time),
    data: dict.Dict(data_type, List(measurement.Measurement)),
  )
}

Constructors

  • TimeRangedData(
      time: List(birl.Time),
      data: dict.Dict(data_type, List(measurement.Measurement)),
    )

    Arguments

    • time

      A list of birl.Time, with each index corresponding to the index of the data argument.

      For example, list.first(time) is the time when the first measurement was taken

Functions

pub fn range_to_current(
  from data: TimeRangedData(a),
  at time: Time,
) -> Result(CurrentData(a), SunnyError)

Converts a TimeRangedData to a CurrentData, given a specific time.

pub fn range_to_data_list(
  from data: TimeRangedData(a),
  get var: a,
) -> Result(List(Data), SunnyError)

Converts a TimeRangedData to a list of Data for a specific InstantVariable or DailyVariable.

Used in the hourly_forecast example.

Search Document