From 285c91c594fdc576320d1c87cee045a06d9e469d Mon Sep 17 00:00:00 2001 From: Mike Fienen Date: Tue, 23 Sep 2025 09:17:36 -0500 Subject: [PATCH 1/2] refactor pathlib import to be just Path (not pl.Path) and clear notebook output --- .../01_functions_scripts.ipynb | 2 +- .../03_useful-std-library-modules.ipynb | 14 +- .../04_files_and_strings.ipynb | 8 +- .../part0_python_intro/06_matplotlib.ipynb | 8 +- .../06b_matplotlib_animation.ipynb | 10 +- .../07a_Theis-exercise.ipynb | 8 +- .../09_b_Geopandas_ABQ.ipynb | 4 +- .../10a_Rasterio_intro.ipynb | 16 +- .../10b_Rasterio_advanced.ipynb | 16 +- .../solutions/00_python_basics_review.ipynb | 2 +- .../00_skills_test_on_basics__solution.ipynb | 2 +- .../01_functions_script__solution.ipynb | 2 +- ...e_objects_modules_packages__solution.ipynb | 2 +- ...useful-std-library-modules-solutions.ipynb | 2 +- .../solutions/04_files_and_strings.ipynb | 10 +- .../solutions/05_numpy__solutions.ipynb | 2 +- .../solutions/06_matplotlib__solution.ipynb | 6 +- .../07a_Theis-exercise-solution.ipynb | 2 +- .../solutions/10a_Rasterio_into.ipynb | 6 +- .../10a_prt_particle_tracking-demo.ipynb | 182 ++---------------- 20 files changed, 66 insertions(+), 238 deletions(-) diff --git a/notebooks/part0_python_intro/01_functions_scripts.ipynb b/notebooks/part0_python_intro/01_functions_scripts.ipynb index 68fb46a0..85857036 100644 --- a/notebooks/part0_python_intro/01_functions_scripts.ipynb +++ b/notebooks/part0_python_intro/01_functions_scripts.ipynb @@ -691,7 +691,7 @@ ], "metadata": { "kernelspec": { - "display_name": "pyclass", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" } diff --git a/notebooks/part0_python_intro/03_useful-std-library-modules.ipynb b/notebooks/part0_python_intro/03_useful-std-library-modules.ipynb index ecde13ba..50cc7d71 100644 --- a/notebooks/part0_python_intro/03_useful-std-library-modules.ipynb +++ b/notebooks/part0_python_intro/03_useful-std-library-modules.ipynb @@ -1254,21 +1254,9 @@ ], "metadata": { "kernelspec": { - "display_name": "pyclass", + "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.11.11" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/04_files_and_strings.ipynb b/notebooks/part0_python_intro/04_files_and_strings.ipynb index a224f347..d08075e3 100644 --- a/notebooks/part0_python_intro/04_files_and_strings.ipynb +++ b/notebooks/part0_python_intro/04_files_and_strings.ipynb @@ -22,12 +22,12 @@ "outputs": [], "source": [ "import sys\n", - "import pathlib as pl\n", + "from pathlib import Path\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "# set up the path to our data\n", - "pthnb = pl.Path('data') / 'fileio'\n", + "pthnb = Path('data') / 'fileio'\n", "assert pthnb.is_dir()" ] }, @@ -259,7 +259,7 @@ "# the current working directory; now we use pathlib\n", "# os.getcwd()\n", "\n", - "cwd = pl.Path.cwd()\n", + "cwd = Path.cwd()\n", "print(cwd)" ] }, @@ -816,7 +816,7 @@ "metadata": {}, "source": [ "### Class Activity 4\n", - "Let's use the `file_filter` function to remove the comment lines from `'FileWithComments.txt'` and create `'FileWithOutComments.txt'`. Use one of the approaches discussed above to open, read, and print data in both files after calling the `file_filter` function. Remember to use the pl.Path() approach to access the file in the `pthnb` directory. \n", + "Let's use the `file_filter` function to remove the comment lines from `'FileWithComments.txt'` and create `'FileWithOutComments.txt'`. Use one of the approaches discussed above to open, read, and print data in both files after calling the `file_filter` function. Remember to use the Path() approach to access the file in the `pthnb` directory. \n", "\n", "Use the blank code block below to complete this activity." ] diff --git a/notebooks/part0_python_intro/06_matplotlib.ipynb b/notebooks/part0_python_intro/06_matplotlib.ipynb index 1923f00c..dc2de546 100644 --- a/notebooks/part0_python_intro/06_matplotlib.ipynb +++ b/notebooks/part0_python_intro/06_matplotlib.ipynb @@ -21,9 +21,9 @@ "source": [ "from IPython.display import clear_output, display\n", "\n", - "import pathlib as pl\n", + "from pathlib import Path\n", "\n", - "output_path = pl.Path(\"./data/matplotlib\")\n", + "output_path = Path(\"./data/matplotlib\")\n", "output_path.mkdir(exist_ok=True, parents=True)" ] }, @@ -1151,7 +1151,7 @@ "metadata": {}, "outputs": [], "source": [ - "path = pl.Path(f\"{output_path}/multipage_pdf.pdf\")\n", + "path = Path(f\"{output_path}/multipage_pdf.pdf\")\n", "y = np.sin(x * np.pi)\n", "\n", "with PdfPages(path) as pdf:\n", @@ -1177,7 +1177,7 @@ ], "metadata": { "kernelspec": { - "display_name": "lisus_p2", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" } diff --git a/notebooks/part0_python_intro/06b_matplotlib_animation.ipynb b/notebooks/part0_python_intro/06b_matplotlib_animation.ipynb index 597cb2b0..78619116 100644 --- a/notebooks/part0_python_intro/06b_matplotlib_animation.ipynb +++ b/notebooks/part0_python_intro/06b_matplotlib_animation.ipynb @@ -94,7 +94,13 @@ "source": [] } ], - "metadata": {}, + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + } + }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/notebooks/part0_python_intro/07a_Theis-exercise.ipynb b/notebooks/part0_python_intro/07a_Theis-exercise.ipynb index 45f6d30e..6d367371 100644 --- a/notebooks/part0_python_intro/07a_Theis-exercise.ipynb +++ b/notebooks/part0_python_intro/07a_Theis-exercise.ipynb @@ -179,7 +179,13 @@ "source": [] } ], - "metadata": {}, + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + } + }, "nbformat": 4, "nbformat_minor": 4 } diff --git a/notebooks/part0_python_intro/09_b_Geopandas_ABQ.ipynb b/notebooks/part0_python_intro/09_b_Geopandas_ABQ.ipynb index a24b035a..21c9f85c 100644 --- a/notebooks/part0_python_intro/09_b_Geopandas_ABQ.ipynb +++ b/notebooks/part0_python_intro/09_b_Geopandas_ABQ.ipynb @@ -16,7 +16,7 @@ "outputs": [], "source": [ "import geopandas as gp\n", - "import pathlib as pl\n", + "from pathlib import Path\n", "import fiona\n", "fiona.drvsupport.supported_drivers['libkml'] = 'rw' # enable KML support which is disabled by default\n", "fiona.drvsupport.supported_drivers['LIBKML'] = 'rw' # enable KML support which is disabled by default\n" @@ -39,7 +39,7 @@ "metadata": {}, "outputs": [], "source": [ - "datapath = pl.Path('./data/geopandas/abq/')" + "datapath = Path('./data/geopandas/abq/')" ] }, { diff --git a/notebooks/part0_python_intro/10a_Rasterio_intro.ipynb b/notebooks/part0_python_intro/10a_Rasterio_intro.ipynb index 33a6e4cf..77178c6f 100644 --- a/notebooks/part0_python_intro/10a_Rasterio_intro.ipynb +++ b/notebooks/part0_python_intro/10a_Rasterio_intro.ipynb @@ -23,7 +23,7 @@ "import rasterio\n", "from rasterio.plot import show\n", "import matplotlib.pyplot as plt\n", - "import pathlib as pl" + "from pathlib import Path" ] }, { @@ -33,7 +33,7 @@ "metadata": {}, "outputs": [], "source": [ - "data_path = pl.Path(\"data/rasterio\") # set path to raster data folder" + "data_path = Path(\"data/rasterio\") # set path to raster data folder" ] }, { @@ -815,18 +815,6 @@ "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.12.2" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/10b_Rasterio_advanced.ipynb b/notebooks/part0_python_intro/10b_Rasterio_advanced.ipynb index 8ab5c41c..40f888a3 100644 --- a/notebooks/part0_python_intro/10b_Rasterio_advanced.ipynb +++ b/notebooks/part0_python_intro/10b_Rasterio_advanced.ipynb @@ -50,7 +50,7 @@ "from rasterio import features\n", "import matplotlib.pyplot as plt\n", "from matplotlib.colors import LightSource\n", - "import pathlib as pl\n", + "from pathlib import Path\n", "\n", "# for elevation hillshade if we want to use it\n", "ls = LightSource(azdeg=315, altdeg=45)" @@ -73,7 +73,7 @@ "metadata": {}, "outputs": [], "source": [ - "data_path = pl.Path(\"data/rasterio\")\n", + "data_path = Path(\"data/rasterio\")\n", "\n", "dem_file_1970 = data_path / \"19700901_ned1_2003_adj_warp.tif\"\n", "dem_file_2008 = data_path / \"20080901_rainierlidar_30m-adj.tif\"\n", @@ -983,18 +983,6 @@ "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.12.2" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/solutions/00_python_basics_review.ipynb b/notebooks/part0_python_intro/solutions/00_python_basics_review.ipynb index 3c7039c5..ebf2124a 100644 --- a/notebooks/part0_python_intro/solutions/00_python_basics_review.ipynb +++ b/notebooks/part0_python_intro/solutions/00_python_basics_review.ipynb @@ -1406,7 +1406,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.13" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/solutions/00_skills_test_on_basics__solution.ipynb b/notebooks/part0_python_intro/solutions/00_skills_test_on_basics__solution.ipynb index 14512ff0..bbc56ad2 100644 --- a/notebooks/part0_python_intro/solutions/00_skills_test_on_basics__solution.ipynb +++ b/notebooks/part0_python_intro/solutions/00_skills_test_on_basics__solution.ipynb @@ -3568,7 +3568,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/solutions/01_functions_script__solution.ipynb b/notebooks/part0_python_intro/solutions/01_functions_script__solution.ipynb index cbd0de5f..55ab2b0d 100644 --- a/notebooks/part0_python_intro/solutions/01_functions_script__solution.ipynb +++ b/notebooks/part0_python_intro/solutions/01_functions_script__solution.ipynb @@ -917,7 +917,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/solutions/02_Namespace_objects_modules_packages__solution.ipynb b/notebooks/part0_python_intro/solutions/02_Namespace_objects_modules_packages__solution.ipynb index 56026e8b..09a27885 100644 --- a/notebooks/part0_python_intro/solutions/02_Namespace_objects_modules_packages__solution.ipynb +++ b/notebooks/part0_python_intro/solutions/02_Namespace_objects_modules_packages__solution.ipynb @@ -2408,7 +2408,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.3" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/solutions/03_useful-std-library-modules-solutions.ipynb b/notebooks/part0_python_intro/solutions/03_useful-std-library-modules-solutions.ipynb index 2de12668..ecc966ec 100644 --- a/notebooks/part0_python_intro/solutions/03_useful-std-library-modules-solutions.ipynb +++ b/notebooks/part0_python_intro/solutions/03_useful-std-library-modules-solutions.ipynb @@ -584,7 +584,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/solutions/04_files_and_strings.ipynb b/notebooks/part0_python_intro/solutions/04_files_and_strings.ipynb index 71c4759c..f871c91e 100644 --- a/notebooks/part0_python_intro/solutions/04_files_and_strings.ipynb +++ b/notebooks/part0_python_intro/solutions/04_files_and_strings.ipynb @@ -22,12 +22,12 @@ "outputs": [], "source": [ "import sys\n", - "import pathlib as pl\n", + "from pathlib import Path\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "# set up the path to our data\n", - "pthnb = pl.Path('../data/fileio')\n", + "pthnb = Path('../data/fileio')\n", "assert pthnb.is_dir()" ] }, @@ -361,7 +361,7 @@ "# the current working directory; now we use pathlib\n", "# os.getcwd()\n", "\n", - "cwd = pl.Path.cwd()\n", + "cwd = Path.cwd()\n", "print(cwd)" ] }, @@ -1159,7 +1159,7 @@ "metadata": {}, "source": [ "### Class Activity 4\n", - "Let's use the `file_filter` function to remove the comment lines from `'FileWithComments.txt'` and create `'FileWithOutComments.txt'`. Use one of the approaches discussed above to open, read, and print data in both files after calling the `file_filter` function. Remember to use the pl.Path() approach to access the file in the `pthnb` directory. \n", + "Let's use the `file_filter` function to remove the comment lines from `'FileWithComments.txt'` and create `'FileWithOutComments.txt'`. Use one of the approaches discussed above to open, read, and print data in both files after calling the `file_filter` function. Remember to use the Path() approach to access the file in the `pthnb` directory. \n", "\n", "Use the blank code block below to complete this activity." ] @@ -1197,7 +1197,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/solutions/05_numpy__solutions.ipynb b/notebooks/part0_python_intro/solutions/05_numpy__solutions.ipynb index 90ac97d6..bccf04e4 100644 --- a/notebooks/part0_python_intro/solutions/05_numpy__solutions.ipynb +++ b/notebooks/part0_python_intro/solutions/05_numpy__solutions.ipynb @@ -486,7 +486,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/solutions/06_matplotlib__solution.ipynb b/notebooks/part0_python_intro/solutions/06_matplotlib__solution.ipynb index 57f94e7a..dc098bc9 100644 --- a/notebooks/part0_python_intro/solutions/06_matplotlib__solution.ipynb +++ b/notebooks/part0_python_intro/solutions/06_matplotlib__solution.ipynb @@ -21,9 +21,9 @@ "source": [ "from IPython.display import clear_output, display\n", "\n", - "import pathlib as pl\n", + "from pathlib import Path\n", "\n", - "output_path = pl.Path(\"../data/matplotlib\")\n", + "output_path = Path(\"../data/matplotlib\")\n", "output_path.mkdir(exist_ok=True, parents=True)" ] }, @@ -1657,7 +1657,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/solutions/07a_Theis-exercise-solution.ipynb b/notebooks/part0_python_intro/solutions/07a_Theis-exercise-solution.ipynb index e5edde46..1a85c15b 100755 --- a/notebooks/part0_python_intro/solutions/07a_Theis-exercise-solution.ipynb +++ b/notebooks/part0_python_intro/solutions/07a_Theis-exercise-solution.ipynb @@ -354,7 +354,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.7" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/notebooks/part0_python_intro/solutions/10a_Rasterio_into.ipynb b/notebooks/part0_python_intro/solutions/10a_Rasterio_into.ipynb index 84668568..474362bd 100644 --- a/notebooks/part0_python_intro/solutions/10a_Rasterio_into.ipynb +++ b/notebooks/part0_python_intro/solutions/10a_Rasterio_into.ipynb @@ -23,7 +23,7 @@ "import rasterio\n", "from rasterio.plot import show\n", "import matplotlib.pyplot as plt\n", - "import pathlib as pl" + "from pathlib import Path" ] }, { @@ -33,7 +33,7 @@ "metadata": {}, "outputs": [], "source": [ - "data_path = pl.Path(\"../data/rasterio\") # set path to raster data folder" + "data_path = Path(\"../data/rasterio\") # set path to raster data folder" ] }, { @@ -1198,7 +1198,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.12.11" } }, "nbformat": 4, diff --git a/notebooks/part1_flopy/10a_prt_particle_tracking-demo.ipynb b/notebooks/part1_flopy/10a_prt_particle_tracking-demo.ipynb index 2ca5e5ab..8ec23325 100644 --- a/notebooks/part1_flopy/10a_prt_particle_tracking-demo.ipynb +++ b/notebooks/part1_flopy/10a_prt_particle_tracking-demo.ipynb @@ -15,15 +15,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:42.843261Z", - "iopub.status.busy": "2025-05-19T23:51:42.843261Z", - "iopub.status.idle": "2025-05-19T23:51:44.720376Z", - "shell.execute_reply": "2025-05-19T23:51:44.720376Z", - "shell.execute_reply.started": "2025-05-19T23:51:42.843261Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "from IPython.display import clear_output, display\n", @@ -48,15 +40,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:44.721381Z", - "iopub.status.busy": "2025-05-19T23:51:44.721381Z", - "iopub.status.idle": "2025-05-19T23:51:44.732875Z", - "shell.execute_reply": "2025-05-19T23:51:44.732875Z", - "shell.execute_reply.started": "2025-05-19T23:51:44.721381Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "# patch upper left and lower right\n", @@ -80,15 +64,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:44.734884Z", - "iopub.status.busy": "2025-05-19T23:51:44.734884Z", - "iopub.status.idle": "2025-05-19T23:51:44.739569Z", - "shell.execute_reply": "2025-05-19T23:51:44.739569Z", - "shell.execute_reply.started": "2025-05-19T23:51:44.734884Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "load_ws = Path('data/quadtree')\n", @@ -128,15 +104,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:44.740578Z", - "iopub.status.busy": "2025-05-19T23:51:44.740578Z", - "iopub.status.idle": "2025-05-19T23:51:46.326188Z", - "shell.execute_reply": "2025-05-19T23:51:46.326188Z", - "shell.execute_reply.started": "2025-05-19T23:51:44.740578Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "%%capture\n", @@ -154,15 +122,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:46.328195Z", - "iopub.status.busy": "2025-05-19T23:51:46.327194Z", - "iopub.status.idle": "2025-05-19T23:51:46.335263Z", - "shell.execute_reply": "2025-05-19T23:51:46.334255Z", - "shell.execute_reply.started": "2025-05-19T23:51:46.327194Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "gwf = sim.get_model(gwf_name)\n", @@ -179,15 +139,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:46.338264Z", - "iopub.status.busy": "2025-05-19T23:51:46.338264Z", - "iopub.status.idle": "2025-05-19T23:51:46.341860Z", - "shell.execute_reply": "2025-05-19T23:51:46.341860Z", - "shell.execute_reply.started": "2025-05-19T23:51:46.338264Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "sim.set_sim_path(gwf_ws)" @@ -221,15 +173,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:46.343869Z", - "iopub.status.busy": "2025-05-19T23:51:46.343869Z", - "iopub.status.idle": "2025-05-19T23:51:47.335786Z", - "shell.execute_reply": "2025-05-19T23:51:47.335786Z", - "shell.execute_reply.started": "2025-05-19T23:51:46.343869Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "%%capture\n", @@ -246,15 +190,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:47.336791Z", - "iopub.status.busy": "2025-05-19T23:51:47.336791Z", - "iopub.status.idle": "2025-05-19T23:51:48.248739Z", - "shell.execute_reply": "2025-05-19T23:51:48.247730Z", - "shell.execute_reply.started": "2025-05-19T23:51:47.336791Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "sim.run_simulation()" @@ -277,15 +213,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:48.249738Z", - "iopub.status.busy": "2025-05-19T23:51:48.249738Z", - "iopub.status.idle": "2025-05-19T23:51:49.499193Z", - "shell.execute_reply": "2025-05-19T23:51:49.498182Z", - "shell.execute_reply.started": "2025-05-19T23:51:48.249738Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(5, 9))\n", @@ -311,15 +239,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:49.500189Z", - "iopub.status.busy": "2025-05-19T23:51:49.499193Z", - "iopub.status.idle": "2025-05-19T23:51:49.710246Z", - "shell.execute_reply": "2025-05-19T23:51:49.710246Z", - "shell.execute_reply.started": "2025-05-19T23:51:49.500189Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "gx = GridIntersect(gwf.modelgrid)\n", @@ -643,15 +563,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:49.759280Z", - "iopub.status.busy": "2025-05-19T23:51:49.758283Z", - "iopub.status.idle": "2025-05-19T23:51:50.320224Z", - "shell.execute_reply": "2025-05-19T23:51:50.319210Z", - "shell.execute_reply.started": "2025-05-19T23:51:49.759280Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "prt_sim.run_simulation()" @@ -672,15 +584,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:50.326230Z", - "iopub.status.busy": "2025-05-19T23:51:50.324226Z", - "iopub.status.idle": "2025-05-19T23:51:50.336707Z", - "shell.execute_reply": "2025-05-19T23:51:50.335695Z", - "shell.execute_reply.started": "2025-05-19T23:51:50.326230Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "hobj = gwf.output.head()" @@ -689,15 +593,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:50.338705Z", - "iopub.status.busy": "2025-05-19T23:51:50.338705Z", - "iopub.status.idle": "2025-05-19T23:51:50.346022Z", - "shell.execute_reply": "2025-05-19T23:51:50.345014Z", - "shell.execute_reply.started": "2025-05-19T23:51:50.338705Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "hds = hobj.get_data()" @@ -713,15 +609,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:50.348023Z", - "iopub.status.busy": "2025-05-19T23:51:50.347022Z", - "iopub.status.idle": "2025-05-19T23:51:50.410326Z", - "shell.execute_reply": "2025-05-19T23:51:50.409317Z", - "shell.execute_reply.started": "2025-05-19T23:51:50.348023Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "particle_data = pd.read_csv(prt_model_ws / trackcsvfile_prt)\n", @@ -738,15 +626,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:50.435176Z", - "iopub.status.busy": "2025-05-19T23:51:50.434174Z", - "iopub.status.idle": "2025-05-19T23:51:51.973396Z", - "shell.execute_reply": "2025-05-19T23:51:51.973396Z", - "shell.execute_reply.started": "2025-05-19T23:51:50.435176Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(5, 9))\n", @@ -766,15 +646,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:51:51.974407Z", - "iopub.status.busy": "2025-05-19T23:51:51.974407Z", - "iopub.status.idle": "2025-05-19T23:52:39.589909Z", - "shell.execute_reply": "2025-05-19T23:52:39.588899Z", - "shell.execute_reply.started": "2025-05-19T23:51:51.974407Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(5, 9))\n", @@ -952,15 +824,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": { - "iopub.execute_input": "2025-05-19T23:52:41.021991Z", - "iopub.status.busy": "2025-05-19T23:52:41.021022Z", - "iopub.status.idle": "2025-05-19T23:52:43.070799Z", - "shell.execute_reply": "2025-05-19T23:52:43.069784Z", - "shell.execute_reply.started": "2025-05-19T23:52:41.021991Z" - } - }, + "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(6, 10))\n", @@ -984,18 +848,6 @@ "display_name": "pyclass", "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.12.11" } }, "nbformat": 4, From 659d59bee69556bf78e8eaa5a343fbedea6c1167 Mon Sep 17 00:00:00 2001 From: Mike Fienen Date: Tue, 23 Sep 2025 12:49:45 -0500 Subject: [PATCH 2/2] fixed more of the refactoring --- notebooks/clear_all_notebooks.py | 4 ++-- .../solutions/06_matplotlib__solution.ipynb | 2 +- .../part1_flopy/04_Modelgrid_and_intersection.ipynb | 4 ++-- .../04_Modelgrid_and_intersection_solution.ipynb | 4 ++-- .../part1_flopy/solutions/06-Project-quadtree.ipynb | 12 ++++++------ .../part1_flopy/solutions/06-Project-voronoi.ipynb | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/notebooks/clear_all_notebooks.py b/notebooks/clear_all_notebooks.py index 54bf0616..aab38f7c 100644 --- a/notebooks/clear_all_notebooks.py +++ b/notebooks/clear_all_notebooks.py @@ -1,5 +1,5 @@ import os -import pathlib as pl +from pathlib import Path import json import subprocess @@ -20,7 +20,7 @@ ] if __name__ == "__main__": - nbdir = pl.Path(".") + nbdir = Path(".") nbs = nbdir.rglob("*.ipynb") for nb in nbs: if ('solutions' not in str(nb) and diff --git a/notebooks/part0_python_intro/solutions/06_matplotlib__solution.ipynb b/notebooks/part0_python_intro/solutions/06_matplotlib__solution.ipynb index dc098bc9..9644ce14 100644 --- a/notebooks/part0_python_intro/solutions/06_matplotlib__solution.ipynb +++ b/notebooks/part0_python_intro/solutions/06_matplotlib__solution.ipynb @@ -1618,7 +1618,7 @@ "metadata": {}, "outputs": [], "source": [ - "path = pl.Path(f\"{output_path}/multipage_pdf.pdf\")\n", + "path = Path(f\"{output_path}/multipage_pdf.pdf\")\n", "y = np.sin(x * np.pi)\n", "\n", "with PdfPages(path) as pdf:\n", diff --git a/notebooks/part1_flopy/04_Modelgrid_and_intersection.ipynb b/notebooks/part1_flopy/04_Modelgrid_and_intersection.ipynb index 0c5c6a81..50f5bc28 100644 --- a/notebooks/part1_flopy/04_Modelgrid_and_intersection.ipynb +++ b/notebooks/part1_flopy/04_Modelgrid_and_intersection.ipynb @@ -27,7 +27,7 @@ "metadata": {}, "outputs": [], "source": [ - "import pathlib as pl\n", + "from pathlib import Path\n", "import flopy\n", "from flopy.utils.gridgen import Gridgen\n", "from flopy.utils import GridIntersect, Raster\n", @@ -38,7 +38,7 @@ "import geopandas as gpd\n", "\n", "# pd.options.mode.chained_assignment = None\n", - "data_path = pl.Path(\"data/modelgrid_intersection\")" + "data_path = Path(\"data/modelgrid_intersection\")" ] }, { diff --git a/notebooks/part1_flopy/solutions/04_Modelgrid_and_intersection_solution.ipynb b/notebooks/part1_flopy/solutions/04_Modelgrid_and_intersection_solution.ipynb index 78b5b2c3..0ecb4f27 100644 --- a/notebooks/part1_flopy/solutions/04_Modelgrid_and_intersection_solution.ipynb +++ b/notebooks/part1_flopy/solutions/04_Modelgrid_and_intersection_solution.ipynb @@ -35,7 +35,7 @@ }, "outputs": [], "source": [ - "import pathlib as pl\n", + "from pathlib import Path\n", "import flopy\n", "from flopy.utils.gridgen import Gridgen\n", "from flopy.utils import GridIntersect, Raster\n", @@ -46,7 +46,7 @@ "import geopandas as gpd\n", "\n", "# pd.options.mode.chained_assignment = None\n", - "data_path = pl.Path(\"../data/modelgrid_intersection\")" + "data_path = Path(\"../data/modelgrid_intersection\")" ] }, { diff --git a/notebooks/part1_flopy/solutions/06-Project-quadtree.ipynb b/notebooks/part1_flopy/solutions/06-Project-quadtree.ipynb index 6658e3ba..5815dbd8 100644 --- a/notebooks/part1_flopy/solutions/06-Project-quadtree.ipynb +++ b/notebooks/part1_flopy/solutions/06-Project-quadtree.ipynb @@ -15,7 +15,7 @@ "metadata": {}, "outputs": [], "source": [ - "import pathlib as pl\n", + "from pathlib import Path\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import geopandas as gpd\n", @@ -36,9 +36,9 @@ "source": [ "model_ws = \"../temp/quadtree/\"\n", "grid_ws = f\"{model_ws}grid/\"\n", - "pl.Path(grid_ws).mkdir(parents=True, exist_ok=True)\n", + "Path(grid_ws).mkdir(parents=True, exist_ok=True)\n", "\n", - "output_folder = pl.Path('../figures')\n", + "output_folder = Path('../figures')\n", "output_folder.mkdir(parents=True, exist_ok=True)" ] }, @@ -259,8 +259,8 @@ } ], "source": [ - "river_pth = (pl.Path(\"../data_project\") / \"Flowline_river\").resolve()\n", - "well_pth = (pl.Path(\"../data_project\") / \"pumping_well_locations\").resolve()\n", + "river_pth = (Path(\"../data_project\") / \"Flowline_river\").resolve()\n", + "well_pth = (Path(\"../data_project\") / \"pumping_well_locations\").resolve()\n", "river_pth, well_pth" ] }, @@ -1540,7 +1540,7 @@ ], "source": [ "name = \"project\"\n", - "# exe_name = pl.Path(\"/Users/jdhughes/Documents/Training/python-for-hydrology/notebooks/part1_flopy/day0\").resolve() / \"mf6\" #\"/Users/jdhughes/Documents/Development/modflow6/modflow6/bin/mf6\"\n", + "# exe_name = Path(\"/Users/jdhughes/Documents/Training/python-for-hydrology/notebooks/part1_flopy/day0\").resolve() / \"mf6\" #\"/Users/jdhughes/Documents/Development/modflow6/modflow6/bin/mf6\"\n", "exe_name = \"mf6\"\n", "exe_name" ] diff --git a/notebooks/part1_flopy/solutions/06-Project-voronoi.ipynb b/notebooks/part1_flopy/solutions/06-Project-voronoi.ipynb index 3305fa4c..7ea74d6a 100644 --- a/notebooks/part1_flopy/solutions/06-Project-voronoi.ipynb +++ b/notebooks/part1_flopy/solutions/06-Project-voronoi.ipynb @@ -15,7 +15,7 @@ "metadata": {}, "outputs": [], "source": [ - "import pathlib as pl\n", + "from pathlib import Path\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import geopandas as gpd\n", @@ -46,10 +46,10 @@ "source": [ "model_ws = \"../temp/voronoi/\"\n", "grid_ws = f\"{model_ws}grid/\"\n", - "pl.Path(grid_ws).mkdir(parents=True, exist_ok=True)\n", - "pl.Path('figures').mkdir(parents=True, exist_ok=True)\n", + "Path(grid_ws).mkdir(parents=True, exist_ok=True)\n", + "Path('figures').mkdir(parents=True, exist_ok=True)\n", "\n", - "output_folder = pl.Path('../figures')\n", + "output_folder = Path('../figures')\n", "output_folder.mkdir(parents=True, exist_ok=True)" ] },