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 0x2b6a65f70c10>
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.e22a06.G1850ECOIAF_JRA_PHYS_DEV.TL319_g17.scope_v1"
component = "pop"
stream = "h"
cluster_scheduler_address = "tcp://10.12.206.26:40301"
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-b89cf286-0c3d-11ed-bfb4-3cecef1b11d4

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

Scheduler Info

Scheduler

Scheduler-59153102-2d90-4250-b1d9-5b9f28512082

Comm: tcp://10.12.206.26:40301 Workers: 32
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/36768/status Total threads: 32
Started: 22 minutes ago Total memory: 744.96 GiB

Workers

Worker: PBSCluster-0

Comm: tcp://10.12.206.25:41180 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/42193/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.25:34568
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-smli87lm
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 477.73 MiB Spilled bytes: 0 B
Read bytes: 128.93 MiB Write bytes: 65.01 MiB

Worker: PBSCluster-1

Comm: tcp://10.12.206.23:35055 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/39970/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.23:39298
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-pajhhimy
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.76 MiB Spilled bytes: 0 B
Read bytes: 306.40 MiB Write bytes: 100.92 kiB

Worker: PBSCluster-10

Comm: tcp://10.12.206.18:39960 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/40058/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.18:33787
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-frtdc9f5
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 451.34 MiB Spilled bytes: 0 B
Read bytes: 64.51 MiB Write bytes: 16.16 MiB

Worker: PBSCluster-11

Comm: tcp://10.12.206.18:35287 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/39615/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.18:36732
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-mmo_bs6s
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 447.27 MiB Spilled bytes: 0 B
Read bytes: 64.55 MiB Write bytes: 16.17 MiB

Worker: PBSCluster-12

Comm: tcp://10.12.206.8:33729 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/35711/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.8:43143
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-svc02rvq
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 456.16 MiB Spilled bytes: 0 B
Read bytes: 145.25 MiB Write bytes: 80.75 MiB

Worker: PBSCluster-13

Comm: tcp://10.12.206.8:37550 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/38907/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.8:40235
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-lys_uzzv
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 529.96 MiB Spilled bytes: 0 B
Read bytes: 145.16 MiB Write bytes: 80.69 MiB

Worker: PBSCluster-14

Comm: tcp://10.12.206.25:44992 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/44154/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.25:43428
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-76two5nt
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.56 MiB Spilled bytes: 0 B
Read bytes: 128.98 MiB Write bytes: 65.04 MiB

Worker: PBSCluster-15

Comm: tcp://10.12.206.15:43062 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/32926/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.15:39144
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-jy38onqp
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 469.14 MiB Spilled bytes: 0 B
Read bytes: 161.20 MiB Write bytes: 96.76 MiB

Worker: PBSCluster-16

Comm: tcp://10.12.206.8:43565 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/41710/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.8:45391
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-_7ilj7sa
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 465.63 MiB Spilled bytes: 0 B
Read bytes: 145.09 MiB Write bytes: 80.66 MiB

Worker: PBSCluster-17

Comm: tcp://10.12.206.11:40919 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/45664/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.11:40649
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-o65npiy5
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 551.29 MiB Spilled bytes: 0 B
Read bytes: 13.24 kiB Write bytes: 4.61 kiB

Worker: PBSCluster-18

Comm: tcp://10.12.206.11:33891 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/38384/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.11:33328
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-nou8aprr
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 568.64 MiB Spilled bytes: 0 B
Read bytes: 12.93 kiB Write bytes: 3.69 kiB

Worker: PBSCluster-19

Comm: tcp://10.12.206.15:36904 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/35533/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.15:34961
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-r5hakwxw
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 483.01 MiB Spilled bytes: 0 B
Read bytes: 161.43 MiB Write bytes: 96.90 MiB

Worker: PBSCluster-2

Comm: tcp://10.12.206.15:43006 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/39124/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.15:43393
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-mmk9h6y4
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 446.79 MiB Spilled bytes: 0 B
Read bytes: 161.13 MiB Write bytes: 96.71 MiB

Worker: PBSCluster-20

Comm: tcp://10.12.206.18:45916 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/35027/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.18:43737
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-xa8tkihj
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 528.88 MiB Spilled bytes: 0 B
Read bytes: 64.53 MiB Write bytes: 16.16 MiB

Worker: PBSCluster-21

Comm: tcp://10.12.206.11:45334 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/46680/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.11:46761
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-t02yg0d0
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.75 MiB Spilled bytes: 0 B
Read bytes: 13.25 kiB Write bytes: 5.42 kiB

Worker: PBSCluster-22

Comm: tcp://10.12.206.18:34993 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/44524/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.18:46562
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-3e1h8ye1
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 456.01 MiB Spilled bytes: 0 B
Read bytes: 64.60 MiB Write bytes: 16.18 MiB

Worker: PBSCluster-23

Comm: tcp://10.12.206.15:39733 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/46168/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.15:41249
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-xyvrzxs3
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 488.50 MiB Spilled bytes: 0 B
Read bytes: 161.13 MiB Write bytes: 96.72 MiB

Worker: PBSCluster-24

Comm: tcp://10.12.206.25:44221 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/45234/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.25:40387
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-yfm951kg
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 524.27 MiB Spilled bytes: 0 B
Read bytes: 145.12 MiB Write bytes: 81.16 MiB

Worker: PBSCluster-25

Comm: tcp://10.12.206.18:33408 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/43488/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.18:41022
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-6df9eo6t
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 439.95 MiB Spilled bytes: 0 B
Read bytes: 64.44 MiB Write bytes: 16.14 MiB

Worker: PBSCluster-26

Comm: tcp://10.12.206.8:38884 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/39795/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.8:40143
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-sb74tso9
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 447.47 MiB Spilled bytes: 0 B
Read bytes: 145.12 MiB Write bytes: 80.67 MiB

Worker: PBSCluster-27

Comm: tcp://10.12.206.15:40873 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/45934/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.15:41861
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-2tgmhfdl
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.53 MiB Spilled bytes: 0 B
Read bytes: 161.28 MiB Write bytes: 96.81 MiB

Worker: PBSCluster-28

Comm: tcp://10.12.206.18:36750 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/42860/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.18:43661
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-6lr4z8hl
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 474.45 MiB Spilled bytes: 0 B
Read bytes: 64.50 MiB Write bytes: 16.15 MiB

Worker: PBSCluster-29

Comm: tcp://10.12.206.8:32978 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/46650/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.8:38238
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-ihw76ltj
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 453.64 MiB Spilled bytes: 0 B
Read bytes: 145.21 MiB Write bytes: 80.73 MiB

Worker: PBSCluster-3

Comm: tcp://10.12.206.18:34352 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/35771/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.18:32780
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-l8qf3wzg
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 466.23 MiB Spilled bytes: 0 B
Read bytes: 64.56 MiB Write bytes: 16.17 MiB

Worker: PBSCluster-30

Comm: tcp://10.12.206.8:39013 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/33562/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.8:40233
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-peochg10
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 463.12 MiB Spilled bytes: 0 B
Read bytes: 145.18 MiB Write bytes: 80.71 MiB

Worker: PBSCluster-31

Comm: tcp://10.12.206.25:43689 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/43012/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.25:43417
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-yfzy1i0u
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 549.89 MiB Spilled bytes: 0 B
Read bytes: 128.94 MiB Write bytes: 65.02 MiB

Worker: PBSCluster-4

Comm: tcp://10.12.206.13:33058 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/43170/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.13:39266
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-yy1kkjd5
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.17 MiB Spilled bytes: 0 B
Read bytes: 112.71 MiB Write bytes: 64.44 MiB

Worker: PBSCluster-5

Comm: tcp://10.12.206.23:36916 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/42702/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.23:45113
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-8th_y8dw
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 472.57 MiB Spilled bytes: 0 B
Read bytes: 306.10 MiB Write bytes: 101.63 kiB

Worker: PBSCluster-6

Comm: tcp://10.12.206.8:38424 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/46679/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.8:44217
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-ml7gmjn8
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 0.0% Last seen: Just now
Memory usage: 459.16 MiB Spilled bytes: 0 B
Read bytes: 145.12 MiB Write bytes: 80.67 MiB

Worker: PBSCluster-7

Comm: tcp://10.12.206.25:44991 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/42629/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.25:45710
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-ab599zkf
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 450.16 MiB Spilled bytes: 0 B
Read bytes: 171.13 MiB Write bytes: 113.06 MiB

Worker: PBSCluster-8

Comm: tcp://10.12.206.25:42326 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/44451/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.25:35373
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-3gi9oohh
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 443.11 MiB Spilled bytes: 0 B
Read bytes: 129.11 MiB Write bytes: 65.10 MiB

Worker: PBSCluster-9

Comm: tcp://10.12.206.15:35080 Total threads: 1
Dashboard: https://jupyterhub.hpc.ucar.edu/stable/user/kristenk/proxy/46851/status Memory: 23.28 GiB
Nanny: tcp://10.12.206.15:39139
Local directory: /glade/scratch/kristenk/dask-workers/dask-worker-space/worker-9ijbos11
Tasks executing: 0 Tasks in memory: 0
Tasks ready: 0 Tasks in flight: 0
CPU usage: 2.0% Last seen: Just now
Memory usage: 452.07 MiB Spilled bytes: 0 B
Read bytes: 161.07 MiB Write bytes: 96.68 MiB

Load the data#

dsets = catalog.to_dataset_dict(
    case=casename,
    component=component,
    stream=stream,
)
dsets.keys()
dict_keys(['g.e22a06.G1850ECOIAF_JRA_PHYS_DEV.TL319_g17.scope_v1.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 0x2b6a9e36dbd0>
_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 0x2b6a9e8dc810>
_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