import s3fs
import xarray as xr
from dask.distributed import Client
client = Client("dask-scheduler:8786")
client
Client
|
Cluster
|
url='https://iu.jetstream-cloud.org:8080'
fs = s3fs.S3FileSystem(client_kwargs=dict(endpoint_url=url), anon=True)
s3map = s3fs.S3Map('rsignell/nwm/test_week', s3=fs)
ds = xr.open_zarr(s3map)
ds
<xarray.Dataset> Dimensions: (nv: 2, reference_time: 146, time: 146, x: 4608, y: 3840) Coordinates: * reference_time (reference_time) datetime64[ns] 2018-04-01 ... * time (time) datetime64[ns] 2018-04-01T01:00:00 ... * x (x) float64 -2.304e+06 -2.303e+06 -2.302e+06 -2.301e+06 ... * y (y) float64 -1.92e+06 -1.919e+06 -1.918e+06 -1.917e+06 ... Dimensions without coordinates: nv Data variables: LWDOWN (time, y, x) float64 dask.array<shape=(146, 3840, 4608), chunksize=(1, 3840, 4608)> PSFC (time, y, x) float64 dask.array<shape=(146, 3840, 4608), chunksize=(1, 3840, 4608)> Q2D (time, y, x) float64 dask.array<shape=(146, 3840, 4608), chunksize=(1, 3840, 4608)> RAINRATE (time, y, x) float32 dask.array<shape=(146, 3840, 4608), chunksize=(1, 3840, 4608)> SWDOWN (time, y, x) float64 dask.array<shape=(146, 3840, 4608), chunksize=(1, 3840, 4608)> T2D (time, y, x) float64 dask.array<shape=(146, 3840, 4608), chunksize=(1, 3840, 4608)> U2D (time, y, x) float64 dask.array<shape=(146, 3840, 4608), chunksize=(1, 3840, 4608)> V2D (time, y, x) float64 dask.array<shape=(146, 3840, 4608), chunksize=(1, 3840, 4608)> time_bounds (time, nv) datetime64[ns] dask.array<shape=(146, 2), chunksize=(146, 2)> Attributes: DODS.strlen: 0 DODS_EXTRA.Unlimited_Dimension: time model_initialization_time: 2018-04-01_00:00:00 model_output_valid_time: 2018-04-01_01:00:00
var='T2D'
print('start:',ds[var][0].time.values)
print(' stop:',ds[var][-1].time.values)
start: 2018-04-01T01:00:00.000000000 stop: 2018-04-07T02:00:00.000000000
ds.nbytes/1.e9
155.005819456
ds[var].nbytes/1.e9
20.66743296
%%time
mean_var = ds[var][:,:,:].mean(dim='time').compute()
isub = 4
mean_var[::isub,::isub].plot.imshow(figsize=(8,6));
Try plotting first time step
isub=50
ds[var][0,::isub,::isub].plot.imshow(figsize=(8,6))