[SciPy-user] module with physical constants

weg werp wegwerp at gmail.com
Tue May 30 10:32:13 EDT 2006


Hi group,

I have a background in physics and I find myself repeatedly defining
things like c=3e8 when I am lazy, or c=299792458 when I need the
accuracy. It would be nice to do just
'from constants import c' and get the correct value without having to
grab for some handbook of physics and risk a typo.

I made a small list of things I use myself. I am willing to spend some
time extending the list with some more commonly used values, but only
if people here find it useful for inclusion in Scipy. An obvious start
would be the 'frequently used constants' table from

http://physics.nist.gov/cuu/Constants/

combined with some other constans like conversion factors between
imperial and SI, lightyears, arcminutes etc. If everything is defined
in SI units, you could do tricks like

from constants import *
speed = 23454 * parsec / week # in m/s
print 'your are going',speed/Mach,'times the speed of sound.'
p = 18 * torr # in Pascal
print 'the pressure is', p/atm, 'atmosphere or', p/psi, 'pounds per
square inch'.

I did some googling, and it appears that someone has done this before:

http://old.scipy.org/mailinglists/mailman?fn=scipy-dev/2002-October/001259.html

The problem I have with that version is that I don't like the format
(it is in a dict with ugly names) and that he imports the complete
CODATA set, which is too much (I think the number of users for the
'shielded helion gyromagn. ratio over 2 pi' is limited). The use case
for the various uncertainties in the constants is also limited I
guess. I am not planning to include the complete periodic system, just
the basic stuff.

I remember one language (pascal?) that had a scientific data type,
which kept track of all the SI units during calculations. I have never
seen anybody using such a thing, so that is probably overkill too. A
simple module with some float constants is probably enough.

Any interest for this or am I wasting my time?

Cheers,
Bas




More information about the SciPy-User mailing list