Skip to content

Instantly share code, notes, and snippets.

@ashiklom
Created May 8, 2025 13:51
Show Gist options
  • Save ashiklom/3dd89652eefdd12393c8243c053cbc4a to your computer and use it in GitHub Desktop.
Save ashiklom/3dd89652eefdd12393c8243c053cbc4a to your computer and use it in GitHub Desktop.
GiOcean constant variables
#!/usr/bin/env python
import xarray as xr
ds = xr.open_dataset("GiOCEAN_e1.sfc_tavg_3hr_glo_L720x361_sfc.20241101_0730z.nc4")
coord_vars = list(ds.coords)
stdev = ds.std()
var_names_all = list(stdev.variables)
var_names = list(set(var_names_all) - {"lon", "lat", "lev", "time"})
# Print variables for which standard deviation is zero
constant_vars = [var for var in var_names if stdev[var] == 0]
print(constant_vars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment