Skip to content

Instantly share code, notes, and snippets.

@rileyhales
Last active April 4, 2024 19:33
Show Gist options
  • Save rileyhales/d411ddbe475064b78092939d4d35658f to your computer and use it in GitHub Desktop.
Save rileyhales/d411ddbe475064b78092939d4d35658f to your computer and use it in GitHub Desktop.
geoglows-data-service-homework.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"private_outputs": true,
"provenance": [],
"toc_visible": true,
"authorship_tag": "ABX9TyNYQrjdvIn9FFYkjJCpuLsZ",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/rileyhales/d411ddbe475064b78092939d4d35658f/geoglows-data-service-homework.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "WQhP2Tz8-b9n"
},
"source": [
"# Using the GEOGLOWS Data Service\n",
"\n",
"Your assignment is to (1) write one or more functions to retrieve data from the GEOGLOWS rest data service, (2) plot the data you retrieved, and (3) calculate something new and interesting using that data.\n",
"\n",
"## Identify a river ID number\n",
"\n",
"Use the tutorials on finding river numbers found at https://data.geoglows.org. You may select a river\n",
"\n",
"## Retrieve Data\n",
"\n",
"Your functions to retrieve data from the data service should follow the patterns documented at https://geoglows.ecmwf.int\n",
"\n",
"1. Write a function which retrieves the simple forecast\n",
"1. Write a fucntion which retrieves the retrospective simulation\n",
"\n",
"Your functions must do all the following:\n",
"\n",
"- Your functions must accept the reach_id (9 digit integer) and return_format (string: either csv or json) arguments\n",
"- If you retrieve in json format, your code should return a dictionary\n",
"- If you retrieve in csv format, your code should return a DataFrame\n",
"- The forecast function must be able to accept an optional date argument (YYYYMMDD strings). The date should not be more than 45 days in the past.\n",
"- The retrospective simulation function should accept optional start_date and end_date arguments (YYYYMMDD strings).\n",
"\n",
"## Plot Data\n",
"\n",
"You may use plotly or matplotlib to make your plots. Your plots should at least have a title, labeled axes showing units of discharge and timezone for the dates, and have a legend.\n",
"\n",
"1. Write a function which plots the simple forecast data\n",
"1. Write a function which plots the retrospective data\n",
"\n",
"## Computations\n",
"\n",
"Calculate something original using the discharge data. You should solve some engineering equations and produce at least 1 plot and 1 numerical solution.\n",
"\n",
"- You could calculate the total loading of a contaminant discharged from your river. Lookup the EPA maximum contaminant level (MCL) for some contaminant (e.g. PFAS, lead, nitrates) and assume the water in your river has that concentration.\n",
"\n",
"- You could choose a river where you can find a surveyed river cross section information. Assume a manning's n value. Calculate a time series of river normal depths assuming the river is at steady state at each of the time steps in the forecast.\n",
"\n",
"## Deliverables\n",
"\n",
"- A link to a GitHub gist or Google Colab notebook.\n",
"- Your notebook ***must*** have the outputs saved so that i don't have to rerun your code to see the outputs.\n",
"- I should be able to see how you produced the url string.\n",
"- Your code should check that the arguments are valid before trying to retrieve the dataset.\n",
"- Use plenty of comments, text cells, and verbose variables names I can understand without guessing.\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "zyHUbph1oc8K"
},
"source": [
"# Select a river ID number\n",
"\n",
"Identify a river number for GEOGLOWS and place it in this cell.\n"
]
},
{
"cell_type": "code",
"source": [
"reach_id = 123_456_789"
],
"metadata": {
"id": "puz-9VFNg-y8"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "3J69EdCx-Pzs"
},
"source": [
"# 1. Retrieve Data\n"
]
},
{
"cell_type": "code",
"source": [
"'''\n",
"Some hints:\n",
"\n",
"1. Use the requests package to get data from the urls you construct\n",
"2. You will need to use pd.read_csv to create dataframes from the csv strings\n",
"3. Your code should raise ValueError if any of the arguments fail your validation checks\n",
"'''"
],
"metadata": {
"id": "tsx28DJPnIj8"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "u5V2iEFClbUR"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "Roh-4KEglbRL"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "szqfIUScEcFn"
},
"source": [
"# 2. Make plots\n"
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "1FUc8zPklakL"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "aSR7VBOTlacz"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "nDrWjXJoFJng"
},
"source": [
"# 3. Calculations\n"
]
},
{
"cell_type": "markdown",
"source": [
"Enter the explanation of your calculations here. Give relevant links to other resources as approrpriate."
],
"metadata": {
"id": "Q6O3oDkpoKbi"
}
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "-A2DDcu4ljwY"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "5bYhnpQwljtu"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "CGLG1yE3ljqz"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment