TIEGCM

The kamodofied tiegcm requires the pytiegcm reader available on github:

pip install -e git+https://github.com/asher-pembroke/pytiegcm.git#egg=pytiegcm

The TIEGCM reader also requires netcdf4 (and numpy, scipy, and pandas, but those are required by kamodo)

pip install netcdf4

Warning

This is a work in progress!

filename = '/Users/apembrok/Work/TIEGCM/sample_data/jasoon_shim_040118_IT_1/s001.nc' # ccmc run (no zgmid)
fname = '/Users/apembrok/Downloads/2013.03.01.tie-gcm.data/s003.nc' # (no zgmid)
from kamodo import readers
from kamodo.readers.tiegcm import TIEGCM_Kamodo

By default, the kamodofied TIEGCM reader will load all 3d and 4d variables from the model. For performance reasons, you may want to only include certain variables for analysis. To do so, pass a list of variables in addition to the filename:

tiegcm = TIEGCM_Kamodo(fname, ['TN', 'UN', 'VN', 'EFLUX', 'Z'])

initializing tiegcm with /Users/apembrok/Downloads/2013.03.01.tie-gcm.data/s003.nc


/Users/apembrok/git/kamodo/docs/notebooks/src/pytiegcm/tiegcm/tiegcm.py:213: UserWarning:

WARNING: missing_value not used since it
cannot be safely cast to variable data type



registered 5 variables
tiegcm

Below is an attempt to use function composition to solve variables as a function of height.

from scipy.interpolate import interp1d
import numpy as np
z = np.squeeze(tiegcm.Z(tiegcm._time[0], lat = 0, lon = 0))
tiegcm['T_N(t, z, lat, lon)'] = 'TN(t,ilev, lat, lon)'
tiegcm

import numpy as np

@np.vectorize
def lev(self, t, z, lat, lon):
    # 1) meshgrid and squeeze the shapes of time, lat, lon if they are not the same
    # 2) calculate z_levels for all points
    # 3) construct rgi for (time, z_level, lat, lon)
    # 4) interpolate over z

    z_levels = self.Z(time = t, lat = lat, lon = lon)
    level = scipy.interpolate.interp1d(z_levels, ilev, bounds_error=False)
    return level(z)
tiegcm.lev = lev
tiegcm['ilev'] = lev
tiegcm['T_N(t, z, lat, lon)'] = 'TN(t, ilev, lat, lon)'
tiegcm

tiegcm['eflux'] = 'EFLUX(t, lat, lon)'
tiegcm

%load_ext autoreload
%autoreload 2
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload