Next / Previous / Contents / TCC Help System / NM Tech homepage

7. class MixedUnits: Handling mixed unit systems

The sidereal.py package uses a number of systems of mixed units:

Operations on mixed-unit quantities include:

In order to make calculations on mixed units, it is necessary to define the relative size of the units in the system. For example, in the days-hours-minutes-seconds system, there are 24 hours in a day, 60 minutes in an hour, and 60 hours in a second.

So we'll define a sequence called the factor list as a Python sequence containing these factors. For example, the factor list for the days-hours-minutes-seconds system is (24, 60, 60). The factor list for a mixed unit system with N units always has length (N-1).

7.1. MixedUnits.__init__(): Constructor

To create a MixedUnits instance, pass the factor list to its constructor like this:

MixedUnits ( factorList )

For example, here is how you would create an instance to represent the days-hours-minutes-seconds mixed units system.

dhms = MixedUnits ( (24, 60, 60) )

Each instance has an attribute .factors containing the factor list passed to the constructor.