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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tsmx/weather-tools

v1.1.2

Published

Toolset for calculating wind chill, dew point, heat index and more.

Downloads

37

Readme

@tsmx/weather-tools

License: MIT npm (scoped) node-current (scoped) Build Status Coverage Status

Toolset for weather data calculations and conversions.

Provides the following functionalities:

  • Wind chill calculation (Celsius and Fahrenheit)
  • Dew point calculation (Celsius)
  • Heat index calculation (Celsius and Fahrenheit)
  • Degree to compass direction conversion
  • Fahrenheit <> Celsius conversion
  • MPH <> KMH conversion
  • Inch <> Millimeter conversion

Usage

Example: calculating the dew point in Celsius from given humidity hum and temperature in Fahrenheit tempF.

const wt = require('@tsmx/weather-tools');

const tempC = wt.fahrenheitToCelsius(tempF);
const dewPoint = wt.dewPoint(tempC, hum);

For details look the API descriptions for:

API

Wind chill functions

windchillCelsius(temp, speed)

Calculates the wind chill temperature in degrees Celsius.

Note: Wind chill calculation is only feasible for low temperatures <= 10 degrees Celsius and a minimum wind speed > 4.8 km/h.

Returns:

  • NaN if temp is greater than 10.0 degress Celsius
  • temp if speed is less than or equal to 4.8 km/h
  • the calculated wind chill otherwise
temp

Type: number

The current temperature in degrees Celsius.

speed

Type: number

The current wind speed in km/h.

windchillFahrenheit(temp, speed)

Calculates the wind chill temperature in degrees Fahrenheit.

Note: Wind chill calculation is only feasible for low temperatures <= 50 degrees Fahrenheit and a minimum wind speed > 3.0 mph.

Returns:

  • NaN if temp is greater than 50.0 degress Fahrenheit
  • temp if speed is less than or equal to 3.0 mph
  • the calculated wind chill otherwise
temp

Type: number

The current temperature in degrees Fahrenheit.

speed

Type: number

The current wind speed in mph.

Dew point functions

dewPoint(temp, humidity)

Calculates the dew point in degrees Celsius.

temp

Type: number

The current temperature in degrees Celsius.

humidity

Type: number

The current humidity in percent (0.0 - 100.0).

Heat index functions

heatIndexCelsius(temp, humidity)

Calculates the heat index in degrees Celsius.

Note: Heat index calculation is only feasible for high temperatures >= 27 degrees Celsius and a minimum humidity >= 40%.

Returns:

  • NaN if temp is lower than 27.0 degress Celsius or humidity is lower than 40.0
  • the calculated heat index otherwise
temp

Type: number

The current temperature in degrees Celsius.

humidity

Type: number

The current humidity in percent (0.0 - 100.0).

heatIndexFahrenheit(temp, humidity)

Calculates the heat index in degrees Fahrenheit.

Note: Heat index calculation is only feasible for high temperatures >= 80 degrees Fahrenheit and a minimum humidity >= 40%.

Returns:

  • NaN if temp is lower than 80.0 degress Fahrenheit or humidity is lower than 40.0
  • the calculated heat index otherwise
temp

Type: number

The current temperature in degrees Fahrenheit.

humidity

Type: number

The current humidity in percent (0.0 - 100.0).

Conversion functions

degreesToDirection(deg)

Converts degrees to the closest matching compass direction, e.g. 0 to N, 35 to NE, 301 to WNW and so on.

A 32-point compass rose is used for the conversion.

| Degree | Direction / returned value| |--------|---------------------------| | 0.0 | N | | 22.5 | NNE | | 45.0 | NE | | 67.5 | ENE | | 90.0 | E | | 112.5 | ESE | | 135.0 | SE | | 157.5 | SSE | | 180.0 | S | | 202.5 | SSW | | 225.0 | SW | | 247.5 | WSW | | 270.0 | W | | 292.5 | WNW | | 315.0 | NW | | 337.5 | NNW |

deg

Type: number

Number of degrees to be converted

fahrenheitToCelsius(fahrenheit)

Converts Fahrenheit to Celsius.

fahrenheit

Type: number

The value to be converted in degrees Fahrenheit

celsiusToFahrenheit(celsius)

Converts Celsius to Fahrenheit.

ceslsius

Type: number

The value to be converted in degrees Celsius

mphToKmh(mph)

Converts MPH to KMH.

mph

Type: number

The value to be converted in MPH.

kmhToMph(kmh)

Converts KMH to MPH.

kmh

Type: number

The value to be converted in KMH.

inchToMillimeter(inch)

Converts inches to millimeters.

inch

Type: number

The value to be converted in millimeters.

millimeterToInch(millimeter)

Converts millimeters to inches.

millimeter

Type: number

The value to be converted in inches.

References

The implementations in this library are based on the following references.

Wind chill formulas

Dew point formulas

Heat index formulas

Wind/compass direction algorithm