Skip to content

Commit

Permalink
Replaced Bash code to download data with Python
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcummins committed Mar 7, 2024
1 parent 26fabfd commit a18b227
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions PINNs_NavierStokes_HFM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@
"outputs": [],
"source": [
"import sys\n",
"import os\n",
"import requests\n",
"import zipfile\n",
"sys.path.insert(0, 'PINNs/Utilities/')\n",
"import tensorflow as tf\n",
"import numpy as np\n",
Expand Down Expand Up @@ -665,6 +668,41 @@
"fi"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "16acb23e-60d5-4fe7-83e6-5330ce71fd45",
"metadata": {},
"outputs": [],
"source": [
"# Check if the file 'Data/Stenosis2D.mat' exists\n",
"if not os.path.exists('Data/Stenosis2D.mat'):\n",
" print(\"Grabbing additional data...\")\n",
" \n",
" # Download the ZIP file\n",
" url = \"https://gitlab.com/CEMACHELEN1/lifd_ml_large_file_store/-/archive/main/lifd_ml_large_file_store-main.zip\"\n",
" response = requests.get(url)\n",
" \n",
" # Save the ZIP file\n",
" with open(\"lifd_ml_large_file_store-main.zip\", \"wb\") as zip_file:\n",
" zip_file.write(response.content)\n",
" \n",
" # Extract the contents\n",
" with zipfile.ZipFile(\"lifd_ml_large_file_store-main.zip\", \"r\") as zip_ref:\n",
" zip_ref.extractall(\"Data\")\n",
" \n",
" # Clean up\n",
" os.remove(\"lifd_ml_large_file_store-main.zip\")\n",
" \n",
" # Move the required file\n",
" os.rename(\"Data/lifd_ml_large_file_store-main/Physics_Informed_Neural_Networks/Data/Stenosis2D.mat\", \"Data/Stenosis2D.mat\")\n",
" \n",
" # List the contents of the 'Data' directory\n",
" print(\"Contents of 'Data':\")\n",
" for item in os.listdir(\"Data\"):\n",
" print(item)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit a18b227

Please sign in to comment.