Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build docs #8

Merged
merged 4 commits into from
May 30, 2019
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
2 changes: 1 addition & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Toolbox
genBasinMasks

Plotting tools
~~~~~~~~
~~~~~~~~~~~~~~~~

.. autosummary::
xyplot
Expand Down
30 changes: 12 additions & 18 deletions docs/source/examples/forcing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1><center>Analysis of Forcing Fields</center></h1>\n",
"# Analysis of Forcing Fields\n",
"\n",
"`mom6_tools.MOM6grid` returns an object with MOM6 grid data.\n",
"\n",
"`mom6_tools.latlon_analysis` has a collection of tools used to perform spatial analysis (e.g., time averages and spatial mean).\n",
"\n",
"The goal of this notebook is the following:\n",
"\n",
Expand All @@ -21,23 +25,13 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Basemap module not found. Some regional plots may not function properly\n"
]
}
],
"outputs": [],
"source": [
"%matplotlib inline\n",
"import sys\n",
"sys.path.append(\"/glade/u/home/gmarques/libs/CESM_MOM6_analysis/mom6_tools\")\n",
"from MOM6grid import MOM6grid\n",
"from latlon_analysis import time_mean_latlon\n",
"from mom6_tools.MOM6grid import MOM6grid\n",
"from mom6_tools.latlon_analysis import time_mean_latlon\n",
"import matplotlib.pyplot as plt"
]
},
Expand Down Expand Up @@ -408,9 +402,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Pangeo (Python 3.6)",
"display_name": "Python [conda env:analysis]",
"language": "python",
"name": "pangeo-3.6"
"name": "conda-env-analysis-py"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -422,7 +416,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1><center>Globally Averaged Ocean Temperature and Salinity</center></h1>"
"# Globally Averaged Ocean Temperature and Salinity"
]
},
{
Expand Down
30 changes: 19 additions & 11 deletions docs/source/examples/meridional_overturning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1><center>Meridional Overturning</center></h1>\n",
"# Meridional Overturning\n",
"\n",
"`mom6_tools.moc` functions for computing and plotting meridional overturning. \n",
"\n",
"The goal of this notebook is the following:\n",
"\n",
Expand All @@ -17,25 +19,23 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import sys\n",
"sys.path.append(\"/glade/u/home/gmarques/libs/CESM_MOM6_analysis/mom6_tools\")\n",
"from meridional_overturning import *\n",
"from latlon_analysis import check_time_interval\n",
"from m6toolbox import genBasinMasks\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib\n",
"import numpy as np\n",
"import xarray as xr"
"import xarray as xr\n",
"# mom6_tools\n",
"from mom6_tools.moc import *\n",
"from mom6_tools.m6toolbox import check_time_interval, genBasinMasks \n",
"import matplotlib.pyplot as plt\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -67,7 +67,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -78,6 +78,14 @@
"\n",
"11.16428 64.78855 [391, 434]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/glade/u/home/gmarques/miniconda3/envs/analysis/lib/python3.7/site-packages/dask/array/numpy_compat.py:28: RuntimeWarning: invalid value encountered in true_divide\n",
" x = np.divide(x1, x2, out)\n"
]
}
],
"source": [
Expand Down
11 changes: 5 additions & 6 deletions docs/source/examples/poleward_heat_transport.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1><center>Poleward Heat Transport</center></h1>\n",
"# Poleward Heat Transport\n",
"\n",
"`mom6_tools.polar_heat_transport` collection of functions for computing and plotting poleward heat transport.\n",
"\n",
"The goal of this notebook is the following:\n",
"\n",
Expand All @@ -22,11 +24,8 @@
"outputs": [],
"source": [
"%matplotlib inline\n",
"import sys\n",
"sys.path.append(\"/glade/u/home/gmarques/libs/CESM_MOM6_analysis/mom6_tools\")\n",
"from poleward_heat_transport import *\n",
"from latlon_analysis import check_time_interval\n",
"from m6toolbox import genBasinMasks\n",
"from mom6_tools.poleward_heat_transport import *\n",
"from mom6_tools.m6toolbox import check_time_interval, genBasinMasks\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib\n",
"import numpy as np\n",
Expand Down
10 changes: 5 additions & 5 deletions docs/source/examples/section_transports.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1><center>Transport across sections</center></h1>\n",
"# Transport across sections\n",
"\n",
"`mom6_tools.section_transports` collection of functions for computing and plotting time-series of transports across vertical sections.\n",
"\n",
"The goal of this notebook is the following:\n",
"\n",
Expand All @@ -17,14 +19,12 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import sys\n",
"sys.path.append(\"/glade/u/home/gmarques/libs/CESM_MOM6_analysis/mom6_tools\")\n",
"from section_transports import Transport, options\n",
"from mom6_tools.section_transports import Transport, options\n",
"import matplotlib.pyplot as plt"
]
},
Expand Down
28 changes: 11 additions & 17 deletions docs/source/examples/surface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1><center>Analysis of Surface Fields </center></h1>\n",
"# Analysis of Forcing Fields\n",
"\n",
"`mom6_tools.MOM6grid` returns an object with MOM6 grid data.\n",
"\n",
"`mom6_tools.latlon_analysis` has a collection of tools used to perform spatial analysis (e.g., time averages and spatial mean).\n",
"\n",
"The goal of this notebook is the following:\n",
"\n",
Expand All @@ -23,21 +27,11 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Basemap module not found. Some regional plots may not function properly\n"
]
}
],
"outputs": [],
"source": [
"%matplotlib inline\n",
"import sys\n",
"sys.path.append(\"/glade/u/home/gmarques/libs/CESM_MOM6_analysis/mom6_tools\")\n",
"from MOM6grid import MOM6grid\n",
"from latlon_analysis import time_mean_latlon\n",
"from mom6_tools.MOM6grid import MOM6grid\n",
"from mom6_tools.latlon_analysis import time_mean_latlon\n",
"import matplotlib.pyplot as plt"
]
},
Expand Down Expand Up @@ -208,9 +202,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Pangeo (Python 3.6)",
"display_name": "Python [conda env:analysis]",
"language": "python",
"name": "pangeo-3.6"
"name": "conda-env-analysis-py"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -222,7 +216,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
8 changes: 4 additions & 4 deletions mom6_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

from pkg_resources import DistributionNotFound, get_distribution

from .MOM6grid import *
from .section_transports import *
from .latlon_analysis import *
from .poleward_heat_transport import *
#from MOM6grid import *
#from section_transports import *
#from latlon_analysis import *
#from poleward_heat_transport import *

try:
__version__ = get_distribution(__name__).version
Expand Down
12 changes: 2 additions & 10 deletions mom6_tools/latlon_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import warnings
import os

import .m6plot
from .MOM6grid import MOM6grid
from mom6_tools import m6plot
from mom6_tools.MOM6grid import MOM6grid

class MyError(Exception):
"""
Expand Down Expand Up @@ -118,14 +118,6 @@ def plot_area_ave_stats(ds, var, args, aspect=[16,9], resolution=576, debug=Fals

return

def check_time_interval(ti,tf,nc):
''' Checks if year_start and year_end are within the time interval of the dataset'''
if ti < nc.time.min() or tf > nc.time.max():
#raise NameError('Selected start/end years outside the range of the dataset. Please fix that and run again.')
raise SyntaxError('Selected start/end years outside the range of the dataset. Please fix that and run again.')

return

# -- time-average 2D latlon fields and call plotting function
def time_mean_latlon(args, grd, variables=[]):
xr_mfopen_args = {'decode_times':False,
Expand Down
3 changes: 1 addition & 2 deletions mom6_tools/m6plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
from matplotlib.ticker import MaxNLocator
import math
import numpy, numpy.matlib
import .m6toolbox
import .VerticalSplitScale
from mom6_tools import m6toolbox

try: from mpl_toolkits.basemap import Basemap
except: print('Basemap module not found. Some regional plots may not function properly')
Expand Down
9 changes: 9 additions & 0 deletions mom6_tools/m6toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
from scipy.io import netcdf
import xarray as xr


def check_time_interval(ti,tf,nc):
''' Checks if year_start and year_end are within the time interval of the dataset'''
if ti < nc.time.min() or tf > nc.time.max():
#raise NameError('Selected start/end years outside the range of the dataset. Please fix that and run again.')
raise SyntaxError('Selected start/end years outside the range of the dataset. Please fix that and run again.')

return

def section2quadmesh(x, z, q, representation='pcm'):
"""
Creates the appropriate quadmesh coordinates to plot a scalar q(1:nk,1:ni) at
Expand Down
9 changes: 4 additions & 5 deletions mom6_tools/meridional_overturning.py → mom6_tools/moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import io
import numpy
import m6plot
import m6toolbox
import matplotlib.pyplot as plt
import os
import sys
import xarray as xr

from .latlon_analysis import check_time_interval
from .MOM6grid import MOM6grid
from mom6_tools import m6plot
from mom6_tools import m6toolbox
from mom6_tools.MOM6grid import MOM6grid

def options():
try: import argparse
Expand Down Expand Up @@ -51,7 +50,7 @@ def main(stream=False):
ti = args.year_start
tf = args.year_end
# check if data includes years between ti and tf
check_time_interval(ti,tf,ds)
m6toolbox.check_time_interval(ti,tf,ds)

# create a ndarray subclass
class C(numpy.ndarray): pass
Expand Down
9 changes: 4 additions & 5 deletions mom6_tools/poleward_heat_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
import warnings
import xarray as xr

import .m6plot
import .m6toolbox
from .latlon_analysis import check_time_interval
from .MOM6grid import MOM6grid
from mom6_tools import m6plot
from mom6_tools import m6toolbox
from mom6_tools.MOM6grid import MOM6grid

def options():
try: import argparse
Expand Down Expand Up @@ -47,7 +46,7 @@ def main(stream=False):
ti = args.year_start
tf = args.year_end
# check if data includes years between ti and tf
check_time_interval(ti,tf,ds)
m6toolbox.check_time_interval(ti,tf,ds)

# create a ndarray subclass
class C(numpy.ndarray): pass
Expand Down
2 changes: 1 addition & 1 deletion mom6_tools/section_transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy
import matplotlib.pyplot as plt
import os
from .latlon_analysis import check_time_interval
from mom6_tools.m6toolbox import check_time_interval

try: import argparse
except: raise Exception('This version of python is not new enough. python 2.7 or newer is required.')
Expand Down