JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 177
  • Score
    100M100P100Q73864F
  • License GPL-3.0-or-later

A collection of atmospheric, meteorological weather calculations

Package Exports

  • weather-formulas
  • weather-formulas/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (weather-formulas) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

License: GPL v3 Node.js CI

weather-formulas

A library of atmospheric and weather-related calculations.

  • Includes test code for all formulas.
  • Supports custom valuation sets where applicable.
  • Published as an ES Module (ESM).

Table of Contents

Features

Temperature

  • Dew Point: Calculate the dew point using the Magnus formula or Arden Buck equation.
  • Wind Chill: Estimate the perceived temperature based on wind speed and air temperature.
  • (Australian) Apparent Temperature: Calculate the apparent temperature considering humidity and wind.
  • Heat Index: Measure the perceived temperature based on air temperature and humidity.
  • Humidex: Calculate the humidex, a Canadian measure of perceived temperature.
  • Potential Temperature: Calculate the temperature an air parcel would have if brought to a standard pressure.
  • Virtual Temperature: Calculate the temperature accounting for water vapor in the air.
  • Lapse Rate: Calculate the rate of temperature change with altitude.
  • Dynamic lapse rate: Calculate the lapse rate dynamically based on readings.
  • Weighted Average Temperature: Calculate the weighted average temperature based on altitude differences.
  • Adjust Temperature by Lapse Rate: Adjust temperature based on a fixed lapse rate.

Humidity

Pressure

  • Pressure Altitude: Calculate the altitude based on observed pressure.
  • Density Altitude: Calculate the altitude adjusted for temperature and air density.
  • Barometric Formula: Calculate pressure at a given altitude using the barometric formula.
  • Adjust Pressure To Sea Level:
    • Simple formula: A quick approximation for standard conditions.
    • Advanced formula: A more accurate calculation using the barometric formula.
    • By dynamic lapse rate: Adjust pressure using a dynamically calculated lapse rate.
    • By historical data: Adjust pressure using historical readings.

Install

Install the library using npm:

$ npm install weather-formulas

How to Use

ES Module Only

This package is published as an ES Module (ESM). It does not natively support CommonJS (require). To use this package:

Ensure your project is configured to support ES Modules (e.g., "type": "module" in package.json). Use the import syntax to load the package. If you are using a CommonJS project, you can dynamically import the package using import() (see below).

Basic Examples

import { temperature, humidity, pressure } from 'weather-formulas';

// Example usage
const RH = humidity.relativeHumidity(TEMPERATURE, DEW_POINT);

CommonJS Workaround

If you are using a CommonJS project, you can dynamically import the package:

(async () => {
  const weatherFormulas = await import('weather-formulas');
  const { temperature } = weatherFormulas;
  const RH = temperature.relativeHumidity(TEMPERATURE, DEW_POINT);
  console.log(`Relative Humidity: ${RH}%`);
})();

Advanced Examples

Use a provided valuation set:

const valuationSet = temperature.DEW_POINT_VALUATIONS.DAVID_BOLTON;
const actual = temperature.dewPointMagnusFormula(TEMPERATURE, HUMIDITY, valuationSet);

Use a custom valuation set:

const valuationSet =  { a: 6, b: 17, c: 250, d: 234.5 };
const actual = temperature.dewPointArdenBuckEquation(TEMPERATURE, HUMIDITY, valuationSet);

Inspect code/tests for all possibilities.

Contribute

Please feel free to contribute by creating a Pull Request including test code, or by suggesting other formulas.

License

This project is licensed under the GPL v3 License.

Support

For support, please open an issue in the GitHub repository.

Disclaimer

This package is published as an ES Module (ESM). It does not natively support CommonJS (require). If you need CommonJS support, consider using a bundler like Webpack or Rollup to transpile the package into CommonJS, or dynamically import the package using import().

Always verify calculations before using in production as edge cases due to floating point errors may exist for large numbers, and which may not be covered by tests today. Please report any issues.