This module behaves much like Quantity.Interval, but
works on Temperature
values.
Construct an interval with the two given endpoints (which can be provided in either order).
Construct an interval from its endpoints (the minimum and maximum temperatures of the interval). The two values should be given in order but will be swapped if necessary to ensure a valid interval is returned.
Construct an interval containing both of the given intervals.
Attempt to construct an interval containing all the temperatures common to
both given intervals. If the intervals do not intersect, returns Nothing. If
the two intervals just touch, a singleton interval will be returned.
These functions let you construct an Interval containing one or more input
temperatures.
Construct an interval containing one or more input temperatures.
Construct an interval containing all temperatures in the given list. If the
list is empty, returns Nothing.
Like hull, but lets you work on any kind of item as long as a
Temperature can be extracted from it:
type alias WeatherMeasurement =
{ windSpeed : Speed
, temperature : Temperature
, barometricPressure : Pressure
}
temperatureRange =
Temperature.Interval.hullOf .temperature <|
measurement1
[ measurement2
, measurement3
, measurement4
]These functions let you 'aggregate' one or more temperature intervals into a single larger interval that contains all of them.
Construct an interval containing one or more given intervals.
Construct an interval containing all of the intervals in the given list. If
the list is empty, returns Nothing.
Combination of aggregateOf and aggregateN.
Get the endpoints of an interval (its minimum and maximum temperatures) as a tuple. The first temperature will always be less than or equal to the second.
Get the width of an interval. This will never be negative. Note that this
returns a Temperature.Delta,
not a Temperature.
Check if an interval contains a given temperature. The minimum and maximum temperatures of the interval are considered to be contained in the interval.
Check if the second interval is fully contained in the first.
Check if two intervals touch or overlap (have any temperatures in common). Intervals that just touch each other are considered to intersect.
Check if the interval is a singleton (the minimum and maximum temperatures are the same).
Interpolate between an interval's endpoints; a value of 0.0 corresponds to the minimum temperature of the interval, a value of 0.5 corresponds to its midpoint and a value of 1.0 corresponds to its maximum temperature. Values less than 0.0 or greater than 1.0 can be used to extrapolate.
Given an interval and a given value, determine the corresponding
interpolation parameter (the parameter that you would pass to interpolate
to get the given value).
Add a temperature delta to a temperature interval, resulting in a new temperature interval.
temperatureInterval =
Temperature.Interval.from
(Temperature.degreesCelsius 20)
(Temperature.degreesCelsius 25)
temperatureInterval
|> Temperature.Interval.plus
(Temperature.celsiusDegrees 10)
--> Temperature.Interval.from
--> (Temperature.degreesCelsius 30)
--> (Temperature.degreesCelsius 35)Subtract a temperature value from a temperature interval to give an interval of temperature deltas.
temperatureInterval =
Temperature.Interval.from
(Temperature.degreesCelsius 20)
(Temperature.degreesCelsius 25)
temperatureInterval
|> Temperature.Interval.minus
(Temperature.degreesCelsius 15)
--> Quantity.Interval.from
--> (Temperature.celsiusDegrees 5)
--> (Temperature.celsiusDegrees 10)The plusInterval and minusInterval functions both involve Interval Float
CelsiusDegrees values, where Interval in this case refers to the type in the
Quantity.Interval module. This represents an interval of temperature deltas.
Add a temperature delta interval to a temperature interval to give a new temperature interval:
temperatureInterval =
Temperature.Interval.from
(Temperature.degreesCelsius 20)
(Temperature.degreesCelsius 25)
deltaInterval =
Quantity.Interval.from
(Temperature.celsiusDegrees -1)
(Temperature.celsiusDegrees 4)
temperatureInterval
|> Temperature.Interval.plus deltaInterval
--> Temperature.Interval.from
--> (Temperature.degreesCelsius 19)
--> (Temperature.degreesCelsius 29)Subtract the first given temperature interval from the second, resulting in a temperature delta interval:
firstInterval =
Temperature.Interval.from
(Temperature.degreesCelsius 5)
(Temperature.degreesCelsius 10)
secondInterval =
Temperature.Interval.from
(Temperature.degreesCelsius 30)
(Temperature.degreesCelsius 40)
secondInterval
|> Temperature.Interval.minus firstInterval
--> Quantity.Interval.from
--> (Temperature.celsiusDegrees 20)
--> (Temperature.celsiusDegrees 35)
Represents a finite, closed interval with a minimum and maximum temperature, for example the interval from 20 to 30 degrees Celsius.