new WeatherData( [config])
Creates a new annual hourly weather data store.
Parameters:
| Name | Type | Argument | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object |
<optional> |
An optional configuration object. |
||||||||||||||||||||||||||||||||||||||||
Properties of
|
|||||||||||||||||||||||||||||||||||||||||||
| Name | Type | Argument | Description |
|---|---|---|---|
stationName |
string |
<optional> |
The name of the weather station. |
stateOrRegion |
number |
<optional> |
The state, province or region of the weather station. |
country |
number |
<optional> |
The country of the weather station. |
WMO |
number |
<optional> |
The World Meteorological Organization (WMO) station identifier. |
latitude |
number |
<optional> |
The terrestrial latitude of the weather station, in decimal degrees. |
longitude |
number |
<optional> |
The terrestrial longitude of the weather station, in decimal degrees. |
timezone |
number |
<optional> |
The local time zone at the weather station, in decimal hours. |
northAngle |
number |
<optional> |
The angle between north and the +Y axis, in decimal degrees. |
elevation |
number |
<optional> |
The average height of the station above sea level, in metres. |
Extends
Members
-
:string
WMO
-
The World Meteorological Organization (WMO) station identifier.
Type
- string
-
annualHourly
-
Stores the available weather data as 24 hourly values for 365 days.
Each metric is stored as array with 365 entries, each containing an array of 24 hourly decimal data values.
Properties:
Name Type Description tempDryBulbArray Dry Bulb Temperature (°C)
tempDewPointArray Dew Point Temperature (°C).
relHumidityArray Relative Humidity (%).
atmPressureArray Atmospheric Pressure (Pa).
extRadHorizontalArray Extraterrestrial Horizontal Radiation (Wh/m2).
extRadDirectBeamArray Extraterrestrial Direct Normal Radiation (Wh/m2).
infraRedHorizontalArray Horizontal Infrared Radiation from Sky (Wh/m2).
solarGlobalHorizontalArray Global Horizontal Radiation (Wh/m2).
solarDirectBeamArray Direct Normal Radiation (Wh/m2).
solarDiffuseHorizontalArray Diffuse Horizontal Radiation (Wh/m2).
illumGlobalHorizontalArray Global Horizontal Illuminance (Lux).
illumDirectBeamArray Direct Normal Illuminance (Lux).
illumDiffuseHorizontalArray Diffuse Horizontal Illuminance (Lux).
zenithLuminanceArray Zenith Luminance (cd/m2).
windDirectionArray Wind Direction (deg).
windSpeedArray Wind Speed (m/s).
cloudCoverArray Total Cloud Cover (%).
cloudOpaqueArray Opaque Sky Cover (%).
visibilityArray Visibility (km).
ceilingHeightArray Ceiling Height (m).
precipitableWaterArray Precipitable Water (mm).
aerosolOpticalDepthArray Aerosol Optical Depth (thou).
snowDepthArray Snow Depth (cm).
snowDaysSinceArray Days Since Last Snowfall (days).
albedoArray Albedo (0-1).
precipitationDepthArray Precipitation Depth (mm).
-
:string
country
-
The country of the weather station.
Type
- string
-
:boolean
dayCount
-
Whether or not the data is for a leap year with 366 days.
Type
- boolean
-
:number
elevation
-
The average height of the site above sea level, in metres.
Type
- number
- Inherited From:
- Overrides:
-
:boolean
isLocation <readonly>
-
A flag identifying this object as a location.
Type
- boolean
- Inherited From:
- Overrides:
-
:boolean
isWeatherData <readonly>
-
A flag identifying this object as a weather data store.
Type
- boolean
-
:number
latitude
-
The terrestrial latitude of the current location, in decimal degrees.
Type
- number
- Inherited From:
- Overrides:
-
:boolean
leapYear
-
Whether or not the data is for a leap year with 366 days.
Type
- boolean
-
:number
longitude
-
The terrestrial longitude of the current location, in decimal degrees.
Type
- number
- Inherited From:
- Overrides:
-
:number
northAngle
-
The angle between north and the +Y axis, in decimal degrees.
Type
- number
- Inherited From:
- Overrides:
-
:string
stateOrRegion
-
The state, province or region of the weather station.
Type
- string
-
:string
stationName
-
The name of the weather station.
Type
- string
-
:number
timezone
-
The local time zone at the current location, in decimal hours.
Type
- number
- Inherited From:
- Overrides:
Methods
-
calc30DayMeanOutdoorTemperature(day)
-
Calculates the ASHRAE mean monthly outdoor temperature for the given date.
This is the arithmetic average of the means of the daily minimum and daily maximum temperature for the preceding 30 days.
Parameters:
Name Type Description daynumber The numeric index of the day in the year (0 to 364).
Returns:
Returns the running mean outdoor temperature (degC).
- Type
- number
-
calcAverageTemperatureAtHour(from_day, to_day, hour)
-
Calculates the average temperature for the given hour over the date range.
Parameters:
Name Type Description from_daynumber The numeric index of the day in the year to start at (0 to 364/5).
to_daynumber The numeric index of the day in the year to end at (0 to 364/5).
hournumber The hour of the day to calculate, in decimal hours (0 tp 24).
Returns:
Returns the calculated average outdoor temperature (degC).
- Type
- number
-
calcAverageTemperatureOverPeriod(day [, day_count])
-
Calculates a running mean outdoor temperature for the given date.
Parameters:
Name Type Argument Description daynumber The numeric index of the day in the year (0 to 364).
day_countnumber <optional>
An optional number of prior days to include in mean, defaults to 30.
Returns:
Returns the running mean outdoor temperature (degC).
- Type
- number
-
calcWindFrequencyData(range, angleBand, speedBand)
-
Computes wind speed/direction frequency data for the given date/time range.
This method calculates the frequency of wind speed and direction data for the given date/time range. The data is returned as an object with the following properties:
{ windRose: [ [0.012, 0.026, ...], [0.002, 0.009, ...], ...], angleIncrementsInDegrees: 30.0, // computed `angleBand`. speedIncrementsInKmh: 10.0, // computed `speedBand`. totalHours: 8760, calmHours: 641, maxValue: 0.13 }The
windRoseproperty is an array of arrays, with an array for each angular segment containing the fractional number of hours at each wind speed band, from lowest speed to highest speed. Any time wind speed is below 1 kilometer per hour, it is considered to be calm with no discernable direction so is added to thecalmHoursproperty.You can give the wind speed band as an array of wind speed thresholds in kilometers per hour if you need irregular sized speed bands. If you pass an empty array, the speed bands will default to the Beaufort scale.
Parameters:
Name Type Description rangePD.DateTimeRange The date/time range over which to calculate.
angleBandnumber The preferred angle of each band in degrees, will be rounded to evenly divide into 360, defaults to 30deg (12 bands).
speedBandnumber | Array.<number> The preferred wind speed of each band in kilometers per hour or an array of speed band threshold values, defaults to 10km/h bands. If you need knots, m/s or mph, convert the required value to km/h.
Returns:
Returns an object with
totalHoursandcalmHoursproperties, as well aswindRosewith an array of angular bands, each with entries for hourly frequencies by speed band.- Type
- object
-
closeTo(latitude, longitude [, timezone])
-
Determines if this location is sufficiently close to the given location to be considered effectively equal.
This method checks if the given latitude and longitude values are within 1e-6 degrees of this location, and that the timezone (if given) is within 1 minute of this location's timezone. A threshold of 1e-6 degrees represents a terrestrial distance of about 0.1 metre (4 inches) at sea level.
Parameters:
Name Type Argument Description latitudenumber The geographic latitude above the equator, in decimal degrees (-90 to 90).
longitudenumber The geographic longitude west of the prime meridian, in decimal degrees (-180 to 180).
timezonenumber <optional>
The timezone in decimal hours (-12 to +13), ignored if not given.
- Inherited From:
- Overrides:
Returns:
Returns true if the given values are very close (within 1e-6 degrees).
- Type
- boolean
-
copy(from)
-
Copy the given location to this location.
Parameters:
Name Type Description fromPD.Location Another location instance to copy from.
- Inherited From:
- Overrides:
Returns:
Returns this location instance to support method chaining.
- Type
- PD.Location
-
distanceTo(loc)
-
Estimates the terrestrial distance to the given location on the Earth's surface.
This uses the static
PD.Location.terrestrialDistancemethod which is based on the haversine formula for calculating the great-circle distance between two given terrestrial locations. This is basically the shortest distance over the Earth’s surface 'as-the-crow-flies' between the two locations, ignoring any hills or valleys they may fly over.Parameters:
Name Type Description locPD.Location The target location.
- Inherited From:
- Overrides:
Returns:
Returns the computed distance 'as-the-crow-flies' over the Earth's surface, in metres.
- Type
- number
-
distanceToLatLng(latitude, longitude)
-
Estimates the terrestrial distance to the given location on the Earth's surface.
This uses the static
PD.Location.terrestrialDistancemethod which is based on the haversine formula for calculating the great-circle distance between two given terrestrial locations. This is basically the shortest distance over the Earth’s surface 'as-the-crow-flies' between the two locations, ignoring any hills or valleys they may fly over.Parameters:
Name Type Description latitudenumber The target geographic latitude above the equator, in decimal degrees (-90 to 90).
longitudenumber The target geographic longitude west of the prime meridian, in decimal degrees (-180 to 180).
- Inherited From:
- Overrides:
Returns:
Returns the computed distance 'as-the-crow-flies' over the Earth's surface, in metres.
- Type
- number
-
fromJSON(data)
-
Extracts weather station and location information from the given object.
Parameters:
Name Type Description dataobject An object that might contain location information.
Properties of
data:Name Type Argument Description stationNamestring <optional>
The name of the weather station.
stateOrRegionnumber <optional>
The state, province or region of the weather station.
countrynumber <optional>
The country of the weather station.
WMOnumber <optional>
The World Meteorological Organization (WMO) station identifier.
latitudenumber <optional>
An optional terrestrial latitude of the current location, in decimal degrees.
longitudenumber <optional>
An optional terrestrial longitude of the current location, in decimal degrees.
timezonenumber <optional>
An optional local time zone at the current location, in decimal hours
northAnglenumber <optional>
An optional angle between north and the +Y axis, in decimal degrees.
elevationnumber <optional>
An optional average height of the site above sea level, in metres.
- Inherited From:
- Overrides:
Returns:
Returns true if any matching data was found, or false if nothing was copied.
-
getData(metric)
-
Returns the annual data array for the given metric.
You can use the
PD.WEATHERDATAindex values to specify the metric you require.The returned array should contain 365/6 x 24hr data values ([day][hr]) and can be used directly with the
PD.WeatherData#getSubHourlyValueandPD.WeatherData#getValuemethods.Parameters:
Name Type Description metricPD.WEATHERDATA The weather data metric index (0-25).
Returns:
Returns an array of 365/6 x 24hr data values ([day][hr]).
- Type
- Array.<Array.<number>>
-
getMetric(metric)
-
Returns data and metadata for the given metric.
You can use the
PD.WEATHERDATAindex values to specify the metric you require.The returned object has the following properties:
NAME TYPE DESCRIPTION dataArray[] An array of 365/6 x 24hr data values ([day][hr]). namestring A human-readable name for the given metric. shortNamestring An abbreviated but still readable name for the metric. abbrevstring A very short, typically 3 letter data type identifier. unitsstring A human-readable string with the metric units. minnumber The minimum bounds of the data range for this metric. maxnumber The maximum bounds of the data range for this metric. stepnumber A recommended step increment value for this range. Parameters:
Name Type Description metricPD.WEATHERDATA The weather data metric index (0-25).
Returns:
Returns a simple meta-data object.
- Type
- object
Example
let day = 90; let hour = 12; let metric = PD.WeatherData.getMetric(PD.WEATHERDATA.DRY_BULB); let t = metric.data[day][hour];
-
getSubHourlyValue(data, day, hour)
-
Returns a data value interpolated between integer hourly values.
Parameters:
Name Type Description dataArray An array with 365 24hr data values.
daynumber The numeric index of the day in the year (0 to 364).
hournumber The decimal hour of the day (0.0 to 23.999).
Returns:
Returns the interpolated data sub-hourly value.
- Type
- number
-
getValue(data, day, hour)
-
Returns a data value at the given integer day/hour values.
Parameters:
Name Type Description dataArray An array with 365 24hr data values.
daynumber The numeric index of the day in the year (0 to 364).
hournumber The numeric indx of the hour in the day (0 to 23).
Returns:
Returns the hourly data value.
- Type
- number
-
parseEPW(text [, options])
-
Imports an EnergyPlus Weather File (EPW).
Parameters:
Name Type Argument Description textstring | FileReader The textual contents of the EPW file.
optionsobject <optional>
Optional configuration callbacks and conversion options.
Properties of
options:Name Type Argument Description progressIncrementnumber <optional>
An optional fractional progress rate for callbacks.
callbackProgressfunction <optional>
An optional function to call after each progress increment.
callbackCompletefunction <optional>
An optional function to call when parsing is complete.
debugboolean <optional>
An optional flag to show parsing time in the console.
Throws:
-
Occurs if the EPW file is empty or invalid.
- Type
- TypeError
Returns:
Returns true if the EPW file contained recognizable data.
- Type
- boolean
-
-
parseWEA(text)
-
Imports a DAYSIM Solar Radiation Weather File (WEA).
Parameters:
Name Type Description textstring The textual contents of the WEA file.
Throws:
-
Occurs if the WEA file is empty or invalid.
- Type
- TypeError
Returns:
Returns true if the WEA file contained recognizable data.
- Type
- boolean
-
-
set(latitude, longitude, timezone)
-
Sets the geographic location to calculate solar positions for.
Parameters:
Name Type Description latitudenumber The geographic latitude above the equator, in decimal degrees (-90 to 90).
longitudenumber The geographic longitude west of the prime meridian, in decimal degrees (-180 to 180).
timezonenumber The difference between local time at the location and UTC, in decimal hours (-13.0 to 13.0). The value should be positive for all time zone behind/east of UTC and negative for ahead/west.
- Inherited From:
- Overrides:
Returns:
Returns this solar calculator to support method chaining.
- Type
- PD.Location
-
setValuesFromArray(data, array)
-
Copies a flat annual hourly array to annual day/hour values.
Parameters:
Name Type Description dataArray An array to receive the 365/366 24hr data values.
arrayArray The flat data array, must contain at least 8760 values.
Throws:
-
Throws an error if either array is invalid or if flat array has less than a full year's worth of hourly data values (8760).
- Type
- Error
Returns:
Returns this weather object to support method chaining.
-
-
toJSON( [data])
-
Converts object instance to a simple POJO for conversion to JSON.
This method is used to copy, store and save the data for this object, so the returned object must have all the properties required be able to rebuild this instance in its entirety when passed to the class constructor.
Parameters:
Name Type Argument Description dataobject <optional>
An optional parent object to append this data to.
- Inherited From:
- Overrides:
Returns:
Returns a Plain Old Javascript Object (POJO).
- Type
- object