I might have completely overlooked something, but I couldn’t find any way to do any of the following:
- get the unit of a variable (for scalar and numpy arrays)
- get the numerical value of the variable (independent of unit), i.e., remove the unit of a variable when it is not known beforehand
var = 10. * b2.mV
what I want:
- func(var) → b2.mV, or
- func(var) → 10
np.array(var) (as well as calling pd.Dataframe on dictionary objects containing arrays with units) automatically transforms the variable to the base unit (e.g., V) before returning the value, in the above case, 0.01, and I don’t know the unit a priori to just divide through by it, but I would like to just receive the numerical value of the variable as I’m keeping track of the non-base units elsewhere.
Specifically, I’m saving out parameter values in a pandas dataframe, and their associated units in a dictionary elsewhere, and I would just like to save the numbers in the unit that’s most commonly used (e.g., pF instead of F).
If there’s a strong reason why doing this is not preferable, I suppose one solution is to do the whole thing in base unit? Please advise. Thanks!