#MonthOfJulia Day 19: Units
The packages we’ll be looking at today should bring joy to the hearts of all Physical Scientists. Actually they should make any flavour of Scientist happy.
It is natural for man to relate the units of distance by which he travels to the dimensions of the globe that he inhabits. Thus, in moving about the earth, he may know by the simple denomination of distance its proportion to the whole circuit of the earth. This has the further advantage of making nautical and celestial measurements correspond. The navigator often needs to determine, one from the other, the distance he has traversed from the celestial arc lying between the zeniths at his point of departure and at his destination. It is important, therefore, that one of these magnitudes should be the expression of the other, with no difference except in the units. But to that end, the fundamental linear unit must be an aliquot part of the terrestrial meridian. ... Thus, the choice of the metre was reduced to that of the unity of angles. Pierre-Simon Laplace
SIUnits package provides unit-checked operations for quantities expressed in SI units.
It supports both long and short forms of units and all the expected arithmetic operations.
Note that it only recognises the American spelling of “meter” and not the (IMHO correct) “metre”! But this is a small matter. And I don’t want to engage in any religious wars.
And now we can freely use these new units in computations.
Read on below to find out about the
Physical package is documented here. Apparently it’s not as performant as
SIUnits but it does appear to have a wider scope of functionality. We’ll use it to address an issue raised on Day 17: converting between Imperial and Metric units.
Let’s kick off by loading the package.
There’s a lot of functionality available, but we are going to focus on just one thing: converting pounds and inches into kilograms and metres. First we define a pair of derived units. To do this, of course, we need to know the appropriate conversion factors!
We can then freely change the average heights and weights that we saw earlier from Imperial to Metric units.
On a related note I’ve just put together a package of physical constants for Julia.
Did you know that a teaspoon was 4.92892 millilitres? There I was, wallowing in my ignorance, thinking that it was 5 millilitres. Pfffft. Silly me. There are
Units can be a contentious issue. Watch the video below to see what Richard Feynman had to say about the profusion of units used by Physicists to measure energy. Also check out the full code for today along with the index to the entire series of #MonthOfJulia posts on github.
For those who want some proof that physicists are human, the proof is in the idiocy of all the different units which they use for measuring energy. Richard P. Feynman