-
Notifications
You must be signed in to change notification settings - Fork 75
Added log-intensity and log-power units. #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
) | ||
|
||
bel_milliwatt = UnitLogPower( | ||
'bel-milliwatt', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string representation needs to be valid python, so it can't include mathematical operators like "-".
Changed the |
Thanks for the submission. I think it needs to include unit tests before we can consider merging. Would it make sense to instead define a Log10Unit class, such that bel = Log10Unit('bel', ...)
decibel = UnitQuantity(..., bel/10)
bel_milliwatt = Log10Unit('bel_milliwatt', ...)
decibel_milliwatt = UnitQuantity(..., bel_milliwatt/10) ? |
That makes a lot of sense. I will go on and remove UnitLogIntensity and UnitLogPower in favor of Log10Unit, then. Would it make sense for the Log10Unit constructor to keep track of the original linear units, for example: bel = Log10Unit('bel', ..., linear_units=1)
bel_milliwatt = Log10Unit('bel_milliwatt', ..., linear_units=milliwatt) |
Could you expand on that? I don't understand how that information would be used. |
It's an incomplete thought, but I was wondering if it would be useful to have a way of converting logarithmic units like dBm back into ordinary units like mW. For example, I imagine an expression like |
Ah. This is a bit tricky, because now you are getting into logarithmic scales, and the quantities package makes no attempt to support measurement scales. I could imagine specifying the base: LogUnit('bel', base=10, ...) which could be used by a function (not a method) provided by the logunits module to convert a linear quantity. But it would need to be documented that it is up to the user to ensure that the conversion is appropriate. |
I doubt this would be useful, as a subtraction of two log quantities would David On Sat, Apr 13, 2013 at 12:57 PM, Chris Granade notifications@github.comwrote:
David Roundy |
Fair enough. Going back to the basic idea of log units, however, without any attempt to convert to any other scale or measure, I think there's still utility due to how logarithmic units can come about in the analysis of circuits and the control of electronic hardware. For instance, it's common to talk about the attenuation due to a circuit element in units of dBm, or to request that the output power of a device be set in logarithmic units. In particular, my main use of the quantities package at the moment is in my contributions to the dev branch of cgranade/gpibusb-comm_code, where hardware properties are get and set using |
closed based on previous comments |
Added two new
IrreducibleUnits
,UnitLogIntensity
andUnitLogPower
for tracking units such as "dB" and "dBm", respectively. These units are especially useful when specifying instructions for instrument control.