Skip to content

Commit

Permalink
Update the download_tide_model notebook to allow the user to select t…
Browse files Browse the repository at this point in the history
…he tide model to download
  • Loading branch information
2320sharon committed Jan 10, 2025
1 parent 573cb52 commit 8e30763
Showing 1 changed file with 37 additions and 97 deletions.
134 changes: 37 additions & 97 deletions Download_tide_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"![image](https://github.com/Doodleverse/CoastSeg/assets/61564689/5f188ced-0f7e-4732-b065-8eb8f2d54986)\n",
"\n",
"### Step 3: Account Verification\n",
"- **Confirmation Email:** After completing the registration, AVISO will send you a confirmation email. Check your inbox (and spam folder if necessary) for this email.\r",
"- **Confirmation Email:** After completing the registration, AVISO will send you a confirmation email. Check your inbox (and spam folder if necessary) for this email.\n",
"- **Verify Your Account**: Click on the link provided in the email to verify your account. This step is crucial to activate your account and gain access to the data models.\n",
"\n",
"### Step 4: Accessing Your Dashboard\n",
Expand Down Expand Up @@ -74,67 +74,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "2c9db87b-1512-4ac7-9e60-961f871f07b9",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "184dca22773f4c12ab94b10a189ea55e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Text(value='', description='Username:', placeholder='Enter username')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e78214c2301e446b94de0cbe0a898e91",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Password(description='Password:', placeholder='Enter password')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9998db3f74da4a389e11dc95ff671255",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(description='Submit', icon='check', style=ButtonStyle(), tooltip='Download Model')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "04744c4787f844af82d0763adc9f171d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"from IPython.display import display\n",
Expand All @@ -143,6 +86,9 @@
"# Create an output widget to capture error messages or other outputs\n",
"output_widget = widgets.Output()\n",
"\n",
"# Create a widget to display instructions\n",
"instructions_widget = widgets.HTML(value=\"<b>Download Tide Model Instructions</b><br>1. Select the model you want to download<br>2. Enter your username and password<br>3. Click Download\")\n",
"\n",
"# Create text input widget for username\n",
"username_input = widgets.Text(\n",
" value='',\n",
Expand All @@ -159,23 +105,46 @@
" disabled=False\n",
")\n",
"\n",
"# Create a dropdown widget for model selection\n",
"model_dropdown = widgets.Dropdown(\n",
" options=['fes2014', 'fes2022'],\n",
" value='fes2014',\n",
" description='Model:',\n",
" disabled=False,\n",
")\n",
"\n",
"\n",
"# Define a function to be called when the button is clicked\n",
"def on_button_click(button):\n",
" with output_widget:\n",
" # Clear any previous outputs\n",
" output_widget.clear_output()\n",
"\n",
" if not username_input.value:\n",
" print(\"Please enter your username\")\n",
" \n",
" if not password_input.value:\n",
" print(\"Please enter your password.\")\n",
" return\n",
"\n",
" try:\n",
" username = username_input.value\n",
" password = password_input.value\n",
" # Handle the username and password here\n",
" download_tide_model.download_fes_tides(user=username,password=password)\n",
" print(f\"Downloading the tide model {model_dropdown.value}...\")\n",
"\n",
" GZIP=True\n",
" if model_dropdown.value == 'fes2022':\n",
" GZIP=False\n",
" \n",
" download_tide_model.download_fes_tides(user=username,password=password,tide=[model_dropdown.value],gzip=GZIP)\n",
" # For security reasons, avoid printing the password\n",
" except Exception as e:\n",
" print(f\"Error: {e}\")\n",
"\n",
"# Create a button and set its properties\n",
"submit_button = widgets.Button(\n",
" description='Submit',\n",
" description='Download Model',\n",
" disabled=False,\n",
" button_style='', # 'success', 'info', 'warning', 'danger' or ''\n",
" tooltip='Download Model',\n",
Expand All @@ -186,7 +155,7 @@
"submit_button.on_click(on_button_click)\n",
"\n",
"# Display the widgets\n",
"display(username_input, password_input, submit_button,output_widget)"
"display(instructions_widget,model_dropdown,username_input, password_input, submit_button,output_widget)"
]
},
{
Expand All @@ -196,45 +165,16 @@
"source": [
"## 2. Clipping the Tide Model to the United States\n",
"---\n",
"### Overview\r\n",
"### Overview\n",
"The global tide mode can be computationally intensive when making predictions across vast areas.To optimize and streamline our tide predictions, we are adapting the global tide model to focus specifically on the United States. By segmenting the US into smaller, more manageable regions, we can enhance the speed and efficiency of our predictions.. By doing so, we can quickly identify and load the relevant regional model based on a given latitude and longitude, making tide predictions faster and more efficien.."
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "edae3939-0949-4fbc-885d-9c3d83242204",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9227c23d696449248376912b75494028",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Button(description='Clip Model', icon='scissors', style=ButtonStyle(), tooltip='Clip Model')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "dc70ef3798d244b98d0452fb2e26470f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"from IPython.display import display\n",
Expand Down Expand Up @@ -309,7 +249,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "tf12_coastseg",
"language": "python",
"name": "python3"
},
Expand All @@ -323,7 +263,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.10.16"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 8e30763

Please sign in to comment.