-
Notifications
You must be signed in to change notification settings - Fork 11
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
How to implement units? #146
base: main
Are you sure you want to change the base?
Conversation
Hi Soren, Amazing that you're tackling this finally. pint looks really good! Ad your points:
|
I really think pint is a nice unit library. I think the unit and unit conversion should lie in the measurement class and partially in the plotting classes and not when one use I think it is more intuitive that Measurement can set a specific unit for the various dataseries Measurement.set_unit(unit_names) And it seems like pint has a nice implementation of plotting on Matplotlib plots using units: https://pint.readthedocs.io/en/stable/user/plotting.html It looks like, there is a lot of converting in the TimeSeries if a TimeSeries is stored in Hours and plotted in Hours then the tseries is first converted to seconds to add the tstamp of the tseries and subtract the tstamp of the measurement before converted back into hours all three operation creating a new copy of the data. I don't know if this is memory costly, but it seems like it could be more elegant. ad 1, by using pint, should we then incoporate it in the data or simply just in the unit? example now is that you use ureg.convert(DataSeries, "IXDAT UNIT NAME", "USER UNIT NAME") instead of DataSeries * ureg.unit_name which would give DataSeries.to("USER UNIT NAME") for conversion. This might be an issue to store the data in a database, if the data is too tightly integrated with pint becoming a ad 2, I am not sure, what the issue really is here? If the data is normalised to something wouldn't this change the unit, hence this is already in the units if it is raw or normalised data? ad 3. This would be the optimal operation when appending new data. ad 4. If the pint plotting with matplotlib is used I think this could be implemented in the base_mpl_plotter instead of the individual plotting classes? |
Thanks, @AlexanderKrabbe and @AnnaWiniwarter for the thoughts here! Responses
|
Long overdue enhancement finally in progress!
This is a request for comment on how best to implement units.
So far I've just given the
Unit
class that had been included without content in ixdat an attributeu
which is the pint unit, and wrote functions for the minimal amount of manipulation such thatgrab
can take aunit_name
and at_unit_name
as an arguments.The API enhancement is demo'd here: https://github.com/ixdat/ixdat/blob/units/development_scripts/demo_units.py . Try it out!
(A lot of the code change has to do with debugging the way the references to
axes_series
are passed on when aField
is copied. Before, it would erroneously try to load an axis series from a directory backend. Now it correctly retrieves it from the MemoryBackend.)Is this the way we want units to be used in ixdat? What additional methods do we need? As an incomplete lists (please add!):