Skip to content

Commit 82a424f

Browse files
committed
Some ecco_access updates to intro to PO tutorials
1 parent c90dbae commit 82a424f

3 files changed

Lines changed: 39 additions & 42 deletions

File tree

Intro_to_PO_Tutorials/Geostrophic_balance.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"metadata": {},
66
"source": [
77
"# Part 1: Geostrophic balance\n",
8-
"Andrew Delman, updated 2024-10-15.\n",
8+
"Andrew Delman, updated 2024-10-16.\n",
99
"\n",
1010
"## Objectives\n",
1111
"\n",
@@ -145,7 +145,7 @@
145145
"\n",
146146
"*ecco_access* provides a convenient function, `ecco_podaac_to_xrdataset` that accesses the requested output from PO.DAAC's cloud storage **and** opens an *xarray* dataset.\n",
147147
"\n",
148-
"We also can specify a \"mode\" option, which tells the function how to access these datasets. The default mode is `download_ifspace`, which downloads these tutorials to your local machine (under `~/Downloads/ECCO_V4r4_PODAAC/`) *if* the downloaded files would occupy less than 50% of available disk space.\n",
148+
"We also can specify a \"mode\" option, which tells the function how to access these datasets. The default mode is `download_ifspace`, which downloads these tutorials to your local machine (under `~/Downloads/ECCO_V4r4_PODAAC/`) *if* the downloaded files would occupy less than 50% of available disk space. See the [access modes](https://ecco-v4-python-tutorial.readthedocs.io/ECCO_access_modes.html) tutorial for more information on these modes.\n",
149149
"\n",
150150
"> Tip: If you are working in the AWS Cloud, you can specify `incloud_access = True`, which will then use mode = `s3_get_ifspace` by default. The `s3_get_ifspace` mode downloads the files to your local instance if they would occupy less than 50% of available disk space; otherwise the data are accessed remotely (typically slower).\n",
151151
"\n",
@@ -179,14 +179,14 @@
179179
"import ecco_v4_py as ecco\n",
180180
"import matplotlib.pyplot as plt\n",
181181
"\n",
182+
"# import ecco_access\n",
183+
"import ecco_access as ea\n",
184+
"\n",
182185
"# specify location to store downloaded files\n",
183186
"\n",
184187
"# ~/Downloads/ECCO_V4r4_PODAAC is also the default path used for download_root_dir; \n",
185188
"# change as needed\n",
186-
"download_root_dir = join(user_home_dir,'Downloads','ECCO_V4r4_PODAAC')\n",
187-
"\n",
188-
"# import ecco_access\n",
189-
"import ecco_access as ea"
189+
"download_root_dir = join(user_home_dir,'Downloads','ECCO_V4r4_PODAAC')"
190190
]
191191
},
192192
{
@@ -10364,7 +10364,7 @@
1036410364
"name": "python",
1036510365
"nbconvert_exporter": "python",
1036610366
"pygments_lexer": "ipython3",
10367-
"version": "3.12.3"
10367+
"version": "3.11.9"
1036810368
},
1036910369
"vscode": {
1037010370
"interpreter": {

Intro_to_PO_Tutorials/Steric_height.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,7 @@
22302230
"name": "python",
22312231
"nbconvert_exporter": "python",
22322232
"pygments_lexer": "ipython3",
2233-
"version": "3.11.8"
2233+
"version": "3.11.9"
22342234
}
22352235
},
22362236
"nbformat": 4,

