PyXPlot’s facilities for converting quantities between different physical units include the ability to convert temperatures between different temperature scales, for example, between ,
and K. However, these conversions have some subtleties, unique to temperature conversions, which mean that they should be used with some caution. Consider the following two questions:
How many Kelvin corresponds to a temperature of C?
How many Kelvin corresponds to a temperature rise of C?
The answers to these two questions are 293 K and 20 K respectively: although we are converting from C in both cases, the corresponding number of Kelvin depends upon whether we are talking about an absolute temperature or a relative temperature. A heat capacity of 1 J/
C equals 1 J/K, even though a temperature of
C does not equal a temperature of 1 K.
The cause of this problem, and the reason why it rarely affects any physical units other than temperatures is that there exists such a thing as absolute temperature. Distances, for example, are very rarely absolute: they measure relative distance gaps between points. Occasionally people might choose to express all their displacements relative to a particular origin, but they wouldn’t expect PyXPlot to be able to convert these into displacements from another origin. But they might expect it to be able to convert temperatures between Celsius and Fahrenheit, even though the problem of doing so is equivalent.
Times are occasionally expressed as absolute quantities: the year AD 1453, for example, implicitly corresponds to a period of 1453 years after the Christian epoch, and so similar problems would arise in trying to convert such a year into the Muslim calendar, which counts from the year AD 622.1
As PyXPlot cannot distinguish between absolute and relative temperatures, it takes a safe approach of performing algebra consistently with any unit of temperature, never performing automatic conversions between different temperature scales. A calculation based on temperatures measured in will produce an answer measured in
. However, as converting temperatures between temperature scales is a useful task which is often wanted, this is allowed, when specifically requested, in the specific case of dividing one temperature by another unit of temperature to get a dimensionless number, as in the following example:
|
print 98*unit(oF) / unit(oC) |
Note that the two units of temperature must be placed in separate unit(...) functions. The following is not allowed:
|
print 98*unit(oF / oC) |
Note that such a conversion always assumes that the temperatures supplied are absolute temperatures. PyXPlot has no facility for converting relative temperatures between different scales. This must be done manually.
The conversion of derived units of temperature, such as or
, to derived units of other temperature scales, such as
or
, is not permitted, since in general these conversions are ill-defined. For example, a temperature squared measured in
has the same value for
, but would have different values in
.
The moral of this story is: pick what unit of temperature you want to work in, convert all of your temperatures to that scale, and then stick to it.
Creating a simple temperature conversion scale.
In this example, we use PyXPlot’s automatic conversion of physical units to create a temperature conversion scale. |
set size ratio 1e-2 |
![]() |
Footnotes