import warnings
from mpl_toolkits.basemap import Basemap
warnings.filterwarnings('ignore')

get_ipython().magic(u'matplotlib inline')
sys.path.append('/Users/ifenty/git_repo_mine/ECCOv4-py')
import ecco_v4_py as ecco

# In[2]:

# specify the location of your nctiles_monthly directory
data_dir = '/Volumes/ECCO_BASE/ECCO_v4r3/nctiles_monthly/SSH/'
var = 'SSH'
var_type = 'c'
ssh_all_tiles = ecco.load_all_tiles_from_netcdf(data_dir,
                                                var,
                                                var_type,
                                                less_output=True)

# specify the location of your nctiles_grid directory
grid_dir = '/Volumes/ECCO_BASE/ECCO_v4r3/nctiles_grid/'
var = 'GRID'
var_type = 'grid'
grid_all_tiles = ecco.load_all_tiles_from_netcdf(grid_dir,
                                                 var,
                                                 var_type,
                                                 less_output=True)

# Merge the SSH and GRID Datasets together into one `v4` Dataset
v4 = xr.merge([ssh_all_tiles, grid_all_tiles])

# ### Plotting a single tile with imshow
import matplotlib.pylab as plt
import numpy as np
import sys
import xarray as xr
from copy import deepcopy
import ecco_v4_py as ecco

# ### 'c' point: ``SSH``

# In[2]:

data_dir = '/Volumes/ECCO_BASE/ECCO_v4r3/nctiles_monthly/SSH/'
var = 'SSH'
var_type = 'c'
ssh_all_tiles = ecco.load_all_tiles_from_netcdf(data_dir, var, var_type)
ecco.minimal_metadata(ssh_all_tiles)

# ### 'u' point: ``ADVxSNOW``
#
# ``ADVxSNOW`` is the horizontal advective flux of snow in each tile's $x$ direction.

# In[3]:

data_dir = '/Volumes/ECCO_BASE/ECCO_v4r3/nctiles_monthly/ADVxSNOW/'
var = 'ADVxSNOW'
var_type = 'u'
advxsnow_all_tiles = ecco.load_all_tiles_from_netcdf(data_dir, var, var_type)
ecco.minimal_metadata(advxsnow_all_tiles)

# ### 'v' point: ``ADVySNOW``
# Let's jump right in and use `load_all_tiles_from_netcdf` to load all 13 GRID tile files.  Call the new `Dataset` object `grid_all_tiles`.   Because we are loading GRID tile files, we specify 'grid' as the *var_type*.

# In[1]:

import matplotlib.pylab as plt
import numpy as np
import sys
import xarray as xr
from copy import deepcopy
import ecco_v4_py as ecco

# specify the locaiotn of your nctiles_grid directory
grid_dir = '/Volumes/ECCO_BASE/ECCO_v4r3/nctiles_grid/'
var = 'GRID'
var_type = 'grid'
grid_all_tiles = ecco.load_all_tiles_from_netcdf(grid_dir, var, var_type)

# minimize the metadata (optional)
ecco.minimal_metadata(grid_all_tiles)

# Let's look at `grid_all_tiles`:

# In[2]:

grid_all_tiles

# ### Examining the Dataset object contents
#
# #### 1. Dimensions
# `Dimensions:  (i: 90, i_g: 90, j: 90, j_g: 90, k: 50, k_g: 50, tile: 13)`
#