Posts with the tag scientific calculations

Counting bits set to 1 in bytes with Python / Popcount or Hamming Weight

I want to run popcount on a large set of 144-byte-long bytearrays. Doing so in Python can be a pita! First, I was using the naive approach with bin(b).count('1') but it was very slow. I did some research on the internet for faster algorithms and I found some. But running...

Read on

False Color Plots

False color (or more exactly pseudo color) can be useful when a device / detector records a grayscale image and a human has to interpret it. Fine differences are hard to see in grayscale images und a false color mapping allows us to map the 255 shades of gray...

Read on

Install ROOT CERN on Mac OS X 10.7 Lion

Prerequisites

First, you need to install XCode 4 which can be found in the Mac App Store. You need it because it's providing the compiler and the git binary. Then install Homebrew using ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)".

ROOT Installation

Installing ROOT using configure and make is fairly easy. I recommend the...

Read on

ezyfit - An Alternative to Matlab's Curve Fitting Toolbox

ezyfit can prevent you from buying the Curve Fitting Tool that Matlab does not come with by default. This is how I use it to fit data according to a function :

x=15:45
y = 30 +...

Read on

Light Wavelength from Energy

You can use the following Python function to convert a photon energy (in electron volts) to the corresponding wavelength (in nano meters):

def wavelength_from_energy ( electron_volts):
    """Returns a photon wavelength in nm from a photon energy given in eV."""
 ...

Read on

Physical Constants in Python

SciPy (updated to CODATA 2010)

Installation (easiest using pip):

  1. Install Fortran as described for your OS on http://www.scipy.org/Installing_SciPy (or via brew install gfortran on Max OS X)
  2. Install SciPy itself: pip install scipy

Usage:

from scipy.constants import *
print "The Planck constant h:", <span...

Read on

Shimadzu 30-002 - Laminar-type Replica Diffraction Grating for the Soft X-ray Region

This is a fancy flat-field focusing, holographic grating as opposed to the previously used Rowland gratings.

Product Description

  • Aberration-corrected Laminar-type Replica Diffraction Gratings for flat-field Polychromators in the range of Extreme Ultra-Violet Light(EUV:13nm). Suitable for the next generation of semiconductor lithography.
  • Less high order light due to laminar type grooves configuration, Low...

Read on

Estimate the transform limited beam duration of a laser pulse from its spectral width in nm in Python

A transform limited pulse has a time-bandwidth product of for Gaussian beams.

Here are a couple of Python functions to find the minimum duration of a gaussian pulse with a certain spectral FWHM (measured in nm) at a given central wavelength plus the...

Read on