Documentation
¶
Index ¶
- Variables
- func Distance(lat1, lon1, lat2, lon2 float64) float64
- func FetchLatestForecastForStation(stationID string) ([]*CuratedForecast, *Coordinates, error)
- func LoadDefaultStations() error
- func LoadStations() error
- func ParseKMLFile(path string) ([]TimeSlotForecast, *Coordinates, error)
- type Coordinates
- type CuratedForecast
- type Document
- type Forecast
- type ForecastTimeSteps
- type ForecastValue
- type Kml
- type MetElement
- type MetElementDefinition
- type Placemark
- type Point
- type ProductDefinition
- type Station
- type Stations
- type TimeSlotForecast
Constants ¶
This section is empty.
Variables ¶
var ErrNoForecastFound = errors.New("no forecast found")
Functions ¶
func Distance ¶ added in v0.1.1
Distance returns the distance between two points on earth (roughly, via Haversine formula)
func FetchLatestForecastForStation ¶
func FetchLatestForecastForStation(stationID string) ([]*CuratedForecast, *Coordinates, error)
FetchLatestForecastForStation fetches the latest MOSMIX forecast for a given station ID, parses it, and returns curated forecast data. Station lists can be found at: - https://wettwarn.de/mosmix/mosmix.html (Map) - https://www.dwd.de/DE/leistungen/met_verfahren_mosmix/mosmix_stationskatalog.html (List)
func LoadDefaultStations ¶ added in v0.1.1
func LoadDefaultStations() error
func LoadStations ¶ added in v0.1.1
func LoadStations() error
LoadStations loads the list of stations from DWD This function exists to allow for updates if the list changes. But typically, users should just use the built-in list.
func ParseKMLFile ¶
func ParseKMLFile(path string) ([]TimeSlotForecast, *Coordinates, error)
ParseKMLFile parses a KML file and returns time-pivoted forecast data.
Types ¶
type Coordinates ¶
func NearestStation ¶ added in v0.1.1
func NearestStation(c *Coordinates) (string, *Coordinates, error)
NearestStation
func ParseCoordinates ¶ added in v0.1.3
func ParseCoordinates(coordStr string) (*Coordinates, error)
type CuratedForecast ¶
type CuratedForecast struct {
Time time.Time
Temp2m float64 // °C, Temperature 2m above surface
ErrTemp2m float64 // K, absolute error of temperature 2m above surface
Temp5cm float64 // °C, Temperature 5cm above surface
CloudCoverTotal float64 // %, Total cloud cover
CloudCoverEff float64 // %, Effective cloud cover
CloudCoverLow float64 // %, Low cloud cover (lower than 2 km)
CloudCoverMid float64 // %, Mid level cloud cover (2-7 km)
CloudCoverHigh float64 // %, High cloud cover (>7 km)
CloudCoverBelow500ft float64 // %, Cloud cover below 500 ft.
GlobalIrradiance float64 // kJ/m2, Global Irradiance
Visibility float64 // m, Visibility
}
CuratedForecast holds a selection of forecast values for a given time slot.
func CurateForecasts ¶
func CurateForecasts(timeSlots []TimeSlotForecast) []*CuratedForecast
CurateForecasts transforms raw TimeSlotForecasts into CuratedForecasts. It extracts only a subset of fields and handles missing values by assigning NaN. The fields are documented at: https://opendata.dwd.de/weather/lib/MetElementDefinition.xml
func GetNearestCurated ¶
func GetNearestCurated(t time.Time, forecasts []*CuratedForecast) (*CuratedForecast, error)
func (CuratedForecast) String ¶ added in v0.1.1
func (cf CuratedForecast) String() string
type Document ¶
type Document struct {
ExtendedData struct {
ProductDefinition ProductDefinition `xml:"https://opendata.dwd.de/weather/lib/pointforecast_dwd_extension_V1_0.xsd ProductDefinition"`
} `xml:"ExtendedData"`
Placemark Placemark `xml:"Placemark"`
}
type ForecastTimeSteps ¶
type ForecastTimeSteps struct {
TimeSteps []string `xml:"https://opendata.dwd.de/weather/lib/pointforecast_dwd_extension_V1_0.xsd TimeStep"`
}
type ForecastValue ¶
type ForecastValue struct {
Value float64
}
ForecastValue holds value of one element at a given time.
type MetElement ¶
type MetElement struct {
ShortName string `xml:"ShortName"`
UnitOfMeasurement string `xml:"UnitOfMeasurement"`
Description string `xml:"Description"`
}
MetElement holds the definition of a meteorological element.
type MetElementDefinition ¶
type MetElementDefinition struct {
XMLName xml.Name `xml:"MetElementDefinition"`
MetElements []MetElement `xml:"MetElement"`
}
MetElementDefinition holds a list of meteorological element definitions.
func LoadMetElementDefinitions ¶
func LoadMetElementDefinitions(path string) (*MetElementDefinition, error)
LoadMetElementDefinitioloads meteorological element definitions from an XML file. It reads from path, which is expected to contain the content of https://opendata.dwd.de/weather/lib/MetElementDefinition.xml
type ProductDefinition ¶
type ProductDefinition struct {
ForecastTimeSteps ForecastTimeSteps `xml:"https://opendata.dwd.de/weather/lib/pointforecast_dwd_extension_V1_0.xsd ForecastTimeSteps"`
}
type Station ¶ added in v0.1.1
type Station struct {
ID string
ICAO string
Name string
Lat float64 // Degrees North, southern latitudes are negative
Lon float64 // Degrees East, western longitude are negative
Elevation float64 // meters
}
func GetStation ¶ added in v0.1.7
GetStation returns the specified station or nil.
type TimeSlotForecast ¶
type TimeSlotForecast struct {
Time time.Time
Values map[string]ForecastValue // map of element name to value
}
TimeSlotForecast holds all forecast elements for a given time slot.