Global BGC metrics#

%load_ext autoreload
%autoreload 2
import xarray as xr

from dask.distributed import Client

import catalog
import util

xr.set_options(keep_attrs=True)

import matplotlib.pyplot as plt
import cartopy
import cartopy.crs as ccrs
import pop_tools
import numpy as np
import pandas as pd
/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
ds_grid = pop_tools.get_grid('POP_gx1v7')
lons=ds_grid.TLONG
lats=ds_grid.TLAT
area = ds_grid.TAREA
area_m = area/1.e4

Parameters#

casename = 'g.e22.GOMIPECOIAF_JRA-1p4-2018.TL319_g17.4p2z.001'
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-965db3b4-9355-11ed-8749-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: 4 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: 254.73 MiB Spilled bytes: 0 B
Read bytes: 437.01 MiB Write bytes: 279.57 MiB

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: 239.00 MiB Spilled bytes: 0 B
Read bytes: 63.36 kiB Write bytes: 105.35 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: 237.13 MiB Spilled bytes: 0 B
Read bytes: 16.98 kiB Write bytes: 9.97 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: 268.32 MiB Spilled bytes: 0 B
Read bytes: 405.66 MiB Write bytes: 117.09 MiB

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: 244.30 MiB Spilled bytes: 0 B
Read bytes: 17.42 kiB Write bytes: 4.11 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: 2.0% Last seen: Just now
Memory usage: 253.82 MiB Spilled bytes: 0 B
Read bytes: 17.30 kiB Write bytes: 6.74 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: 2.0% Last seen: Just now
Memory usage: 242.37 MiB Spilled bytes: 0 B
Read bytes: 18.38 kiB Write bytes: 7.67 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: 258.38 MiB Spilled bytes: 0 B
Read bytes: 437.22 MiB Write bytes: 279.71 MiB

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: 248.69 MiB Spilled bytes: 0 B
Read bytes: 17.29 kiB Write bytes: 8.34 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: 246.27 MiB Spilled bytes: 0 B
Read bytes: 18.36 kiB Write bytes: 5.94 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: 235.92 MiB Spilled bytes: 0 B
Read bytes: 437.17 MiB Write bytes: 279.68 MiB

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: 268.20 MiB Spilled bytes: 0 B
Read bytes: 553.11 MiB Write bytes: 384.14 MiB

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: 246.82 MiB Spilled bytes: 0 B
Read bytes: 17.44 kiB Write bytes: 4.12 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: 0.0% Last seen: Just now
Memory usage: 252.24 MiB Spilled bytes: 0 B
Read bytes: 63.09 kiB Write bytes: 104.24 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: 2.0% Last seen: Just now
Memory usage: 254.80 MiB Spilled bytes: 0 B
Read bytes: 18.38 kiB Write bytes: 9.28 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: 260.64 MiB Spilled bytes: 0 B
Read bytes: 1.18 MiB Write bytes: 9.15 MiB

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: 256.15 MiB Spilled bytes: 0 B
Read bytes: 63.31 kiB Write bytes: 105.87 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: 259.64 MiB Spilled bytes: 0 B
Read bytes: 302.09 MiB Write bytes: 224.00 MiB

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: 243.75 MiB Spilled bytes: 0 B
Read bytes: 17.49 kiB Write bytes: 5.74 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: 2.0% Last seen: Just now
Memory usage: 258.55 MiB Spilled bytes: 0 B
Read bytes: 406.14 MiB Write bytes: 117.23 MiB

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: 2.0% Last seen: Just now
Memory usage: 261.18 MiB Spilled bytes: 0 B
Read bytes: 1.28 GiB Write bytes: 908.31 MiB

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: 239.98 MiB Spilled bytes: 0 B
Read bytes: 17.25 kiB Write bytes: 7.52 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: 2.0% Last seen: Just now
Memory usage: 260.31 MiB Spilled bytes: 0 B
Read bytes: 406.10 MiB Write bytes: 117.22 MiB

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: 252.99 MiB Spilled bytes: 0 B
Read bytes: 17.35 kiB Write bytes: 5.14 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: 0.0% Last seen: Just now
Memory usage: 246.96 MiB Spilled bytes: 0 B
Read bytes: 17.40 kiB Write bytes: 3.31 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: 0.0% Last seen: Just now
Memory usage: 242.38 MiB Spilled bytes: 0 B
Read bytes: 17.29 kiB Write bytes: 8.34 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: 0.0% Last seen: Just now
Memory usage: 262.45 MiB Spilled bytes: 0 B
Read bytes: 436.82 MiB Write bytes: 279.45 MiB

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: 263.95 MiB Spilled bytes: 0 B
Read bytes: 804.25 MiB Write bytes: 210.77 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: 2.0% Last seen: Just now
Memory usage: 241.26 MiB Spilled bytes: 0 B
Read bytes: 17.26 kiB Write bytes: 9.93 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: 248.26 MiB Spilled bytes: 0 B
Read bytes: 18.46 kiB Write bytes: 6.90 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: 257.93 MiB Spilled bytes: 0 B
Read bytes: 405.81 MiB Write bytes: 117.14 MiB

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: 254.30 MiB Spilled bytes: 0 B
Read bytes: 17.34 kiB Write bytes: 5.14 kiB

Load the data#

%%time

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
CPU times: user 1min 14s, sys: 1.34 s, total: 1min 16s
Wall time: 1min 38s
dict_keys(['g.e22.GOMIPECOIAF_JRA-1p4-2018.TL319_g17.4p2z.001branch.pop.h'])
ds = dsets[f'{casename}.{component}.{stream}']

Variable list#

