pvgis

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

domain.go exposes pvgis as a kit Domain: a driver that a multi-domain host (ant) enables with a single blank import,

import _ "github.com/tamnd/pvgis-cli/pvgis"

exactly as a database/sql program enables a driver with `import _ "github.com/lib/pq"`. The init below registers it; the host then dereferences pvgis:// URIs by routing to the operations Register installs. The same Domain also builds the standalone pvgis binary (see cli.NewApp), so the binary and a host share one source of truth.

Package pvgis is the library behind the pvgis command line: the HTTP client, request shaping, and typed data models for the EU Photovoltaic Geographical Information System API (re.jrc.ec.europa.eu).

PVGIS is a free EU-hosted service providing solar energy calculations for any geographic coordinate. No API key or registration is required. The Client paces requests, retries transient failures (429 and 5xx) with exponential backoff, and decodes the JSON responses into clean typed structs.

Two operations are provided: annual PV energy yield (PVCalc) and monthly solar radiation data (Monthly).

Index

Constants

View Source
const BaseURL = "https://re.jrc.ec.europa.eu/api/v5_2"

BaseURL is the API base path.

View Source
const Host = "re.jrc.ec.europa.eu"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to re.jrc.ec.europa.eu over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) Monthly

func (c *Client) Monthly(ctx context.Context, lat, lon float64, angle, aspect int) ([]MonthlyData, error)

Monthly returns monthly solar radiation data for the given coordinates. angle is tilt in degrees; aspect is azimuth (0=south).

func (*Client) PVCalc

func (c *Client) PVCalc(ctx context.Context, lat, lon, peakPower, loss float64, angle, aspect int) (*PVResult, error)

PVCalc returns the annual PV energy yield for the given coordinates. peakPower is installed peak power in kWp; loss is system loss percentage. angle is tilt in degrees; aspect is azimuth (0=south, -90=east, 90=west).

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds tunable knobs for the HTTP client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults for production use.

type Domain

type Domain struct{}

Domain is the pvgis driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type MonthlyData

type MonthlyData struct {
	Month      int     `json:"month"`
	Radiation  float64 `json:"radiation_kwh_m2_day"` // H(i) irradiation on fixed plane
	DirectRad  float64 `json:"direct_radiation,omitempty"`
	DiffuseRad float64 `json:"diffuse_radiation,omitempty"`
}

MonthlyData holds solar radiation data for one calendar month.

type PVResult

type PVResult struct {
	Latitude         float64 `json:"latitude"`
	Longitude        float64 `json:"longitude"`
	PeakPower        float64 `json:"peak_power_kw,omitempty"`
	Loss             float64 `json:"loss_pct,omitempty"`
	YearlyEnergy     float64 `json:"yearly_energy_kwh"`
	DailyEnergy      float64 `json:"daily_energy_kwh"`
	PerformanceRatio float64 `json:"performance_ratio"`
}

PVResult holds the annual PV energy yield for a location.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL