miχpods - TAO#

  • eulerian 0-40m control volume

  • focus on Jq

  • use model chl / double exponentials

χpod notes:

  • eps = 0 at -39

  • 119m in 2015

%load_ext watermark

import glob
import os

import dask
import dcpy
import distributed
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

import pump
import xarray as xr
from pump import mixpods

dask.config.set({"array.slicing.split_large_chunks": False})
mpl.rcParams["figure.dpi"] = 140
xr.set_options(keep_attrs=True)

gcmdir = "/glade/campaign/cgd/oce/people/bachman/TPOS_1_20_20_year/OUTPUT/"  # MITgcm output directory
stationdirname = gcmdir

import holoviews as hv

hv.notebook_extension("bokeh")

%watermark -iv
The watermark extension is already loaded. To reload it, use:
  %reload_ext watermark
dcpy       : 0.1.dev385+g121534c
json       : 2.0.9
pandas     : 1.5.3
ipywidgets : 8.0.4
sys        : 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:26:04) [GCC 10.4.0]
distributed: 2023.1.0
dask       : 2023.1.0
holoviews  : 1.15.4
flox       : 0.6.8
xarray     : 2023.1.0
numpy      : 1.23.5
pump       : 0.1
matplotlib : 3.6.3
import dask_jobqueue

if "client" in locals():
    client.close()
    del client
if "cluster" in locals():
    cluster.close()

cluster = dask_jobqueue.PBSCluster(
    cores=4,  # The number of cores you want
    memory="23GB",  # Amount of memory
    processes=1,  # How many processes
    queue="casper",  # The type of queue to utilize (/glade/u/apps/dav/opt/usr/bin/execcasper)
    local_directory="/local_scratch/pbs.$PBS_JOBID",
    log_directory="/glade/scratch/dcherian/dask/",  # Use your local directory
    resource_spec="select=1:ncpus=4:mem=23GB",  # Specify resources
    project="ncgd0011",  # Input your project ID here
    walltime="02:00:00",  # Amount of wall time
    interface="ib0",  # Interface to use
)
cluster.adapt(minimum_jobs=2, maximum_jobs=8)
# cluster.scale(4)
client = distributed.Client(cluster)
client

Client

Client-cf4e8ab4-b86c-11ed-b502-3cecef1b11dc

Connection method: Cluster object Cluster type: dask_jobqueue.PBSCluster
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/dcherian/proxy/8787/status

Cluster Info

%autoreload

tao_gridded = mixpods.load_tao()
tao_gridded["Ih"] = 0.45 * tao_gridded.swnet * np.exp(-0.04 * np.abs(tao_gridded.mldT))
/glade/u/home/dcherian/miniconda3/envs/pump/lib/python3.10/site-packages/xarray/core/dataset.py:256: UserWarning: The specified Dask chunks separate the stored chunks along dimension "depth" starting at index 42. This could degrade performance. Instead, consider rechunking after loading.
  warnings.warn(
/glade/u/home/dcherian/miniconda3/envs/pump/lib/python3.10/site-packages/xarray/core/dataset.py:256: UserWarning: The specified Dask chunks separate the stored chunks along dimension "time" starting at index 199726. This could degrade performance. Instead, consider rechunking after loading.
  warnings.warn(
/glade/u/home/dcherian/miniconda3/envs/pump/lib/python3.10/site-packages/xarray/core/dataset.py:256: UserWarning: The specified Dask chunks separate the stored chunks along dimension "longitude" starting at index 2. This could degrade performance. Instead, consider rechunking after loading.
  warnings.warn(
tao_gridded["Ih"] = 0.45 * tao_gridded.swnet * np.exp(-0.04 * np.abs(tao_gridded.mldT))
tao_gridded.Ih.groupby("time.month").mean().plot()
tao_gridded["Ih"] = 0.45 * tao_gridded.swnet * np.exp(-0.04 * 15)
tao_gridded.Ih.groupby("time.month").mean().plot()
[<matplotlib.lines.Line2D at 0x2b2bcc1bc880>]
_images/074cbea15ba37e4474646127618a4d2e9bd2b166ab4031176383aab61c19acb4.png

Check masking#

From Sally:

ind = find(chihr.time > datenum(2007,1,14,10,25,0),1,'first');
chihr.Jq(3,ind) = NaN;
chihr.eps(3,ind) = NaN;
chihr.Kt(3,ind) = NaN;

ind = find(chihr.time > datenum(2007,1,28,14,25,0),1,'first');
chihr.Jq(4,ind) = NaN;
chihr.eps(4,ind) = NaN;
chihr.Kt(4,ind) = NaN;
%autoreload

chi = mixpods.read_chipod_mat_file(
    os.path.expanduser("~/work/pump/datasets/microstructure/chipods_0_140W_hourly.mat")
)

chi
<xarray.Dataset>
Dimensions:  (depth: 7, time: 128756)
Coordinates:
  * depth    (depth) float64 29.0 39.0 49.0 59.0 69.0 89.0 119.0
  * time     (time) datetime64[ns] 2005-09-23T04:30:00 ... 2020-05-31T23:30:00
Data variables:
    Jq       (time, depth) float64 -4.549 nan -0.0657 nan ... nan nan nan nan
    KT       (time, depth) float64 9.694e-05 nan 1.4e-06 nan ... nan nan nan nan
    N2       (time, depth) float64 3.798e-05 nan 4.135e-05 nan ... nan nan nan
    T        (time, depth) float64 25.56 nan 25.31 nan nan ... nan nan nan nan
    chi      (time, depth) float64 2.708e-08 nan 4.073e-10 nan ... nan nan nan
    dTdz     (time, depth) float64 0.01282 nan 0.01419 nan ... nan nan nan nan
    eps      (time, depth) float64 1.657e-08 nan 2.357e-10 nan ... nan nan nan
import holoviews as hv

kwargs = dict(groupby="time.year", by="depth", grid=True, aspect=10, frame_height=100)
(
    # chi.chi.hvplot.line(**kwargs, logy=True, ylim=(1e-11, 1e-3))
    chi.eps.hvplot.line(**kwargs, logy=True, ylim=(1e-11, 1e-3))
    + chi.KT.hvplot.line(**kwargs, logy=True, ylim=(1e-11, 10))
    + chi.Jq.hvplot.line(**kwargs)
    + chi.dTdz.hvplot.line(**kwargs)
).opts(
    hv.opts.Overlay(legend_cols=2, legend_position="top"),
    hv.opts.Layout(sizing_mode="stretch_width"),
).cols(
    1
)

ε-Ri histograms#

  • I think I’m missing some low Ri values.

%autoreload

tao_gridded = mixpods.load_tao()
tao_gridded
/glade/u/home/dcherian/miniconda3/envs/pump/lib/python3.10/site-packages/cf_xarray/accessor.py:2109: AccessorRegistrationWarning: registration of accessor <class 'cf_xarray.accessor.CFDatasetAccessor'> under name 'cf' for type <class 'xarray.core.dataset.Dataset'> is overriding a preexisting attribute with the same name.
  class CFDatasetAccessor(CFAccessor):
/glade/u/home/dcherian/miniconda3/envs/pump/lib/python3.10/site-packages/cf_xarray/accessor.py:2605: AccessorRegistrationWarning: registration of accessor <class 'cf_xarray.accessor.CFDataArrayAccessor'> under name 'cf' for type <class 'xarray.core.dataarray.DataArray'> is overriding a preexisting attribute with the same name.
  class CFDataArrayAccessor(CFAccessor):
/glade/u/home/dcherian/miniconda3/envs/pump/lib/python3.10/site-packages/xarray/core/dataset.py:256: UserWarning: The specified Dask chunks separate the stored chunks along dimension "depth" starting at index 42. This could degrade performance. Instead, consider rechunking after loading.
  warnings.warn(
/glade/u/home/dcherian/miniconda3/envs/pump/lib/python3.10/site-packages/xarray/core/dataset.py:256: UserWarning: The specified Dask chunks separate the stored chunks along dimension "time" starting at index 199726. This could degrade performance. Instead, consider rechunking after loading.
  warnings.warn(
/glade/u/home/dcherian/miniconda3/envs/pump/lib/python3.10/site-packages/xarray/core/dataset.py:256: UserWarning: The specified Dask chunks separate the stored chunks along dimension "longitude" starting at index 2. This could degrade performance. Instead, consider rechunking after loading.
  warnings.warn(
<xarray.Dataset>
Dimensions:             (time: 212302, depth: 61, depthchi: 6)
Coordinates: (12/19)
    deepest             (time) float64 dask.array<chunksize=(212302,), meta=np.ndarray>
  * depth               (depth) float64 -300.0 -295.0 -290.0 ... -10.0 -5.0 0.0
    eucmax              (time) float64 dask.array<chunksize=(33130,), meta=np.ndarray>
    latitude            float32 0.0
    longitude           float32 -140.0
    mld                 (time) float64 dask.array<chunksize=(212302,), meta=np.ndarray>
    ...                  ...
    oni                 (time) float32 -0.9 -0.9 -0.9 -0.9 ... nan nan nan nan
    en_mask             (time) bool False False False ... False False False
    ln_mask             (time) bool True True True True ... False False False
    warm_mask           (time) bool True True True True ... True True True True
    cool_mask           (time) bool False False False ... False False False
    enso_transition     (time) <U12 'La-Nina warm' ... '____________'
Data variables: (12/38)
    N2                  (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    N2T                 (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    Ri                  (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    Rig_T               (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    S                   (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    S2                  (time, depth) float32 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    ...                  ...
    shred2              (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    Rig                 (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    sst                 (time) float64 dask.array<chunksize=(33130,), meta=np.ndarray>
    Tflx_dia_diff       (time, depthchi) float64 nan nan nan nan ... nan nan nan
    Jb                  (time, depthchi, depth) float64 dask.array<chunksize=(33130, 6, 61), meta=np.ndarray>
    Rif                 (time, depthchi, depth) float64 dask.array<chunksize=(33130, 6, 61), meta=np.ndarray>
Attributes:
    CREATION_DATE:                23:26 24-FEB-2021
    Data_Source:                  Global Tropical Moored Buoy Array Project O...
    File_info:                    Contact: Dai.C.McClurg@noaa.gov
    Request_for_acknowledgement:  If you use these data in publications or pr...
    _FillValue:                   1.0000000409184788e+35
    array:                        TAO/TRITON
    missing_value:                1.0000000409184788e+35
    platform_code:                0n165e
    site_code:                    0n165e
    wmo_platform_code:            52321
tao_gridded.update(
    mixpods.pdf_N2S2(tao_gridded.sel(depthchi=slice(-69, -29), time=slice("2017")))
)
<xarray.Dataset>
Dimensions:                (time: 212302, depth: 61, depthchi: 6, N2T_bins: 29,
                            S2_bins: 29, enso_transition_phase: 7, stat: 2,
                            N2_bins: 29, Rig_T_bins: 9)
Coordinates: (12/26)
    deepest                (time) float64 dask.array<chunksize=(212302,), meta=np.ndarray>
  * depth                  (depth) float64 -300.0 -295.0 -290.0 ... -5.0 0.0
    eucmax                 (time) float64 dask.array<chunksize=(33130,), meta=np.ndarray>
    latitude               float32 0.0
    longitude              float32 -140.0
    mld                    (time) float64 dask.array<chunksize=(212302,), meta=np.ndarray>
    ...                     ...
  * S2_bins                (S2_bins) object [-5.0, -4.9) ... [-2.200000000000...
  * enso_transition_phase  (enso_transition_phase) object 'none' ... 'all'
  * stat                   (stat) object 'mean' 'count'
  * N2_bins                (N2_bins) object [-5.0, -4.9) ... [-2.200000000000...
    bin_areas              (N2T_bins, S2_bins) float64 0.01 0.01 ... 0.01 0.01
  * Rig_T_bins             (Rig_T_bins) object (0.025118864315095794, 0.03981...
Data variables: (12/41)
    N2                     (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    N2T                    (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    Ri                     (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    Rig_T                  (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    S                      (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    S2                     (time, depth) float32 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    ...                     ...
    Tflx_dia_diff          (time, depthchi) float64 nan nan nan ... nan nan nan
    Jb                     (time, depthchi, depth) float64 dask.array<chunksize=(33130, 6, 61), meta=np.ndarray>
    Rif                    (time, depthchi, depth) float64 dask.array<chunksize=(33130, 6, 61), meta=np.ndarray>
    n2s2pdf                (N2T_bins, S2_bins, enso_transition_phase) float64 dask.array<chunksize=(29, 29, 1), meta=np.ndarray>
    eps_n2s2               (stat, N2_bins, S2_bins, enso_transition_phase) float64 dask.array<chunksize=(1, 29, 29, 7), meta=np.ndarray>
    eps_ri                 (stat, Rig_T_bins, enso_transition_phase) float64 dask.array<chunksize=(1, 9, 1), meta=np.ndarray>
Attributes:
    CREATION_DATE:                23:26 24-FEB-2021
    Data_Source:                  Global Tropical Moored Buoy Array Project O...
    File_info:                    Contact: Dai.C.McClurg@noaa.gov
    Request_for_acknowledgement:  If you use these data in publications or pr...
    _FillValue:                   1.0000000409184788e+35
    array:                        TAO/TRITON
    missing_value:                1.0000000409184788e+35
    platform_code:                0n165e
    site_code:                    0n165e
    wmo_platform_code:            52321
tao_gridded.update(mixpods.daily_composites())
<xarray.Dataset>
Dimensions:                (time: 212302, depth: 61, depthchi: 6, N2T_bins: 29,
                            S2_bins: 29, enso_transition_phase: 7, stat: 2,
                            N2_bins: 29, Rig_T_bins: 9, hour: 24, tau_bins: 3)
Coordinates: (12/28)
    deepest                (time) float64 -200.0 -200.0 -200.0 ... nan nan nan
  * depth                  (depth) float64 -300.0 -295.0 -290.0 ... -5.0 0.0
    eucmax                 (time) float64 -25.0 -25.0 -25.0 ... -85.0 -80.0
    latitude               float32 0.0
    longitude              float32 -140.0
    mld                    (time) float64 0.0 0.0 0.0 0.0 ... nan nan nan nan
    ...                     ...
  * stat                   (stat) object 'mean' 'count'
  * N2_bins                (N2_bins) object [-5.0, -4.9) ... [-2.200000000000...
    bin_areas              (N2T_bins, S2_bins) float64 0.01 0.01 ... 0.01 0.01
  * Rig_T_bins             (Rig_T_bins) object (0.025118864315095794, 0.03981...
  * hour                   (hour) int64 0 1 2 3 4 5 6 7 ... 17 18 19 20 21 22 23
  * tau_bins               (tau_bins) object (0.0, 0.04] ... (0.075, inf]
Data variables: (12/42)
    N2                     (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    N2T                    (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    Ri                     (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    Rig_T                  (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    S                      (time, depth) float64 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    S2                     (time, depth) float32 dask.array<chunksize=(33130, 61), meta=np.ndarray>
    ...                     ...
    Jb                     (time, depthchi, depth) float64 dask.array<chunksize=(33130, 6, 61), meta=np.ndarray>
    Rif                    (time, depthchi, depth) float64 dask.array<chunksize=(33130, 6, 61), meta=np.ndarray>
    n2s2pdf                (N2T_bins, S2_bins, enso_transition_phase) float64 dask.array<chunksize=(29, 29, 1), meta=np.ndarray>
    eps_n2s2               (stat, N2_bins, S2_bins, enso_transition_phase) float64 dask.array<chunksize=(1, 29, 29, 7), meta=np.ndarray>
    eps_ri                 (stat, Rig_T_bins, enso_transition_phase) float64 dask.array<chunksize=(1, 9, 1), meta=np.ndarray>
    eps_tau_median         (depthchi, hour, tau_bins) float64 4.463e-09 ... 1...
Attributes:
    CREATION_DATE:                23:26 24-FEB-2021
    Data_Source:                  Global Tropical Moored Buoy Array Project O...
    File_info:                    Contact: Dai.C.McClurg@noaa.gov
    Request_for_acknowledgement:  If you use these data in publications or pr...
    _FillValue:                   1.0000000409184788e+35
    array:                        TAO/TRITON
    missing_value:                1.0000000409184788e+35
    platform_code:                0n165e
    site_code:                    0n165e
    wmo_platform_code:            52321
%autoreload
mixpods.plot_eps_ri_hist(tao_gridded.eps_ri)
%autoreload

newda = xr.DataArray(
    np.log10(
        tao_gridded.eps_ri.sel(
            enso_transition_phase=["La-Nina cool", "El-Nino warm"], stat="mean"
        )
    )
)

f, ax = plt.subplots(1, 1, constrained_layout=True)
newda.plot.step(hue="enso_transition_phase", xscale="log", ylim=(-7, -6))
ticks = [0.04, 0.1, 0.25, 0.63, 1.6]
ax.set_xticks(ticks)
ax.set_xticklabels([0.04, 0.1, 0.25, 0.63, 1.6])
dcpy.plots.linex(0.25)
_images/db4b062a07de05e7958727e0da16f6b5ceb85254f55392d1d69258907a955500.png

Develop “wind dependencies”: ε-τ-time-of-day diagnostic#

tao_gridded.eps.load().count()
<xarray.DataArray 'eps' ()>
array(176164)
Coordinates:
    latitude            float32 0.0
    longitude           float32 -140.0
    reference_pressure  int64 0
tao_gridded.taux.load().count()
<xarray.DataArray 'taux' ()>
array(166854)
Coordinates:
    latitude            float32 0.0
    longitude           float32 -140.0
    reference_pressure  int64 0
eps_tau_median.sortby("depthchi", ascending=False).plot(
    row="depthchi", x="hour", hue="tau_bins", yscale="log"
)
<xarray.plot.facetgrid.FacetGrid at 0x2aed1fd40ca0>
_images/2361b8716e56afb4053b96cd91386adb15537ca9d94c86777d65ce0b2215cd9a.png
a = eps_tau_median.drop_vars("tau_bins").hvplot.line(
    col="depthchi", x="hour", row="tau_bins", logy=True, label="TAO"
)

Test daily composite sensitivity#

Testing sensitivity to grouping by the hourly mean wind, or the daily mean wind (in the local time-zone 12AM-12PM)

tau = tao_gridded.tau.copy(deep=True).reset_coords(drop=True)
tau["time"] = tau["time"] - pd.Timedelta(hours=10)
newtau = tau.resample(time="D").mean().reindex(time=tau.time, method="ffill")
tau.sel(time="2008").hvplot.line() * newtau.sel(time="2008").hvplot.line()
from flox.xarray import xarray_reduce

hourly = xarray_reduce(
    tao_gridded.eps.load(),
    tao_gridded.time.dt.hour,
    tao_gridded.tau.load(),
    expected_groups=(None, pd.IntervalIndex.from_breaks([0, 0.04, 0.075, 1])),
    func=mixpods.agg_median,
).rename("hourly")


daily = xarray_reduce(
    tao_gridded.eps.load(),
    tao_gridded.time.dt.hour,
    newtau.assign_coords(time=tao_gridded.time).load(),
    expected_groups=(None, pd.IntervalIndex.from_breaks([0, 0.04, 0.075, 1])),
    func=mixpods.agg_median,
).rename("daily")
(
    hourly.hvplot.line(
        label="hourly",
        col="depthchi",
        x="hour",
        row="tau_bins",
    )
    * daily.hvplot.line(
        label="daily",
        col="depthchi",
        x="hour",
        row="tau_bins",
    )
).opts(hv.opts.GridSpace(show_legend=True, show_title=False), hv.opts.Curve(logy=True))
concatted = xr.concat([hourly, daily], dim="freq").assign_coords(
    freq=["hourly", "daily"]
)

(
    concatted.hvplot.line(
        by="freq", col="depthchi", x="hour", row="tau_bins", logy=True, legend=False
    )
).opts(
    hv.opts.GridSpace(show_legend=True, show_title=False),
)

Moum et al (2013) Climatologies#

  • The published .nc file seems “over cleaned” with mask ε < 3e-6 or so

tropflux = xr.open_mfdataset(
    sorted(glob.glob("/glade/work/dcherian/datasets/tropflux/**/*.nc")),
    engine="netcdf4",
    parallel=True,
)

tropflux_0140 = tropflux.interp(latitude=0, longitude=360 - 140).load()
tropflux_clim = tropflux_0140.groupby("time.month").mean()

Monthly climatology, Vertical mean#

Didn’t work with published nc file#

clim = xr.Dataset()
clim["netflux"] = (
    tropflux_0140.netflux.sel(time=slice("2005", "2011")).groupby("time.month").mean()
)
clim["Ih"] = tao_gridded.Ih.sel(time=slice("2005", "2011")).groupby("time.month").mean()
clim["Jq"] = (
    tao_gridded.Jq.sel(time=slice("2005", "2011"), depthchi=slice(-60, -20))
    .groupby("time.month")
    .mean(["depthchi", "time"])
)

(-1 * clim.Jq).plot(ylim=(0, 200))
(clim.netflux - clim.Ih).plot(ylim=(0, 200))
[<matplotlib.lines.Line2D>]
_images/c4d8b165ed8ac0a35879730974a8539d2fb274add6355329f20fa379ae6a61d7.png

Try with .mat file#

cchdo = dcpy.oceans.read_cchdo_chipod_file(
    "/glade/u/home/dcherian/datasets/microstructure/osu/chipod/tao/chipods_0_140W.nc"
)
cchdo
<xarray.Dataset>
Dimensions:     (depth: 7, time: 107588)
Coordinates:
    timeSeries  (depth) float64 ...
  * time        (time) datetime64[ns] 2005-09-23T04:30:00 ... 2017-12-31T23:2...
    lat         (depth) float64 dask.array<chunksize=(7,), meta=np.ndarray>
    lon         (depth) float64 dask.array<chunksize=(7,), meta=np.ndarray>
  * depth       (depth) float64 29.0 39.0 49.0 59.0 69.0 89.0 119.0
Data variables:
    T           (depth, time) float64 dask.array<chunksize=(7, 10000), meta=np.ndarray>
    dTdz        (depth, time) float64 dask.array<chunksize=(7, 10000), meta=np.ndarray>
    N2          (depth, time) float64 dask.array<chunksize=(7, 10000), meta=np.ndarray>
    KT          (depth, time) float64 dask.array<chunksize=(7, 10000), meta=np.ndarray>
    chi         (depth, time) float64 dask.array<chunksize=(7, 10000), meta=np.ndarray>
    eps         (depth, time) float64 dask.array<chunksize=(7, 10000), meta=np.ndarray>
    Jq          (depth, time) float64 dask.array<chunksize=(7, 10000), meta=np.ndarray>
Attributes: (12/68)
    ncei_template_version:           NCEI_NetCDF_TimeSeries_Orthogonal_Templa...
    featureType:                     timeSeries
    title:                           Turbulence quantities measured by chipod...
    summary:                         Turbulence data in upper w m / all good ...
    keywords:                        sea_water_temperature, square_of_brunt_v...
    Conventions:                     CF-1.6, ACDD-1.3
    ...                              ...
    reference8:                      Moum, J.N., Ocean speed and turbulence m...
    reference9:                      Warner, S.J., J. Becherer, K. Pujiana, E...
    reference10:                     Moum, J.N., K. Pujiana, R-C. Lien and W....
    reference11:                     Becherer, J. and J.N. Moum, An efficient...
    reference12:                     Moulin, A.J., J.N. Moum and E.L. Shroyer...
    reference13:                     Thakur, R., E.L. Shroyer, R. Govindaraja...
mat = mixpods.read_chipod_mat_file(
    os.path.expanduser("~/work/pump/datasets/microstructure/chipods_0_140W_hourly.mat")
)
mat.Jq.where(np.abs(mat.Jq) < 10000).groupby("time.year").mean().sel(
    year=slice(2005, 2011)
).hvplot.line(
    by="year", y="depth", flip_yaxis=True
)  # .opts(legend_cols=1)

Compare#

h1 = (
    cchdo.Jq.reset_coords(drop=True)
    .resample(time="M")
    .mean()
    .hvplot.quadmesh(
        cmap="greys",
        flip_yaxis=True,
        frame_width=1200,
        frame_height=200,
        clim=(40, -100),
    )
)
h2 = (
    mat.Jq.resample(time="M")
    .mean()
    .hvplot.quadmesh(
        cmap="greys",
        flip_yaxis=True,
        frame_width=1200,
        frame_height=200,
        clim=(40, -100),
    )
)
(h2.opts(title=".mat") + h1.opts(title="CCHDO")).cols(1)
h = (
    (
        np.abs(cchdo.Jq.resample(time="D").mean())
        .reset_coords(drop=True)
        .hvplot.line(by="depth", x="time")
        .opts(frame_width=1200)
        + np.abs(mat.Jq.resample(time="D").mean())
        .reset_coords(drop=True)
        .hvplot.line(by="depth", x="time")
        .opts(frame_width=1200)
    )
    .opts(shared_axes=True)
    .cols(1)
)
h
def plot_monthly_clim(ds, **kwargs):
    return np.abs(
        ds.Jq.sel(time=slice("2005", "2011-02"))
        .sel(depth=slice(20, 60))
        .mean("depth")
        .groupby("time.month")
        .mean()
    ).hvplot.line(**kwargs)


(
    plot_monthly_clim(mat, label=".mat")
    * plot_monthly_clim(mat.where(np.abs(mat.Jq) < 20000), label=".mat, Jq < 20000")
    * plot_monthly_clim(mat.where(np.abs(mat.Jq) < 10000), label=".mat, Jq < 10000")
    * plot_monthly_clim(mat.where(np.abs(mat.Jq) < 3000), label=".mat, Jq < 3000")
    * plot_monthly_clim(mat.where(mat.eps < 5e-4), label=".mat, ε < 5e-4")
    * plot_monthly_clim(mat.where(mat.eps < 1e-5), label=".mat, ε < 1e-5")
    * plot_monthly_clim(mat.where(mat.eps < 3e-6), label=".mat, ε < 3e-6")
    * plot_monthly_clim(cchdo, label="CCHDO", color="k")
    * (clim.netflux - clim.Ih)
    .rename("a")
    .hvplot.line(label="Jq0 - Ih", color="k", line_width=4)
).opts(show_grid=True, legend_position="right", frame_width=600, ylim=(0, 160))

Seasonal climatology, Vertical profile#

def plot_seasonal_clim(ds, **kwargs):
    return (
        np.abs(
            ds.Jq.sel(time=slice("2005", "2011-02"))
            .sel(depth=slice(20, 70))
            # .mean("depth")
            .groupby("time.season")
            .mean()
            .sel(season=["DJF", "MAM", "JJA", "SON"])
        ).hvplot.line(flip_yaxis=True, y="depth", col="season", **kwargs)
        # .opts()
    )


h = (
    plot_seasonal_clim(mat, label=".mat")
    * plot_seasonal_clim(mat.where(mat.eps < 1e-4), label=".mat, ε < 1e-4")
    * plot_seasonal_clim(mat.where(mat.eps < 1e-5), label=".mat, ε < 1e-5")
    * plot_seasonal_clim(mat.where(mat.eps < 3e-6), label=".mat, ε < 3e-6")
    * plot_seasonal_clim(cchdo, label="CCHDO", color="k")
)
h.opts(plot_size=(270, 350), shared_xaxis=True, shared_yaxis=True, show_legend=True)
from cycler import cycler

with plt.rc_context({"axes.prop_cycle": cycler(color=["k", "r", "b", "g"])}):
    (
        (-1 * cchdo.Jq.where(cchdo.Jq > -1e3).squeeze())
        .sel(time=slice("2005", "2012-02-01"))
        .groupby("time.season")
        .mean()
        .sel(season=["DJF", "MAM", "JJA", "SON"])
        .cf.plot(y="depth", hue="season")
    )
_images/f5f1f6dd8ca25ba73804aaf63c6b32e29736ebb41814470dd2563e568d88949a.png

Labeling ENSO phase transitions#

pump.obs.process_oni().sel(time=slice("2005-Oct", "2016-Feb")).reset_coords(
    drop=True
).plot.line(aspect=3, size=5, color="k")
pump.obs.make_enso_transition_mask().sel(
    time=slice("2005-Oct", "2016-Feb")
).reset_coords(drop=True).plot.line(ax=plt.gca().twinx(), marker="x")
plt.grid(True, which="both", axis="both")
_images/00836254780fc596fc7131ee5e02a9fe1f892b4bee1e09f6749e2ab8675d7923.png

N2 vs N2T#

Lot more data with N2T

tao_gridded.N2.cf.plot()
<matplotlib.collections.QuadMesh>
_images/cd6f9be9126fe23184dc75307e2e5b9c4cacec40c2a84c3c38eb066bb640921f.png
tao_gridded.N2T.cf.plot()
<matplotlib.collections.QuadMesh>
_images/87a212fcf30ee330ddd0c12640381f9454a3226c0fe9d5b3db6c73c9e13e5ba4.png

PDFs change#

fg = tao_gridded.n2s2pdf.sel(
    enso_transition_phase=[
        "La-Nina cool",
        "La-Nina warm",
        "El-Nino warm",
        "El-Nino cool",
    ]
).plot(vmax=1, col="enso_transition_phase")
fg.set_titles("{value}")
fg.map(dcpy.plots.line45)
fg.axes[0, 0].set_xlim((-4.5, -2.5))
fg.axes[0, 0].set_ylim((-4.5, -2.5))
(-4.5, -2.5)
_images/d627d44e2dfb8da2a24a5be154bafa5494ee33c23263641a4fdad48cdd06a4f9.png
(
    tao_gridded.n2s2pdf.sel(
        enso_transition_phase=[
            "La-Nina cool",
            "La-Nina warm",
            "El-Nino warm",
            "El-Nino cool",
        ]
    )
    .sum("N2_bins")
    .plot(hue="enso_transition_phase")
)
plt.figure()
(
    tao_gridded.n2s2pdf.sel(
        enso_transition_phase=[
            "La-Nina cool",
            "La-Nina warm",
            "El-Nino warm",
            "El-Nino cool",
        ]
    )
    .sum("S2_bins")
    .plot(hue="enso_transition_phase")
)
[<matplotlib.lines.Line2D>,
 <matplotlib.lines.Line2D>,
 <matplotlib.lines.Line2D>,
 <matplotlib.lines.Line2D>]
_images/15537986861473a90cc14242affa6f9d1e2f0d1f487b019629c73b6c0561fca0.png _images/78ee4166ac84ec78d69dea039e124ab8249f067a12b0e155811c5455a2975366.png
fg = tao_gridded.n2s2Tpdf.sel(
    enso_transition_phase=[
        "La-Nina cool",
        "La-Nina warm",
        "El-Nino warm",
        "El-Nino cool",
    ]
).plot(vmax=1, col="enso_transition_phase")
fg.set_titles("{value}")
fg.map(dcpy.plots.line45)
fg.axes[0, 0].set_xlim((-4.5, -2.5))
fg.axes[0, 0].set_ylim((-4.5, -2.5))
(-4.5, -2.5)
_images/4cc0df86ffc8fe4e617f4be5ec1dc83b8931b0fd578b5d8f102a244433ec7758.png
(
    tao_gridded.n2s2Tpdf.sel(
        enso_transition_phase=[
            "La-Nina cool",
            "La-Nina warm",
            "El-Nino warm",
            "El-Nino cool",
        ]
    )
    .sum("N2_bins")
    .plot(hue="enso_transition_phase")
)
plt.figure()
(
    tao_gridded.n2s2Tpdf.sel(
        enso_transition_phase=[
            "La-Nina cool",
            "La-Nina warm",
            "El-Nino warm",
            "El-Nino cool",
        ]
    )
    .sum("S2_bins")
    .plot(hue="enso_transition_phase")
)
[<matplotlib.lines.Line2D>,
 <matplotlib.lines.Line2D>,
 <matplotlib.lines.Line2D>,
 <matplotlib.lines.Line2D>]
_images/5ccfb0f28cfc95fd66fc6c63499a899dac6c0b6904b8cb7fe8222be84db5798b.png _images/babe9b2e2c8e71e7fd6b5a299442e598da7115e0b2ea35fca8a873d6c52d832f.png