diff --git a/book/thesis_projects/BSc/2024_Q2_ElineMol_CEG/Drafts/CMIP6/example_model_run_pcrglobwb.ipynb b/book/thesis_projects/BSc/2024_Q2_ElineMol_CEG/Drafts/CMIP6/example_model_run_pcrglobwb.ipynb index 8fe2179..2e5fd05 100644 --- a/book/thesis_projects/BSc/2024_Q2_ElineMol_CEG/Drafts/CMIP6/example_model_run_pcrglobwb.ipynb +++ b/book/thesis_projects/BSc/2024_Q2_ElineMol_CEG/Drafts/CMIP6/example_model_run_pcrglobwb.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 15, "id": "424992ea", "metadata": {}, "outputs": [], @@ -31,7 +31,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 16, "id": "cec50ce3", "metadata": {}, "outputs": [], @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 17, "id": "3f186494-1f05-445d-8663-306591c87320", "metadata": {}, "outputs": [], @@ -82,7 +82,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 18, "id": "3d38bc4c-fec2-4572-983b-376edbaefde3", "metadata": {}, "outputs": [], @@ -98,7 +98,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 19, "id": "fbabe50c", "metadata": {}, "outputs": [ @@ -150,23 +150,38 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 20, "id": "870c4af6", "metadata": {}, "outputs": [ { - "ename": "PermissionError", - "evalue": "[Errno 13] Permission denied: '/home/emol/forcing/csonoran_desert/work/diagnostic/script/ewatercycle_forcing.yaml'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mPermissionError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[6], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m forcing \u001b[38;5;241m=\u001b[39m \u001b[43mewatercycle\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mforcing\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msources\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mPCRGlobWBForcing\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[43m \u001b[49m\u001b[43mdirectory\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m/home/emol/forcing/csonoran_desert/work/diagnostic/script\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m)\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(forcing)\n", - "File \u001b[0;32m~/.local/lib/python3.12/site-packages/ewatercycle/base/forcing.py:271\u001b[0m, in \u001b[0;36mDefaultForcing.load\u001b[0;34m(cls, directory)\u001b[0m\n\u001b[1;32m 268\u001b[0m meta \u001b[38;5;241m=\u001b[39m data_source \u001b[38;5;241m/\u001b[39m FORCING_YAML\n\u001b[1;32m 269\u001b[0m yaml \u001b[38;5;241m=\u001b[39m YAML(typ\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msafe\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m--> 271\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[43mmeta\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexists\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m:\n\u001b[1;32m 272\u001b[0m msg \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 273\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mForcing file \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmeta\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m not found. \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 274\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPerhaps you want to use \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mcls\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m(...)?\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 275\u001b[0m )\n\u001b[1;32m 276\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m(msg)\n", - "File \u001b[0;32m/opt/conda/envs/ewatercycle2/lib/python3.12/pathlib.py:860\u001b[0m, in \u001b[0;36mPath.exists\u001b[0;34m(self, follow_symlinks)\u001b[0m\n\u001b[1;32m 853\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 854\u001b[0m \u001b[38;5;124;03mWhether this path exists.\u001b[39;00m\n\u001b[1;32m 855\u001b[0m \n\u001b[1;32m 856\u001b[0m \u001b[38;5;124;03mThis method normally follows symlinks; to check whether a symlink exists,\u001b[39;00m\n\u001b[1;32m 857\u001b[0m \u001b[38;5;124;03madd the argument follow_symlinks=False.\u001b[39;00m\n\u001b[1;32m 858\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 859\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 860\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstat\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfollow_symlinks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfollow_symlinks\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 861\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 862\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m _ignore_error(e):\n", - "File \u001b[0;32m/opt/conda/envs/ewatercycle2/lib/python3.12/pathlib.py:840\u001b[0m, in \u001b[0;36mPath.stat\u001b[0;34m(self, follow_symlinks)\u001b[0m\n\u001b[1;32m 835\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mstat\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39m, follow_symlinks\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m):\n\u001b[1;32m 836\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 837\u001b[0m \u001b[38;5;124;03m Return the result of the stat() system call on this path, like\u001b[39;00m\n\u001b[1;32m 838\u001b[0m \u001b[38;5;124;03m os.stat() does.\u001b[39;00m\n\u001b[1;32m 839\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 840\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mos\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstat\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfollow_symlinks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfollow_symlinks\u001b[49m\u001b[43m)\u001b[49m\n", - "\u001b[0;31mPermissionError\u001b[0m: [Errno 13] Permission denied: '/home/emol/forcing/csonoran_desert/work/diagnostic/script/ewatercycle_forcing.yaml'" - ] + "data": { + "text/html": [ + "
PCRGlobWBForcing(\n", + " start_time='2025-08-01T00:00:00Z',\n", + " end_time='2030-08-31T00:00:00Z',\n", + " directory=PosixPath('/home/emol/forcing/csonoran_desert/work/diagnostic/script'),\n", + " shape=PosixPath('/home/emol/forcing/csonoran_desert/work/diagnostic/script/hysets_09488650.shp'),\n", + " filenames={},\n", + " precipitationNC='pcrglobwb_CMIP6_MPI-ESM1-2-HR_day_ssp585_r1i1p1f1_pr_gn_2025-2030_hysets_09488650.nc',\n", + " temperatureNC='pcrglobwb_CMIP6_MPI-ESM1-2-HR_day_ssp585_r1i1p1f1_tas_gn_2025-2030_hysets_09488650.nc'\n", + ")\n", + "\n" + ], + "text/plain": [ + "\u001b[1;35mPCRGlobWBForcing\u001b[0m\u001b[1m(\u001b[0m\n", + " \u001b[33mstart_time\u001b[0m=\u001b[32m'2025-08-01T00:00:00Z'\u001b[0m,\n", + " \u001b[33mend_time\u001b[0m=\u001b[32m'2030-08-31T00:00:00Z'\u001b[0m,\n", + " \u001b[33mdirectory\u001b[0m=\u001b[1;35mPosixPath\u001b[0m\u001b[1m(\u001b[0m\u001b[32m'/home/emol/forcing/csonoran_desert/work/diagnostic/script'\u001b[0m\u001b[1m)\u001b[0m,\n", + " \u001b[33mshape\u001b[0m=\u001b[1;35mPosixPath\u001b[0m\u001b[1m(\u001b[0m\u001b[32m'/home/emol/forcing/csonoran_desert/work/diagnostic/script/hysets_09488650.shp'\u001b[0m\u001b[1m)\u001b[0m,\n", + " \u001b[33mfilenames\u001b[0m=\u001b[1m{\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[33mprecipitationNC\u001b[0m=\u001b[32m'pcrglobwb_CMIP6_MPI-ESM1-2-HR_day_ssp585_r1i1p1f1_pr_gn_2025-2030_hysets_09488650.nc'\u001b[0m,\n", + " \u001b[33mtemperatureNC\u001b[0m=\u001b[32m'pcrglobwb_CMIP6_MPI-ESM1-2-HR_day_ssp585_r1i1p1f1_tas_gn_2025-2030_hysets_09488650.nc'\u001b[0m\n", + "\u001b[1m)\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -188,10 +203,62 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "id": "08a4ed9e", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
PCRGlobWB(\n", + " parameter_set=ParameterSet(\n", + " name='custom_parameter_set',\n", + " directory=PosixPath('/data/shared/parameter-sets/pcrglobwb_global'),\n", + " config=PosixPath('pcrglobwb_sonoran_mpi-esm1-2-hr_05min.ini'),\n", + " doi='N/A',\n", + " target_model='pcrglobwb',\n", + " supported_model_versions={'setters'},\n", + " downloader=None\n", + " ),\n", + " forcing=PCRGlobWBForcing(\n", + " start_time='2025-08-01T00:00:00Z',\n", + " end_time='2030-08-31T00:00:00Z',\n", + " directory=PosixPath('/home/emol/forcing/csonoran_desert/work/diagnostic/script'),\n", + " shape=PosixPath('/home/emol/forcing/csonoran_desert/work/diagnostic/script/hysets_09488650.shp'),\n", + " filenames={},\n", + " precipitationNC='pcrglobwb_CMIP6_MPI-ESM1-2-HR_day_ssp585_r1i1p1f1_pr_gn_2025-2030_hysets_09488650.nc',\n", + " temperatureNC='pcrglobwb_CMIP6_MPI-ESM1-2-HR_day_ssp585_r1i1p1f1_tas_gn_2025-2030_hysets_09488650.nc'\n", + " )\n", + ")\n", + "\n" + ], + "text/plain": [ + "\u001b[1;35mPCRGlobWB\u001b[0m\u001b[1m(\u001b[0m\n", + " \u001b[33mparameter_set\u001b[0m=\u001b[1;35mParameterSet\u001b[0m\u001b[1m(\u001b[0m\n", + " \u001b[33mname\u001b[0m=\u001b[32m'custom_parameter_set'\u001b[0m,\n", + " \u001b[33mdirectory\u001b[0m=\u001b[1;35mPosixPath\u001b[0m\u001b[1m(\u001b[0m\u001b[32m'/data/shared/parameter-sets/pcrglobwb_global'\u001b[0m\u001b[1m)\u001b[0m,\n", + " \u001b[33mconfig\u001b[0m=\u001b[1;35mPosixPath\u001b[0m\u001b[1m(\u001b[0m\u001b[32m'pcrglobwb_sonoran_mpi-esm1-2-hr_05min.ini'\u001b[0m\u001b[1m)\u001b[0m,\n", + " \u001b[33mdoi\u001b[0m=\u001b[32m'N/A'\u001b[0m,\n", + " \u001b[33mtarget_model\u001b[0m=\u001b[32m'pcrglobwb'\u001b[0m,\n", + " \u001b[33msupported_model_versions\u001b[0m=\u001b[1m{\u001b[0m\u001b[32m'setters'\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[33mdownloader\u001b[0m=\u001b[3;35mNone\u001b[0m\n", + " \u001b[1m)\u001b[0m,\n", + " \u001b[33mforcing\u001b[0m=\u001b[1;35mPCRGlobWBForcing\u001b[0m\u001b[1m(\u001b[0m\n", + " \u001b[33mstart_time\u001b[0m=\u001b[32m'2025-08-01T00:00:00Z'\u001b[0m,\n", + " \u001b[33mend_time\u001b[0m=\u001b[32m'2030-08-31T00:00:00Z'\u001b[0m,\n", + " \u001b[33mdirectory\u001b[0m=\u001b[1;35mPosixPath\u001b[0m\u001b[1m(\u001b[0m\u001b[32m'/home/emol/forcing/csonoran_desert/work/diagnostic/script'\u001b[0m\u001b[1m)\u001b[0m,\n", + " \u001b[33mshape\u001b[0m=\u001b[1;35mPosixPath\u001b[0m\u001b[1m(\u001b[0m\u001b[32m'/home/emol/forcing/csonoran_desert/work/diagnostic/script/hysets_09488650.shp'\u001b[0m\u001b[1m)\u001b[0m,\n", + " \u001b[33mfilenames\u001b[0m=\u001b[1m{\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[33mprecipitationNC\u001b[0m=\u001b[32m'pcrglobwb_CMIP6_MPI-ESM1-2-HR_day_ssp585_r1i1p1f1_pr_gn_2025-2030_hysets_09488650.nc'\u001b[0m,\n", + " \u001b[33mtemperatureNC\u001b[0m=\u001b[32m'pcrglobwb_CMIP6_MPI-ESM1-2-HR_day_ssp585_r1i1p1f1_tas_gn_2025-2030_hysets_09488650.nc'\u001b[0m\n", + " \u001b[1m)\u001b[0m\n", + "\u001b[1m)\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "pcrglob = ewatercycle.models.PCRGlobWB(\n", " parameter_set=parameter_set,\n", @@ -202,10 +269,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 22, "id": "a45eba5c", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'setters'" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "pcrglob.version" ] @@ -220,10 +298,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 23, "id": "4a62965a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
dict_items([('start_time', '2025-08-01T00:00:00Z'), ('end_time', '2025-08-01T00:00:00Z'), ('routing_method', \n", + "'accuTravelTime'), ('max_spinups_in_years', '0')])\n", + "\n" + ], + "text/plain": [ + "\u001b[1;35mdict_items\u001b[0m\u001b[1m(\u001b[0m\u001b[1m[\u001b[0m\u001b[1m(\u001b[0m\u001b[32m'start_time'\u001b[0m, \u001b[32m'2025-08-01T00:00:00Z'\u001b[0m\u001b[1m)\u001b[0m, \u001b[1m(\u001b[0m\u001b[32m'end_time'\u001b[0m, \u001b[32m'2025-08-01T00:00:00Z'\u001b[0m\u001b[1m)\u001b[0m, \u001b[1m(\u001b[0m\u001b[32m'routing_method'\u001b[0m, \n", + "\u001b[32m'accuTravelTime'\u001b[0m\u001b[1m)\u001b[0m, \u001b[1m(\u001b[0m\u001b[32m'max_spinups_in_years'\u001b[0m, \u001b[32m'0'\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m\u001b[1m)\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "print(pcrglob.parameters)" ] @@ -238,10 +332,22 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "id": "cc852425", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "('/home/emol/repos/projects/book/thesis_projects/BSc/2024_Q2_ElineMol_CEG/Drafts/CMIP6/pcrglobwb_20241217_092442/pcrglobwb_ewatercycle.ini',\n", + " '/home/emol/repos/projects/book/thesis_projects/BSc/2024_Q2_ElineMol_CEG/Drafts/CMIP6/pcrglobwb_20241217_092442')" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "cfg_file, cfg_dir = pcrglob.setup(\n", " end_time=\"2025-08-31T00:00:00Z\",\n", @@ -252,10 +358,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "id": "4456b5e2", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
dict_items([('start_time', '2025-08-01T00:00:00Z'), ('end_time', '2025-08-31T00:00:00Z'), ('routing_method', \n", + "'accuTravelTime'), ('max_spinups_in_years', '0')])\n", + "\n" + ], + "text/plain": [ + "\u001b[1;35mdict_items\u001b[0m\u001b[1m(\u001b[0m\u001b[1m[\u001b[0m\u001b[1m(\u001b[0m\u001b[32m'start_time'\u001b[0m, \u001b[32m'2025-08-01T00:00:00Z'\u001b[0m\u001b[1m)\u001b[0m, \u001b[1m(\u001b[0m\u001b[32m'end_time'\u001b[0m, \u001b[32m'2025-08-31T00:00:00Z'\u001b[0m\u001b[1m)\u001b[0m, \u001b[1m(\u001b[0m\u001b[32m'routing_method'\u001b[0m, \n", + "\u001b[32m'accuTravelTime'\u001b[0m\u001b[1m)\u001b[0m, \u001b[1m(\u001b[0m\u001b[32m'max_spinups_in_years'\u001b[0m, \u001b[32m'0'\u001b[0m\u001b[1m)\u001b[0m\u001b[1m]\u001b[0m\u001b[1m)\u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "print(pcrglob.parameters)" ] @@ -270,7 +392,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "id": "87144041", "metadata": {}, "outputs": [], @@ -288,10 +410,78 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "id": "664b32b6-2b4c-49f1-be5a-b451fceb9ecc", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + " | PCRGlobWB: Sonoran Desert | \n", + "
---|---|
time | \n", + "\n", + " |
2025-08-01 00:00:00+00:00 | \n", + "NaN | \n", + "
2025-08-02 00:00:00+00:00 | \n", + "NaN | \n", + "
2025-08-03 00:00:00+00:00 | \n", + "NaN | \n", + "
2025-08-04 00:00:00+00:00 | \n", + "NaN | \n", + "
2025-08-05 00:00:00+00:00 | \n", + "NaN | \n", + "