|
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | 8 | "# Part 2: Thermal Wind\n", |
9 | | - "Andrew Delman, updated 2024-04-04.\n", |
| 9 | + "Andrew Delman, updated 2024-10-16.\n", |
10 | 10 | "\n", |
11 | 11 | "## Objectives\n", |
12 | 12 | "\n", |
|
61 | 61 | "\n", |
62 | 62 | "- **ECCO_L4_OCEAN_VEL_LLC0090GRID_MONTHLY_V4R4** (Jan 2000)\n", |
63 | 63 | "- **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", |
65 | 65 | "\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", |
67 | 69 | "\n", |
68 | 70 | "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```." |
69 | 71 | ] |
|
75 | 77 | "metadata": {}, |
76 | 78 | "outputs": [], |
77 | 79 | "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", |
78 | 88 | "# first import needed packages\n", |
79 | 89 | "import numpy as np\n", |
80 | 90 | "import xarray as xr\n", |
|
87 | 97 | "sys.path.append(join(user_home_dir,'ECCOv4-py')) # only needed if ecco_v4_py files are stored under this directory\n", |
88 | 98 | "import matplotlib.pyplot as plt\n", |
89 | 99 | "import ecco_v4_py as ecco\n", |
| 100 | + "import ecco_access as ea\n", |
90 | 101 | "from ecco_po_tutorials import * # import from ecco_po_tutorials.py module downloaded in the last tutorial\n", |
91 | 102 | "\n", |
| 103 | + "\n", |
92 | 104 | "# ShortNames\n", |
93 | 105 | "vel_monthly_shortname = \"ECCO_L4_OCEAN_VEL_LLC0090GRID_MONTHLY_V4R4\"\n", |
94 | 106 | "denspress_monthly_shortname = \"ECCO_L4_DENS_STRAT_PRESS_LLC0090GRID_MONTHLY_V4R4\"\n", |
|
102 | 114 | "metadata": {}, |
103 | 115 | "outputs": [], |
104 | 116 | "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", |
106 | 118 | "\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')" |
117 | 122 | ] |
118 | 123 | }, |
119 | 124 | { |
|
635 | 640 | "# now open density and grid parameter files\n", |
636 | 641 | "\n", |
637 | 642 | "# 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", |
645 | 647 | "ds_dens" |
646 | 648 | ] |
647 | 649 | }, |
|
664 | 666 | ], |
665 | 667 | "source": [ |
666 | 668 | "# 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", |
673 | 672 | "\n", |
674 | 673 | "# find index closest to target latitude\n", |
675 | 674 | "lat_target = 26.\n", |
|
1174 | 1173 | "outputs": [], |
1175 | 1174 | "source": [ |
1176 | 1175 | "# 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", |
1183 | 1180 | "\n", |
1184 | 1181 | "# interpolate velocities to center of grid cells\n", |
1185 | 1182 | "ds_vel.UVEL.values[np.isnan(ds_vel.UVEL.values)] = 0\n", |
|
1678 | 1675 | "name": "python", |
1679 | 1676 | "nbconvert_exporter": "python", |
1680 | 1677 | "pygments_lexer": "ipython3", |
1681 | | - "version": "3.11.8" |
| 1678 | + "version": "3.11.9" |
1682 | 1679 | } |
1683 | 1680 | }, |
1684 | 1681 | "nbformat": 4, |
|
0 commit comments