Phytoplankton productivity#

%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 0x2b1485fb0cd0>
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

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-4880be14-9357-11ed-99cd-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: 16 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: 4.0% Last seen: Just now
Memory usage: 362.54 MiB Spilled bytes: 0 B
Read bytes: 132.29 MiB Write bytes: 100.81 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: 2.0% Last seen: Just now
Memory usage: 445.88 MiB Spilled bytes: 0 B
Read bytes: 20.32 kiB Write bytes: 7.61 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: 460.36 MiB Spilled bytes: 0 B
Read bytes: 19.84 kiB Write bytes: 11.98 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: 0.0% Last seen: Just now
Memory usage: 437.38 MiB Spilled bytes: 0 B
Read bytes: 24.46 kiB Write bytes: 9.11 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: 405.22 MiB Spilled bytes: 0 B
Read bytes: 31.14 kiB Write bytes: 24.74 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: 414.01 MiB Spilled bytes: 0 B
Read bytes: 19.94 kiB Write bytes: 7.14 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: 464.34 MiB Spilled bytes: 0 B
Read bytes: 26.31 kiB Write bytes: 46.66 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: 411.12 MiB Spilled bytes: 0 B
Read bytes: 132.16 MiB Write bytes: 100.71 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: 414.74 MiB Spilled bytes: 0 B
Read bytes: 19.63 kiB Write bytes: 13.25 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: 2.0% Last seen: Just now
Memory usage: 392.65 MiB Spilled bytes: 0 B
Read bytes: 26.32 kiB Write bytes: 44.26 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: 412.42 MiB Spilled bytes: 0 B
Read bytes: 132.20 MiB Write bytes: 100.74 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: 4.0% Last seen: Just now
Memory usage: 361.07 MiB Spilled bytes: 0 B
Read bytes: 84.31 kiB Write bytes: 28.79 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: 358.96 MiB Spilled bytes: 0 B
Read bytes: 26.30 kiB Write bytes: 44.23 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: 417.92 MiB Spilled bytes: 0 B
Read bytes: 20.28 kiB Write bytes: 5.98 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: 429.60 MiB Spilled bytes: 0 B
Read bytes: 26.04 kiB Write bytes: 48.29 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: 419.82 MiB Spilled bytes: 0 B
Read bytes: 115.08 kiB Write bytes: 155.50 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: 461.72 MiB Spilled bytes: 0 B
Read bytes: 20.31 kiB Write bytes: 5.99 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: 0.0% Last seen: Just now
Memory usage: 321.39 MiB Spilled bytes: 0 B
Read bytes: 24.61 kiB Write bytes: 11.65 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: 0.0% Last seen: Just now
Memory usage: 304.46 MiB Spilled bytes: 0 B
Read bytes: 26.35 kiB Write bytes: 44.31 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: 314.06 MiB Spilled bytes: 0 B
Read bytes: 24.93 kiB Write bytes: 11.77 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: 2.0% Last seen: Just now
Memory usage: 361.09 MiB Spilled bytes: 0 B
Read bytes: 27.22 kiB Write bytes: 13.59 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: 2.0% Last seen: Just now
Memory usage: 407.43 MiB Spilled bytes: 0 B
Read bytes: 19.96 kiB Write bytes: 7.95 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: 393.84 MiB Spilled bytes: 0 B
Read bytes: 24.59 kiB Write bytes: 9.22 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: 300.03 MiB Spilled bytes: 0 B
Read bytes: 19.96 kiB Write bytes: 6.34 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: 413.62 MiB Spilled bytes: 0 B
Read bytes: 26.45 kiB Write bytes: 43.53 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: 362.80 MiB Spilled bytes: 0 B
Read bytes: 20.01 kiB Write bytes: 8.78 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: 4.0% Last seen: Just now
Memory usage: 352.09 MiB Spilled bytes: 0 B
Read bytes: 132.17 MiB Write bytes: 100.72 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: 343.86 MiB Spilled bytes: 0 B
Read bytes: 8.90 MiB Write bytes: 48.51 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: 300.09 MiB Spilled bytes: 0 B
Read bytes: 19.96 kiB Write bytes: 11.18 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: 345.66 MiB Spilled bytes: 0 B
Read bytes: 26.27 kiB Write bytes: 47.40 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: 409.21 MiB Spilled bytes: 0 B
Read bytes: 24.57 kiB Write bytes: 10.83 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: 535.48 MiB Spilled bytes: 0 B
Read bytes: 19.96 kiB Write bytes: 6.34 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}']
ds
<xarray.Dataset>
Dimensions:                           (time: 120, d2: 2, moc_comp: 3, transport_comp: 5, transport_reg: 2, z_t: 60, z_t_150m: 15, z_w: 60, z_w_top: 60, z_w_bot: 60, lat_aux_grid: 395, moc_z: 61, nlat: 384, nlon: 320)
Coordinates: (12/16)
    transport_components              (transport_comp) |S384 dask.array<chunksize=(5,), meta=np.ndarray>
    transport_regions                 (transport_reg) |S384 dask.array<chunksize=(2,), meta=np.ndarray>
  * time                              (time) object 2012-01-16 12:00:00 ... 2...
  * z_t                               (z_t) float32 500.0 1.5e+03 ... 5.375e+05
  * z_t_150m                          (z_t_150m) float32 500.0 ... 1.45e+04
  * z_w                               (z_w) float32 0.0 1e+03 ... 5e+05 5.25e+05
    ...                                ...
    ULONG                             (nlat, nlon) float64 dask.array<chunksize=(384, 320), meta=np.ndarray>
    ULAT                              (nlat, nlon) float64 dask.array<chunksize=(384, 320), meta=np.ndarray>
    TLONG                             (nlat, nlon) float64 dask.array<chunksize=(384, 320), meta=np.ndarray>
    TLAT                              (nlat, nlon) float64 dask.array<chunksize=(384, 320), meta=np.ndarray>
    KMT                               (nlat, nlon) float64 dask.array<chunksize=(384, 320), meta=np.ndarray>
    TAREA                             (nlat, nlon) float64 dask.array<chunksize=(384, 320), meta=np.ndarray>
