drafting post on workout and nutrition WIP

This commit is contained in:
lieuwe B. Leene 2024-11-25 12:00:35 +01:00
parent c6391ab734
commit 3ee0d4f499
7 changed files with 2867 additions and 0 deletions

2
.gitattributes vendored
View File

@ -3,3 +3,5 @@
*.jpg binary
*.gif binary
*.toml filter=hostmgmt
*.xls binary
*.xlsx binary

Binary file not shown.

View File

@ -0,0 +1,150 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import csv\n",
"import re\n",
"import numpy as np\n",
"from cds2py import plot_svg\n",
"from datetime import datetime, date\n",
"from collections import namedtuple\n",
"from slugify import slugify\n",
"from quantiphy import Quantity\n",
"from tabulate import tabulate"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"with open('diet.csv') as csvfile:\n",
" data = list(csv.reader(csvfile, delimiter=','))\n",
"\n",
"DietEntry = namedtuple(\"DietEntry\", [slugify(elem).replace(\"-\",\"_\") for elem in data[0]])\n",
"\n",
"def quantify_elem(elem:str, field:str):\n",
" if field == \"date\":\n",
" return datetime.strptime(elem,\"%Y-%m-%d\")\n",
" elif field == \"completed\":\n",
" return elem == \"true\"\n",
" elif field.split(\"_\")[-1] == \"mg\":\n",
" return Quantity(float(elem)*1e-3, units=\"g\")\n",
" elif field.split(\"_\")[-1] == \"ug\":\n",
" return Quantity(float(elem)*1e-6, units=\"g\")\n",
" elif field.split(\"_\")[-1] == \"iu\":\n",
" return Quantity(float(elem)*1e-6/40, units=\"g\")\n",
" elif field.split(\"_\")[-1] == \"kcal\":\n",
" return Quantity(float(elem)*1e3, units=\"cal\")\n",
" else:\n",
" return Quantity(elem, units=field.split(\"_\")[-1])\n",
"\n",
"quantities = [\n",
" DietEntry(\n",
" *[\n",
" quantify_elem(value, DietEntry._fields[index])\n",
" for index,value in enumerate(elem)\n",
" ]\n",
" ) for elem in data[1:]\n",
"]\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"darray = np.array(quantities)[:,1:-1].astype(float)\n",
"Names = [re.sub(\" [kmiu]\",\" \", elem.replace(\"_\",\" \")).replace(\" u\",\" g\") for elem in DietEntry._fields[1:-1]]\n",
"metric_table = np.vstack(\n",
" ( Names, [ Quantity(elem).render(prec=2) for elem in darray.mean(axis=0) ], [ Quantity(elem).render(prec=2) for elem in darray.std(axis=0) ] )\n",
" )\n",
"\n",
"with open(\"diet.table\",\"w\") as mdfile:\n",
" mdfile.write(\n",
" tabulate( metric_table.T, headers=[\"Metric\", \"Average\", \"Deviation\"],)\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"import importlib.resources as rsc\n",
"import json\n",
"import re\n",
"import nutrimetrics.resources.dri\n",
"\n",
"src_txt = rsc.read_text(nutrimetrics.resources.dri,\"ear-male.json\")\n",
"average_requirement = json.loads(re.sub(\"//.*\",\"\",src_txt))[\"dietary_reference_intakes\"]\n",
"src_txt = rsc.read_text(nutrimetrics.resources.dri,\"rda-male.json\")\n",
"average_allowance = json.loads(re.sub(\"//.*\",\"\",src_txt))[\"dietary_reference_intakes\"]\n"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"folate\n",
"vitamin-a\n",
"vitamin-c\n",
"vitamin-d\n",
"vitamin-e\n",
"calcium\n",
"copper\n",
"iron\n",
"magnesium\n",
"manganese\n",
"phosphorus\n",
"potassium\n",
"selenium\n",
"sodium\n",
"zinc\n"
]
}
],
"source": [
"\n",
"for name, average, _ in metric_table.T:\n",
" nutrient = name.replace(\" \",\"-\").replace(\"-g\",\"\")\n",
" if nutrient in average_requirement:\n",
" print(nutrient)\n",
" # print(Quantity(average_requirement[nutrient],units=\"g\")/Quantity(average, units=\"g\"))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "git",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

View File

@ -0,0 +1,9 @@
Date,Energy (kcal),Alcohol (g),Caffeine (mg),Water (g),B1 (Thiamine) (mg),B2 (Riboflavin) (mg),B3 (Niacin) (mg),B5 (Pantothenic Acid) (mg),B6 (Pyridoxine) (mg),B12 (Cobalamin) (µg),Folate (µg),Vitamin A (µg),Vitamin C (mg),Vitamin D (IU),Vitamin E (mg),Vitamin K (µg),Calcium (mg),Copper (mg),Iron (mg),Magnesium (mg),Manganese (mg),Phosphorus (mg),Potassium (mg),Selenium (µg),Sodium (mg),Zinc (mg),Carbs (g),Fiber (g),Starch (g),Sugars (g),Added Sugars (g),Net Carbs (g),Fat (g),Cholesterol (mg),Monounsaturated (g),Polyunsaturated (g),Saturated (g),Trans-Fats (g),Omega-3 (g),Omega-6 (g),Cystine (g),Histidine (g),Isoleucine (g),Leucine (g),Lysine (g),Methionine (g),Phenylalanine (g),Protein (g),Threonine (g),Tryptophan (g),Tyrosine (g),Valine (g),Completed
2023-10-22,3341.92,0.00,360.00,3577.87,2.03,2.95,26.26,7.00,3.25,3.73,650.34,1779.26,272.83,97.52,12.88,437.59,1328.30,1.12,13.18,354.19,3.33,1547.99,3981.15,112.48,1951.10,10.24,333.74,54.80,81.47,131.57,7.59,275.91,151.60,280.56,35.38,18.22,66.52,1.68,9.65,3.83,0.99,2.93,3.87,7.21,6.43,2.00,4.08,191.90,3.34,1.08,3.66,4.72,true
2023-10-23,3817.20,0.00,541.50,3892.14,3.29,4.75,39.01,12.77,5.82,12.98,697.25,1336.87,101.43,985.22,12.31,278.45,1963.19,1.52,13.84,454.15,2.85,2273.92,5367.52,190.74,5560.49,15.68,459.56,53.53,134.03,173.22,39.23,403.31,140.28,836.63,36.16,32.36,48.08,1.39,3.49,28.03,1.70,4.02,5.94,10.71,9.29,3.15,6.02,203.28,5.33,1.55,5.00,7.12,true
2023-10-24,3942.98,0.00,360.00,2802.70,1.98,3.88,29.46,9.57,3.54,7.18,414.31,698.38,120.55,553.01,8.39,114.14,1777.33,0.97,10.63,363.60,3.51,1920.01,4103.29,154.97,6837.22,12.67,496.21,58.27,53.50,201.50,50.30,436.51,133.70,899.51,39.04,13.23,45.47,1.33,1.21,11.45,1.42,3.39,4.92,8.82,8.03,2.63,4.83,217.38,4.45,1.40,3.96,5.62,true
2023-10-25,3849.45,0.00,160.00,2298.22,1.77,2.50,28.42,8.56,4.10,9.48,320.80,397.76,71.48,217.68,6.37,74.27,1508.71,1.49,11.62,391.41,2.23,1781.18,4817.48,95.89,3501.27,19.28,484.89,59.49,103.91,130.89,4.05,422.90,126.58,273.77,21.00,5.81,36.90,1.75,0.83,4.31,0.98,2.72,3.92,7.34,6.52,2.10,3.97,219.75,3.41,0.75,3.23,4.92,true
2023-10-26,4911.16,0.00,0.00,1231.38,1.97,2.61,14.51,5.13,2.12,4.26,709.20,1011.82,69.12,334.28,6.25,108.26,1382.69,1.13,19.17,321.46,2.74,1404.52,3421.28,194.88,5789.38,9.52,678.35,75.15,132.10,199.21,70.33,601.30,142.47,493.38,18.81,6.00,56.83,1.70,0.49,4.87,1.07,2.32,3.58,6.84,4.49,1.63,3.98,251.07,3.12,1.01,2.91,4.33,true
2023-10-27,4084.73,0.00,265.60,3111.11,2.35,3.43,24.44,10.03,5.35,9.87,617.74,1485.26,184.53,284.14,13.10,438.47,2760.81,1.67,16.80,550.89,3.87,2773.57,7452.27,136.46,4984.42,17.69,479.51,59.27,128.92,172.13,11.18,418.69,165.84,243.25,30.66,48.25,58.56,1.29,5.95,40.93,1.17,3.39,5.05,9.64,8.64,2.69,5.50,199.97,4.40,1.20,4.78,6.75,true
2023-10-28,3548.53,0.00,341.50,2350.51,1.14,1.29,23.56,3.35,2.91,4.30,504.67,543.18,88.02,239.17,4.33,41.20,1250.61,0.73,6.28,175.10,1.95,643.95,2556.57,37.76,2894.01,2.40,489.54,47.60,77.35,117.87,7.00,439.47,130.43,158.69,33.91,6.78,69.53,1.60,0.29,1.27,0.32,0.59,0.69,1.30,0.79,0.31,0.92,130.61,0.62,0.21,0.53,0.85,true
2023-10-29,3987.24,0.00,162.80,3746.95,1.63,3.17,14.74,8.15,2.36,5.86,568.39,785.39,228.91,339.37,13.14,469.88,1498.41,1.10,12.47,308.84,2.51,1774.37,3089.60,140.99,3116.55,8.86,501.96,61.93,49.27,217.84,92.23,436.86,137.36,912.53,38.16,25.47,43.07,0.68,10.25,11.13,1.24,2.31,3.83,6.53,5.44,1.96,3.77,215.77,3.38,0.95,3.04,4.45,true
1 Date Energy (kcal) Alcohol (g) Caffeine (mg) Water (g) B1 (Thiamine) (mg) B2 (Riboflavin) (mg) B3 (Niacin) (mg) B5 (Pantothenic Acid) (mg) B6 (Pyridoxine) (mg) B12 (Cobalamin) (µg) Folate (µg) Vitamin A (µg) Vitamin C (mg) Vitamin D (IU) Vitamin E (mg) Vitamin K (µg) Calcium (mg) Copper (mg) Iron (mg) Magnesium (mg) Manganese (mg) Phosphorus (mg) Potassium (mg) Selenium (µg) Sodium (mg) Zinc (mg) Carbs (g) Fiber (g) Starch (g) Sugars (g) Added Sugars (g) Net Carbs (g) Fat (g) Cholesterol (mg) Monounsaturated (g) Polyunsaturated (g) Saturated (g) Trans-Fats (g) Omega-3 (g) Omega-6 (g) Cystine (g) Histidine (g) Isoleucine (g) Leucine (g) Lysine (g) Methionine (g) Phenylalanine (g) Protein (g) Threonine (g) Tryptophan (g) Tyrosine (g) Valine (g) Completed
2 2023-10-22 3341.92 0.00 360.00 3577.87 2.03 2.95 26.26 7.00 3.25 3.73 650.34 1779.26 272.83 97.52 12.88 437.59 1328.30 1.12 13.18 354.19 3.33 1547.99 3981.15 112.48 1951.10 10.24 333.74 54.80 81.47 131.57 7.59 275.91 151.60 280.56 35.38 18.22 66.52 1.68 9.65 3.83 0.99 2.93 3.87 7.21 6.43 2.00 4.08 191.90 3.34 1.08 3.66 4.72 true
3 2023-10-23 3817.20 0.00 541.50 3892.14 3.29 4.75 39.01 12.77 5.82 12.98 697.25 1336.87 101.43 985.22 12.31 278.45 1963.19 1.52 13.84 454.15 2.85 2273.92 5367.52 190.74 5560.49 15.68 459.56 53.53 134.03 173.22 39.23 403.31 140.28 836.63 36.16 32.36 48.08 1.39 3.49 28.03 1.70 4.02 5.94 10.71 9.29 3.15 6.02 203.28 5.33 1.55 5.00 7.12 true
4 2023-10-24 3942.98 0.00 360.00 2802.70 1.98 3.88 29.46 9.57 3.54 7.18 414.31 698.38 120.55 553.01 8.39 114.14 1777.33 0.97 10.63 363.60 3.51 1920.01 4103.29 154.97 6837.22 12.67 496.21 58.27 53.50 201.50 50.30 436.51 133.70 899.51 39.04 13.23 45.47 1.33 1.21 11.45 1.42 3.39 4.92 8.82 8.03 2.63 4.83 217.38 4.45 1.40 3.96 5.62 true
5 2023-10-25 3849.45 0.00 160.00 2298.22 1.77 2.50 28.42 8.56 4.10 9.48 320.80 397.76 71.48 217.68 6.37 74.27 1508.71 1.49 11.62 391.41 2.23 1781.18 4817.48 95.89 3501.27 19.28 484.89 59.49 103.91 130.89 4.05 422.90 126.58 273.77 21.00 5.81 36.90 1.75 0.83 4.31 0.98 2.72 3.92 7.34 6.52 2.10 3.97 219.75 3.41 0.75 3.23 4.92 true
6 2023-10-26 4911.16 0.00 0.00 1231.38 1.97 2.61 14.51 5.13 2.12 4.26 709.20 1011.82 69.12 334.28 6.25 108.26 1382.69 1.13 19.17 321.46 2.74 1404.52 3421.28 194.88 5789.38 9.52 678.35 75.15 132.10 199.21 70.33 601.30 142.47 493.38 18.81 6.00 56.83 1.70 0.49 4.87 1.07 2.32 3.58 6.84 4.49 1.63 3.98 251.07 3.12 1.01 2.91 4.33 true
7 2023-10-27 4084.73 0.00 265.60 3111.11 2.35 3.43 24.44 10.03 5.35 9.87 617.74 1485.26 184.53 284.14 13.10 438.47 2760.81 1.67 16.80 550.89 3.87 2773.57 7452.27 136.46 4984.42 17.69 479.51 59.27 128.92 172.13 11.18 418.69 165.84 243.25 30.66 48.25 58.56 1.29 5.95 40.93 1.17 3.39 5.05 9.64 8.64 2.69 5.50 199.97 4.40 1.20 4.78 6.75 true
8 2023-10-28 3548.53 0.00 341.50 2350.51 1.14 1.29 23.56 3.35 2.91 4.30 504.67 543.18 88.02 239.17 4.33 41.20 1250.61 0.73 6.28 175.10 1.95 643.95 2556.57 37.76 2894.01 2.40 489.54 47.60 77.35 117.87 7.00 439.47 130.43 158.69 33.91 6.78 69.53 1.60 0.29 1.27 0.32 0.59 0.69 1.30 0.79 0.31 0.92 130.61 0.62 0.21 0.53 0.85 true
9 2023-10-29 3987.24 0.00 162.80 3746.95 1.63 3.17 14.74 8.15 2.36 5.86 568.39 785.39 228.91 339.37 13.14 469.88 1498.41 1.10 12.47 308.84 2.51 1774.37 3089.60 140.99 3116.55 8.86 501.96 61.93 49.27 217.84 92.23 436.86 137.36 912.53 38.16 25.47 43.07 0.68 10.25 11.13 1.24 2.31 3.83 6.53 5.44 1.96 3.77 215.77 3.38 0.95 3.04 4.45 true

View File

@ -0,0 +1,54 @@
Metric Average Deviation
--------------------- --------- -----------
energy cal 3.94M 433k
alcohol g 0 0
caffeine g 274m 155m
water g 2.88k 841
b1 thiamine g 2.02m 583u
b2 riboflavin g 3.07m 958u
b3 niacin g 25.1m 7.48m
b5 pantothenic acid g 8.07m 2.75m
b6 pyridoxine g 3.68m 1.25m
b12 cobalamin g 7.21u 3.09u
folate g 560u 130u
vitamin a g 1m 456u
vitamin c g 142m 72.3m
vitamin d g 9.53u 6.47u
vitamin e g 9.6m 3.42m
vitamin g 245u 171u
calcium g 1.68 463m
copper g 1.22m 296u
iron g 13m 3.64m
magnesium g 365m 103m
manganese g 2.87m 615u
phosphorus g 1.76 585m
potassium g 4.35 1.45
selenium g 133u 48.2u
sodium g 4.33 1.59
zinc g 12m 5.13m
carbs g 490 87.4
fiber g 58.8 7.48
starch g 95.1 32.5
sugars g 168 35.1
added sugars g 35.2 31.3
net carbs g 429 82.3
fat g 141 11.8
cholesterol g 512m 301m
monounsaturated g 31.6 7.21
polyunsaturated g 19.5 14.1
saturated g 53.1 10.8
trans fats g 1.43 328m
omega 3 g 4.02 3.86
omega 6 g 13.2 13.1
cystine g 1.11 374m
histidine g 2.71 968m
isoleucine g 3.97 1.45
leucine g 7.3 2.65
lysine g 6.2 2.54
methionine g 2.06 804m
phenylalanine g 4.13 1.43
protein g 204 32.3
threonine g 3.51 1.3
tryptophan g 1.02 387m
tyrosine g 3.39 1.3
valine g 4.85 1.8

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
---
title: "Sampling Fitness and In"
date: 2024-11-12T16:10:10+02:00
draft: true
toc: false
images:
tags:
- health
- python
- workout
- fitness
---
Test