Documentation
¶
Index ¶
- Constants
- type Client
- type ClientOption
- type IEMNetowrkJsonResposne
- type IEMNetworkService
- type IEMNotFoundError
- type IEMStationService
- type IEMStationsJsonResponse
- type IEMWeatherData
- type IEMWeatherService
- type Network
- type NetworkService
- type Station
- type StationService
- type TestWeatherService
- type WeatherDataData
- type WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) BuildUrl() (url.Values, error)
- func (b *WeatherDataQueryBuilder) Data(data ...WeatherDataData) *WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) Elevation(elev bool) *WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) End(t time.Time) *WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) Format(format WeatherDataQueryFormat) *WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) LatLon(latlon bool) *WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) Missing(missing WeatherDataQueryMissing) *WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) ReportType(types ...int) *WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) Start(t time.Time) *WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) Stations(stations ...string) *WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) Timezone(tz string) *WeatherDataQueryBuilder
- func (b *WeatherDataQueryBuilder) Trace(trace WeatherDataQueryTrace) *WeatherDataQueryBuilder
- type WeatherDataQueryBuilderError
- type WeatherDataQueryFormat
- type WeatherDataQueryMissing
- type WeatherDataQueryTrace
- type WeatherDataQueryYesNo
- type WeatherService
Constants ¶
const ( OnlyComma WeatherDataQueryFormat = "onlycomma" OnlyTDF WeatherDataQueryFormat = "onlytdf" Comma WeatherDataQueryFormat = "comma" TDF WeatherDataQueryFormat = "tdf" Yes WeatherDataQueryYesNo = "yes" No WeatherDataQueryYesNo = "no" MissingM WeatherDataQueryMissing = "M" MissingNull WeatherDataQueryMissing = "null" MissingEmpty WeatherDataQueryMissing = "empty" TraceT WeatherDataQueryTrace = "T" TraceNull WeatherDataQueryTrace = "null" TraceEmpty WeatherDataQueryTrace = "empty" TraceFloat WeatherDataQueryTrace = "0.0001" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithOptions ¶
func NewClientWithOptions(opts ...ClientOption) *Client
func (*Client) Networks ¶
func (c *Client) Networks() NetworkService
func (*Client) Stations ¶
func (c *Client) Stations() StationService
func (*Client) Weather ¶
func (c *Client) Weather() WeatherService
type ClientOption ¶
type ClientOption func(*Client)
func WithNetworkService ¶
func WithNetworkService(service NetworkService) ClientOption
func WithWeatherService ¶
func WithWeatherService(service WeatherService) ClientOption
type IEMNetowrkJsonResposne ¶
type IEMNetowrkJsonResposne struct {
Data []*Network `json:"data"`
}
type IEMNetworkService ¶
type IEMNetworkService struct {
// contains filtered or unexported fields
}
func (*IEMNetworkService) GetNetworks ¶
func (s *IEMNetworkService) GetNetworks(ctx context.Context) ([]*Network, error)
type IEMNotFoundError ¶
func (IEMNotFoundError) Error ¶
func (err IEMNotFoundError) Error() string
type IEMStationService ¶
type IEMStationService struct {
// contains filtered or unexported fields
}
func (*IEMStationService) GetStation ¶
func (*IEMStationService) GetStations ¶
type IEMStationsJsonResponse ¶
type IEMStationsJsonResponse struct {
Data []*Station
}
type IEMWeatherData ¶
type IEMWeatherData struct { Station string `json:"station"` // Station recorded at (station) Time *time.Time `json:"time"` // Time recorded at (valid) Lon float64 `json:"lon,omitempty"` // Longitude recorded at (lon) Lat float64 `json:"lat,omitempty"` // Latitude recorded at (lat) Elevation string `json:"elevation,omitempty"` // Elevation recorded at (elev) TemperatureF float64 `json:"tmpf,omitempty"` // Air Temperature [F] (tempf) TemperatureC float64 `json:"tmpc,omitempty"` // Air Temperature [C] (tempc) DewPointF float64 `json:"dwpf,omitempty"` // Dew Point [F] (dwpf) DewPointC float64 `json:"dwpc,omitempty"` // Dew Point [C] (dwpc) RelativeHumidity float64 `json:"relh,omitempty"` // Relative humidity [%] (relh) Feel float64 `json:"feel,omitempty"` // Heat Index/Wind Chil [F] (feel) WindDirection float64 `json:"drct,omitempty"` // Wind Direction [deg] (drct) WindSpeedKnots float64 `json:"sknt,omitempty"` // Wind Speed [knots] (sknt) WindSpeedMPH float64 `json:"sped,omitempty"` // Wind Speed [mph] (sped) WindGustKnots float64 `json:"gust,omitempty"` // Wind Gust [knots] (gust) WindGustMPH float64 `json:"gust_mph,omitempty"` // Wind Gust [mph] (gust_mph) PeakWindGustKnots float64 `json:"peak_wind_gust,omitempty"` // Peak Wind Gust [knots] (peak_wind_gust) PeakWindGustMPH float64 `json:"peak_wind_mph,omitempty"` // Peak Wind Gust [mph] (peak_wind_mph) PeakWindDirection float64 `json:"peak_wind_drct,omitempty"` // Peak Wind Direction [deg] (peak_wind_drct) PeakWindTime *time.Time `json:"peak_wind_time,omitempty"` // Peak Wind Time (peak_wind_time) Altimeter float64 `json:"alti,omitempty"` // Altimeter [inches] (alti) SeaLevelPressure float64 `json:"mslp,omitempty"` // Sea Level Pressure [mb] (mslp) PrecipMM float64 `json:"p01m,omitempty"` // 1 hour Precipitation [mm] (p01m) PrecipInch float64 `json:"p01i,omitempty"` // 1 hour Precipitation [inch] (po1i) Visibility float64 `json:"vsby,omitempty"` // Visibility [miles] (vsby) CloudCoverageL1 string `json:"skyc1,omitempty"` // Cloud Coverage Level 1 (skyc1) CloudCoverageL2 string `json:"skyc2,omitempty"` // Cloud Coverage Level 2 (skyc2) CloudCoverageL3 string `json:"skyc3,omitempty"` // Cloud Coverage Level 3 (skyc3) CloudHeightL1 float64 `json:"skyl1,omitempty"` // Cloud Height Level 1 [ft] (skyl1) CloudHeightL2 float64 `json:"skyl2,omitempty"` // Cloud Height Level 2 [ft] (skyl2) CloudHeightL3 float64 `json:"skyl3,omitempty"` // Cloud Height Level 3 [ft] (skyl3) PresentWeatherCodes string `json:"wxcodes,omitempty"` // Present Weather Code(s) IceAccretion1HR float64 `json:"ice_accretion_1hr,omitempty"` // Ice Accretion 1 Hour (ice_accretion_1hr) IceAccretion3HR float64 `json:"ice_accretion_3hr,omitempty"` // Ice Accretion 3 Hour (ice_accretion_3hr) IceAccretion6HR float64 `json:"ice_accretion_6hr,omitempty"` // Ice Accretion 6 Hour (ice_accretion_6hr) SnowDepth float64 `json:"snowdepth,omitempty"` // Snow Depth (4-group) [inch] (snowdepth) METAR string `json:"metar,omitempty"` // Raw METAR (metar) }
IEMWeatherData represents a weather reading at a station at a time Properties are present depending on the query used to fetch weather data
func ParseWeatherData ¶
func ParseWeatherData(reader io.Reader, query *WeatherDataQueryBuilder) ([]*IEMWeatherData, error)
Parse weather data from a io.Reader that reads CSV data based on a WeatherDataQueryBuilder
type IEMWeatherService ¶
type IEMWeatherService struct {
// contains filtered or unexported fields
}
func (*IEMWeatherService) Get ¶
func (s *IEMWeatherService) Get(ctx context.Context, query *WeatherDataQueryBuilder) ([]*IEMWeatherData, error)
type NetworkService ¶
type Station ¶
type Station struct { Index int `json:"index"` Id string `json:"id"` Synop float64 `json:"synop"` Name string `json:"name"` State string `json:"state"` Country string `json:"country"` Elevation float64 `json:"elevation"` Network string `json:"network"` Online bool `json:"online"` Params string `json:"params"` County string `json:"county"` PlotName string `json:"plot_name"` ClimateSite string `json:"climate_site"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` Timezone string `json:"tzname"` ArchiveBegins time.Time `json:"archive_begin"` }
type StationService ¶
type TestWeatherService ¶
type TestWeatherService struct{}
func (*TestWeatherService) GetWeatherAtStation ¶
func (s *TestWeatherService) GetWeatherAtStation(ctx context.Context, query *WeatherDataQueryBuilder) ([]*IEMWeatherData, error)
type WeatherDataData ¶
type WeatherDataData string
const ( All WeatherDataData = "all" // All Available TempF WeatherDataData = "tmpf" // Air Temperature [F] TempC WeatherDataData = "tmpc" // Air Temperature [C] DewPointF WeatherDataData = "dwpf" // Dew Point [F] DewPointC WeatherDataData = "dwpc" // Dew Point [C] RelativeHumidity WeatherDataData = "relh" // Relative Humidity [%] Feel WeatherDataData = "feel" // Heat Index/Wind Chill [F] WindDirection WeatherDataData = "drct" // Wind Direction WindSpeedKnots WeatherDataData = "sknt" // Wind Speed [knots] WindSpeedMPH WeatherDataData = "sped" // Wind Speed [mph] Altimeter WeatherDataData = "alti" // Altimeter [inches] SeaLevelPressure WeatherDataData = "mslp" // Sea Level Pressure [mb] PrecipMM WeatherDataData = "p01m" // 1 hour Precipitation [mm] PrecipInch WeatherDataData = "p01i" // 1 hour Precipitation [inch] Visibility WeatherDataData = "vsby" // Visibility [miles] WindGustKnots WeatherDataData = "gust" // Wind Gust [knots] WindGustMPH WeatherDataData = "gust_mph" // Wind Gust [mph] CloudCoverageL1 WeatherDataData = "skyc1" // Cloud Coverage Level 1 CloudCoverageL2 WeatherDataData = "skyc2" // Cloud Coverage Level 2 CloudCoverageL3 WeatherDataData = "skyc3" // Cloud Coverage Level 3 CloudHeightL1 WeatherDataData = "skyl1" // Cloud Height Level 1 [ft] CloudHeightL2 WeatherDataData = "skyl2" // Cloud Height Level 2 [ft] CloudHeightL3 WeatherDataData = "skyl3" // Cloud Height Level 3 [ft] PresentWeatherCodes WeatherDataData = "wxcodes" // Present Weather Code(s) IceAccretion1HR WeatherDataData = "ice_accretion_1hr" // Ice Accretion 1 Hour IceAccretion3HR WeatherDataData = "ice_accretion_3hr" // Ice Accretion 3 Hour IceAccretion6HR WeatherDataData = "ice_accretion_6hr" // Ice Accretion 6 Hour PeakWindGustKnots WeatherDataData = "peak_wind_gust" // Peak Wind Gust [knots] PeakWindGustMPH WeatherDataData = "peak_wind_gust_mph" // Peak Wind Gust [MPH] PeakWindDirection WeatherDataData = "peak_wind_drct" // Peak Wind Direction [deg] PeakWindTime WeatherDataData = "peak_wind_time" // Peak Wind Time SnowDepth WeatherDataData = "snowdepth" // Snow Depth (4-group) [inch] METAR WeatherDataData = "metar" // Raw METAR )
type WeatherDataQueryBuilder ¶
type WeatherDataQueryBuilder struct {
// contains filtered or unexported fields
}
WeatherDataQueryBuilder represents the url query sent to the IEM API when requesting weather data for stations
func NewWeatherDataQuery ¶
func NewWeatherDataQuery() *WeatherDataQueryBuilder
Creates a new WeatherDataQueryBuilder with defaults set to optional fields
func (*WeatherDataQueryBuilder) BuildUrl ¶
func (b *WeatherDataQueryBuilder) BuildUrl() (url.Values, error)
Creates url.Values with validated data from query builder
func (*WeatherDataQueryBuilder) Data ¶
func (b *WeatherDataQueryBuilder) Data(data ...WeatherDataData) *WeatherDataQueryBuilder
Appends data to query builder.data
func (*WeatherDataQueryBuilder) Elevation ¶
func (b *WeatherDataQueryBuilder) Elevation(elev bool) *WeatherDataQueryBuilder
Sets query builder elev property (defaults to false)
func (*WeatherDataQueryBuilder) End ¶
func (b *WeatherDataQueryBuilder) End(t time.Time) *WeatherDataQueryBuilder
Sets query builder end date (defaults to today)
func (*WeatherDataQueryBuilder) Format ¶
func (b *WeatherDataQueryBuilder) Format(format WeatherDataQueryFormat) *WeatherDataQueryBuilder
Sets query builder format (defaults to Etc/UTC)
func (*WeatherDataQueryBuilder) LatLon ¶
func (b *WeatherDataQueryBuilder) LatLon(latlon bool) *WeatherDataQueryBuilder
Sets query builder latlon property (defaults to false)
func (*WeatherDataQueryBuilder) Missing ¶
func (b *WeatherDataQueryBuilder) Missing(missing WeatherDataQueryMissing) *WeatherDataQueryBuilder
Sets query builder missing property (defaults to M)
func (*WeatherDataQueryBuilder) ReportType ¶
func (b *WeatherDataQueryBuilder) ReportType(types ...int) *WeatherDataQueryBuilder
Sets query builder report_type property (defaults to {3, 4})
func (*WeatherDataQueryBuilder) Start ¶
func (b *WeatherDataQueryBuilder) Start(t time.Time) *WeatherDataQueryBuilder
Sets query builder start date (defaults to today)
func (*WeatherDataQueryBuilder) Stations ¶
func (b *WeatherDataQueryBuilder) Stations(stations ...string) *WeatherDataQueryBuilder
Appends stations to builder.station
func (*WeatherDataQueryBuilder) Timezone ¶
func (b *WeatherDataQueryBuilder) Timezone(tz string) *WeatherDataQueryBuilder
Sets query builder end date (defaults to Etc/UTC)
func (*WeatherDataQueryBuilder) Trace ¶
func (b *WeatherDataQueryBuilder) Trace(trace WeatherDataQueryTrace) *WeatherDataQueryBuilder
Sets query builder trace property (defaults to T)
type WeatherDataQueryBuilderError ¶
type WeatherDataQueryBuilderError struct {
// contains filtered or unexported fields
}
func (WeatherDataQueryBuilderError) Error ¶
func (err WeatherDataQueryBuilderError) Error() string
type WeatherDataQueryFormat ¶
type WeatherDataQueryFormat string
type WeatherDataQueryMissing ¶
type WeatherDataQueryMissing string
type WeatherDataQueryTrace ¶
type WeatherDataQueryTrace string
type WeatherDataQueryYesNo ¶
type WeatherDataQueryYesNo string
type WeatherService ¶
type WeatherService interface {
Get(ctx context.Context, query *WeatherDataQueryBuilder) ([]*IEMWeatherData, error)
}