Skip to content

Instantly share code, notes, and snippets.

View jgbos's full-sized avatar

Justin Goodwin jgbos

  • MIT Lincoln Laboratory
  • Cambridge
View GitHub Profile
@jgbos
jgbos / workflows.py
Last active April 14, 2022 00:39
Base class definition of a workflow
from abc import abstractmethod
from collections import defaultdict
from typing import Any, Dict, List, Mapping, Optional, Sequence, Union
from hydra.core.utils import JobReturn
from hydra_zen import make_config
from .hydra import launch, zen
@jgbos
jgbos / BarToolTip.ipynb
Last active August 29, 2015 14:01
mpld3 tooltip plugin example for ax.bar
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jgbos
jgbos / README.md
Last active August 29, 2015 13:58
D3 Reusable Charts with Prototypes

Uses prototypes instead of closures to execute the D3 enter/update/exit pattern. This example shows the axes, grids, and plot elements being updated on each call so that the enter, update, and exit functions are executed. The code is based off of the javascript code for mpld3. You can find the code base for this visualization here.

@jgbos
jgbos / README.md
Last active February 25, 2018 20:23
Simple Single Axis Zoom

This is an example of adding simple interface for single axis zoom and pan capability using the mouse. When the mouse is over the x or y axes, the panning and zooming with the mouse will execute on only those axes. When the mouse is over the main plotting canvas, pan and zoom with the mouse works on both axes. Feel free to comment on the gist.

@jgbos
jgbos / index.html
Last active December 16, 2015 08:59
Time of Flight From North Korea
<!DOCTYPE html>
<meta charset="utf-8">
<title>Time of Flight from North Korea</title>
<style>
body {
background: #fcfcfc;
}
.background {
@jgbos
jgbos / README.md
Last active December 16, 2015 03:18
Distances from North Korea

Jason Davies recently demostrated the power of map projections for visualizating the distance a missile from North Korea would have to travel to hit any point on earth. An assumption in his visualization is that the earth is spherical and not rotating during the trajectory. This visualization examines the distances given the following assumptions:

  • Spherical, non-rotating: Left plot copies Jason's creation , each contour is 1,000 km
  • Spherical, rotating: Middle plot assumes a rotating earth, but keeps the earth as a sphere
  • Elliptical, rotating: Right plot models the WGS-84 elliptical earth that rotates

As expected, the rotating earth makes a difference on the actual distance a missile would travel over the earth (keeping the range of the missile constant). Trajectories moving eastward along the direction the earth is rotating travel less distance and opposite for westward trajectories. There isn't much difference between spherical and elliptica

@jgbos
jgbos / index.html
Created April 10, 2013 17:05
Bean Machine
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg {
background: #222;
}
</style>
<body>
@jgbos
jgbos / geodesic.js
Last active December 15, 2015 15:38
Simple Ellipsoid Gravity
(function() {
// From http://bl.ocks.org/mbostock/3057239
var φ = 1.618033988749895,
ρ = 180 / Math.PI;
var vertices = [
[1,φ,0], [-1,φ,0], [1,-φ,0], [-1,-φ,0],
[0,1,φ], [0,-1,φ], [0,1,-φ], [0,-1,-φ],
[φ,0,1], [-φ,0,1], [φ,0,-1], [-φ,0,-1]
];
@jgbos
jgbos / README.md
Last active December 15, 2015 14:58
Wargames

Note: Best viewed with Google Chrome; not tested on any other browser. If you view with another browser or on a smartphone the animation may not be smooth due to the computations of trajectories happening as they are drawn.

This demonstrates the power of numerical integration of nonlinear equations using Javascript in the browser. I would have never considered using Javascript for such a task if I had not seen the benchmark tests for Julia and Numeric.js.

The animation is based on an influential movie from my childhood, Wargames. I must have watched it a hundred times as a kid. Since I've been trying to learn D3, I thought I'd try to recreate a portion of the final scene (you can watch here) using javascript. Some thoughts on the scene:

  • Clearly the movie uses a Mercator projection
@jgbos
jgbos / index.html
Last active December 15, 2015 08:19
Kalman Filter
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {