Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a rebinning ability #20

Open
marshallmcdonnell opened this issue Dec 13, 2018 · 0 comments
Open

Add a rebinning ability #20

marshallmcdonnell opened this issue Dec 13, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@marshallmcdonnell
Copy link
Member

marshallmcdonnell commented Dec 13, 2018

Here is the rebin code I have that did this previously. Want it for smoothing via coarsening the binning:

#!/usr/bin/env python
from __future__ import (absolute_import, division, print_function)

import numpy as np
import argparse
import matplotlib.pyplot as plt

def rebin2_rmc(xin, yin, minx, xdiv, maxx):
    xout  = np.arange(minx, maxx+2.*xdiv, xdiv)
    yout  = np.zeros_like(xout)
    ynorm = np.zeros_like(xout)
    print('Number of points ', len(xout))

    for x, y in zip(xin, yin):
        if minx <= x and x<= maxx:
            idx = int((x-minx)/xdiv)
            scale1=1.-(x-xout[idx])/xdiv
            scale2=1.-scale1

            yout[idx]   = yout[idx]   + y*scale1
            yout[idx+1] = yout[idx+1] + y*scale2

            ynorm[idx]   = ynorm[idx]   + scale1
            ynorm[idx+1] = ynorm[idx+1] + scale2

    yout = yout / ynorm

    return xout, yout

@marshallmcdonnell marshallmcdonnell added the enhancement New feature or request label Dec 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant