VisPy Sinewave Demo

VisPy is quite an interesting tool.  They say it is for “scientific visualization”.  Here is an example of that.  I took a demo from their github page and added a little code to generate a sinewave.  The cool thing is that the graph, scaling, panning, zooming, and redrawing all come out of the box.

I previously wrote about installing VisPy.  Thanks to the great efforts of some unnamed people, Python on Windows is really working nicely now.

Here is a screenshot:


Here is the code:

# -*- coding: utf-8 -*-
# Copyright (c) Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
Demonstration of InfiniteLine visual.
import sys
import numpy as np
from vispy import app, scene
# vertex positions of data to draw
N = 200
pos = np.zeros((N, 2), dtype=np.float32)
x_lim = [50., 1750.]
y_lim = [2., 2.]
pos[:, 0] = np.linspace(x_lim[0], x_lim[1], N)
pos[:, 1] = np.random.normal(size=N)
pos1 = np.zeros((20000,2), dtype=np.float32)
color1 = np.ones((20000,4), dtype=np.float32)
pos1[0,0] = 0.0
pos1[0,1] = 15.0
pos1[1,0] = 100.0
pos1[1,1] = 15.0
import math
for x in range(20000):
pos1[x,0] = x*10
pos1[x,1] = math.sin(x/20.) * 40.
# color array
color = np.ones((N, 4), dtype=np.float32)
color[:, 0] = np.linspace(0, 1, N)
color[:, 1] = color[::1, 0]
canvas = scene.SceneCanvas(keys='interactive', show=True)
grid = canvas.central_widget.add_grid(spacing=0)
viewbox = grid.add_view(row=0, col=1, camera='panzoom')
# add some axes
x_axis = scene.AxisWidget(orientation='bottom')
x_axis.stretch = (1, 0.1)
grid.add_widget(x_axis, row=1, col=1)
y_axis = scene.AxisWidget(orientation='left')
y_axis.stretch = (0.1, 1)
grid.add_widget(y_axis, row=0, col=0)
# add a line plot inside the viewbox
#line = scene.Line(pos, color, parent=viewbox.scene)
line1 = scene.Line(pos1, color1, parent=viewbox.scene)
# add vertical lines
vert_line1 = scene.InfiniteLine(100, [1.0, 0.0, 0.0, 1.0],
vert_line2 = scene.InfiniteLine(549.2, [0.0, 1.0, 0.0, 1.0], vertical=True,
# add horizontal lines
hor_line1 = scene.InfiniteLine(0.3, [1.0, 0.0, 1.0, 1.0], vertical=False,
hor_line2 = scene.InfiniteLine(5.1, [1.0, 1.0, 0.0, 1.0], vertical=False,
# auto-scale to see the whole line.,1000), (100,100))
if __name__ == '__main__' and sys.flags.interactive == 0:

view raw
hosted with ❤ by GitHub

How to Calculate Pi

π (pi) is the ratio between a circle’s circumference and it’s diameter. You can check this by using a tape measure. Measure around a circle. Then measure across the circle.

π = Around / Across

Did you know there is a way to calculate π? There are a lot of different ways, but one is called the Leibniz formula for π.

Where the original Leibniz formula for π ends up calculating π/4, I’ve just factored this 4 into the infinite series.

π = 4/1 – 4/3 + 4/5 – 4/7 + 4/9 – 4/11 + 4/13 – 4/15 + 4/17 – … (forever)

The more terms you add/subtract to it, the closer it gets to being accurate. A problem with the Leibniz formula for π is that it takes a lot of calculations to get an accurate version of pi.

Here is a mini-program I wrote in Python 3 to repeat this one million times.

pi = 0
for n in range(1000000):
  pi += ((-1)**n*4) / (2*n+1)

Here are some of the numbers from that calculation:
…999980 more times…

Here is real PI:

Isn’t it interesting that my version of PI, after a million iterations, is 1 digit off of real Pi, but the digit is in the middle? This has something to do with Euler numbers which you can read about at .

For most practical purposes, 3.14159 is more than enough digits to use with Pi.

Ever wonder if you could use Pie to calculate Pi?

We saw four geese… and first snow!

We saw four geese on our property the other day!  Maybe we should tell them they are late in flying south  :)


Here are a few facts on geese.

  • Geese are a type of waterfowl belonging to the group of Anserini.
  • Geese mostly eat greens vegetation and grains.
  • There are three kinds of true geese gray geese, white geese ,and black geese.

Some Geese do amazing things while they are migrating.  There is a species in Asia, Bar-headed Geese (Aner indicus), that migrate over the tallest mountain in the world (can you guess?) in the Himalayan Mountains.  The air temperature is as low as -60 Degrees F.

Now that is a “wow”.


  1. Wikipedia contributors, “Goose,” Wikipedia, The Free Encyclopedia, (accessed November 19, 2014).
  2. “Migrating Geese”, Chipper Woods Bird Observatory, (accessed November 19, 2014)

We found a big spider

Here is a big spider that we found while raking leaves today.


Spiders are air-breathing arthropods.  They are found in every continent except Antarctica.

Spiders mostly prey on bugs, but few large species prey on large birds and lizards.  Argh, that is scary!

To find out more about spiders click here.

That’s all for now.


Arduino Marble Roller #2

Here is an update to the marble roller project.  We are using foam board and hot glue for construction.  This is a surprisingly strong construction method for prototyping and projects like this.

In the foreground is a new stepper motor.  Not sure if we will be using it or not for this project yet.

Marble Roller

Arduino Bipolar Stepper Circuit

I got a cool little 4-wire bipolar stepper motor and wanted to drive it via Arduino.

I based the design on this reference: (credit for following image belongs there as well)




Here is how it looks for real.  Kind of a mess of wires, but you know what?  It works great.