Dimensions without coordinates: d2, moc_comp, transport_comp, transport_reg, nlat, nlon
Data variables: (12/543)
    time_bound                        (time, d2) float64 dask.array<chunksize=(1, 2), meta=np.ndarray>
    moc_components                    (time, moc_comp) |S384 dask.array<chunksize=(1, 3), meta=np.ndarray>
    dz                                (time, z_t) float32 dask.array<chunksize=(1, 60), meta=np.ndarray>
    dzw                               (time, z_w) float32 dask.array<chunksize=(1, 60), meta=np.ndarray>
    KMU                               (time, nlat, nlon) float64 dask.array<chunksize=(1, 384, 320), meta=np.ndarray>
    REGION_MASK                       (time, nlat, nlon) float64 dask.array<chunksize=(1, 384, 320), meta=np.ndarray>
    ...                                ...
    XBLT                              (time, nlat, nlon) float32 dask.array<chunksize=(1, 384, 320), meta=np.ndarray>
    TBLT                              (time, nlat, nlon) float32 dask.array<chunksize=(1, 384, 320), meta=np.ndarray>
    BSF                               (time, nlat, nlon) float32 dask.array<chunksize=(1, 384, 320), meta=np.ndarray>
    MOC                               (time, transport_reg, moc_comp, moc_z, lat_aux_grid) float32 dask.array<chunksize=(1, 2, 3, 61, 395), meta=np.ndarray>
    N_HEAT                            (time, transport_reg, transport_comp, lat_aux_grid) float32 dask.array<chunksize=(1, 2, 5, 395), meta=np.ndarray>
    N_SALT                            (time, transport_reg, transport_comp, lat_aux_grid) float32 dask.array<chunksize=(1, 2, 5, 395), meta=np.ndarray>
Attributes:
    title:             g.e22.GOMIPECOIAF_JRA-1p4-2018.TL319_g17.4p2z.001branch
    history:           none
    Conventions:       CF-1.0; http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-cu...
    time_period_freq:  month_1
    model_doi_url:     https://doi.org/10.5065/D67H1H0V
    contents:          Diagnostic and Prognostic Variables
    source:            CCSM POP2, the CCSM Ocean Component
    revision:          $Id$
    calendar:          All years have exactly  365 days.
    start_time:        This dataset was created on 2022-09-27 at 10:32:16.2
    cell_methods:      cell_methods = time: mean ==> the variable values are ...

Variable list#

variables =['photoC_TOT_zint',
            'photoC_sp_zint','photoC_diat_zint',
            'photoC_diaz_zint','photoC_cocco_zint']
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.photoC_cocco_zint.isel(time=0).plot()
<matplotlib.collections.QuadMesh at 0x2b1489e3af90>
_images/ocn-phyto-prod_17_1.png
ds.photoC_cocco_zint.isel(time=6).plot()
<matplotlib.collections.QuadMesh at 0x2b148a6d1910>
_images/ocn-phyto-prod_18_1.png
dt_wgt = ds.time_bound.diff('d2').squeeze()
dt_wgt /= dt_wgt.sum()
#dt_wgt
ds = ds.weighted(dt_wgt).mean('time')
fig = plt.figure(figsize=(8,10))

ax = fig.add_subplot(4,1,1, projection=ccrs.Robinson(central_longitude=305.0))
ax.set_title('Small phytoplankton production', fontsize=12)
lon, lat, field = util.adjust_pop_grid(lons, lats, ds.photoC_sp_zint * 864.)
pc=ax.pcolormesh(lon, lat, field, cmap='jet',vmin=0,vmax=15,transform=ccrs.PlateCarree())

cbar1 = fig.colorbar(pc, ax=ax,extend='max',label='sp prod (mmol m$^{-2}$ d$^{-1}$)')

ax = fig.add_subplot(4,1,2, projection=ccrs.Robinson(central_longitude=305.0))
ax.set_title('Diatom production', fontsize=12)
lon, lat, field = util.adjust_pop_grid(lons, lats, ds.photoC_diat_zint * 864.)
pc=ax.pcolormesh(lon, lat, field, cmap='jet',vmin=0,vmax=15,transform=ccrs.PlateCarree())

cbar1 = fig.colorbar(pc, ax=ax,extend='max',label='diat prod (mmol m$^{-2}$ d$^{-1}$)')

ax = fig.add_subplot(4,1,3, projection=ccrs.Robinson(central_longitude=305.0))
ax.set_title('Diazotroph production', fontsize=12)
lon, lat, field = util.adjust_pop_grid(lons, lats, ds.photoC_diaz_zint * 864.)
pc=ax.pcolormesh(lon, lat, field, cmap='jet',vmin=0,vmax=10,transform=ccrs.PlateCarree())

cbar1 = fig.colorbar(pc, ax=ax,extend='max',label='diaz prod (mmol m$^{-2}$ d$^{-1}$)')

ax = fig.add_subplot(4,1,4, projection=ccrs.Robinson(central_longitude=305.0))
ax.set_title('Coccolithophore production', fontsize=12)
lon, lat, field = util.adjust_pop_grid(lons, lats, ds.photoC_cocco_zint * 864.)
pc=ax.pcolormesh(lon, lat, field, cmap='jet',vmin=0,vmax=10,transform=ccrs.PlateCarree())

cbar1 = fig.colorbar(pc, ax=ax,extend='max',label='cocco prod (mmol m$^{-2}$ d$^{-1}$)');
_images/ocn-phyto-prod_21_0.png
fig = plt.figure(figsize=(12,5))

ax = fig.add_subplot(1,1,1, projection=ccrs.Robinson(central_longitude=305.0))
ax.set_title('Total NPP', fontsize=12)
lon, lat, field = util.adjust_pop_grid(lons, lats,  ds.photoC_TOT_zint*864.)
pc=ax.pcolormesh(lon, lat, field, cmap='jet',vmin=0,vmax=60,transform=ccrs.PlateCarree())
cbar1 = fig.colorbar(pc, ax=ax,extend='max',label='NPP (mmol m$^{-2}$ d$^{-1}$)');
_images/ocn-phyto-prod_22_0.png

Globally integrated NPP#

ds_glb = util.global_mean(ds, ds_grid, variables,normalize=False).compute()

nmols_to_PgCyr = 1e-9 * 12. * 1e-15 * 365. * 86400.

for v in variables:
    ds_glb[v] = ds_glb[v] * nmols_to_PgCyr        
    ds_glb[v].attrs['units'] = 'Pg C yr$^{-1}$'
    
ds_glb
<xarray.Dataset>
Dimensions:            ()
Data variables:
    photoC_TOT_zint    float64 53.64
    photoC_sp_zint     float64 27.88
    photoC_diat_zint   float64 21.33
    photoC_diaz_zint   float64 1.002
    photoC_cocco_zint  float64 3.428

TO DO#

• make climatologies and plot map for each month

• Compare global NPP map to satellite-derived NPP (CbPM, VGPM, Eppley-VGPM)