Skip to content
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

Use unit prefix only instead of full unit #10

Open
laborleben opened this issue Mar 14, 2015 · 10 comments
Open

Use unit prefix only instead of full unit #10

laborleben opened this issue Mar 14, 2015 · 10 comments
Assignees
Milestone

Comments

@laborleben
Copy link
Collaborator

instead set_voltage(self, channel, value, unit='mV') use set_voltage(self, channel, value, unit='m').

Makes things easier when comes to abstraction. We can also do some unit conversion based on a new class that we can put inside utils. The conversion is then based on a dict like that one:
_prefix = {'y': 1e-24, # yocto
'z': 1e-21, # zepto
'a': 1e-18, # atto
'f': 1e-15, # femto
'p': 1e-12, # pico
'n': 1e-9, # nano
'u': 1e-6, # micro
'm': 1e-3, # mili
'c': 1e-2, # centi
'd': 1e-1, # deci
'k': 1e3, # kilo
'M': 1e6, # mega
'G': 1e9, # giga
'T': 1e12, # tera
'P': 1e15, # peta
'E': 1e18, # exa
'Z': 1e21, # zetta
'Y': 1e24, # yotta
}
also check http://stackoverflow.com/questions/10969759/python-library-to-convert-between-si-unit-prefixes.

@laborleben
Copy link
Collaborator Author

We can stay compatible to the old interface by just evaluating the first char.

@themperek
Copy link
Member

full ack

@DavidLP
Copy link
Collaborator

DavidLP commented Mar 14, 2015

I would not add a unit feature at all. It should be understood that all is in SI base units. Adding a e.g. e-3 at the base unit should be no issue. Otherwise one can only understand any value with the unit string. At least I would make this a not mandatory API feature, but an optional way to define values. And the standard unit should be SI base units.

@laborleben
Copy link
Collaborator Author

depends, actually I can live without that feature. Others are using it.
However, implementing the conversion into every function is a waste of code. It can also be, that a conversion is needed for a DAC or ADC (wich is not using SI base unit).

@DavidLP
Copy link
Collaborator

DavidLP commented Mar 14, 2015

A conversion for a ADC/DAC? What is that? ADC/DAC is just a value and no unit at all.

@themperek
Copy link
Member

You do not want to thing what is 1.273V in DAC units. And calibration on
top.

On Sat, Mar 14, 2015 at 6:15 PM, D.-L.Pohl [email protected] wrote:

A conversion for a ADC/DAC? What is that? ADC/DAC is just a value and no
unit at all.


Reply to this email directly or view it on GitHub
#10 (comment).

@DavidLP
Copy link
Collaborator

DavidLP commented Mar 14, 2015

Now we are talking about calibration and not units ;-). But for calibration data it is much better to have the SI base units only, otherwise some calibrations will be in mV, some in V...
To say set_voltage(1.273) is what I would prefer. How this is translated to a DAC value is irrelevant.

@themperek
Copy link
Member

One does not go against other we assume we use default Si unit as default so e-3 etc will work.
And we have optional unit parameter.
Would this work? Does not break current situation.

@laborleben laborleben added this to the 3.0.0 milestone Sep 17, 2015
@laborleben laborleben self-assigned this Sep 17, 2015
@themperek
Copy link
Member

@themperek
Copy link
Member

We do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants