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 🙏

© 2026 – Pkg Stats / Ryan Hefner

taup-js

v1.0.0

Published

Seismic travel time calculator (TauP method) for JavaScript/TypeScript

Readme

taup-js

Seismic travel-time calculator for JavaScript and TypeScript, implementing the TauP method with the IASP91, AK135, and PREM reference Earth models.

Installation

npm install taup-js

Quick start

import { TauPTime } from "taup-js";

const taup = new TauPTime(); // defaults to IASP91

const arrivals = taup.calculate(
  10,    // source depth (km)
  60,    // epicentral distance (degrees)
  ["P", "S", "PcP"]
);

for (const a of arrivals) {
  console.log(`${a.phase}: ${a.time.toFixed(1)} s`);
}
// P:   594.3 s
// PcP: 681.2 s
// S:   978.6 s

API

new TauPTime(options?)

| Option | Type | Default | Description | |--------|------|---------|-------------| | model | "iasp91" \| "ak135" \| "prem" \| VelocityModelData | "iasp91" | Velocity model to use |

.calculate(sourceDepth, distanceDeg, phases?)

Returns Arrival[] sorted by arrival time.

  • sourceDepth — source depth in km (0 = surface)
  • distanceDeg — epicentral distance in degrees (0–360)
  • phases — array of phase names (default: ["P", "S"])

.calculateAll(sourceDepth, distanceDeg)

Calculates all supported phases. Equivalent to calling .calculate() with TauPTime.supportedPhases().

.calculatePhase(phaseName, sourceDepth, distanceDeg)

Calculates a single named phase. Returns Arrival | null if the phase does not arrive at that distance.

.velocityAt(depth, waveType)

Returns the P or S velocity (km/s) at a given depth in the current model.

taup.velocityAt(35, "P");  // velocity just below the Moho

Static methods

TauPTime.supportedPhases()  // string[]
TauPTime.supportedModels()  // ["iasp91", "ak135", "prem"]

Arrival object

interface Arrival {
  phase: string;          // e.g. "P", "PKP"
  time: number;           // travel time in seconds
  rayParam: number;       // ray parameter in s/km
  takeoffAngle: number;   // angle at source (degrees from vertical)
  incidentAngle: number;  // angle at receiver (degrees from vertical)
  distanceDeg: number;    // actual computed distance in degrees
  sourceDepth: number;    // source depth in km
  piercePoints?: PiercePoint[];
}

Supported phases

| Phase | Description | |-------|-------------| | P, S | Direct P and S waves through the mantle | | PP, SS | Surface-reflected P and S | | PcP, ScS, ScP | Reflections off the core-mantle boundary | | PKP, PKIKP | P wave through the outer/inner core | | PKiKP | P wave reflected off the inner core boundary | | SKS, SKKS | S–P conversion through the outer core | | pP, sS | Depth phases (upgoing leg from source) | | Pdiff, Sdiff | Waves diffracted along the CMB (~97°–170°) |

Velocity models

import { TauPTime } from "taup-js";

const ak = new TauPTime({ model: "ak135" });
const prem = new TauPTime({ model: "prem" });

Custom velocity model

Pass a VelocityModelData object directly:

import { TauPTime, VelocityModelData } from "taup-js";

const model: VelocityModelData = {
  name: "simple",
  earthRadius: 6371,
  mohoDepth: 35,
  cmbDepth: 2889,
  icbDepth: 5154,
  layers: [
    { topDepth: 0,  botDepth: 35,   topVp: 6.0, botVp: 6.0, topVs: 3.5, botVs: 3.5, topDensity: 2.7, botDensity: 2.7 },
    { topDepth: 35, botDepth: 2889, topVp: 8.0, botVp: 13.7, topVs: 4.5, botVs: 7.3, topDensity: 3.3, botDensity: 5.6 },
    // ...
  ],
};

const taup = new TauPTime({ model });

Each layer uses linear interpolation of Vp, Vs, and density between topDepth and botDepth.

Method

Travel times are computed using the flat-Earth tau-p method:

  • Velocities are transformed to a flat-Earth equivalent (v_flat = v · R/r)
  • Layer integrals are solved with exact analytical antiderivatives, avoiding numerical issues near turning depths
  • Ray parameter inversion uses a 300-point grid scan followed by bisection, which correctly handles triplications and shadow zones
  • All results represent first arrivals on each phase branch