%matplotlib inline
import xarray as xr
import matplotlib.pyplot as plt
from dask.distributed import Client, progress, LocalCluster
from dask_kubernetes import KubeCluster
import s3fs
cluster = KubeCluster(n_workers=8)
client = Client(cluster)
cluster
VBox(children=(HTML(value='<h2>KubeCluster</h2>'), HBox(children=(HTML(value='\n<div>\n <style scoped>\n .…
#url = 'http://gamone.whoi.edu/thredds/dodsC/sand/usgs/users/nganju/portal_runs/chincoteague_bedelevation/00_dir.ncml'
# AWS s3
fs = s3fs.S3FileSystem(anon=True)
s3map = s3fs.S3Map('esipfed/pangeo/COAWST', s3=fs)
ds = xr.open_zarr(s3map)
ds.salt
<xarray.DataArray 'salt' (ocean_time: 2877, s_rho: 7, eta_rho: 670, xi_rho: 300)> dask.array<shape=(2877, 7, 670, 300), dtype=float64, chunksize=(24, 7, 670, 300)> Coordinates: lat_rho (eta_rho, xi_rho) float64 dask.array<shape=(670, 300), chunksize=(670, 300)> lon_rho (eta_rho, xi_rho) float64 dask.array<shape=(670, 300), chunksize=(670, 300)> * ocean_time (ocean_time) datetime64[ns] 2014-11-01T01:00:00 ... 2015-02-28T21:00:00 * s_rho (s_rho) float64 -0.9286 -0.7857 -0.6429 ... -0.2143 -0.07143 Dimensions without coordinates: eta_rho, xi_rho Attributes: field: salinity, scalar, series long_name: salinity time: ocean_time
ds['salt'][-1,0,:,:].plot(vmin=33, vmax=34)
<matplotlib.collections.QuadMesh at 0x7f4d70130860>
ds.salt.nbytes/1e9
32.383512
dsmean = ds.salt.mean(dim=['s_rho','ocean_time']).persist()
progress(dsmean)
VBox()
dsmean.plot(vmin=33, vmax=34)
<matplotlib.collections.QuadMesh at 0x7f4d513467f0>