Functions

BiTWeather.readFunction
read(configuration::Configuration,
        range::Union{Tuple{Union{Date, Nothing}, Union{Date, Nothing}}, Nothing},
        fields::Union{Vector{Symbol}, Nothing})::DataFrame

Arguments

  • configuration::BiTWeather.Configuration: A BiTWeather.Configuration providing the location and structure of the weather data.
  • range::Union{Tuple{Union{Dates.Date, Nothing}, Union{Dates.Date, Nothing}}, Nothing}: The date range of the records to retrieve. A value of nothing for the lower, upper or both date bounds means there is no lower, upper or any date limit respectively. By selecting a date range here, you can do things such limit the records to the dates you need for your downstream processing.
  • fields::Union{Vector{Symbol}, Nothing}: The fields to include from each record. A value of nothing means all fields included in configure.fieldMappings will be included. The :dateTime field will be included reguardless of the value of fields. By providing a list of fields here, you can limit the records to the fields you need for your downstream processing.

Return

  • A DataFrames.DataFrame containing the requested weather data in SI units stored as Float64 and indexed by year/month/day/hour/minute/second.

Fetches and returns the weather data described by configuration. It assumes the Julia environment is configured so configure.dsn is a DSN that is able to connect to the SQL database containing the weather data and read the table configure.table. It renames the configure.table fields using the configure.fieldMappings. It parses the :dateTime field into separate columns of integers containing the year, month, day, hour, minute and second. All other fields are converted to SI units equivalents and stored as Float64 values. It drops any records with missing field values.

Example

import DataFrames
import BiTWeather

configuration = BiTWeather.Configuration(
    dsn = "meteobridge",
    table = "backinthirty",
    fieldMappings = Dict(
        :dateTime =>    BiTWeather.FieldMapping(name = "DateTime",   units = nothing),
        :temperature => BiTWeather.FieldMapping(name = "TempOutNow", units = "F")
    )
)

weatherData::DataFrames.DataFrame = BiTWeather.read(configuration, nothing, nothing)
source
BiTWeather.chillFunction
chill(::Val{:CumulativeChillHour}, weatherData::DataFrame)::DataFrame

Implements the Cumulative Chill Hour model.

Arguments

  • weatherData::DataFrames.DataFrame: The weather data used for calculating the accumulated chill hours. weatherData must be formatted to match the output of BiTWeather.read and contain at least the :temperature` field.

Return

  • A DataFrames.DataFrame containing the chill hours indexed by year/month/day/hour. The returned columns are: year, month, day, hour, temperature, $\Delta y(n)$, and $y(n)$.

Example

import DataFrames
import Dates
import BiTWeather

configuration = BiTWeather.Configuration(
    dsn = "meteobridge",
    table = "backinthirty",
    fieldMappings = Dict(
        :dateTime =>    BiTWeather.FieldMapping(name = "DateTime",   units = nothing),
        :temperature => BiTWeather.FieldMapping(name = "TempOutNow", units = "F")
    )
)

year::Int = 2021
rangeStart::Dates.Date = Dates.Date(year - 1, 11, 1)
rangeEnd::Dates.Date = Dates.Date(year, 2, 28)
range::Tuple{Float64, Float64} = (rangeStart, rangeEnd)
fields::Vector{Symbol} = [:temperature]
weatherData::DataFrames.DataFrame = BiTWeather.read(configuration, range, fields)
chillData::DataFrames.DataFrame = BiTWeather.chill(Val(:CumulativeChillHour), weatherData)
println(chillData)
source
chill(::Val{:CumulativeChillUnit}, weatherData::DataFrame)::DataFrame

Implements the Cumulative Chill Unit model (also known as the Utah model).

Arguments

  • weatherData::DataFrames.DataFrame: The weather data used for calculating the cumulative chill units. weatherData must be formatted to match the output of BiTWeather.read and contain at least the :temperature field.

Return

  • A DataFrames.DataFrame containing the chill units indexed by year/month/day/hour. The returned columns are: year, month, temperature, $\Delta y(n)$, and $y(n)$.

Example

import DataFrames
import Dates
import BiTWeather

configuration = BiTWeather.Configuration(
    dsn = "meteobridge",
    table = "backinthirty",
    fieldMappings = Dict(
        :dateTime =>    BiTWeather.FieldMapping(name = "DateTime",   units = nothing),
        :temperature => BiTWeather.FieldMapping(name = "TempOutNow", units = "F")
    )
)

year::Int = 2021
rangeStart::Dates.Date = Dates.Date(year - 1, 11, 1)
rangeEnd::Dates.Date = Dates.Date(year, 2, 28)
range::Tuple{Float64, Float64} = (rangeStart, rangeEnd)
fields::Vector{Symbol} = [:temperature]
weatherData::DataFrames.DataFrame = BiTWeather.read(configuration, range, fields)
chillData::DataFrames.DataFrame = BiTWeather.chill(Val(:CumulativeChillUnit), weatherData)
println(chillData)
source
chill(::Val{:CumulativeChillPortion}, weatherData::DataFrame)::DataFrame

Implements the Cumulative Chill Portion model (also known as the Dynamic model).

Arguments

  • weatherData::DataFrames.DataFrame: The weather data used for calculating the accumulated chill portions. weatherData must be formatted to match the output of BiTWeather.read and contain at least the:temperature field.

Return

  • A DataFrames.DataFrame containing the chill portions indexed by year/month/day/hour. The returned columns are: year, month, day, hour, temperature, $x(n)$, $\Delta y(n)$, and $y(n)$.

Example

import DataFrames
import Dates
import BiTWeather

configuration = BiTWeather.Configuration(
    dsn = "meteobridge",
    table = "backinthirty",
    fieldMappings = Dict(
        :dateTime =>    BiTWeather.FieldMapping(name = "DateTime",   units = nothing),
        :temperature => BiTWeather.FieldMapping(name = "TempOutNow", units = "F")
    )
)

year::Int = 2021
rangeStart::Dates.Date = Dates.Date(year - 1, 9, 1)
rangeEnd::Dates.Date = Dates.Date(year, 2, 28)
range::Tuple{Float64, Float64} = (rangeStart, rangeEnd)
fields::Vector{Symbol} = [:temperature]
weatherData::DataFrames.DataFrame = BiTWeather.read(configuration, range, fields)
chillData::DataFrames.DataFrame = BiTWeather.chill(Val(:CumulativeChillPortion), weatherData)
println(chillData)
source
chill(::Val{:MeanTemperature}, weatherData::DataFrame)::DataFrame

Implements the Mean Temperature model.

Arguments

  • weatherData: A DataFrames.DataFrame containing the weather data used for estimating the chill units. weatherData must be formatted to match the output of BiTWeather.read and contain at least the :temperature field.

Return

  • A DataFrames.DataFrame containing the chill units indexed by year/month/day/hour. The returned columns are: x and y.

For temperate climates, you want to use data from the coldest month of the year for the calculation. Whereas, for cold climates, you want to use data from the coldest two months of the year.

Example

import DataFrames
import Dates
import BiTWeather

configuration = BiTWeather.Configuration(
    dsn = "meteobridge",
    table = "backinthirty",
    fieldMappings = Dict(
        :dateTime =>    BiTWeather.FieldMapping(name = "DateTime",   units = nothing),
        :temperature => BiTWeather.FieldMapping(name = "TempOutNow", units = "F")
    )
)

year::Int = 2021
rangeStart::Dates.Date = Dates.Date(year, 1, 1)
rangeEnd::Dates.Date = Dates.Date(year, 1, 31)
range::Tuple{Float64, Float64} = (rangeStart, rangeEnd)
fields::Vector{Symbol} = [:temperature]
weatherData::DataFrames.DataFrame = BiTWeather.read(configuration, range, fields)
chillData::DataFrames.DataFrame = BiTWeather.chill(Val(:MeanTemperature), weatherData)
println(chillData)
source
BiTWeather.chillPlotFunction
chillPlot(::Val{:CumulativeChillHour}, chillData::DataFrame)::PlotlyJS.Plot

Generates a plot of the Cumulative Chill Hour model data.

Arguments

  • chillData::DataFrames.DataFrame: The chill data used in generating the plot. chillData must be formated to match the output of BiTWeather.chill called with Val(:CumulativeChillHour).

Return

  • A PlotlyJS.Plot containing a plot of the temperature and chill portion data.

Example

import DataFrames
import Dates
import PlotlyJS
import BiTWeather

configuration = BiTWeather.Configuration(
    dsn = "meteobridge",
    table = "backinthirty",
    fieldMappings = Dict(
        :dateTime =>    BiTWeather.FieldMapping(name = "DateTime",   units = nothing),
        :temperature => BiTWeather.FieldMapping(name = "TempOutNow", units = "F")
    )
)

year::Int = 2021
rangeStart::Dates.Date = Dates.Date(year - 1, 11, 1)
rangeEnd::Dates.Date = Dates.Date(year, 2, 28)
range::Tuple{Float64, Float64} = (rangeStart, rangeEnd)
fields::Vector{Symbol} = [:temperature]
weatherData::DataFrames.DataFrame = BiTWeather.read(configuration, range, fields)
chillData::DataFrames.DataFrame = BiTWeather.chill(Val(:CumulativeChillHour), weatherData)
plot::PlotlyJS.Plot = BiTWeather.chillPlot(Val(:CumulativeChillHour), chillData)
PlotlyJS.display(plot)
source
chillPlot(::Val{:CumulativeChillUnit}, chillData::DataFrame)::PlotlyJS.Plot

Generates a plot of the Cumulative Chill Unit model data.

Arguments

  • chillData::DataFrames.DataFrame: The chill data used in generating the plot. chillData must be formated to match the output of BiTWeather.chill called with Val(:CumulativeChillUnit).

Return

  • A PlotlyJS.Plot containing a plot of the temperature and chill portion data.

Example

import DataFrames
import Dates
import PlotlyJS
import BiTWeather

configuration = BiTWeather.Configuration(
    dsn = "meteobridge",
    table = "backinthirty",
    fieldMappings = Dict(
        :dateTime =>    BiTWeather.FieldMapping(name = "DateTime",   units = nothing),
        :temperature => BiTWeather.FieldMapping(name = "TempOutNow", units = "F")
    )
)

year::Int = 2021
rangeStart::Dates.Date = Dates.Date(year - 1, 11, 1)
rangeEnd::Dates.Date = Dates.Date(year, 2, 28)
range::Tuple{Float64, Float64} = (rangeStart, rangeEnd)
fields::Vector{Symbol} = [:temperature]
weatherData::DataFrames.DataFrame = BiTWeather.read(configuration, range, fields)
chillData::DataFrames.DataFrame = BiTWeather.chill(Val(:CumulativeChillUnit), weatherData)
plot::PlotlyJS.Plot = BiTWeather.chillPlot(Val(:CumulativeChillUnit), chillData)
PlotlyJS.display(plot)
source
chillPlot(::Val{:CumulativeChillPortion}, chillData::DataFrame)::PlotlyJS.Plot

Generates a plot of the Cumulative Chill Portion data.

Arguments

  • chillData::DataFrames.DataFrame: The chill data used in generating the plot. chillData must be formated to match the output of BiTWeather.chill called with Val(:CumulativeChillPortion).

Return

  • A PlotlyJS.Plot containing a plot of the temperature and chill portion data.

Example

import DataFrames
import Dates
import PlotlyJS
import BiTWeather

configuration = BiTWeather.Configuration(
    dsn = "meteobridge",
    table = "backinthirty",
    fieldMappings = Dict(
        :dateTime =>    BiTWeather.FieldMapping(name = "DateTime",   units = nothing),
        :temperature => BiTWeather.FieldMapping(name = "TempOutNow", units = "F")
    )
)

year::Int = 2021
rangeStart::Dates.Date = Dates.Date(year - 1, 9, 1)
rangeEnd::Dates.Date = Dates.Date(year, 2, 28)
range::Tuple{Float64, Float64} = (rangeStart, rangeEnd)
fields::Vector{Symbol} = [:temperature]
weatherData::DataFrames.DataFrame = BiTWeather.read(configuration, range, fields)
chillData::DataFrames.DataFrame = BiTWeather.chill(Val(:CumulativeChillPortion), weatherData)
plot::PlotlyJS.Plot = BiTWeather.chillPlot(Val(:CumulativeChillPortion), chillData)
PlotlyJS.display(plot)
source
chillPlot(::Val{:MeanTemperature}, chillData::DataFrame)::PlotlyJS.Plot

Generates a plot of the Cumulative Chill Unit model data.

Arguments

  • chillData::DataFrames.DataFrame: The chill data used in generating the plot. chillData must be formated to match the output of BiTWeather.chill called with Val(:MeanTemperature).

Return

  • A PlotlyJS.Plot containing a plot of the temperature and chill portion data.

Example

import DataFrames
import Dates
import PlotlyJS
import BiTWeather

configuration = BiTWeather.Configuration(
    dsn = "meteobridge",
    table = "backinthirty",
    fieldMappings = Dict(
        :dateTime =>    BiTWeather.FieldMapping(name = "DateTime",   units = nothing),
        :temperature => BiTWeather.FieldMapping(name = "TempOutNow", units = "F")
    )
)

year::Int = 2021
rangeStart::Dates.Date = Dates.Date(year, 1, 1)
rangeEnd::Dates.Date = Dates.Date(year, 1, 31)
range::Tuple{Float64, Float64} = (rangeStart, rangeEnd)
fields::Vector{Symbol} = [:temperature]
weatherData::DataFrames.DataFrame = BiTWeather.read(configuration, range, fields)
chillData::DataFrames.DataFrame = BiTWeather.chill(Val(:MeanTemperature), weatherData)
plot::PlotlyJS.Plot = BiTWeather.chillPlot(Val(:MeanTemperature), chillData)
PlotlyJS.display(plot)
source

Last Reviewed on 19 February 2021