Ocean macronutrients#

%load_ext autoreload
%autoreload 2
import xarray as xr

from dask.distributed import Client

import catalog
import util

xr.set_options(keep_attrs=True)
/glade/work/kristenk/miniconda/envs/cesm-exp/lib/python3.7/site-packages/dask_jobqueue/core.py:20: FutureWarning: tmpfile is deprecated and will be removed in a future release. Please use dask.utils.tmpfile instead.
  from distributed.utils import tmpfile
<xarray.core.options.set_options at 0x2b4a9d78e310>
import matplotlib.pyplot as plt
import cartopy
import cartopy.crs as ccrs
import pop_tools
ds_grid = pop_tools.get_grid('POP_gx1v7')
lons = ds_grid.TLONG
lats = ds_grid.TLAT
depths = ds_grid.z_t * 0.01

Parameters#

casename = 'g.e22a06.G1850ECOIAF_JRA_PHYS_DEV.TL319_g17.scope_v1'
component = 'pop'
stream = 'h'

cluster_scheduler_address = None
# Parameters
casename = "g.e22.GOMIPECOIAF_JRA-1p4-2018.TL319_g17.4p2z.001branch"
component = "pop"
stream = "h"
cluster_scheduler_address = "tcp://10.12.206.3:35506"
assert component in ['pop']
assert stream in ['h', 'h.ecosys.nday1']

Connect to cluster#

if cluster_scheduler_address is None:
    cluster, client = util.get_ClusterClient()
    cluster.scale(12)
else:
    client = Client(cluster_scheduler_address)
client

Client

Client-c8b82224-9359-11ed-b054-3cecef1acc46

Connection method: Direct
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/8787/status

Scheduler Info

Scheduler

Scheduler-7b28f886-17c1-40f8-ae24-3360603786e8

Comm: tcp://10.12.206.3:35506 Workers: 32
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/8787/status Total threads: 32
Started: 34 minutes ago Total memory: 744.96 GiB

Workers

Worker: PBSCluster-0

Comm: tcp://10.12.206.60:40381 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/37473/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.60:43642
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-she593m8
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 500.19 MiB Spilled bytes: 0 B
Read bytes: 1.08 GiB Write bytes: 439.22 kiB

Worker: PBSCluster-1

Comm: tcp://10.12.206.57:34913 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/43168/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.57:40520
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-ais4w5nl
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 536.50 MiB Spilled bytes: 0 B
Read bytes: 34.64 MiB Write bytes: 51.95 kiB

Worker: PBSCluster-10

Comm: tcp://10.12.206.55:40610 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/41580/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.55:41770
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-24q12p4a
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 577.90 MiB Spilled bytes: 0 B
Read bytes: 39.35 kiB Write bytes: 23.47 kiB

Worker: PBSCluster-11

Comm: tcp://10.12.206.35:36760 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/34231/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.35:39163
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-tm589a2g
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 609.45 MiB Spilled bytes: 0 B
Read bytes: 28.60 kiB Write bytes: 15.78 kiB

Worker: PBSCluster-12

Comm: tcp://10.12.206.42:46667 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/44609/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.42:43503
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-63bl396p
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 476.43 MiB Spilled bytes: 0 B
Read bytes: 33.64 kiB Write bytes: 11.85 kiB

Worker: PBSCluster-13

Comm: tcp://10.12.206.55:34741 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/41987/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.55:39933
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-3taktpky
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 478.29 MiB Spilled bytes: 0 B
Read bytes: 37.50 kiB Write bytes: 19.64 kiB

Worker: PBSCluster-14

Comm: tcp://10.12.206.42:44723 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/38884/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.42:37139
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-btgwv71o
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 547.30 MiB Spilled bytes: 0 B
Read bytes: 34.75 kiB Write bytes: 16.34 kiB

Worker: PBSCluster-15

Comm: tcp://10.12.206.60:34840 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/36356/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.60:36517
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-s50upym9
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 557.71 MiB Spilled bytes: 0 B
Read bytes: 91.27 MiB Write bytes: 119.77 kiB

Worker: PBSCluster-16

Comm: tcp://10.12.206.55:33480 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/44604/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.55:34515
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-20gqvxq8
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 522.93 MiB Spilled bytes: 0 B
Read bytes: 28.85 kiB Write bytes: 17.51 kiB

Worker: PBSCluster-17

Comm: tcp://10.12.206.42:46005 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/44117/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.42:32947
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-18iilri4
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 551.85 MiB Spilled bytes: 0 B
Read bytes: 34.36 kiB Write bytes: 14.58 kiB

Worker: PBSCluster-18

Comm: tcp://10.12.206.60:33226 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/42773/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.60:46337
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-8qq6z3y3
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 483.32 MiB Spilled bytes: 0 B
Read bytes: 91.11 MiB Write bytes: 120.36 kiB

Worker: PBSCluster-19

Comm: tcp://10.12.206.36:36934 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/38605/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.36:40345
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-0wibvgh_
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 583.45 MiB Spilled bytes: 0 B
Read bytes: 74.72 kiB Write bytes: 15.92 kiB

Worker: PBSCluster-2

Comm: tcp://10.12.206.42:35532 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/37233/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.42:38029
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-tvn8qi89
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 476.18 MiB Spilled bytes: 0 B
Read bytes: 33.90 kiB Write bytes: 13.56 kiB

Worker: PBSCluster-20

Comm: tcp://10.12.206.57:44618 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/35828/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.57:39590
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-j87b3i6z
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 489.71 MiB Spilled bytes: 0 B
Read bytes: 34.58 MiB Write bytes: 73.30 kiB

Worker: PBSCluster-21

Comm: tcp://10.12.206.42:36146 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/42013/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.42:42567
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-te65hpsa
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 578.39 MiB Spilled bytes: 0 B
Read bytes: 25.28 kiB Write bytes: 17.24 kiB

Worker: PBSCluster-22

Comm: tcp://10.12.206.37:45266 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/41617/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.37:46778
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-6zjl_rf2
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 530.46 MiB Spilled bytes: 0 B
Read bytes: 133.50 kiB Write bytes: 246.42 kiB

Worker: PBSCluster-23

Comm: tcp://10.12.206.57:36646 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/33282/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.57:39220
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-tedt0oqb
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 567.37 MiB Spilled bytes: 0 B
Read bytes: 34.61 MiB Write bytes: 51.08 kiB

Worker: PBSCluster-24

Comm: tcp://10.12.206.35:43781 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/41280/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.35:41682
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-oenmf7ye
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 518.06 MiB Spilled bytes: 0 B
Read bytes: 28.79 kiB Write bytes: 17.51 kiB

Worker: PBSCluster-25

Comm: tcp://10.12.206.42:38958 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/45762/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.42:41096
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-r999w54s
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 479.43 MiB Spilled bytes: 0 B
Read bytes: 34.41 kiB Write bytes: 14.60 kiB

Worker: PBSCluster-26

Comm: tcp://10.12.206.35:41019 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/46197/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.35:41093
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-n8z_ugpj
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 595.27 MiB Spilled bytes: 0 B
Read bytes: 28.80 kiB Write bytes: 17.51 kiB

Worker: PBSCluster-27

Comm: tcp://10.12.206.40:37756 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/34868/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.40:46061
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-ah4h4uwy
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 4.0% Last seen: Just now
Memory usage: 521.61 MiB Spilled bytes: 0 B
Read bytes: 23.06 kiB Write bytes: 10.28 kiB

Worker: PBSCluster-28

Comm: tcp://10.12.206.55:40536 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/40763/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.55:43688
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-mqh1_swd
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 482.54 MiB Spilled bytes: 0 B
Read bytes: 28.88 kiB Write bytes: 19.94 kiB

Worker: PBSCluster-29

Comm: tcp://10.12.206.35:43010 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/45869/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.35:38155
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-0zp2yifw
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 516.81 MiB Spilled bytes: 0 B
Read bytes: 33.00 kiB Write bytes: 17.35 kiB

Worker: PBSCluster-3

Comm: tcp://10.12.206.55:43243 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/45154/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.55:40506
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-d77lpe1m
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 473.82 MiB Spilled bytes: 0 B
Read bytes: 37.22 kiB Write bytes: 17.20 kiB

Worker: PBSCluster-30

Comm: tcp://10.12.206.42:40059 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/38562/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.42:35150
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-s1j98ibm
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 495.98 MiB Spilled bytes: 0 B
Read bytes: 33.56 kiB Write bytes: 11.82 kiB

Worker: PBSCluster-31

Comm: tcp://10.12.206.55:40509 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/46123/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.55:42505
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-0193oowl
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 480.99 MiB Spilled bytes: 0 B
Read bytes: 38.06 kiB Write bytes: 20.58 kiB

Worker: PBSCluster-4

Comm: tcp://10.12.206.60:33761 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/38547/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.60:43086
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-go_20xsh
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 577.92 MiB Spilled bytes: 0 B
Read bytes: 91.34 MiB Write bytes: 119.85 kiB

Worker: PBSCluster-5

Comm: tcp://10.12.206.56:36183 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/39960/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.56:36523
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-ak_et0qx
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 487.75 MiB Spilled bytes: 0 B
Read bytes: 256.48 MiB Write bytes: 129.44 MiB

Worker: PBSCluster-6

Comm: tcp://10.12.206.55:42418 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/43316/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.55:35755
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-w069mt42
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 515.77 MiB Spilled bytes: 0 B
Read bytes: 38.09 kiB Write bytes: 22.21 kiB

Worker: PBSCluster-7

Comm: tcp://10.12.206.42:38064 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/33959/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.42:37237
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-8g92ok8a
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 520.62 MiB Spilled bytes: 0 B
Read bytes: 35.42 kiB Write bytes: 16.47 kiB

Worker: PBSCluster-8

Comm: tcp://10.12.206.35:46716 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/38950/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.35:46823
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-t0bj5mka
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 514.25 MiB Spilled bytes: 0 B
Read bytes: 28.66 kiB Write bytes: 15.80 kiB

Worker: PBSCluster-9

Comm: tcp://10.12.206.55:36074 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/41381/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.55:35112
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-vzrt3wyj
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 518.98 MiB Spilled bytes: 0 B
Read bytes: 37.23 kiB Write bytes: 17.20 kiB

Load the data#

dsets = catalog.to_dataset_dict(
    case=casename,
    component=component,
    stream=stream,
)
dsets.keys()
g.e22.GOMIPECOIAF_JRA-1p4-2018.TL319_g17.4p2z.001branch pop h /glade/scratch/kristenk/archive
dict_keys(['g.e22.GOMIPECOIAF_JRA-1p4-2018.TL319_g17.4p2z.001branch.pop.h'])
ds = dsets[f'{casename}.{component}.{stream}']

Variable list#

variables =['PO4','NO3','SiO3']
keep_vars=['z_t','z_t_150m','dz','time_bound','TAREA','TLAT','TLONG'] + variables
ds = ds.drop([v for v in ds.variables if v not in keep_vars])
ds.NO3.isel(time=0,z_t=0).plot()
<matplotlib.collections.QuadMesh at 0x2b4ad7222450>
_images/ocn-macronuts_17_1.png
dt_wgt = ds.time_bound.diff('d2').squeeze()
dt_wgt /= dt_wgt.sum()
#dt_wgt
ds = ds.weighted(dt_wgt).mean('time')
ds['NO3'].isel(z_t=0).plot()
<matplotlib.collections.QuadMesh at 0x2b4ae49d5390>
_images/ocn-macronuts_20_1.png

Compare long-term mean to World Ocean Atlas 2018#

WOA18

file = '/glade/work/kristenk/WOA_data/regrid_POP/WOA2018_POPgrid.nc' 
ds_woa = xr.load_dataset(file, decode_times=False, decode_coords=False)
ds_woa['z_t'] = ds.z_t
NO3_diff = ds.NO3 - ds_woa.NO3
PO4_diff = ds.PO4 - ds_woa.PO4
SiO3_diff = ds.SiO3 - ds_woa.SiO3

Surface comparison#

fig = plt.figure(figsize=(18,10))

####################NO3
#COLUMN 1  - NO3
#---- CESM panel
ax = fig.add_subplot(3,3,1, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('CESM surface NO$_3$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats, ds.NO3.isel(z_t=0))
pc1=ax.pcolormesh(lon, lat,field, vmin=0, vmax=20, cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc1, ax=ax,extend='max',label='NO$_3$ (mmol m$^{-3}$)')

#---- OBS panel
ax = fig.add_subplot(3,3,4, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('WOA surface NO$_3$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  ds_woa.NO3.isel(z_t=0))
pc2=ax.pcolormesh(lon, lat, field, vmin=0, vmax=20, cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc2, ax=ax,extend='max',label='NO$_3$ (mmol m$^{-3}$)')

#---- DIFF panel
ax = fig.add_subplot(3,3,7, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('Surface NO$_3$ model bias', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  NO3_diff.isel(z_t=0))
pc3=ax.pcolormesh(lon, lat, field, vmin=-10, vmax=10, cmap='bwr',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc3, ax=ax,extend='both',label='NO$_3$ bias (mmol m$^{-3}$)')



####################PO4
#---- CESM panel
ax = fig.add_subplot(3,3,2, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('CESM surface PO$_4$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats, ds.PO4.isel(z_t=0))
pc1=ax.pcolormesh(lon, lat,field, vmin=0, vmax=2, cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc1, ax=ax,extend='max',label='PO$_4$ (mmol m$^{-3}$)')

#---- OBS panel
ax = fig.add_subplot(3,3,5, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('WOA surface PO$_4$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  ds_woa.PO4.isel(z_t=0))
pc2=ax.pcolormesh(lon, lat,field, vmin=0, vmax=2, cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc2, ax=ax,extend='max',label='PO$_4$ (mmol m$^{-3}$)')

#---- DIFF panel
ax = fig.add_subplot(3,3,8, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('Surface PO$_4$ bias', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  PO4_diff.isel(z_t=0))
pc3=ax.pcolormesh(lon, lat,field, vmin=-1, vmax=1, cmap='bwr',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc3, ax=ax,extend='both',label='PO$_4$ bias (mmol m$^{-3}$)')



####################SiO3
#---- CESM panel
ax = fig.add_subplot(3,3,3, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('CESM surface SiO$_3$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats, ds.SiO3.isel(z_t=0))
pc1=ax.pcolormesh(lon, lat, field, 
                  vmin=0, vmax=30, 
                  cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc1, ax=ax,extend='max',label='SiO$_3$ (mmol m$^{-3}$)')

#---- OBS panel
ax = fig.add_subplot(3,3,6, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('WOA surface SiO$_3$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  ds_woa.SiO3.isel(z_t=0))
pc2=ax.pcolormesh(lon, lat,field, 
                  vmin=0, vmax=30, 
                  cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc2, ax=ax,extend='max',label='SiO$_3$ (mmol m$^{-3}$)')

#---- DIFF panel
ax = fig.add_subplot(3,3,9, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('Surface SiO$_3$ bias', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  SiO3_diff.isel(z_t=0))
pc3=ax.pcolormesh(lon, lat, field, 
                  vmin=-15, vmax=15, 
                  cmap='bwr',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc3, ax=ax,extend='both',label='SiO$_3$ bias (mmol m$^{-3}$)');
_images/ocn-macronuts_25_0.png

Comparison at 100m#

fig = plt.figure(figsize=(18,10))

####################NO3
#COLUMN 1  - NO3
#---- CESM panel
ax = fig.add_subplot(3,3,1, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('CESM 100m NO$_3$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats, ds.NO3.isel(z_t=10))
pc1=ax.pcolormesh(lon, lat,field, vmin=0, vmax=20, cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc1, ax=ax,extend='max',label='NO$_3$ (mmol m$^{-3}$)')

#---- OBS panel
ax = fig.add_subplot(3,3,4, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('WOA 100m NO$_3$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  ds_woa.NO3.isel(z_t=10))
pc2=ax.pcolormesh(lon, lat, field, vmin=0, vmax=20, cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc2, ax=ax,extend='max',label='NO$_3$ (mmol m$^{-3}$)')

#---- DIFF panel
ax = fig.add_subplot(3,3,7, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('100m NO$_3$ model bias', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  NO3_diff.isel(z_t=10))
pc3=ax.pcolormesh(lon, lat, field, vmin=-10, vmax=10, cmap='bwr',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc3, ax=ax,extend='both',label='NO$_3$ bias (mmol m$^{-3}$)')



####################PO4
#---- CESM panel
ax = fig.add_subplot(3,3,2, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('CESM 100m PO$_4$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats, ds.PO4.isel(z_t=10))
pc1=ax.pcolormesh(lon, lat,field, vmin=0, vmax=2, cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc1, ax=ax,extend='max',label='PO$_4$ (mmol m$^{-3}$)')

#---- OBS panel
ax = fig.add_subplot(3,3,5, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('WOA 100m PO$_4$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  ds_woa.PO4.isel(z_t=10))
pc2=ax.pcolormesh(lon, lat,field, vmin=0, vmax=2, cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc2, ax=ax,extend='max',label='PO$_4$ (mmol m$^{-3}$)')

#---- DIFF panel
ax = fig.add_subplot(3,3,8, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('100m PO$_4$ bias', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  PO4_diff.isel(z_t=10))
pc3=ax.pcolormesh(lon, lat,field, vmin=-1, vmax=1, cmap='bwr',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc3, ax=ax,extend='both',label='PO$_4$ bias (mmol m$^{-3}$)')



####################SiO3
#---- CESM panel
ax = fig.add_subplot(3,3,3, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('CESM 100m SiO$_3$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats, ds.SiO3.isel(z_t=10))
pc1=ax.pcolormesh(lon, lat, field, 
                  vmin=0, vmax=30, 
                  cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc1, ax=ax,extend='max',label='SiO$_3$ (mmol m$^{-3}$)')

#---- OBS panel
ax = fig.add_subplot(3,3,6, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('WOA 100m SiO$_3$', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  ds_woa.SiO3.isel(z_t=10))
pc2=ax.pcolormesh(lon, lat,field, 
                  vmin=0, vmax=30, 
                  cmap='Oranges',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc2, ax=ax,extend='max',label='SiO$_3$ (mmol m$^{-3}$)')

#---- DIFF panel
ax = fig.add_subplot(3,3,9, projection=ccrs.Robinson(central_longitude=305.0))
ax.coastlines('110m',linewidth=0.5)
ax.set_title('100m SiO$_3$ bias', fontsize=10)
lon, lat, field = util.adjust_pop_grid(lons, lats,  SiO3_diff.isel(z_t=10))
pc3=ax.pcolormesh(lon, lat, field, 
                  vmin=-15, vmax=15, 
                  cmap='bwr',
                 transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc3, ax=ax,extend='both',label='SiO$_3$ bias (mmol m$^{-3}$)');
_images/ocn-macronuts_27_0.png

Global mean macronutrient profiles#

ds_glb = util.global_mean(ds, ds_grid, ['NO3','PO4','SiO3']).compute()
ds_glb_woa = util.global_mean(ds_woa, ds_grid, ['NO3','PO4','SiO3']).compute()
fig = plt.figure(figsize=(15,10))

plt.suptitle('Global mean macronutrient profiles', fontsize=14)


#COLUMN 1  - NO3

ax = fig.add_subplot(2,3,1)
ax.set_title('Global mean NO$_3$')
ax.plot(ds_glb['NO3'].values, depths, label='CESM', linewidth=3)
ax.plot(ds_glb_woa['NO3'].values, depths, label='WOA', linewidth=3)
ax.legend()
ax.set(ylabel='depth (m)',xlabel='NO$_3$ (mmol m$^{-3}$)')
plt.gca().invert_yaxis()

#COLUMN 2  - PO4

ax = fig.add_subplot(2,3,2)
ax.set_title('Global mean PO$_4$')
ax.plot(ds_glb['PO4'].values, depths, label='CESM', linewidth=3)
ax.plot(ds_glb_woa['PO4'].values, depths, label='WOA', linewidth=3)
ax.legend()
ax.set(ylabel='depth (m)',xlabel='PO$_4$ (mmol m$^{-3}$)')
plt.gca().invert_yaxis()

#COLUMN 3  - SiO3

ax = fig.add_subplot(2,3,3)
ax.set_title('Global mean SiO$_3$')
ax.plot(ds_glb['SiO3'].values, depths, label='CESM', linewidth=3)
ax.plot(ds_glb_woa['SiO3'].values, depths, label='WOA', linewidth=3)
ax.legend()
ax.set(ylabel='depth (m)',xlabel='SiO$_3$ (mmol m$^{-3}$)')
plt.gca().invert_yaxis()


#COLUMN 1  - NO3 diff

ax = fig.add_subplot(2,3,4)
ax.plot(ds_glb['NO3'].values - ds_glb_woa['NO3'].values, depths, label='bias', linewidth=3, color='green')
ax.legend()
ax.set(ylabel='depth (m)',xlabel='NO$_3$ bias (mmol m$^{-3}$)')
ax.axvline(x=0,color='black',linestyle='--',linewidth=0.5)
plt.gca().invert_yaxis()

#COLUMN 2  - PO4 diff

ax = fig.add_subplot(2,3,5)
ax.plot(ds_glb['PO4'].values - ds_glb_woa['PO4'].values, depths, label='bias', linewidth=3, color='green')
ax.legend()
ax.set(ylabel='depth (m)',xlabel='PO$_4$ bias (mmol m$^{-3}$)')
ax.axvline(x=0,color='black',linestyle='--',linewidth=0.5)
plt.gca().invert_yaxis()

#COLUMN 3  - SiO3 diff

ax = fig.add_subplot(2,3,6)
ax.plot(ds_glb['SiO3'].values - ds_glb_woa['SiO3'].values, depths, label='bias', linewidth=3, color='green')
ax.legend()
ax.set(ylabel='depth (m)',xlabel='SiO$_3$ bias (mmol m$^{-3}$)')
ax.axvline(x=0,color='black',linestyle='--',linewidth=0.5)
plt.gca().invert_yaxis()
_images/ocn-macronuts_31_0.png

TO DO#

• Add regional profiles