variables =['photoC_TOT_zint',
            'photoC_sp_zint','photoC_diat_zint',
            'photoC_diaz_zint','photoC_cocco_zint',
            'SiO2_PROD','CaCO3_PROD_zint','diaz_Nfix',
            'mesozooC','microzooC','x_graze_microzoo_zint','x_graze_mesozoo_zint',
            'POC_FLUX_100m']
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])
dt_wgt = ds.time_bound.diff('d2').squeeze()
dt_wgt /= dt_wgt.sum()
#dt_wgt
ds = ds.weighted(dt_wgt).mean('time')

Make Global integrals#

Percent NPP by diatoms#

ds_glb['diatNPPpercent'] = ds_glb.photoC_diat_zint / ds_glb.photoC_TOT_zint * 100.
ds_glb['diatNPPpercent'].attrs['units'] = '%'

Diatom silicification#

tmp = (ds.SiO2_PROD.isel(z_t=slice(0,10)) * 10.).sum(dim='z_t') ## depth integral, units in mmol/m2/s
tmp = tmp * area_m ## mmol/s
tmp = tmp * 86400. * 365 * 0.001 ## mol/yr 
tmp = tmp.sum(dim=('nlon','nlat')) * 1.e-12 #Tmol/yr

ds_glb['SiO2_PROD'] = tmp
ds_glb['SiO2_PROD'].attrs['units'] = 'Tmol Si yr$^{-1}$'

Nitrogen fixation#

tmp = (ds['diaz_Nfix'] * 10.).sum(dim='z_t_150m') # unit is mmol/m2/s
tmp = tmp * area_m ## mmol/s
tmp = tmp * 86400. * 365. * 0.001 * 14. * 1e-12 #convert to Tg N / yr

ds_glb['diaz_Nfix'] = tmp.sum(dim=('nlon','nlat'))
ds_glb['diaz_Nfix'].attrs['units'] = 'Tg N yr$^{-1}$'

Zooplankton biomass#

tmp = (ds.microzooC * 10.).sum(dim='z_t_150m') #mmol/m2
tmp = (tmp * area_m * 0.001).sum(dim=('nlon','nlat')) ## mol
tmp = tmp.values * 1.e-15 * 12.011 #Pg C
ds_glb['microzooC'] = tmp
ds_glb['microzooC'].attrs['units'] = 'Pg C'

tmp = (ds.mesozooC * 10.).sum(dim='z_t_150m') #mmol/m2
tmp = (tmp * area_m * 0.001).sum(dim=('nlon','nlat')) ## mol
tmp = tmp.values * 1.e-15 * 12.011 #Pg C
ds_glb['mesozooC'] = tmp
ds_glb['mesozooC'].attrs['units'] = 'Pg C'

Zooplankton productivity as % NPP#

ds_glb['zooprodNPPpercent'] = (ds_glb['x_graze_mesozoo_zint'] + ds_glb['x_graze_microzoo_zint'])/ds_glb['photoC_TOT_zint'] * 100.
ds_glb['zooprodNPPpercent'].attrs['units'] = '%'

Make a table of global metrics#

df = pd.DataFrame(columns=['Metric','unit','CESM','Obs','Reference'])
df.loc[0] = ['NPP',ds_glb.photoC_TOT_zint.attrs['units'],np.round(ds_glb.photoC_TOT_zint.values, 2),'45 to 55','Behrenfeld & Falkowski 1997; Carr et al., 2006']
df.loc[1] = ['POC export 100m',ds_glb.POC_FLUX_100m.attrs['units'],np.round(ds_glb.POC_FLUX_100m.values, 2),'4 to 12','DeVries & Weber, 2017']
df.loc[2] = ['%NPP by diatoms',ds_glb.diatNPPpercent.attrs['units'],np.round(ds_glb.diatNPPpercent.values, 2),'40%','Nelson et al., 1995']
df.loc[3] = ['Silicification',ds_glb.SiO2_PROD.attrs['units'],np.round(ds_glb.SiO2_PROD.values, 2),'100 to 190','Nelson et al., 1995; Holzer et al., 2014']
df.loc[4] = ['Nitrogen fixation',ds_glb.diaz_Nfix.attrs['units'],np.round(ds_glb.diaz_Nfix.values, 2),'125.6 and 222.9','Wang et al., 2019']
df.loc[5] = ['Microzooplankton biomass',ds_glb.microzooC.attrs['units'],np.round(ds_glb.microzooC.values, 2),'0.24','Buitenhuis et al., 2010']
df.loc[6] = ['Mesozooplankton biomass',ds_glb.mesozooC.attrs['units'],np.round(ds_glb.mesozooC.values, 2),'0.16 to 0.19','Buitenhuis et al., 2006; Moriarty & OBrien, 2013']
df.loc[7] = ['Zoo prod % of NPP',ds_glb.zooprodNPPpercent.attrs['units'],np.round(ds_glb.zooprodNPPpercent.values, 2),'~25%','ref?']
df
Metric unit CESM Obs Reference
0 NPP Pg C yr$^{-1}$ 53.64 45 to 55 Behrenfeld & Falkowski 1997; Carr et al., 2006
1 POC export 100m Pg C yr$^{-1}$ 6.83 4 to 12 DeVries & Weber, 2017
2 %NPP by diatoms % 39.76 40% Nelson et al., 1995
3 Silicification Tmol Si yr$^{-1}$ 106.48 100 to 190 Nelson et al., 1995; Holzer et al., 2014
4 Nitrogen fixation Tg N yr$^{-1}$ 169.05 125.6 and 222.9 Wang et al., 2019
5 Microzooplankton biomass Pg C 0.23 0.24 Buitenhuis et al., 2010
6 Mesozooplankton biomass Pg C 0.40 0.16 to 0.19 Buitenhuis et al., 2006; Moriarty & OBrien, 2013
7 Zoo prod % of NPP % 25.14 ~25% ref?