food_energy_paper/ag_yields_graph/.ipynb_checkpoints/make_figure-checkpoint.ipynb

476 lines
12 KiB
Plaintext
Raw Normal View History

2023-01-12 16:13:39 +02:00
{
"cells": [
{
"cell_type": "code",
2023-01-12 20:25:12 +02:00
"execution_count": null,
"id": "41405f3d",
2023-01-12 16:13:39 +02:00
"metadata": {},
"outputs": [],
"source": [
"from matplotlib import pyplot as plt\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
2023-01-12 20:25:12 +02:00
"id": "dfc88764",
"metadata": {},
"source": [
"## General conversions \n",
"\n",
"Conversions\n",
"\n",
"Sunflower Seeds, sunflower seed kernels, dried\n",
"584kcal/100g\n",
"https://fdc.nal.usda.gov/fdc-app.html#/food-details/170562/nutrients\n",
"FDC ID: 170562\n",
"USDA Unit LB/acre\n",
" \n",
"Potatoes, flesh and skin, raw\n",
"https://fdc.nal.usda.gov/fdc-app.html#/food-details/170026/nutrients\n",
"77kcal/100g\n",
"FDC ID: 170026 \n",
"USDA Unit CWT/acre\n",
"1 CWT = 100lbs\n",
" \n",
"Wheat, hard red winter\n",
"FDC ID: 168890\n",
"327kcal/100g\n",
"https://fdc.nal.usda.gov/fdc-app.html#/food-details/168890/nutrients\n",
"USDA Unit BU/acre\n",
"60lb / BU https://www.plainsgrains.org/wp-content/uploads/2018/10/2017-HRWW-Report__HiRes-FINAL.pdf\n",
"\n",
"Corn grain, yellow\n",
"365kcal/100g\n",
"https://fdc.nal.usda.gov/fdc-app.html#/food-details/170288/nutrients\n",
"FDC ID: 170288 \n",
"USDA Unit BU/acre\n",
"Shelled, 56lbs/BU\n",
"\n",
"Soybeans, mature seeds, raw\n",
"446kcal/100g\n",
"https://fdc.nal.usda.gov/fdc-app.html#/food-details/174270/nutrients\n",
"FDC ID: 174270 \n",
"USDA Unit BU/acre\n",
"60LB/BU https://soybeanresearchinfo.com/research-highlight/exploring-the-impact-of-genetics-on-soybean-test-weight\n"
]
},
{
"cell_type": "markdown",
"id": "72029669",
2023-01-12 16:13:39 +02:00
"metadata": {},
"source": [
"## Corn"
]
},
{
"cell_type": "code",
2023-01-12 20:25:12 +02:00
"execution_count": null,
"id": "116f0267",
2023-01-12 16:13:39 +02:00
"metadata": {},
2023-01-12 20:25:12 +02:00
"outputs": [],
2023-01-12 16:13:39 +02:00
"source": [
"csv=np.genfromtxt ('./data/corn.csv',\n",
" skip_header=1,\n",
" delimiter=\",\")\n",
"csv[0:3]\n",
"#csv[0:3].astype(float)"
]
},
{
"cell_type": "code",
2023-01-12 20:25:12 +02:00
"execution_count": null,
"id": "0db69a97",
2023-01-12 16:13:39 +02:00
"metadata": {},
"outputs": [],
"source": [
"corn_year=csv[:,1]\n",
2023-01-12 20:25:12 +02:00
"corn_bu_per_acre=csv[:,-2]\n",
"\n",
"grams_per_lbs=453.592\n",
"corn_lbs_per_bu=(56.0/1.0)\n",
"corn_kcal_per_gram=(365/100)\n",
"corn_kcal_per_acre = corn_bu_per_acre*corn_lbs_per_bu*grams_per_lbs*corn_kcal_per_gram"
2023-01-12 16:13:39 +02:00
]
},
{
"cell_type": "code",
"execution_count": null,
2023-01-12 20:25:12 +02:00
"id": "eb375958",
2023-01-12 16:13:39 +02:00
"metadata": {},
"outputs": [],
2023-01-12 20:25:12 +02:00
"source": [
"plt.plot(corn_year,corn_bu_per_acre,\"o\",label=\"corn\")\n",
"plt.xlabel(\"time (calendar year)\")\n",
"plt.ylabel(\"Corn, bu/acre\")\n",
"plt.title(\"US Agriculture yields, NASS (USDA)\")\n",
"plt.legend()\n",
"\n",
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
2023-01-12 16:13:39 +02:00
},
{
"cell_type": "code",
2023-01-12 20:25:12 +02:00
"execution_count": null,
"id": "9c6ffb7f",
2023-01-12 16:13:39 +02:00
"metadata": {},
2023-01-12 20:25:12 +02:00
"outputs": [],
2023-01-12 16:13:39 +02:00
"source": [
2023-01-12 20:25:12 +02:00
"plt.plot(corn_year,corn_kcal_per_acre,\"o\",label=\"corn\")\n",
2023-01-12 16:13:39 +02:00
"plt.xlabel(\"time (calendar year)\")\n",
2023-01-12 20:25:12 +02:00
"plt.ylabel(\"kcal/acre\")\n",
2023-01-12 16:13:39 +02:00
"plt.title(\"US Agriculture yields, NASS (USDA)\")\n",
"plt.legend()\n",
"\n",
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
},
{
"cell_type": "markdown",
2023-01-12 20:25:12 +02:00
"id": "fa891f0e",
"metadata": {},
"source": [
"## Wheat"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "263ea341",
"metadata": {},
"outputs": [],
"source": [
"csv=np.genfromtxt ('./data/wheat.csv',\n",
" skip_header=1,\n",
" delimiter=\",\")\n",
"csv[0:3]\n",
"#csv[0:3].astype(float)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5aa38243",
"metadata": {},
"outputs": [],
"source": [
"wheat_year=csv[:,1]\n",
"wheat_bu_per_acre=csv[:,-2]\n",
"\n",
"wheat_lbs_per_bu=60\n",
"#grams_per_lbs\n",
"wheat_kcal_per_gram=327.0/100.0\n",
"\n",
"wheat_kcal_per_acre=wheat_bu_per_acre*wheat_lbs_per_bu*grams_per_lbs*wheat_kcal_per_gram"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5dd77124",
"metadata": {},
"outputs": [],
"source": [
"plt.plot(corn_year,corn_bu_per_acre,\"o\",label=\"Corn (BU/ACRE)\")\n",
"plt.plot(wheat_year,wheat_bu_per_acre,\"x\",label=\"Wheat (BU/ACRE)\")\n",
"plt.plot(potatoes_year,potatoes_cwt_per_acre,\"+\",label=\"Potatoes (CWT / ACRE)\")\n",
"plt.xlabel(\"time (calendar year)\")\n",
"plt.ylabel(\"Average per acre production\")\n",
"plt.title(\"US Agriculture yields, NASS (USDA)\")\n",
"plt.legend()\n",
"plt.yscale(\"log\")\n",
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "99433ae1",
"metadata": {},
"outputs": [],
"source": [
"plt.plot(corn_year,corn_bu_per_acre,\"o\",label=\"Corn (BU/ACRE)\")\n",
"plt.plot(wheat_year,wheat_bu_per_acre,\"x\",label=\"Wheat (BU/ACRE)\")\n",
"plt.plot(potatoes_year,potatoes_cwt_per_acre,\"+\",label=\"Potatoes (CWT / ACRE)\")\n",
"plt.xlabel(\"time (calendar year)\")\n",
"plt.ylabel(\"Average per acre production\")\n",
"plt.title(\"US Agriculture yields, NASS (USDA)\")\n",
"plt.legend()\n",
"plt.yscale(\"log\")\n",
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
},
{
"cell_type": "markdown",
"id": "89c8f489",
2023-01-12 16:13:39 +02:00
"metadata": {},
"source": [
"## Potatoes"
]
},
{
"cell_type": "code",
2023-01-12 20:25:12 +02:00
"execution_count": null,
"id": "c31828d0",
2023-01-12 16:13:39 +02:00
"metadata": {},
2023-01-12 20:25:12 +02:00
"outputs": [],
2023-01-12 16:13:39 +02:00
"source": [
"csv=np.genfromtxt ('./data/potatoes.csv',\n",
" skip_header=1,\n",
" delimiter=\",\")\n",
"csv[0:3]\n",
"#csv[0:3].astype(float)"
]
},
{
"cell_type": "code",
2023-01-12 20:25:12 +02:00
"execution_count": null,
"id": "86091fed",
2023-01-12 16:13:39 +02:00
"metadata": {},
"outputs": [],
"source": [
"potatoes_year=csv[:,1]\n",
2023-01-12 20:25:12 +02:00
"potatoes_cwt_per_acre=csv[:,-2]\n",
"\n",
"lbs_per_cwt=100\n",
"#grams_per_lbs\n",
"potatoes_kcal_per_gram=77.0/100.0\n",
"potatoes_kcal_per_acre=potatoes_cwt_per_acre*lbs_per_cwt*grams_per_lbs*potatoes_kcal_per_gram"
2023-01-12 16:13:39 +02:00
]
},
{
"cell_type": "code",
2023-01-12 20:25:12 +02:00
"execution_count": null,
"id": "5ea8b2ac",
2023-01-12 16:13:39 +02:00
"metadata": {},
2023-01-12 20:25:12 +02:00
"outputs": [],
2023-01-12 16:13:39 +02:00
"source": [
"plt.plot(corn_year,corn_bu_per_acre,\"o\",label=\"Corn (BU/ACRE)\")\n",
"plt.plot(wheat_year,wheat_bu_per_acre,\"x\",label=\"Wheat (BU/ACRE)\")\n",
2023-01-12 20:25:12 +02:00
"plt.plot(potatoes_year,potatoes_cwt_per_acre,\"+\",label=\"Potatoes (CWT / ACRE)\")\n",
2023-01-12 16:13:39 +02:00
"plt.xlabel(\"time (calendar year)\")\n",
"plt.ylabel(\"Average per acre production\")\n",
"plt.title(\"US Agriculture yields, NASS (USDA)\")\n",
"plt.legend()\n",
2023-01-12 20:25:12 +02:00
"plt.yscale(\"log\")\n",
2023-01-12 16:13:39 +02:00
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
},
{
"cell_type": "code",
"execution_count": null,
2023-01-12 20:25:12 +02:00
"id": "2b78c297",
2023-01-12 16:13:39 +02:00
"metadata": {},
"outputs": [],
2023-01-12 20:25:12 +02:00
"source": [
"plt.plot(corn_year,corn_bu_per_acre,\"o\",label=\"Corn (BU/ACRE)\")\n",
"plt.plot(wheat_year,wheat_bu_per_acre,\"x\",label=\"Wheat (BU/ACRE)\")\n",
"plt.plot(potatoes_year,potatoes_cwt_per_acre,\"+\",label=\"Potatoes (CWT / ACRE)\")\n",
"plt.xlabel(\"time (calendar year)\")\n",
"plt.ylabel(\"Average per acre production\")\n",
"plt.title(\"US Agriculture yields, NASS (USDA)\")\n",
"plt.legend()\n",
"plt.yscale(\"log\")\n",
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
},
{
"cell_type": "markdown",
"id": "0201b588",
"metadata": {},
"source": [
"## Soybeans"
]
2023-01-12 16:13:39 +02:00
},
{
"cell_type": "code",
2023-01-12 20:25:12 +02:00
"execution_count": null,
"id": "ce223c5b",
2023-01-12 16:13:39 +02:00
"metadata": {},
2023-01-12 20:25:12 +02:00
"outputs": [],
2023-01-12 16:13:39 +02:00
"source": [
2023-01-12 20:25:12 +02:00
"csv=np.genfromtxt ('./data/soybeans.csv',\n",
" skip_header=1,\n",
" delimiter=\",\")\n",
"csv[0:3]\n",
"#csv[0:3].astype(float)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "12fe395c",
"metadata": {},
"outputs": [],
"source": [
"soybeans_year=csv[:,1]\n",
"soybeans_bu_per_acre=csv[:,-2]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ae3f6ad4",
"metadata": {},
"outputs": [],
"source": [
"plt.plot(corn_year,corn_bu_per_acre,\"o\",label=\"Corn (BU/ACRE)\")\n",
"plt.plot(wheat_year,wheat_bu_per_acre,\"x\",label=\"Wheat (BU/ACRE)\")\n",
"plt.plot(potatoes_year,potatoes_cwt_per_acre,\"+\",label=\"Potatoes (CWT / ACRE)\")\n",
"plt.plot(soybeans_year,soybeans_bu_per_acre,\"*\",label=\"Soybeans (BU/ACRE)\")\n",
2023-01-12 16:13:39 +02:00
"plt.xlabel(\"time (calendar year)\")\n",
2023-01-12 20:25:12 +02:00
"plt.ylabel(\"Average per acre production\")\n",
2023-01-12 16:13:39 +02:00
"plt.title(\"US Agriculture yields, NASS (USDA)\")\n",
"plt.legend()\n",
2023-01-12 20:25:12 +02:00
"plt.yscale(\"log\")\n",
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
},
{
"cell_type": "markdown",
"id": "c68984fa",
"metadata": {},
"source": [
"## Sugarbeets"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6e74b0b8",
"metadata": {},
"outputs": [],
"source": [
"csv=np.genfromtxt ('./data/sugarbeets.csv',\n",
" skip_header=1,\n",
" delimiter=\",\")\n",
"csv[0:3]\n",
"#csv[0:3].astype(float)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ab73b355",
"metadata": {},
"outputs": [],
"source": [
"sugarbeets_year=csv[:,1]\n",
"sugarbeets_tons_per_acre=csv[:,-2]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cbaa454a",
"metadata": {},
"outputs": [],
"source": [
"plt.plot(corn_year,corn_bu_per_acre,\"o\",label=\"Corn (BU/ACRE)\")\n",
"plt.plot(wheat_year,wheat_bu_per_acre,\"x\",label=\"Wheat (BU/ACRE)\")\n",
"plt.plot(potatoes_year,potatoes_cwt_per_acre,\"+\",label=\"Potatoes (CWT / ACRE)\")\n",
"plt.plot(soybeans_year,soybeans_bu_per_acre,\"*\",label=\"Soybeans (BU/ACRE)\")\n",
"plt.plot(sugarbeets_year,sugarbeets_tons_per_acre,\".\",label=\"Sugarbeets (TONS/ACRE)\")\n",
"plt.xlabel(\"time (calendar year)\")\n",
"plt.ylabel(\"Average per acre production\")\n",
"plt.title(\"US Agriculture yields, NASS (USDA)\")\n",
"plt.legend()\n",
"plt.yscale(\"log\")\n",
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
},
{
"cell_type": "markdown",
"id": "884a7b05",
"metadata": {},
"source": [
"## Sunflowers"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "846722a4",
"metadata": {},
"outputs": [],
"source": [
"csv=np.genfromtxt ('./data/sunflowers.csv',\n",
" skip_header=1,\n",
" delimiter=\",\")\n",
"csv[0:3]\n",
"#csv[0:3].astype(float)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c79d0d11",
"metadata": {},
"outputs": [],
"source": [
"sunflowers_year=csv[:,1]\n",
"sunflowers_lbs_per_acre=csv[:,-2]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "569111b9",
"metadata": {},
"outputs": [],
"source": [
"plt.plot(corn_year,corn_bu_per_acre,\"o\",label=\"Corn (BU/ACRE)\")\n",
"plt.plot(wheat_year,wheat_bu_per_acre,\"x\",label=\"Wheat (BU/ACRE)\")\n",
"plt.plot(potatoes_year,potatoes_cwt_per_acre,\"+\",label=\"Potatoes (CWT / ACRE)\")\n",
"plt.plot(soybeans_year,soybeans_bu_per_acre,\"*\",label=\"Soybeans (BU/ACRE)\")\n",
"plt.plot(sugarbeets_year,sugarbeets_tons_per_acre,\".\",label=\"Sugarbeets (TONS/ACRE)\")\n",
"plt.plot(sunflowers_year,sunflowers_lbs_per_acre,\"d\",label=\"Sunflowers (LB/ACRE)\")\n",
"plt.xlabel(\"time (calendar year)\")\n",
"plt.ylabel(\"Average per acre production\")\n",
"plt.title(\"US Agriculture yields, NASS (USDA)\")\n",
"plt.legend()\n",
"plt.yscale(\"log\")\n",
2023-01-12 16:13:39 +02:00
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
2023-01-12 20:25:12 +02:00
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a71b7e2",
"metadata": {},
"outputs": [],
"source": []
2023-01-12 16:13:39 +02:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}