From 3f66cf89b56b6949484c0991f881f3f8dd18c3ca Mon Sep 17 00:00:00 2001 From: changliao1025 Date: Thu, 10 Mar 2022 10:01:42 -0800 Subject: [PATCH] new path --- notebooks/pyflowline.ipynb | 1136 +-------------------- pyflowline/classes/pycase.py | 10 +- tests/configurations/template.json | 29 +- tests/configurations/template_basins.json | 12 +- tests/example/notebook.py | 22 +- 5 files changed, 56 insertions(+), 1153 deletions(-) diff --git a/notebooks/pyflowline.ipynb b/notebooks/pyflowline.ipynb index f83c02f..f3ca274 100644 --- a/notebooks/pyflowline.ipynb +++ b/notebooks/pyflowline.ipynb @@ -11,18 +11,10 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "d101804e", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "2022-03-03 12:44:09,324 is the time Pyflowline simulation started.\n" - ] - } - ], + "outputs": [], "source": [ "import sys\n", "\n", @@ -46,7 +38,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "84987ece", "metadata": {}, "outputs": [], @@ -68,18 +60,10 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "f6a280b6", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "/Users/liao313/workspace/python/pyflowline_icom/notebooks\n" - ] - } - ], + "outputs": [], "source": [ "from pathlib import Path\n", "from os.path import realpath\n", @@ -89,13 +73,16 @@ "\n", "iFlag_option = 1\n", "sPath = str( Path().resolve() )\n", - "sPath_data = realpath( sPath + '/../data/susquehanna' )\n", - "print(sPath)\n", + "sWorkspace_data = realpath( sPath + '/data/susquehanna' )\n", + "sWorkspace_input = str(Path(sWorkspace_data) / 'input')\n", + "sWorkspace_output= str(Path(sWorkspace_data) / 'output')\n", "\n", "if iFlag_option ==1:\n", " \n", - " sFilename_configuration_in = realpath(sPath + '/../tests/configurations/template.json' )\n", - " oPyflowline = pyflowline_generate_template_configuration_json_file(sFilename_configuration_in,sPath_data, sMesh_type_in=sMesh_type, iCase_index_in = iCase_index, sDate_in = sDate)\n", + " sFilename_configuration_in = realpath(sPath + '/tests/configurations/template.json' )\n", + " oPyflowline = pyflowline_generate_template_configuration_json_file(sFilename_configuration_in,\\\n", + " sWorkspace_input, sWorkspace_output, sMesh_type_in=sMesh_type, iCase_index_in = iCase_index, sDate_in = sDate)\n", + " \n", "else: \n", " if iFlag_option == 2:\n", " #an example configuration file is provided with the repository, \n", @@ -112,55 +99,16 @@ " else:\n", " sFilename_configuration_in =realpath( sPath + '/../tests/configurations/pyflowline_susquehanna_mpas.json' )\n", " \n", - " oPyflowline = pyflowline_read_model_configuration_file(sFilename_configuration_in)\n", + " oPyflowline = pyflowline_read_model_configuration_file(sFilename_configuration_in, iCase_index_in=iCase_index, dResolution_meter_in=dResolution_meter, sDate_in=sDate)\n", " " ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "4e96d31d", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\n", - " \"dLatitude_bot\": -90.0,\n", - " \"dLatitude_top\": 90.0,\n", - " \"dLongitude_left\": -180.0,\n", - " \"dLongitude_right\": 180.0,\n", - " \"dResolution_degree\": 0.5,\n", - " \"dResolution_meter\": 50000.0,\n", - " \"iCase_index\": 1,\n", - " \"iFlag_flowline\": 1,\n", - " \"iFlag_save_mesh\": 1,\n", - " \"iFlag_standalone\": 1,\n", - " \"iFlag_use_mesh_dem\": 0,\n", - " \"iFlag_use_shapefile_extent\": 0,\n", - " \"iMesh_type\": 4,\n", - " \"nOutlet\": 1,\n", - " \"sCase\": \"pyflowline20220301001\",\n", - " \"sDate\": \"20220301\",\n", - " \"sFilename_basins\": \"/Users/liao313/workspace/python/pyflowline_icom/tests/configurations/template_basins.json\",\n", - " \"sFilename_mesh\": \"/Users/liao313/workspace/python/pyflowline_icom/data/susquehanna/output/pyflowline20220301001/mpas.json\",\n", - " \"sFilename_mesh_info\": \"/Users/liao313/workspace/python/pyflowline_icom/data/susquehanna/output/pyflowline20220301001/mpas_mesh_info.json\",\n", - " \"sFilename_mesh_netcdf\": \"/Users/liao313/workspace/python/pyflowline_icom/data/susquehanna/input/lnd_cull_mesh.nc\",\n", - " \"sFilename_model_configuration\": \"/Users/liao313/workspace/python/pyflowline_icom/tests/configurations/template.json\",\n", - " \"sFilename_spatial_reference\": \"/Users/liao313/workspace/python/pyflowline_icom/data/susquehanna/input/boundary_proj.shp\",\n", - " \"sJob\": \"pyflowline\",\n", - " \"sMesh_type\": \"mpas\",\n", - " \"sModel\": \"pyflowline\",\n", - " \"sRegion\": \"susquehanna\",\n", - " \"sWorkspace_data\": \"/Users/liao313/workspace/python/pyflowline_icom/data/susquehanna\",\n", - " \"sWorkspace_data_project\": \"/Users/liao313/workspace/python/pyflowline_icom/data/susquehanna/pyflowline\",\n", - " \"sWorkspace_output\": \"/Users/liao313/workspace/python/pyflowline_icom/data/susquehanna/output/pyflowline20220301001\",\n", - " \"sWorkspace_project\": \"pyflowline\"\n", - "}\n" - ] - } - ], + "outputs": [], "source": [ "print(oPyflowline.tojson())\n" ] @@ -185,7 +133,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "65744d62", "metadata": {}, "outputs": [], @@ -196,7 +144,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "be0624e4", "metadata": {}, "outputs": [], @@ -209,34 +157,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "689984cb", "metadata": {}, - "outputs": [ - { - "ename": "KeyboardInterrupt", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m/Users/liao313/workspace/python/pyflowline_icom/notebooks/pyflowline.ipynb Cell 12'\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0m oPyflowline\u001b[39m.\u001b[39;49mflowline_simplification()\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/classes/pycase.py:323\u001b[0m, in \u001b[0;36mflowlinecase.flowline_simplification\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 321\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39miFlag_simplification \u001b[39m==\u001b[39m \u001b[39m1\u001b[39m: \n\u001b[1;32m 322\u001b[0m \u001b[39mfor\u001b[39;00m pBasin \u001b[39min\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39maBasin:\n\u001b[0;32m--> 323\u001b[0m aFlowline_basin \u001b[39m=\u001b[39m pBasin\u001b[39m.\u001b[39;49mflowline_simplification() \n\u001b[1;32m 324\u001b[0m aFlowline_out \u001b[39m=\u001b[39m aFlowline_out \u001b[39m+\u001b[39m aFlowline_basin\n\u001b[1;32m 326\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39maFlowline_simplified \u001b[39m=\u001b[39m aFlowline_out\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/classes/basin.py:286\u001b[0m, in \u001b[0;36mpybasin.flowline_simplification\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 284\u001b[0m point[\u001b[39m'\u001b[39m\u001b[39mdLatitude_degree\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mdLatitude_outlet_degree\n\u001b[1;32m 285\u001b[0m pVertex_outlet\u001b[39m=\u001b[39mpyvertex(point)\n\u001b[0;32m--> 286\u001b[0m aFlowline_basin_simplified \u001b[39m=\u001b[39m correct_flowline_direction(aFlowline_basin_simplified, pVertex_outlet )\n\u001b[1;32m 287\u001b[0m pVertex_outlet \u001b[39m=\u001b[39m aFlowline_basin_simplified[\u001b[39m0\u001b[39m]\u001b[39m.\u001b[39mpVertex_end\n\u001b[1;32m 288\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mpVertex_outlet \u001b[39m=\u001b[39m pVertex_outlet\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/algorithms/direction/correct_flowline_direction.py:106\u001b[0m, in \u001b[0;36mcorrect_flowline_direction\u001b[0;34m(aFlowline_in, pVertex_outlet_in)\u001b[0m\n\u001b[1;32m 103\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 104\u001b[0m \u001b[39mpass\u001b[39;00m\n\u001b[0;32m--> 106\u001b[0m tag_upstream(pVertex_start, pVertex_end)\n\u001b[1;32m 108\u001b[0m \u001b[39mreturn\u001b[39;00m aFlowline_out\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/algorithms/direction/correct_flowline_direction.py:100\u001b[0m, in \u001b[0;36mcorrect_flowline_direction..tag_upstream\u001b[0;34m(pVertex_start_in, pVertex_end_in)\u001b[0m\n\u001b[1;32m 98\u001b[0m aFlowline_out\u001b[39m.\u001b[39mappend(pFlowline)\n\u001b[1;32m 99\u001b[0m lID \u001b[39m=\u001b[39m lID \u001b[39m+\u001b[39m \u001b[39m1\u001b[39m\n\u001b[0;32m--> 100\u001b[0m tag_upstream( pFlowline\u001b[39m.\u001b[39;49mpVertex_start, pFlowline\u001b[39m.\u001b[39;49mpVertex_end ) \n\u001b[1;32m 102\u001b[0m \u001b[39mpass\u001b[39;00m\n\u001b[1;32m 103\u001b[0m \u001b[39melse\u001b[39;00m:\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/algorithms/direction/correct_flowline_direction.py:100\u001b[0m, in \u001b[0;36mcorrect_flowline_direction..tag_upstream\u001b[0;34m(pVertex_start_in, pVertex_end_in)\u001b[0m\n\u001b[1;32m 98\u001b[0m aFlowline_out\u001b[39m.\u001b[39mappend(pFlowline)\n\u001b[1;32m 99\u001b[0m lID \u001b[39m=\u001b[39m lID \u001b[39m+\u001b[39m \u001b[39m1\u001b[39m\n\u001b[0;32m--> 100\u001b[0m tag_upstream( pFlowline\u001b[39m.\u001b[39;49mpVertex_start, pFlowline\u001b[39m.\u001b[39;49mpVertex_end ) \n\u001b[1;32m 102\u001b[0m \u001b[39mpass\u001b[39;00m\n\u001b[1;32m 103\u001b[0m \u001b[39melse\u001b[39;00m:\n", - " \u001b[0;31m[... skipping similar frames: correct_flowline_direction..tag_upstream at line 100 (236 times)]\u001b[0m\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/algorithms/direction/correct_flowline_direction.py:100\u001b[0m, in \u001b[0;36mcorrect_flowline_direction..tag_upstream\u001b[0;34m(pVertex_start_in, pVertex_end_in)\u001b[0m\n\u001b[1;32m 98\u001b[0m aFlowline_out\u001b[39m.\u001b[39mappend(pFlowline)\n\u001b[1;32m 99\u001b[0m lID \u001b[39m=\u001b[39m lID \u001b[39m+\u001b[39m \u001b[39m1\u001b[39m\n\u001b[0;32m--> 100\u001b[0m tag_upstream( pFlowline\u001b[39m.\u001b[39;49mpVertex_start, pFlowline\u001b[39m.\u001b[39;49mpVertex_end ) \n\u001b[1;32m 102\u001b[0m \u001b[39mpass\u001b[39;00m\n\u001b[1;32m 103\u001b[0m \u001b[39melse\u001b[39;00m:\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/algorithms/direction/correct_flowline_direction.py:85\u001b[0m, in \u001b[0;36mcorrect_flowline_direction..tag_upstream\u001b[0;34m(pVertex_start_in, pVertex_end_in)\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[39mpass\u001b[39;00m\n\u001b[1;32m 84\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m---> 85\u001b[0m nUpstream, aUpstream, aReverse \u001b[39m=\u001b[39m find_upstream_flowline(pVertex_start_in, pVertex_end_in)\n\u001b[1;32m 86\u001b[0m \u001b[39mif\u001b[39;00m nUpstream \u001b[39m>\u001b[39m \u001b[39m0\u001b[39m:\n\u001b[1;32m 87\u001b[0m \u001b[39mglobal\u001b[39;00m lID\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/algorithms/direction/correct_flowline_direction.py:58\u001b[0m, in \u001b[0;36mcorrect_flowline_direction..find_upstream_flowline\u001b[0;34m(pVertex_start_in, pVertex_end_in)\u001b[0m\n\u001b[1;32m 56\u001b[0m pVerter_start \u001b[39m=\u001b[39m pFlowline\u001b[39m.\u001b[39mpVertex_start\n\u001b[1;32m 57\u001b[0m pVerter_end \u001b[39m=\u001b[39m pFlowline\u001b[39m.\u001b[39mpVertex_end\n\u001b[0;32m---> 58\u001b[0m \u001b[39mif\u001b[39;00m pVerter_end \u001b[39m==\u001b[39;49m pVertex_start_in \u001b[39mand\u001b[39;00m pVerter_start\u001b[39m!=\u001b[39mpVertex_end_in:\n\u001b[1;32m 59\u001b[0m \u001b[39mif\u001b[39;00m aFlag_process[i] \u001b[39m!=\u001b[39m \u001b[39m1\u001b[39m:\n\u001b[1;32m 60\u001b[0m nUpstream \u001b[39m=\u001b[39m nUpstream \u001b[39m+\u001b[39m \u001b[39m1\u001b[39m\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/classes/vertex.py:53\u001b[0m, in \u001b[0;36mpyvertex.__eq__\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 50\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__eq__\u001b[39m(\u001b[39mself\u001b[39m, other):\n\u001b[1;32m 51\u001b[0m iFlag \u001b[39m=\u001b[39m \u001b[39m-\u001b[39m\u001b[39m1\u001b[39m\n\u001b[0;32m---> 53\u001b[0m c \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mcalculate_distance(other)\n\u001b[1;32m 54\u001b[0m \u001b[39mif\u001b[39;00m( c \u001b[39m<\u001b[39m \u001b[39m1.0E-6\u001b[39m ): \u001b[39m#be careful\u001b[39;00m\n\u001b[1;32m 55\u001b[0m iFlag \u001b[39m=\u001b[39m \u001b[39m1\u001b[39m\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/classes/vertex.py:69\u001b[0m, in \u001b[0;36mpyvertex.calculate_distance\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 67\u001b[0m lon2 \u001b[39m=\u001b[39m other\u001b[39m.\u001b[39mdLongitude_degree\n\u001b[1;32m 68\u001b[0m lat2 \u001b[39m=\u001b[39m other\u001b[39m.\u001b[39mdLatitude_degree\n\u001b[0;32m---> 69\u001b[0m dDistance \u001b[39m=\u001b[39m calculate_distance_based_on_lon_lat(lon1, lat1, lon2, lat2) \n\u001b[1;32m 70\u001b[0m \u001b[39mreturn\u001b[39;00m dDistance\n", - "File \u001b[0;32m/opt/miniconda3/envs/pypfdemo/lib/python3.8/site-packages/pyflowline/algorithms/auxiliary/gdal_functions.py:293\u001b[0m, in \u001b[0;36mcalculate_distance_based_on_lon_lat\u001b[0;34m(lon1, lat1, lon2, lat2)\u001b[0m\n\u001b[1;32m 288\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 289\u001b[0m \u001b[39mCalculate the great circle distance between two points \u001b[39;00m\n\u001b[1;32m 290\u001b[0m \u001b[39mon the earth (specified in decimal degrees)\u001b[39;00m\n\u001b[1;32m 291\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 292\u001b[0m \u001b[39m# convert decimal degrees to radians \u001b[39;00m\n\u001b[0;32m--> 293\u001b[0m lon1, lat1, lon2, lat2 \u001b[39m=\u001b[39m \u001b[39mmap\u001b[39m(np\u001b[39m.\u001b[39mradians, [lon1, lat1, lon2, lat2])\n\u001b[1;32m 295\u001b[0m \u001b[39m# haversine formula \u001b[39;00m\n\u001b[1;32m 296\u001b[0m dlon \u001b[39m=\u001b[39m lon2 \u001b[39m-\u001b[39m lon1 \n", - "\u001b[0;31mKeyboardInterrupt\u001b[0m: " - ] - } - ], + "outputs": [], "source": [ "\n", "oPyflowline.flowline_simplification()\n" @@ -260,1028 +184,10 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "e898bc82", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "/Users/liao313/workspace/python/pyflowline_icom/data/susquehanna/output/pyflowline20220301001/mpas.json\n" - ] - }, - { - "data": { - "text/plain": [ - "[,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ,\n", - " ...]" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "print(oPyflowline.sFilename_mesh)\n", "\n", diff --git a/pyflowline/classes/pycase.py b/pyflowline/classes/pycase.py index 3c4e35a..23faa36 100644 --- a/pyflowline/classes/pycase.py +++ b/pyflowline/classes/pycase.py @@ -98,9 +98,9 @@ class flowlinecase(object): dLatitude_bot = -90 dLatitude_top = 90 sFilename_model_configuration='' - sWorkspace_input='' - #sWorkspace_project='' + sWorkspace_input='' sWorkspace_output='' + #sWorkspace_output_case='' sRegion='' sModel='' sMesh_type ='hexagon' @@ -139,9 +139,6 @@ def __init__(self, aConfig_in,\ if 'iFlag_flowline' in aConfig_in: self.iFlag_flowline = int(aConfig_in[ 'iFlag_flowline']) - - - if 'iFlag_global' in aConfig_in: self.iFlag_global = int(aConfig_in[ 'iFlag_global']) @@ -219,8 +216,7 @@ def __init__(self, aConfig_in,\ if 'sWorkspace_input' in aConfig_in: self.sWorkspace_input = aConfig_in[ 'sWorkspace_input'] - if 'sWorkspace_project' in aConfig_in: - self.sWorkspace_project= aConfig_in[ 'sWorkspace_project'] + if sWorkspace_output_in is not None: self.sWorkspace_output = sWorkspace_output_in diff --git a/tests/configurations/template.json b/tests/configurations/template.json index a2ceea1..f3073c6 100644 --- a/tests/configurations/template.json +++ b/tests/configurations/template.json @@ -7,23 +7,24 @@ "dResolution_meter": 50000.0, "iCase_index": 1, "iFlag_flowline": 1, + "iFlag_save_mesh": 1, "iFlag_standalone": 1, - "iFlag_use_shapefile_extent": 1, - "iMesh_type": 1, + "iFlag_use_mesh_dem": 0, + "iFlag_use_shapefile_extent": 0, + "iMesh_type": 4, "nOutlet": 1, - "sCase": "pyflowline20220110001", - "sDate": "20220110", - "sFilename_basins": "/qfs/people/liao313/workspace/python/pyflowline/notebooks/../tests/configurations/template_basins.json", - "sFilename_mesh": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/output/pyflowline20220110001/hexagon.json", - "sFilename_mesh_info": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/output/pyflowline20220110001/hexagon_mesh_info.json", - "sFilename_model_configuration": "/qfs/people/liao313/workspace/python/pyflowline/notebooks/../tests/configurations/template.json", - "sFilename_spatial_reference": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/boundary_proj.shp", + "sCase": "pyflowline20220308001", + "sDate": "20220308", + "sFilename_basins": "/qfs/people/liao313/workspace/python/pyflowline/tests/configurations/template_basins.json", + "sFilename_mesh": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/output/pyflowline20220308001/mpas.json", + "sFilename_mesh_info": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/output/pyflowline20220308001/mpas_mesh_info.json", + "sFilename_mesh_netcdf": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/input/lnd_cull_mesh.nc", + "sFilename_model_configuration": "/qfs/people/liao313/workspace/python/pyflowline/tests/configurations/template.json", + "sFilename_spatial_reference": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/input/boundary_proj.shp", "sJob": "pyflowline", - "sMesh_type": "hexagon", + "sMesh_type": "mpas", "sModel": "pyflowline", "sRegion": "susquehanna", - "sWorkspace_data": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna", - "sWorkspace_data_project": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/pyflowline", - "sWorkspace_output": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/output/pyflowline20220110001", - "sWorkspace_project": "pyflowline" + "sWorkspace_input": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/input", + "sWorkspace_output": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/output/pyflowline20220308001" } \ No newline at end of file diff --git a/tests/configurations/template_basins.json b/tests/configurations/template_basins.json index 69febaa..2a71d36 100644 --- a/tests/configurations/template_basins.json +++ b/tests/configurations/template_basins.json @@ -13,18 +13,18 @@ "sFilename_basin_info": "basin_info.json", "sFilename_confluence_conceptual_info": "confluence_conceptual_info.json", "sFilename_confluence_simplified_info": "confluence_simplified_info.json", - "sFilename_dam": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/ICoM_dams.csv", + "sFilename_dam": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/input/ICoM_dams.csv", "sFilename_flowline_conceptual": "flowline_conceptual.json", "sFilename_flowline_conceptual_info": "flowline_conceptual_info.json", "sFilename_flowline_edge": "flowline_edge.json", - "sFilename_flowline_filter": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/streamord7above.shp", - "sFilename_flowline_filter_json": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/output/pyflowline20220110001/001/flowline_filter.json", + "sFilename_flowline_filter": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/input/streamord7above.shp", + "sFilename_flowline_filter_json": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/output/001/flowline_filter.json", "sFilename_flowline_intersect": "flowline_intersect_mesh.json", - "sFilename_flowline_raw": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/allflowline.shp", + "sFilename_flowline_raw": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/input/allflowline.shp", "sFilename_flowline_segment_index_before_intersect": "flowline_segment_index_before_intersect.json", "sFilename_flowline_simplified": "flowline_simplified.json", "sFilename_flowline_simplified_info": "flowline_simplified_info.json", - "sFilename_flowline_topo": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/flowline.csv", - "sWorkspace_output_basin": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/output/pyflowline20220110001/001" + "sFilename_flowline_topo": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/input/flowline.csv", + "sWorkspace_output_basin": "/qfs/people/liao313/workspace/python/pyflowline/data/susquehanna/output/001" } ] \ No newline at end of file diff --git a/tests/example/notebook.py b/tests/example/notebook.py index e451988..959e352 100644 --- a/tests/example/notebook.py +++ b/tests/example/notebook.py @@ -57,32 +57,32 @@ def is_module_available(module_name): sPath = str( Path().resolve() ) iFlag_option = 1 +sWorkspace_data = realpath( sPath + '/data/susquehanna' ) +sWorkspace_input = str(Path(sWorkspace_data) / 'input') +sWorkspace_output= str(Path(sWorkspace_data) / 'output') if iFlag_option == 1: sFilename_configuration_in = realpath( sPath + '/tests/configurations/template.json' ) - sWorkspace_data = realpath( sPath + '/data/susquehanna' ) + oPyflowline = pyflowline_generate_template_configuration_json_file(sFilename_configuration_in,\ - sWorkspace_data, sMesh_type_in=sMesh_type, iCase_index_in = iCase_index, sDate_in = sDate) - print(oPyflowline.tojson()) + sWorkspace_input, sWorkspace_output, sMesh_type_in=sMesh_type, iCase_index_in = iCase_index, sDate_in = sDate) + print(oPyflowline.tojson()) else: if iFlag_option == 2: - #an example configuration file is provided with the repository, but you need to update this file based on your own case study - #linux - - + #an example configuration file is provided with the repository, but you need to update this file based on your own case study if sMesh_type=='hexagon': - sFilename_configuration_in = realpath( sPath + '/../configurations/pyflowline_susquehanna_hexagon.json' ) + sFilename_configuration_in = realpath( sPath + '/tests/configurations/pyflowline_susquehanna_hexagon.json' ) else: if sMesh_type=='square': - sFilename_configuration_in = realpath( sPath + '/../configurations/pyflowline_susquehanna_square.json' ) + sFilename_configuration_in = realpath( sPath + '/test/configurations/pyflowline_susquehanna_square.json' ) else: if sMesh_type=='latlon': - sFilename_configuration_in = realpath( sPath + '/../configurations/pyflowline_susquehanna_latlon.json' ) + sFilename_configuration_in = realpath( sPath + '/tests/configurations/pyflowline_susquehanna_latlon.json' ) else: - sFilename_configuration_in = realpath( sPath + '/../configurations/)pyflowline_susquehanna_mpas.json' ) + sFilename_configuration_in = realpath( sPath + '/tests/configurations/)pyflowline_susquehanna_mpas.json' ) oPyflowline = pyflowline_read_model_configuration_file(sFilename_configuration_in, iCase_index_in=iCase_index, dResolution_meter_in=dResolution_meter, sDate_in=sDate)