Intro_to_PO_Tutorials/Thermal_wind.ipynb

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"metadata": {},
77
"source": [
88
"# Part 2: Thermal Wind\n",
9-
"Andrew Delman, updated 2024-04-04.\n",
9+
"Andrew Delman, updated 2024-10-16.\n",
1010
"\n",
1111
"## Objectives\n",
1212
"\n",
@@ -61,9 +61,11 @@
6161
"\n",
6262
"- **ECCO_L4_OCEAN_VEL_LLC0090GRID_MONTHLY_V4R4** (Jan 2000)\n",
6363
"- **ECCO_L4_DENS_STRAT_PRESS_LLC0090GRID_MONTHLY_V4R4** (Jan 2000)\n",
64-
"- **ECCO_L4_GEOMETRY_LLC0090GRID_V4R4** (no time dimension; can use any time 1992-2017 in download functions)\n",
64+
"- **ECCO_L4_GEOMETRY_LLC0090GRID_V4R4** (no time dimension)\n",
6565
"\n",
66-
"To download these datasets to your local machine, you can use the [ecco_download.py](https://raw.githubusercontent.com/ECCO-GROUP/ECCO-v4-Python-Tutorial/master/ecco_access/ecco_download.py) module. See the [previous tutorial](https://ecco-v4-python-tutorial.readthedocs.io/Geostrophic_balance.html#Download-the-ECCO-output) or the [ECCO download](https://ecco-v4-python-tutorial.readthedocs.io/Downloading_ECCO_Datasets_from_PODAAC_Python.html) for more info on how to use this module. If you are working on an AWS instance, just set `incloud_access = True` in the 2nd cell below and the datasets will be downloaded or opened remotely using the `ecco_s3_retrieve.py` module.\n",
66+
"To download these datasets to your local machine, you can use the `ecco_access` library; see the [*ecco_access* intro tutorial](https://ecco-v4-python-tutorial.readthedocs.io/ECCO_access_intro.html) for instructions on how to [set up](https://ecco-v4-python-tutorial.readthedocs.io/ECCO_access_intro.html#Setting-up-ecco_access) this library in your Python path. The \"access mode\" for retrieving the datasets is `download_ifspace` by default, which downloads the data (under `~/Downloads/ECCO_V4r4_PODAAC/`) only if it will occupy <50% of available storage. See the [access modes](https://ecco-v4-python-tutorial.readthedocs.io/ECCO_access_modes.html) tutorial for more information on these modes.\n",
67+
"\n",
68+
"> Tip: If you are working in the AWS Cloud, you can specify `incloud_access = True`, which will then use mode = `s3_get_ifspace` by default. The `s3_get_ifspace` mode downloads the files to your local instance if they would occupy less than 50% of available disk space; otherwise the data are accessed remotely (typically slower).\n",
6769
"\n",
6870
"We are going to load the density dataset and plot density on longitude-depth axes following the line in the grid nearest to $26^{o}$ N, i.e., ```i = 73```."
6971
]
@@ -75,6 +77,14 @@
7577
"metadata": {},
7678
"outputs": [],
7779
"source": [
80+
"# specify incloud_access = True if working in the AWS Cloud, otherwise False\n",
81+
"incloud_access = False\n",
82+
"\n",
83+
"if incloud_access:\n",
84+
" access_mode = 's3_get_ifspace'\n",
85+
"else:\n",
86+
" access_mode = 'download_ifspace'\n",
87+
"\n",
7888
"# first import needed packages\n",
7989
"import numpy as np\n",
8090
"import xarray as xr\n",
@@ -87,8 +97,10 @@
8797
"sys.path.append(join(user_home_dir,'ECCOv4-py')) # only needed if ecco_v4_py files are stored under this directory\n",
8898
"import matplotlib.pyplot as plt\n",
8999
"import ecco_v4_py as ecco\n",
100+
"import ecco_access as ea\n",
90101
"from ecco_po_tutorials import * # import from ecco_po_tutorials.py module downloaded in the last tutorial\n",
91102
"\n",
103+
"\n",
92104
"# ShortNames\n",
93105
"vel_monthly_shortname = \"ECCO_L4_OCEAN_VEL_LLC0090GRID_MONTHLY_V4R4\"\n",
94106
"denspress_monthly_shortname = \"ECCO_L4_DENS_STRAT_PRESS_LLC0090GRID_MONTHLY_V4R4\"\n",
@@ -102,18 +114,11 @@
102114
"metadata": {},
103115
"outputs": [],
104116
"source": [
105-
"# if working in the AWS cloud, set incloud_access = True and run this cell\n",
117+
"# specify location to store downloaded files\n",
106118
"\n",
107-
"incloud_access = False\n",
108-
"\n",
109-
"ShortNames_list = [vel_monthly_shortname,denspress_monthly_shortname,grid_params_shortname]\n",
110-
"if incloud_access == True:\n",
111-
" from ecco_s3_retrieve import ecco_podaac_s3_get_diskaware\n",
112-
" # download files to default path ~/Downloads/ECCO_V4r4_PODAAC/\n",
113-
" files_dict = ecco_podaac_s3_get_diskaware(ShortNames=ShortNames_list,\\\n",
114-
" StartDate='2000-01',EndDate='2000-01',\\\n",
115-
" max_avail_frac=0.5,\\\n",
116-
" download_root_dir=None)"
119+
"# ~/Downloads/ECCO_V4r4_PODAAC is also the default path used for download_root_dir; \n",
120+
"# change as needed\n",
121+
"download_root_dir = join(user_home_dir,'Downloads','ECCO_V4r4_PODAAC')"
117122
]
118123
},
119124
{
@@ -635,13 +640,10 @@
635640
"# now open density and grid parameter files\n",
636641
"\n",
637642
"# density file\n",
638-
"download_root_dir = join(user_home_dir,'Downloads','ECCO_V4r4_PODAAC')\n",
639-
"download_dir = join(download_root_dir,denspress_monthly_shortname)\n",
640-
"if incloud_access == True:\n",
641-
" curr_denspress_file = files_dict[denspress_monthly_shortname]\n",
642-
"else:\n",
643-
" curr_denspress_file = list(glob.glob(join(download_dir,'*2000-01*.nc')))\n",
644-
"ds_dens = xr.open_dataset(curr_denspress_file[0])\n",
643+
"ds_dens = xr.ecco_podaac_to_xrdataset(denspress_monthly_shortname,\\\n",
644+
" StartDate=\"2000-01\",EndDate=\"2000-01\",\\\n",
645+
" mode=access_mode,\\\n",
646+
" download_root_dir=download_root_dir)\n",
645647
"ds_dens"
646648
]
647649
},
@@ -664,12 +666,9 @@
664666
],
665667
"source": [
666668
"# load grid parameters file\n",
667-
"grid_params_file = \"GRID_GEOMETRY_ECCO_V4r4_native_llc0090.nc\"\n",
668-
"if incloud_access == True:\n",
669-
" grid_params_file_path = files_dict[grid_params_shortname]\n",
670-
"else:\n",
671-
" grid_params_file_path = join(download_root_dir,grid_params_shortname,grid_params_file)\n",
672-
"ds_grid = xr.open_dataset(grid_params_file_path)\n",
669+
"ds_grid = xr.ecco_podaac_to_xrdataset(grid_params_shortname,\\\n",
670+
" mode=access_mode,\\\n",
671+
" download_root_dir=download_root_dir)\n",
673672
"\n",
674673
"# find index closest to target latitude\n",
675674
"lat_target = 26.\n",
@@ -1174,12 +1173,10 @@
11741173
"outputs": [],
11751174
"source": [
11761175
"# load velocity dataset\n",
1177-
"download_dir = join(download_root_dir,vel_monthly_shortname)\n",
1178-
"if incloud_access == True:\n",
1179-
" curr_vel_file = files_dict[vel_monthly_shortname]\n",
1180-
"else:\n",
1181-
" curr_vel_file = list(glob.glob(join(download_dir,'*2000-01*.nc')))\n",
1182-
"ds_vel = xr.open_dataset(curr_vel_file[0])\n",
1176+
"ds_vel = xr.ecco_podaac_to_xrdataset(vel_monthly_shortname,\\\n",
1177+
" StartDate='2000-01',EndDate='2000-01',\\\n",
1178+
" mode=access_mode,\\\n",
1179+
" download_root_dir=download_root_dir)\n",
11831180
"\n",
11841181
"# interpolate velocities to center of grid cells\n",
11851182
"ds_vel.UVEL.values[np.isnan(ds_vel.UVEL.values)] = 0\n",
@@ -1678,7 +1675,7 @@
16781675
"name": "python",
16791676
"nbconvert_exporter": "python",
16801677
"pygments_lexer": "ipython3",
1681-
"version": "3.11.8"
1678+
"version": "3.11.9"
16821679
}
16831680
},
16841681
"nbformat": 4,

0 commit comments

Comments
 (0)