Raspberry Pi – Ultrasonic distance sensor

For a current hobby project I need an ultrasonic distance sensor. They work by sending a short pulse of ultrasound and measuring the time $t$ it needs to get reflected back from the first obstacle. A nice introduction can be found here. The distance traveled by the sound $d$ can then be calculated from a […]

PDF-OCR: Sorting documents into searchable PDFs

I’v gotten rid of paper at home by installing an automatic scanner/OCR/document sorting system on based on an all-in-one printer-scanner and a raspberry pi. For years I’ve been struggling to keep up with bureaucracy. I do really dislike everything to do with official papers. In most years that meant that I would just briefly read […]

Coding: python particle to grid interpolation

[latexpage] In particle tracking simulations you often need to interpolate particles onto a grid in one or more dimensions. Recently I decided to write a linear particle-to-grid interpolation in one dimension in python.This is an educational introduction into interpolating particles onto a one-dimensional grid. Interpolation of particles onto a grid Particles are usually described by […]

Raspberry Pi – Animated temperature plot

For the Christmas party yesterday I was asked to bring a large pot. The contents were supposed to be, as is customary in Germany mulled wine (Glühwein). Mulled apple wine in this case. Besides a pot we needed a hotplate which was brought by a colleague. Well, having mulled wine on a hot plate has […]

Tune diagram in python

I am trying to move whatever I can to python. The main reason being that I want it to be free, and not require expensive commercial software. So recently I took the time to revisit my Mathematica code for the tune diagram and port it to Python. Basically I rewrote the whole thing and it […]

Platform independent, crude timing of code

I work a lot on MacOS where I write code that I want to use on linux later. Unfortunately some of the normal timing functions are missing on MacOS. I don’t quite remember which. So I have some crude platform independent code for timing c++ code. I am aware it does not really count the […]

Basseti-Earskine field calculation

Yesterday I needed code to calculate the electric fields of an elliptical two-dimensional Gaussian charge distribution. I decided to implement it in c++ using libcerf for the error function. I used the formula from the Accelerator Physics Handbook. Beware 1: using Mathematica your results will be noisy because when you create the w-of-z error function […]

Fourier transformation quick and dirty

I tend to forget how to recover a frequency spectrum from a series of data points using the FourierSeries (read as: I forget how to compute the frequency corresponding to a specific channel in the fourier series). To stop me from forgetting I came up with the following quick and dirty module. It takes a […]

Neat plots with Mathematica

For several years now I am frustrated with how Mathematica plots look. They are sufficient to get an impression of what your data might look like, but they are as far from publication quality as a plot can get. While it is relatively easy to change how a plot looks, the PlotLegends package that comes […]

Tune / Resonance diagram

In Accelerator physics you often need a Tune diagram to display machine tunes. A quick Google search gave me no readily available Mathematica code for drawing one, so I came up with a Mathematica notebook that produces graphics similar to the following diagram: The Mathematica notebook and package I used to generate the diagram can […]