Yongfu's Blog

Nutrical

All about nutrition and food

May 25, 2024

Load nutrical for nutrition calculation.

1from nutrical import Ingredient, Recipe
2from nutrical.utils import UREG

Imei whole wheat toast

1toast = Ingredient("Imei Toast",
2    amount = '300g',
3    calories = 3 * 264,
4    protein = 3 * 11.4,
5    fiber = 3 * 8.1
6)
7toast = toast * (2/7) + 0 * toast
8toast
  servings  amount        calories    fiber    protein
----------  ----------  ----------  -------  ---------
         1  85.71 gram      226.29     6.94       9.77

Home-made Yogurt

  • Protein: 6g / 100g
 1powder = Ingredient("powered milk", amount='32g', protein=7.8)
 2water = Ingredient("water", amount='200g')
 3probio = Ingredient("probiotics (yogurt)", amount="75g", protein=2.7)
 4
 5target_protein_concentration = 6
 6target_total_weight = 700
 7protein_from_milk = target_protein_concentration * (target_total_weight/100) - 2.7
 8powder_to_add = powder.to(protein=protein_from_milk)
 9water_weight = UREG(f"{target_total_weight} gram") - probio.total_amount - powder_to_add.total_amount
10
11yogurt = Recipe("yogurt", components=[
12    powder_to_add,
13    water.to(amount=water_weight),
14    probio
15])
16yogurt
<Recipe (yogurt)>

    servings  amount        protein
  ----------  ----------  ---------
           1  700.0 gram         42

  [INGREDIENTS]
        name                   servings  amount         protein
    --  -------------------  ----------  -----------  ---------
     1  powered milk            5.03846  161.23 gram       39.3
     2  water                   2.31885  463.77 gram
     3  probiotics (yogurt)     1        75 gram            2.7