Click or drag to resize

AverageDataSpec Class

Defines a specification for a set of average data such as 5-year-average degree days.
Inheritance Hierarchy
SystemObject
  DegreeDays.Api.DataDataSpec
    DegreeDays.Api.DataAverageDataSpec

Namespace: DegreeDays.Api.Data
Assembly: DegreeDays (in DegreeDays.dll) Version: 1.4
Syntax
public sealed class AverageDataSpec : DataSpec

The AverageDataSpec type exposes the following members.

Constructors
 NameDescription
Public methodAverageDataSpec Constructs an AverageDataSpec object with the specified Calculation and AverageBreakdown.
Top
Properties
 NameDescription
Public propertyBreakdown Gets the non-null AverageBreakdown that defines the way in which the degree days should be broken down and the period in time that they should cover.
Public propertyCalculation Gets the non-null Calculation object that defines the way in which the degree days should be calculated in terms of their base temperature and whether they should be heating degree days or cooling degree days.
Top
Methods
 NameDescription
Public methodEquals Two DataSpec objects are equal if they have the same class and the same configuration.
(Inherited from DataSpec)
Public methodGetHashCode Overridden to ensure consistency with Equals.
(Inherited from DataSpec)
Public methodToString Returns a non-null, non-empty string representation of this instance for logging and debugging purposes.
(Overrides ObjectToString)
Top
Remarks

An AverageDataSpec specifies a set of average degree days in terms of:

  • the calculation process used to calculate the dated figures that the averages are derived from (heating or cooling, and the base temperature); and
  • its breakdown (which years of data to include in the averaged figures).

Example AverageDataSpec code:

Here's how you could specify 10-year average heating degree days with a base temperature of 70°F:

AverageDataSpec averageDataSpec = DataSpec.Average(
    Calculation.HeatingDegreeDays(Temperature.Fahrenheit(70)),
    AverageBreakdown.FullYears(Period.LatestValues(10)));

You could then send that AverageDataSpec to the API as part of a LocationDataRequest, and get a response containing an AverageDataSet back:

DegreeDaysApi api = new DegreeDaysApi(new AccountKey(yourStringAccountKey),
    new SecurityKey(yourStringSecurityKey));
LocationDataRequest request = new LocationDataRequest(
    Location.PostalCode("02630", "US"),
    new DataSpecs(averageDataSpec));
LocationDataResponse response = api.DataApi.GetLocationData(request);
AverageDataSet averageData = response.DataSets.GetAverage(averageDataSpec);
for (int month = 1; month <= 12; month++) {
    Console.WriteLine("Average HDD for month " + month + ": " +
        averageData.MonthlyAverage(month).Value);
}
Console.WriteLine("Annual average HDD: " + averageData.AnnualAverage.Value);

To request multiple sets of average data with different calculation processes (e.g. multiple different base temperatures) and/or different breakdowns, simply put multiple AverageDataSpec objects into the DataSpecs object that you pass into your LocationDataRequest.

Thread Safety
Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.
See Also