download carbon data automatically

parent 3d8ac3ba
...@@ -12,6 +12,60 @@ ...@@ -12,6 +12,60 @@
"\n", "\n",
"_C. D. Keeling, S. C. Piper, R. B. Bacastow, M. Wahlen, T. P. Whorf, M. Heimann, and H. A. Meijer, Exchanges of atmospheric CO2 and 13CO2 with the terrestrial biosphere and oceans from 1978 to 2000. I. Global aspects, SIO Reference Series, No. 01-06, Scripps Institution of Oceanography, San Diego, 88 pages, 2001._\n" "_C. D. Keeling, S. C. Piper, R. B. Bacastow, M. Wahlen, T. P. Whorf, M. Heimann, and H. A. Meijer, Exchanges of atmospheric CO2 and 13CO2 with the terrestrial biosphere and oceans from 1978 to 2000. I. Global aspects, SIO Reference Series, No. 01-06, Scripps Institution of Oceanography, San Diego, 88 pages, 2001._\n"
] ]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
" %matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import isoweek\n",
"import os\n",
"import urllib"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Le fichier `csv` contenant les données est disponible à l'adresse suivante :"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"data_url = \"https://scrippsco2.ucsd.edu/assets/data/atmospheric/stations/in_situ_co2/monthly/monthly_in_situ_co2_mlo.csv\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" Nous conservons les données dans un fichier local, afin que la conservation du fichier sur lequel nous effectuons notre analyse soit robuste aux défaillances du site Sentiweb. À cette fin également, nous ne retéléchargeons pas automatiquement une nouvelle version à chaque exécution, mais seulement si le fichier local est manquant."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"if not os.path.exists(\"monthly_in_situ_co2_mlo.csv\"):\n",
" urllib.request.urlretrieve(data_url, \"monthly_in_situ_co2_mlo.csv\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment