Skip to content

Instantly share code, notes, and snippets.

@raphaeldussin
Created December 3, 2020 02:09
Show Gist options
  • Select an option

  • Save raphaeldussin/6681d03339975050e7b38f4c1e8cb081 to your computer and use it in GitHub Desktop.

Select an option

Save raphaeldussin/6681d03339975050e7b38f4c1e8cb081 to your computer and use it in GitHub Desktop.
function for the roms2zarr tutorial
def remove_all_small_variables(ds):
""" remove all the variables that have less than 3 dimensions
Parameters:
ds (xarray.Dataset): ROMS dataset
"""
for v in ds.variables:
if v not in ['Cs_r', 'Cs_w', 'hc', 'Vtransform', 'ocean_time']:
ds = ds.drop_vars(v) if len(ds[v].dims) < 3 else ds
return ds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment