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

Could you add watthour unit in the Energy class? #68

Open
GPanthou opened this issue Sep 17, 2021 · 7 comments
Open

Could you add watthour unit in the Energy class? #68

GPanthou opened this issue Sep 17, 2021 · 7 comments
Assignees

Comments

@GPanthou
Copy link

Hello,

I am wondering if you can add the watthour unit within the official pypi packages (https://pypi.org/project/measurement/).
I have added this unit locally (fedora 34, python 3.9, measurement 3.2.0), and it works fine for me :-).
Maybe some other people could be interested.

class Energy(MeasureBase):
STANDARD_UNIT = 'J'
UNITS = {
'c': 4.18400,
'C': 4184.0,
'J': 1.0,
'eV': 1.602177e-19,
'tonne_tnt': 4184000000,
'wh': 3600,
}
ALIAS = {
'joule': 'J',
'calorie': 'c',
'Calorie': 'C',
'watthour': 'wh',
}
SI_UNITS = ['J', 'c', 'eV', 'tonne_tnt', "wh"]

@codingjoe
Copy link
Collaborator

Hi @GPanthou,

Thank you for reaching out. The new version (currently in alpha) does include Watthours or seconds. However, watt hour is not an energy unit but a power (energy per time).

I hope this helps.

Best
Joe

@codingjoe codingjoe self-assigned this Sep 17, 2021
@GPanthou
Copy link
Author

Sorry, I'm not sure I understand your answer.
Watts is a power unit: 1 Watt = 1Joule / 1 second
Watt-hour is a energy unit, it correspond to a power of 1watt during 1 hour. Thus, it corresponds to 3600 Joules.
Maybe this link could help: https://en.wikipedia.org/wiki/Kilowatt-hour

Geremy

@codingjoe
Copy link
Collaborator

Hi @GPanthou,

Pardon me, you are absolutely right. I don't know where my head is today.
My, we'd need to add this. We do support Watts in the new version already. However, we would need to add handling for Watts per time.

I am currently not using this package and therefore have only limited time I can dedicate to this project. I would be more than happy to review a PR, should you want to contribute this feature yourself.

Best
Joe

@GPanthou
Copy link
Author

Hi @codingjoe,

It would be a pleasure.

I've been using python for a long time, but I'm new to github, and I don't really know the procedures.

Could you quickly tell me what I need to do to make a proposal?

  • where can I find the last version in development (is it the pypi one) ?
  • the idea is to create a Power(BidimensionalMeasure) class in a power.py file?

Sorry if I'm still not clever.

Geremy

@codingjoe
Copy link
Collaborator

Hi @GPanthou,

First, welcome to GitHub :)

Now to your questions. No, the latest version is the master branch here on GitHub. We also have an alpha released on PyPi.
Yes, the idea is to build a 2-dimensional measure. However, this works slightly different now. Maybe take a look at velocity to get a better idea.

Best
Joe

@GPanthou
Copy link
Author

GPanthou commented Sep 21, 2021

Hi @codingjoe

Here is a first attempt.
I started from the file energy.py because (it seems to me) that it belongs to the same type of variable.

energy.zip

I stay tuned
Best

Geremy

@GPanthou
Copy link
Author

Hi @codingjoe,

Did you have time to look at the code I submitted? Maybe that was not the right way to do it?

Best

Geremy

GPanthou added a commit to GPanthou/python-measurement that referenced this issue Jul 1, 2022
Some propositions to the issue coddingtonbear#68
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

2 participants