val = 100000000 * u.s
print(val.to(units.yr) ) # Year, non-SI
print(val.to(units.yr).si) # Returns seconds!
I’m sure there’s something obvious I’m missing here…
val = 100000000 * u.s
print(val.to(units.yr) ) # Year, non-SI
print(val.to(units.yr).si) # Returns seconds!
I’m sure there’s something obvious I’m missing here…
As far as I know, there is no such thing as an “SI year”. A year is a non-SI unit, and – unlike the non-SI time units of minute, hour, or day – it’s not even one of the non-SI units that are officially accepted for use with SI (see Non-SI units mentioned in the SI - Wikipedia, or Section 4 of the SI Brochure). Can you elaborate on what you expected that call to return?
So my understanding of ‘SI’ (Scientific Notation?) is that you get a number like this:
3 * 10^6 seconds.
And if I do
val.to(units.yr).si
I get something like that in seconds:
x * 10^y seconds
But what I want to display is the number of years in the same format:
x * 10^y years
So it’s easy to convert to years, but I seem to get the implicit conversion back to seconds.
It seems that:
print(“{:e}”.format(val.to(units.yr)))
gives me what I was after.
SI = Système international, this describes the set of units (see link above); it has nothing to do with the formatting of the numbers.
Yeah, I thought it meant ‘scientific notation’, hence the confusion!