Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

sunergy-calc

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sunergy-calc

TypeScript library for geometry-based solar potential, irradiance, and solar PV energy calculations without external APIs.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

sunergy-calc

TypeScript library for geometry-based solar potential, irradiance, and solar PV energy calculations — no external APIs, only math and physics.

npm MIT License

Features

  • Accurate solar geometry: Compute sun position (declination, hour angle, altitude, azimuth, zenith) for any lat/lon/date.
  • Instantaneous and integrated PV power calculation using panel specs and solar irradiance.
  • Energy output estimation for any period and PV system (daily, annual, custom).
  • Physics-based, no Google API or network dependency.
  • TypeScript-first, typed, and fully documented.

Formulas

StepEquation
Declinationδ = 23.45 × sin[(360/365) × (n − 81)]
Hour angleH = 15 × (solar-time-hours − 12)
Altitudesin(α) = sin(δ) sin(φ) + cos(δ) cos(φ) cos(H)
Azimuthsin(Az) = cos(δ) sin(H) / cos(α)
IrradianceI = I₀ × sin(α) (for horizontal surface, clear sky)

Installation

npm install sunergy-calc

# or

yarn add sunergy-calc

Usage

import {
    computeSolarPotential,
    computePanelPower,
    estimateEnergyProduced
} from "sunergy-calc";

// Example 1: Sun position and irradiance at NY, August 15, 2025, 16:00 UTC
const sun = computeSolarPotential(
    40.7128, // latitude
    -74.0060, // longitude
    new Date(Date.UTC(2025, 7, 15, 16, 0, 0)) // UTC date/time
);

console.log(sun);

{
    declination: ...,
    hourAngle: ...,
    altitude: ...,
    azimuth: ...,
    zenith: ...,
    irradiance: ... // W/m² on horizontal
}


// Example 2: Compute actual panel output at this moment
const area = 1.6; // m² (single panel)
const efficiency = 0.20; // 20%
const powerW = computePanelPower(area, efficiency, sun.irradiance);

// Example 3: Estimate daily energy (kWh) for your panel
const averageIrradiance = 5 \* 1000 / 24; // e.g., 5kWh/m²/day avg = ~208 W/m² avg
const kWh = estimateEnergyProduced(
    area,
    efficiency,
    averageIrradiance,
    24, // hours in day
    0.75 // typical performance ratio (losses)
);

API

computeSolarPotential(lat, lon, date): SolarPosition

  • All angles in degrees; irradiance in W/m².
  • Calculates solar declination, hour angle, altitude, azimuth, zenith, and solar irradiance for a given moment/location.
  • See: Solar Insolation Formula

computePanelPower(area, efficiency, irradiance): number

  • area: Panel area (m²)
  • efficiency: PV efficiency (0...1)
  • irradiance: Solar irradiance (W/m²)
  • Power (W) = area * efficiency * irradiance
  • See: PV Power Equation

estimateEnergyProduced(area, efficiency, averageIrradiance, periodHours, performanceRatio=0.75): number

  • Estimates energy output for the system over the given period in kWh
  • Typical PR (performance ratio) = 0.75–0.85 (accounts for temperature, dust, inverter)
  • See: Output Formulas, EcoFlow Guide

References

Development & Testing

  • Written in TypeScript, fully typed
  • Robust Jest test suite
  • To run tests:
npm install
npx jest

License

MIT © Abdullah Waqar

Sunergy-calc is not affiliated with or endorsed by pveducation.org, palmetto.com, Sunbase, or EcoFlow. Reference links are for documentation and scientific transparency only.

Keywords

solar

FAQs

Package last updated on 15 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts