Skip to content

Instantly share code, notes, and snippets.

@fjaviersanchez
Created December 7, 2017 20:34
Show Gist options
  • Save fjaviersanchez/ee3fe852d9b8fac1366bf4c2123955b5 to your computer and use it in GitHub Desktop.
Save fjaviersanchez/ee3fe852d9b8fac1366bf4c2123955b5 to your computer and use it in GitHub Desktop.
small function
def compute_stats(x,y,z,bins,cut=[]):
b1, binx, biny, _ = binned_statistic_2d(x[cut],y[cut],z[cut],statistic='sum',bins=bins)
c1, binx, biny, _ = binned_statistic_2d(x[cut],y[cut],z[cut],statistic='count',bins=bins)
b2, binx, biny, _ = binned_statistic_2d(x[cut],y[cut],z[cut]**2,statistic='sum',bins=bins)
bin_center = 0.5*(bin_edges[1:]+bin_edges[:-1])
return b1, c1, b2, bin_center
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment