#!/usr/bin/env python # coding: utf-8 # #### Encoding for streamflow from single NetCDF file from S3 # In[1]: import xarray as xr import fsspec # In[2]: url = 's3://noaa-nwm-retrospective-2-1-pds/model_output/2020/202001011100.CHRTOUT_DOMAIN1.comp' # In[3]: fs = fsspec.filesystem('s3', anon=True) ds = xr.open_dataset(fs.open(url), drop_variables='reference_time', chunks={}) # In[4]: ds.streamflow.encoding # In[5]: ds.to_netcdf('roundtrip.nc', mode='w') # In[6]: xr.open_dataset('roundtrip.nc').streamflow.encoding