<jupyter_start><jupyter_text>Zero the Ciliates in the Restart File<jupyter_code>import numpy as np
import xarray as xr

%matplotlib inline
tracerrestart = '/results2/SalishSea/nowcast-green.201905/31oct14/SalishSea_03021840_restart_trc.nc'
df = xr.open_dataset(tracerrestart)
df.keys()
mesorub_keys = ['rnf_pis_MYRI_b', '<KEY>TRNMYRI', 'TRBMYRI']
df[mesorub_keys[2]][0, 0].plot();
for key in mesorub_keys:
    df[key] = 0.*df[key]
df[mesorub_keys[2]][0, 0].plot();
df
df.attrs['Manipulation'] = 'All Mesodinium rubrum fields set to zero'
netcdf_file = 'SalishSea_ZeroCiliates_03021840_restart_trc.nc'
df.attrs['file_name'] = netcdf_file
df.attrs
encoding = {var: {'zlib': True} for var in df.data_vars}

df.to_netcdf(netcdf_file, unlimited_dims=('t'),
        encoding=encoding,)
ds = xr.Dataset(
    {"zero": (["time_counter", "y", "x"], np.zeros((1, 898, 398)))},
    coords={
        "time_counter": np.array([0]),
        "y": np.arange(898),
        "x": np.arange(398),
       },
    attrs = {'summary': 'Flat field of zeros'}

)
ds
encoding = {'zero': {'zlib': True} }

ds.to_netcdf('all_zeros.nc', unlimited_dims=('time_counter'),
        encoding=encoding,)
ds.zero
checkfile = xr.open_dataset('SalishSea_ZeroCiliates_03153600_restart_trc.nc')
checkfile
checkfile.rnf_pis_MYRI_b.plot();
checkfile.sbc_MYRI_b.plot()
checkfile.TRNMYRI[0].sum(axis=0).plot()
checkfile.TRBMYRI[0].sum(axis=0).plot()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup