Skip to content

Commit d605ce4

Browse files
committed
in-cloud access updates to geostrophic balance tutorial
1 parent f8b8db4 commit d605ce4

3 files changed

Lines changed: 66 additions & 13 deletions

File tree

Intro_to_PO_Tutorials/Geostrophic_balance.ipynb

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"source": [
7979
"## Download the ECCO output\n",
8080
"\n",
81-
"If you haven't been through the Using Python to Download ECCO Datasets tutorial yet, I recommend going through it before proceeding further with this tutorial. If you've done that tutorial, you can save the [ecco_download.py](https://raw.githubusercontent.com/ECCO-GROUP/ECCO-v4-Python-Tutorial/master/ECCO-ACCESS/Downloading_ECCO_datasets_from_PODAAC/ecco_download.py) file on your local machine and use it to get the output we need to assess geostrophic balance.\n",
81+
"If you haven't been through the Using Python to Download ECCO Datasets tutorial yet, I recommend going through it before proceeding further with this tutorial.\n",
8282
"\n",
8383
"What fields will we need? Look at the geostrophic balance equations. On the left-hand side, the Coriolis parameter $f$ is a function of latitude which we can compute, so we only need to download horizontal velocities $u$ and $v$. On the right-hand side we need density $\\rho$ and pressure $p$, as well as the grid parameters that allow us to compute spatial derivatives.\n",
8484
"\n",
@@ -103,7 +103,14 @@
103103
"Now that the datasets we need have been identified, let's download them for the month of January 2000.\n",
104104
"\n",
105105
"\n",
106-
"> Tip: do you find yourself having to say \"PO.DAAC\", and wondering if you have to spell out all of those letters? Please don't...spare yourself! It's pronounced Poh-dack, and rhymes with \"low stack\", as in the amount of homework you can only hope for as a 1st year PO grad student. :-o"
106+
"> Tip: do you find yourself having to say \"PO.DAAC\", and wondering if you have to spell out all of those letters? Please don't...spare yourself! It's pronounced Poh-dack, and rhymes with \"low stack\", as in the amount of homework you can only hope for as a 1st year grad student. :-o\n",
107+
"\n",
108+
"\n",
109+
"### Download to your local machine\n",
110+
"\n",
111+
"This sub-section uses the `ecco_download.py` module to help get the datasets needed for this tutorial onto your local machine (laptop, university computing server, etc.) where you can use them offline. Download the module using [this link](https://raw.githubusercontent.com/ECCO-GROUP/ECCO-v4-Python-Tutorial/master/ECCO-ACCESS/Downloading_ECCO_datasets_from_PODAAC/ecco_download.py), and then run the cells below.\n",
112+
"\n",
113+
"> Tip: If you are running these tutorials on an instance in the Amazon Web Services (AWS) cloud, skip these cells and instead run the next section, [Download to your AWS instance](https://ecco-v4-python-tutorial.readthedocs.io/Geostrophic_balance.html#Download-to-your-AWS-instance)."
107114
]
108115
},
109116
{
@@ -176,10 +183,10 @@
176183
],
177184
"source": [
178185
"# download file (granule) containing Jan 2000 velocities,\n",
179-
"# to default path ~/Downloads/ECCO_V4r4_PODAAC/\n",
186+
"download_root_dir = join(user_home_dir,'Downloads','ECCO_V4r4_PODAAC') # this is the default path used for download_root_dir\n",
180187
"vel_monthly_shortname = \"ECCO_L4_OCEAN_VEL_LLC0090GRID_MONTHLY_V4R4\"\n",
181188
"ecco_podaac_download(ShortName=vel_monthly_shortname,\\\n",
182-
" StartDate=\"2000-01-01\",EndDate=\"2000-01-31\",download_root_dir=None,\\\n",
189+
" StartDate=\"2000-01\",EndDate=\"2000-01\",download_root_dir=download_root_dir,\\\n",
183190
" n_workers=6,force_redownload=False)"
184191
]
185192
},
@@ -209,16 +216,14 @@
209216
"# to default path ~/Downloads/ECCO_V4r4_PODAAC/\n",
210217
"denspress_monthly_shortname = \"ECCO_L4_DENS_STRAT_PRESS_LLC0090GRID_MONTHLY_V4R4\"\n",
211218
"ecco_podaac_download(ShortName=denspress_monthly_shortname,\\\n",
212-
" StartDate=\"2000-01-01\",EndDate=\"2000-01-31\",download_root_dir=None,\\\n",
219+
" StartDate=\"2000-01\",EndDate=\"2000-01\",download_root_dir=None,\\\n",
213220
" n_workers=6,force_redownload=False)"
214221
]
215222
},
216223
{
217224
"cell_type": "markdown",
218225
"metadata": {},
219226
"source": [
220-
"Notice that the StartDate for each of the downloads was set to the 2nd of the month (2000-01-02) not the 1st. If it is set to the 1st, then the file for Dec 1999 will also be downloaded (which ends on 2000-01-01).\n",
221-
"\n",
222227
"Once you have downloaded the monthly files for velocities and density/pressure, let's also download daily files for each (2000-01-01). Consulting the \"Daily Means\" list of variables, the ShortNames of the datasets needed are very similar; MONTHLY is just replaced with DAILY."
223228
]
224229
},
@@ -306,7 +311,56 @@
306311
"cell_type": "markdown",
307312
"metadata": {},
308313
"source": [
309-
"Now check the directory where the ECCO output was downloaded to, this will be under ~/Downloads/ECCO_V4r4_PODAAC/ unless you changed the path under the ```download_root_dir``` option. There should be (at least) 5 subfolders corresponding to 2 datasets each of monthly and daily means, as well as a folder for the grid parameters. The monthly mean folders contain 1 file each for Jan 2000, the daily mean folders contain 2 files each (1999-12-31 and 2000-01-01)."
314+
"Now check the directory where the ECCO output was downloaded to, this will be under ~/Downloads/ECCO_V4r4_PODAAC/ unless you changed the path under the ```download_root_dir``` option. There should be (at least) 5 subfolders corresponding to 2 datasets each of monthly and daily means, as well as a folder for the grid parameters. The monthly mean folders contain 1 file each for Jan 2000, the daily mean folders contain 1 file each for 2000-01-01.\n",
315+
"\n",
316+
"\n",
317+
"### Download to your AWS instance\n",
318+
"\n",
319+
"The cell below uses the `ecco_s3_retrieve.py` module to download to your instance (or open remotely) the datasets you need for this tutorial. If you followed the setup instructions in the [AWS Cloud setup](https://ecco-v4-python-tutorial.readthedocs.io/AWS_Cloud_getting_started.html) tutorial you already have access to this module, or you can download it [here](https://raw.githubusercontent.com/ECCO-GROUP/ECCO-v4-Python-Tutorial/master/ECCO-ACCESS/ecco_s3_retrieve.py).\n",
320+
"\n",
321+
"> Tip: In future tutorials, you will see there is a boolean variable `incloud_access` that is usually set to `False` by default. If you set this variable to `True`, the `ecco_s3_retrieve.py` module will access the datasets on the cloud properly from your instance."
322+
]
323+
},
324+
{
325+
"cell_type": "code",
326+
"execution_count": null,
327+
"metadata": {},
328+
"outputs": [],
329+
"source": [
330+
"# # only need this if ecco_s3_retrieve.py is in a different directory than the tutorial notebook\n",
331+
"# import sys\n",
332+
"# sys.path.append('/home/user/some_other_directory')\n",
333+
"\n",
334+
"# load module into workspace\n",
335+
"from ecco_s3_retrieve import *\n",
336+
"# query to see the syntax needed for the ecco_podaac_s3_get_diskaware function,\n",
337+
"# which assesses available disk space to make sure that there is sufficient storage to download the ECCO datasets,\n",
338+
"# and opens them \"remotely\" on S3 otherwise\n",
339+
"help(ecco_podaac_s3_get_diskaware)"
340+
]
341+
},
342+
{
343+
"cell_type": "code",
344+
"execution_count": null,
345+
"metadata": {},
346+
"outputs": [],
347+
"source": [
348+
"incloud_access = True\n",
349+
"\n",
350+
"ShortNames_monthly_list = [\"ECCO_L4_OCEAN_VEL_LLC0090GRID_MONTHLY_V4R4\",\\\n",
351+
" \"ECCO_L4_DENS_STRAT_PRESS_LLC0090GRID_MONTHLY_V4R4\"]\n",
352+
"ShortNames_daily_list = [\"ECCO_L4_OCEAN_VEL_LLC0090GRID_DAILY_V4R4\",\\\n",
353+
" \"ECCO_L4_DENS_STRAT_PRESS_LLC0090GRID_DAILY_V4R4\"]\n",
354+
"if incloud_access == True:\n",
355+
" download_root_dir = join(user_home_dir,'Downloads','ECCO_V4r4_PODAAC')\n",
356+
" files_nested_list = ecco_podaac_s3_get_diskaware(ShortNames=ShortNames_monthly_list,\\\n",
357+
" StartDate='2000-01',EndDate='2000-01',\\\n",
358+
" max_avail_frac=0.5,\\\n",
359+
" download_root_dir=download_root_dir)\n",
360+
" files_nested_list = ecco_podaac_s3_get_diskaware(ShortNames=ShortNames_daily_list,\\\n",
361+
" StartDate='2000-01-01',EndDate='2000-01-01',\\\n",
362+
" max_avail_frac=0.5,\\\n",
363+
" download_root_dir=download_root_dir)"
310364
]
311365
},
312366
{
@@ -349,7 +403,6 @@
349403
"import matplotlib.pyplot as plt\n",
350404
"\n",
351405
"# locate files to load\n",
352-
"download_root_dir = join(user_home_dir,'Downloads','ECCO_V4r4_PODAAC')\n",
353406
"download_dir = join(download_root_dir,denspress_monthly_shortname)\n",
354407
"curr_denspress_files = list(glob.glob(join(download_dir,'*nc')))\n",
355408
"\n",
@@ -5317,7 +5370,6 @@
53175370
],
53185371
"source": [
53195372
"# locate files to load\n",
5320-
"download_root_dir = join(user_home_dir,'Downloads','ECCO_V4r4_PODAAC')\n",
53215373
"download_dir = join(download_root_dir,vel_monthly_shortname)\n",
53225374
"curr_vel_files = list(glob.glob(join(download_dir,'*nc')))\n",
53235375
"\n",
@@ -7558,7 +7610,7 @@
75587610
"name": "python",
75597611
"nbconvert_exporter": "python",
75607612
"pygments_lexer": "ipython3",
7561-
"version": "3.9.13"
7613+
"version": "3.11.8"
75627614
},
75637615
"vscode": {
75647616
"interpreter": {
@@ -7567,5 +7619,5 @@
75677619
}
75687620
},
75697621
"nbformat": 4,
7570-
"nbformat_minor": 2
7622+
"nbformat_minor": 4
75717623
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../ECCO-ACCESS/Downloading_ECCO_datasets_from_PODAAC/ecco_download.py
1+
../ECCO-ACCESS/ecco_download.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../ECCO-ACCESS/ecco_s3_retrieve.py

0 commit comments

Comments
 (0)