Skip to content

Commit

Permalink
Merge pull request #96 from aleaf/main
Browse files Browse the repository at this point in the history
Fix remaining part 0 notebook test fails
  • Loading branch information
mnfienen authored Jan 31, 2024
2 parents a96a422 + 1ba90cf commit 676ac02
Show file tree
Hide file tree
Showing 9 changed files with 7,455 additions and 456 deletions.
13 changes: 7 additions & 6 deletions notebooks/part0_python_intro/05_numpy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"#Note that the following does not work. Brackets are required so that the input is a list.\n",
"a = np.array(1, 2, 3)"
"Note that the following does not work. Brackets are required so that the input is a list.\n",
"\n",
"```python\n",
"a = np.array(1, 2, 3)\n",
"```"
]
},
{
Expand Down Expand Up @@ -572,7 +573,7 @@
"metadata": {},
"outputs": [],
"source": [
"a[slice(5, None, 5)]"
"a[slice(50, None, 5)]"
]
},
{
Expand Down
11 changes: 1 addition & 10 deletions notebooks/part0_python_intro/06_matplotlib.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@
"The other notebooks in this lecture series are indexed at [https://github.com/jrjohansson/scientific-python-lectures](https://github.com/jrjohansson/scientific-python-lectures)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -1175,7 +1166,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
37 changes: 18 additions & 19 deletions notebooks/part0_python_intro/08_pandas.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from pathlib import Path\n",
"import numpy as np\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"from dataretrieval import nwis\n",
"import datetime \n",
"import statsmodels.api as sm\n",
"from matplotlib.backends.backend_pdf import PdfPages\n",
"from scipy.signal import detrend\n",
"\n",
"data_path = os.path.join(\"data\", \"pandas\")"
"data_path = Path(\"data\", \"pandas\")"
]
},
{
Expand Down Expand Up @@ -80,7 +79,7 @@
"source": [
"info, metadata = nwis.get_info(bBox=[str(i) for i in bbox])\n",
"info\n",
"info.to_csv(os.path.join(data_path, \"site_info.csv\"), index=False)"
"info.to_csv(data_path / \"site_info.csv\", index=False)"
]
},
{
Expand All @@ -107,16 +106,6 @@
" - `.describe()`: statistically describe the data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "935770bd-2b49-49c0-9249-8a2c4883bb7f",
"metadata": {},
"outputs": [],
"source": [
"info = pd.read_csv(os.path.join(data_path, \"site_info.csv\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -322,7 +311,7 @@
"metadata": {},
"outputs": [],
"source": [
"csv_file = os.path.join(data_path, \"RussianRiverGWsites.csv\")\n",
"csv_file = data_path / \"RussianRiverGWsites.csv\"\n",
"dfgw.to_csv(csv_file, index=False)"
]
},
Expand Down Expand Up @@ -397,7 +386,7 @@
" parameterCd=pcode, \n",
" multi_index=False\n",
")\n",
"df.to_csv(os.path.join(data_path, \"RR_gage_data.csv\"))"
"df.to_csv(data_path / \"RR_gage_data.csv\")"
]
},
{
Expand All @@ -407,7 +396,7 @@
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv(os.path.join(data_path, \"RR_gage_data.csv\"))\n",
"df = pd.read_csv(data_path / \"RR_gage_data.csv\", dtype={'site_no': object})\n",
"df[\"datetime\"] = pd.to_datetime(df[\"datetime\"])\n",
"df = df.set_index(\"datetime\")\n",
"df.head()"
Expand Down Expand Up @@ -501,6 +490,16 @@
"the `rename()` method accepts a dictionary that is formated `{current_col_name: new_col_name}`"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e79003ce",
"metadata": {},
"outputs": [],
"source": [
"info"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -648,7 +647,7 @@
"metadata": {},
"outputs": [],
"source": [
"cimis_file = os.path.join(data_path, \"santa_rosa_CIMIS_83.csv\")\n",
"cimis_file = data_path / \"santa_rosa_CIMIS_83.csv\"\n",
"df_cimis = pd.read_csv(cimis_file)\n",
"drop_list = [\"qc\"] + [f\"qc.{i}\" for i in range(1, 22)]\n",
"df_cimis.drop(columns=drop_list, inplace=True)\n",
Expand Down Expand Up @@ -1108,7 +1107,7 @@
"# add the decomposition trend to the dataframe to make plotting easy\n",
"df2[\"baseflow_trend\"] = decomposition.trend\n",
"\n",
"pdf_file = os.path.join(data_path, \"all_years_russian.pdf\")\n",
"pdf_file = data_path / \"all_years_russian.pdf\"\n",
"with PdfPages(pdf_file) as outpdf:\n",
" for year in sorted(df2.year.unique()):\n",
" plt.figure()\n",
Expand Down
1,590 changes: 1,517 additions & 73 deletions notebooks/part0_python_intro/10_Rasterio.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 676ac02

Please sign in to comment.