food_energy_paper/ag_yields_graph/make_figure.ipynb
Nathan Moore 06e217c1de figures
2023-01-12 12:25:12 -06:00

476 lines
12 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "41405f3d",
"metadata": {},
"outputs": [],
"source": [
"from matplotlib import pyplot as plt\n",
"import numpy as np"
]
},
{
"cell_type": "markdown",
"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",
"metadata": {},
"source": [
"## Corn"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "116f0267",
"metadata": {},
"outputs": [],
"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",
"execution_count": null,
"id": "0db69a97",
"metadata": {},
"outputs": [],
"source": [
"corn_year=csv[:,1]\n",
"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"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eb375958",
"metadata": {},
"outputs": [],
"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\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c6ffb7f",
"metadata": {},
"outputs": [],
"source": [
"plt.plot(corn_year,corn_kcal_per_acre,\"o\",label=\"corn\")\n",
"plt.xlabel(\"time (calendar year)\")\n",
"plt.ylabel(\"kcal/acre\")\n",
"plt.title(\"US Agriculture yields, NASS (USDA)\")\n",
"plt.legend()\n",
"\n",
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
},
{
"cell_type": "markdown",
"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",
"metadata": {},
"source": [
"## Potatoes"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c31828d0",
"metadata": {},
"outputs": [],
"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",
"execution_count": null,
"id": "86091fed",
"metadata": {},
"outputs": [],
"source": [
"potatoes_year=csv[:,1]\n",
"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"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5ea8b2ac",
"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": "2b78c297",
"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": "0201b588",
"metadata": {},
"source": [
"## Soybeans"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ce223c5b",
"metadata": {},
"outputs": [],
"source": [
"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",
"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": "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",
"#plt.show()\n",
"#plt.savefig(\"bear-quadratic.pdf\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1a71b7e2",
"metadata": {},
"outputs": [],
"source": []
}
],
"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
}