Skip to content

Instantly share code, notes, and snippets.

@jhamman
Created February 25, 2016 17:19
Show Gist options
  • Select an option

  • Save jhamman/557d04356b2699d7ba4d to your computer and use it in GitHub Desktop.

Select an option

Save jhamman/557d04356b2699d7ba4d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jhamman
Copy link
Copy Markdown
Author

jhamman commented Feb 27, 2016

Updated snow function using xarray objects:

def snow_disappearance_date(swe, dim='time', thresh=5):
    # create an array of indices the same shape as da,
    _, diminds = xr.broadcast(swe, swe[dim])
    # Find the indicies of the max swe
    maxinds = swe.argmax(dim=dim)
    # find the index of the first day where swe < thresh
    return swe.where((swe < thresh) & (diminds > maxinds)).argmax(dim=dim)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment