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

geomag

v1.0.0

Published

A library to calculate the geomagnetic field (incl. declination and inclination) based on the World Magnetic Model

Downloads

5,236

Readme

geomag

MIT License

A JavaScript module for accurately calculating the parameters of the geomagnetic field incl. declination (variation), and inclination (dip) using the World Magnetic Model (currently WMM2020, valid from 2020-2025). It is adapted from magvar by Darren Yeates (https://github.com/dpyeates/magvar)

Documentation

Installation

Script Include

Compiled versions (both minified and not) are located in dist/.

<script src="{yourjspath}/geomag.min.js"></script>

These versions expose a geomag global.

NPM

npm install geomag

For bundling (e.g., with Rollup) you can then import the ES6 module via

import * as geomag from 'geomag'

or directly use it in the browser via

import * as geomag from 'node_modules/geomag/dist/geomag-es.js'

Usage

import * as geomag from 'geomag';

const field = geomag.field(latitude, longitude);
// or const field = geomag.field(latitude, longitude, altitude);
const { 
    declination,
    inclination,
    intensity,
    northIntensity,
    eastIntensity,
    verticalIntensity,
    horizontalIntensity,
} = field;

latitude is the geographic latitude (WGS 84) in degrees (-90 to 90, north is positive, south negative).

longitude is the geographic longitude (WGS 84) in degrees (-180 to 180, east is positive, west negative).

altitude is the altitude in km above sea level. The parameter is optional and defaults to 0 if not provided.

declination is the angle in degrees between magnetic north and true north in the horizontal plane. Positive values correspond to magnetic north pointing eastward from true north.

inclination is the angle in degrees of the magnetic field lines with respect to the horizontal plane. Positive values correspond to the field pointing downward.

intensity, northIntensity, eastIntensity, verticalIntensity, and horizontalIntensity are the intensities in nT of the geomagnetic fields - total magnitude, north-pointing component, east-pointing component, vertical component, and horizontal component, respectively.

TypeScript

The package provides type definitions in dist/geomag.d.ts.

License

geomag is freely distributable under the terms of the MIT license.