Skip to content

Instantly share code, notes, and snippets.

@willrayeo
Last active May 3, 2021 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willrayeo/218bd2d59caf5e2ec088d489a0b99af6 to your computer and use it in GitHub Desktop.
Save willrayeo/218bd2d59caf5e2ec088d489a0b99af6 to your computer and use it in GitHub Desktop.
creating new variable
#convert VV DN to Decibels
vv_dn = s1_cube.VV
vv_db = 10 * (xr.ufuncs.log10(vv_dn))
vv_db = vv_db.where(xr.ufuncs.isfinite(vv_db), 0)
# attribute long name and units to new variable
vv_db.attrs['long_name']='VV_dB'
vv_db.attrs['units']='decibels'
# define the new variable
s1_cube['VV_dB']= vv_db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment