Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ _templates
*.ipynb_checkpoints*
/Tutorials_as_Jupyter_Notebooks/.ipynb_checkpoints/*
.README.md.swp
/ECCO-ACCESS/Downloading_ECCO_Datasets_from_PODAAC/~/
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"id": "d8999184",
"metadata": {},
"source": [
"# Tutorial Python 3 Notebook for Downloading ECCO Datasets from PO.DAAC\n",
"# Using Python to Download ECCO Datasets\n",
"\n",
"**Note: This notebook is modified from the tutorial on the [ECCO-GROUP Github](https://github.com/ECCO-GROUP/ECCO-ACCESS/blob/master/PODAAC/Downloading_ECCO_datasets_from_PODAAC/Tutorial_Python3_Jupyter_Notebook_Downloading_ECCO_Datasets_from_PODAAC.ipynb) by Jack McNelis and Ian Fenty, Version 1.1 dated 2021-06-25.**\n",
"**Note: This notebook was modified by Andrew Delman (updated 2022-12-15) from the tutorial on the [ECCO-GROUP Github](https://github.com/ECCO-GROUP/ECCO-ACCESS/blob/master/PODAAC/Downloading_ECCO_datasets_from_PODAAC/Tutorial_Python3_Jupyter_Notebook_Downloading_ECCO_Datasets_from_PODAAC.ipynb) by Jack McNelis and Ian Fenty, Version 1.1 dated 2021-06-25.**\n",
"\n",
"This notebook provides instructions for downloading a set of granules (files) for an ECCO \"Dataset\" hosted by PO.DAAC. The focus is on downloading datasets in the lat-lon-cap 90 (llc90) native grid of the ECCO v4 simulations, since the tutorials mostly use output on the native grid. If you're new to this grid geometry, don't worry! The ecco_v4_py package discussed in the previous tutorial will help you load the ECCO output, make computations, and plot the results while hardly needing to interact with the model grid.\n",
"This Jupyter notebook provides instructions and Python code for downloading a set of granules (files) for an ECCO \"Dataset\" hosted by PO.DAAC. The focus is on downloading datasets in the lat-lon-cap 90 (llc90) native grid of the ECCO v4 simulations, since the tutorials mostly use output on the native grid. If you're new to this grid geometry, don't worry! The ecco_v4_py package discussed in the previous tutorial will help you load the ECCO output, make computations, and plot the results while hardly needing to interact with the model grid.\n",
"\n",
"The example ECCO Dataset used in this tutorial is \"ECCO Sea Surface Height - Daily Mean llc90 Grid (Version 4 Release 4)\" which provides daily mean sea surface height on the native llc90 grid ([10.5067/ECL5D-SSH44](https://doi.org/10.5067/ECL5D-SSH44)). \n",
"\n",
Expand Down Expand Up @@ -925,7 +925,7 @@
"\n",
"[**ecco_download** module](../../ECCO-ACCESS/Downloading_ECCO_datasets_from_PODAAC/ecco_download.py)\n",
"\n",
"You can save this file either in the same directory where you store the tutorial notebooks, or a different directory that you then add to your path using sys.path.append. The syntax for using this module will be discussed in the next tutorial (Geostrophic Balance)."
"You can save this file either in the same directory where you store the tutorial notebooks, or a different directory that you then add to your path using sys.path.append. You can see the syntax of how the module is used in upcoming tutorials."
]
}
],
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tutorial: Using Command Line _wget_ to Download ECCO Datasets from PO.DAAC
# Using _wget_ to Download ECCO Datasets from PO.DAAC

Version 1.0 2021-06-25

Expand Down Expand Up @@ -91,4 +91,4 @@ $wget --no-verbose \
--no-clobber \
--continue \
-i 5237392644-download.txt -P data/
```
```
Binary file not shown.
7,464 changes: 7,464 additions & 0 deletions Intro_to_PO_Tutorials/Geostrophic_balance.ipynb

Large diffs are not rendered by default.

1,056 changes: 1,056 additions & 0 deletions Intro_to_PO_Tutorials/Thermal_wind.ipynb

Large diffs are not rendered by default.

Binary file not shown.
1 change: 1 addition & 0 deletions Intro_to_PO_Tutorials/ecco_download.py
78 changes: 78 additions & 0 deletions Intro_to_PO_Tutorials/geos_vel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
def geos_vel_compute(dens_press_filename,grid_filename="~/Downloads/ECCO_V4r4_PODAAC/ECCO_L4_GEOMETRY_LLC0090GRID_V4R4/GRID_GEOMETRY_ECCO_V4r4_native_llc0090.nc",fc_filename="llc_13tile_fc.txt"):
"""
This routine computes geostrophic velocities from an input netCDF file containing ECCO v4r4 density and pressure anomalies on the native llc90 grid.

Parameters
----------
dens_press_filename: the name (including path if not in current directory) of the netCDF file containing the density and pressure anomalies

grid_filename: the name (including path if not in current directory) of the netCDF file containing the latitudes ('YC') and grid parameters ('dxC','dyC') needed to compute horizontal derivatives

fc_filename: text file containing a Python dictionary specifying the tile/face connections in the ECCO llc90 grid
"""

import numpy as np
import xarray as xr
import json
import xgcm

# load file into workspace
ds_denspress = xr.open_dataset(dens_press_filename, data_vars='minimal',\
coords='minimal', compat='override')

densanom = ds_denspress.RHOAnoma

rhoConst = 1029.
dens = rhoConst + densanom

pressanom = ds_denspress.PHIHYDcR


# load grid parameters file
ds_grid = xr.open_dataset(grid_filename)


# load face_connections dictionary

# read in as string
with open(fc_filename) as fc:
data = fc.read()
# convert string to dictionary
face_connections = json.loads(data)


# create xgcm Grid object
grid = xgcm.Grid(ds_grid,periodic=False,face_connections=face_connections)

# compute derivatives of pressure in x and y
d_press_dx = (grid.diff(rhoConst*pressanom,axis="X",boundary='extend'))/ds_grid.dxC
d_press_dy = (grid.diff(rhoConst*pressanom,axis="Y",boundary='extend'))/ds_grid.dyC

# interpolate (vector) gradient values to center of grid cells
press_grads_interp = grid.interp_2d_vector({'X':d_press_dx,'Y':d_press_dy},boundary='extend')
dp_dx = press_grads_interp['X']
dp_dy = press_grads_interp['Y']

# compute f from latitude of grid cell centers
lat = ds_grid.YC
Omega = (2*np.pi)/86164
lat_rad = (np.pi/180)*lat # convert latitude from degrees to radians
f = 2*Omega*np.sin(lat_rad)

# compute geostrophic velocities
v_g = dp_dx/(f*dens)
u_g = -dp_dy/(f*dens)

# assign attributes to DataArrays (names) and units
u_g.name = 'u_g'
u_g.attrs.update({'long_name': 'Geostrophic velocity in model-x direction',\
'units': 'm s-1'})
v_g.name = 'v_g'
v_g.attrs.update({'long_name': 'Geostrophic velocity in model-y direction',\
'units': 'm s-1'})

# create xarray Dataset containing geostrophic velocities
ds_geos_vel = u_g.to_dataset(name='u_g',promote_attrs=True)
ds_geos_vel['v_g'] = v_g

return ds_geos_vel
1 change: 1 addition & 0 deletions Intro_to_PO_Tutorials/llc_13tile_fc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'tile': {0: {'X': ((12, 'Y', False), (3, 'X', False)), 'Y': (None, (1, 'Y', False))}, 1: {'X': ((11, 'Y', False), (4, 'X', False)), 'Y': ((0, 'Y', False), (2, 'Y', False))}, 2: {'X': ((10, 'Y', False), (5, 'X', False)), 'Y': ((1, 'Y', False), (6, 'X', False))}, 3: {'X': ((0, 'X', False), (9, 'Y', False)), 'Y': (None, (4, 'Y', False))}, 4: {'X': ((1, 'X', False), (8, 'Y', False)), 'Y': ((3, 'Y', False), (5, 'Y', False))}, 5: {'X': ((2, 'X', False), (7, 'Y', False)), 'Y': ((4, 'Y', False), (6, 'Y', False))}, 6: {'X': ((2, 'Y', False), (7, 'X', False)), 'Y': ((5, 'Y', False), (10, 'X', False))}, 7: {'X': ((6, 'X', False), (8, 'X', False)), 'Y': ((5, 'X', False), (10, 'Y', False))}, 8: {'X': ((7, 'X', False), (9, 'X', False)), 'Y': ((4, 'X', False), (11, 'Y', False))}, 9: {'X': ((8, 'X', False), None), 'Y': ((3, 'X', False), (12, 'Y', False))}, 10: {'X': ((6, 'Y', False), (11, 'X', False)), 'Y': ((7, 'Y', False), (2, 'X', False))}, 11: {'X': ((10, 'X', False), (12, 'X', False)), 'Y': ((8, 'Y', False), (1, 'X', False))}, 12: {'X': ((11, 'X', False), None), 'Y': ((9, 'Y', False), (0, 'X', False))}}}
1 change: 1 addition & 0 deletions doc/Downloading_ECCO_Datasets_from_PODAAC_Python.ipynb
1 change: 1 addition & 0 deletions doc/Downloading_ECCO_Datasets_from_PODAAC_wget.md
1 change: 1 addition & 0 deletions doc/Geostrophic_balance.ipynb
1 change: 1 addition & 0 deletions doc/Thermal_wind.ipynb
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
# built documents.
#
# The short X.Y version.
version = u'4.3-20191128'
version = u'4.4-20221215'
# The full version, including alpha/beta/rc tags.
release = u'4.3-20191128'
release = u'4.4-20221215'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
9 changes: 9 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ The `ecco_v4_py`_ package used in this tutorial was inspired by the `xmitgcm`_ p
fields
Installing_Python_and_Python_Packages
Downloading_the_ECCO_v4_state_estimate
Downloading_ECCO_Datasets_from_PODAAC_Python.ipynb
Downloading_ECCO_Datasets_from_PODAAC_wget.md
Tutorial_Introduction

.. toctree::
Expand Down Expand Up @@ -68,6 +70,13 @@ The `ecco_v4_py`_ package used in this tutorial was inspired by the `xmitgcm`_ p

ECCO_v4_Example_calculations_with_scalar_quantities.ipynb

.. toctree::
:maxdepth: 2
:caption: Intro to PO Tutorials

Geostrophic_balance.ipynb
Thermal_wind.ipynb

.. toctree::
:maxdepth: 2
:caption: More Advanced Calculations
Expand Down