npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

sunergy-calc

v1.0.1

Published

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

Readme

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

| Step | Equation | | ----------- | --------------------------------------------------- | | Declination | δ = 23.45 × sin[(360/365) × (n − 81)] | | Hour angle | H = 15 × (solar-time-hours − 12) | | Altitude | sin(α) = sin(δ) sin(φ) + cos(δ) cos(φ) cos(H) | | Azimuth | sin(Az) = cos(δ) sin(H) / cos(α) | | Irradiance | I = 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.