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

Add formula for calculating SRM #10

Merged
merged 2 commits into from
Dec 27, 2018
Merged

Conversation

shouptech
Copy link
Contributor

I have added a formula to the Recipe class which will calculate a recipe's color in units SRM.

pybeerxml/recipe.py Outdated Show resolved Hide resolved
Copy link
Owner

@hotzenklotz hotzenklotz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the contribution. Calculating the color is a great idea. Please check my code suggestion before merging.

Happy Holidays!

@hotzenklotz
Copy link
Owner

I just double-checked the brew wiki reference page. Apparently, in the provided formula the malt weight needs to be in pounds (lbs). The same is true for the batch size / amount of water. It needs to be in gallons.

According to the BeerXML specification all volume and weight units are metric. (liters and kilogram) http://www.beerxml.com/beerxml.htm

Therefore, the color implementation is wrong as is. I suppose it can easily be fixed by converting the units accordingly.
@shouptech Have you checked the color values from the example recipes used in the unit tests with another program?

@shouptech
Copy link
Contributor Author

The formula is correct. 8.3453 is the conversion factor from kg/L to lb/gal. I checked it against BeerSmith and it's within a hundredth of SRM.

* `mcu` default value is now a float
* Check for fermentable amount and color for `None`
* Correct metric to imperial conversion factor
* Add test to ensure color updates for recipe are ignored
@shouptech
Copy link
Contributor Author

I've updated this PR with a new commit. Please review.

Thanks!

mcu = 0.0
for f in self.fermentables:
if f.amount is not None and f.color is not None:
# 8.3454 is conversion factor from kg/L to lb/gal
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@hotzenklotz hotzenklotz merged commit 7102b7c into hotzenklotz:master Dec 27, 2018
@hotzenklotz
Copy link
Owner

@shouptech I released version 1.0.6 on PyPi which includes your PR. Thank you very much.

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

Successfully merging this pull request may close these issues.

2 participants