def prime(ctx, beer, vol, temp): """ Calculates the amount of table sugar, corn sugar, or DME needed to achieve the requested CO2 volumes """ if not beer: unit = ctx.obj["units"]["vol"] beer = utils.get_input("Volume of beer to prime ({}): ".format(unit), lambda x: float(x)) if not vol: vol = utils.get_input("Desired volumes of CO2: ", lambda x: float(x)) if not temp: unit = ctx.obj["units"]["temp"] temp = utils.get_input("Temperature of beer ({}): ".format(unit), lambda x: float(x)) if ctx.obj['unit'] == 'metric': temp = bm.c_to_f(temp) beer = bm.l_to_g(beer) sugar = bm.priming(temp, beer, vol) if ctx.obj['unit'] == 'imperial': sugar = bm.g_to_oz(sugar) unit = ctx.obj["units"]["weight"] print() print("Use only one of the following:") print("Table sugar: {0:.2f}{1}".format(sugar, unit)) print("Corn Sugar: {0:.2f}{1}".format(sugar * 1.099421965317919, unit)) print("DME: {0:.2f}{1}".format(sugar * 1.4705202312138728, unit))
def strike(ctx, grain, vol, temp): """ Calculate the required strike water temperature given the mass of grains, volume of water, and desired final mash temperature """ if not grain: grain = inputs.get_unit_input(ctx.obj["units"]["lrg_weight"], "Weight of grains: ") if not vol: vol = inputs.get_unit_input(ctx.obj["units"]["vol"], "Volume of water: ") if not temp: temp = inputs.get_unit_input(ctx.obj["units"]["temp"], "Desired mash temp: ") if is_metric(ctx): grain = bm.kg_to_lbs(grain) vol = bm.l_to_g(vol) temp = bm.c_to_f(temp) strike_temp = bm.strike_temp(grain, vol, temp) if is_metric(ctx): strike_temp = bm.f_to_c(strike_temp) print("Strike water temp should be {0:.3f}{1}".format( strike_temp, ctx.obj["units"]["temp"]))
def prime(ctx, beer, vol, temp): """ Calculates the amount of table sugar, corn sugar, or DME needed to achieve the requested CO2 volumes for bottle priming """ if not beer: beer = inputs.get_unit_input(ctx.obj["units"]["vol"], "Volume of beer to prime") if not vol: vol = inputs.get_input("Desired volumes of CO2: ", lambda x: float(x)) if not temp: temp = temp = inputs.get_unit_input(ctx.obj["units"]["temp"], "Temperature of beer") if is_metric(ctx): temp = bm.c_to_f(temp) beer = bm.l_to_g(beer) sugar = bm.priming(temp, beer, vol) if is_imperial(ctx): sugar = bm.g_to_oz(sugar) unit = ctx.obj["units"]["weight"] print() print("Use only one of the following:") print("Table sugar: {0:.2f}{1}".format(sugar, unit)) print("Corn Sugar: {0:.2f}{1}".format(sugar * 1.099421965317919, unit)) print("DME: {0:.2f}{1}".format(sugar * 1.4705202312138728, unit))
def dme(ctx, points, vol): """ Given the current volume of the mash, work out how much Dry Malt Extract(DME) to add to reach your target gravity """ if not points: points = inputs.get_input("Points needed to achieve target gravity: ", lambda x: float(x)) if not vol: vol = inputs.get_unit_input(ctx.obj["units"]["temp"], "Current volume of the wort") if is_metric(ctx): vol = bm.l_to_g(vol) amt_dme = bm.pre_boil_dme(points, vol) if is_metric(ctx): amt_dme = bm.oz_to_g(amt_dme) print( "Add {0:.2f}{1} of DME to raise the wort gravity by {2} points".format( amt_dme, ctx.obj["units"]["weight"], points))
def print_volume(value: float) -> None: print("{0} l => {1:.3f} gal".format(value, bm.l_to_g(value))) print("{0} gal => {1:.3f} l".format(value, bm.g_to_l(value)))
def test_l_to_g(): g = bm.l_to_g(47) assert g == pytest.approx(12.416, 0.001)