def infuse(ctx, temp, target, ratio, grain, water): """ Given the current mash temperature, work out how much water of a given temp needs to be added to adjust the temperature """ temp_unit = ctx.obj["units"]["temp"] if not temp: temp = temp = inputs.get_unit_input(temp_unit, "Current temperature of mash") if not target: target = inputs.get_unit_input(temp_unit, "Target temperature of mash") if not ratio: unit = "Quarts/lbs" if is_metric(ctx): unit = "Liters/kg" ratio = inputs.get_unit_input(unit, "Grist/water ratio") if not grain: grain = inputs.get_unit_input(ctx.obj["units"]["lrg_weight"], "Weight of grain in mash") if not water: water = inputs.get_unit_input(ctx.obj["units"]["temp"], "Temperature of infusion water") try: infusion = bm.infusion(ratio, temp, target, water, grain) except ZeroDivisionError: infusion = 0 unit = "quarts" if is_metric(ctx): unit = "liters" print("Infuse with {0:.2f} {1} @ {2}{3}".format(infusion, unit, water, temp_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 adjust_gravity(ctx, og, vol, ng): """ Calculate the amount of liquid to boil off/dilute with to achieve a desired gravity. """ if not og: og = inputs.get_gravity_input("Original Gravity: ") if not ng: ng = inputs.get_gravity_input("Desired Gravity: ") if not vol: vol = inputs.get_unit_input(ctx.obj["units"]["vol"], "Current volume of wort") valid_range = inputs.between(1.0, 1.2) if not valid_range(og) or not valid_range(ng): sys.exit(1) vol_adj = bm.adjust_gravity_volume(vol, og, ng) print("\nNew volume of wort will be {0:.2f}".format(vol_adj)) diff = vol - vol_adj if diff >= 0: print("Boil off {0:.2f} {1} of wort".format(diff, ctx.obj["units"]["vol"])) else: print("Dilute wort with {0:.2f} {1} of water".format( diff * -1, ctx.obj["units"]["vol"]))
def adjust_volume(ctx, og, vol, newvol): """ Calculate the new gravity after a change in wort volume either through dilution or boil off """ if not og: og = inputs.get_gravity_input("Original Gravity: ") if not vol: vol = inputs.get_unit_input(ctx.obj["units"]["vol"], "Current volume of wort") if not newvol: newvol = inputs.get_unit_input(ctx.obj["units"]["vol"], "New volume of wort") valid_range = inputs.between(1.0, 1.2) if not valid_range(og): sys.exit(1) new_grav = bm.adjust_volume_gravity(vol, og, newvol) print("The new gravity will be {0:.3f}".format(new_grav))
def kegpsi(ctx, vol, temp): """ Calculates the regulator pressure required to achieve desired CO2 volumes. """ if not vol: vol = inputs.get_input("Desired volumes of CO2: ", lambda x: float(x)) if not temp: temp = inputs.get_unit_input(ctx.obj["units"]["temp"], "Temperature of keg") if is_metric(ctx): temp = bm.c_to_f(temp) print("Keg pressure required: {0:.2f}psi".format(bm.keg_psi(temp, vol)))
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))