Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'bigyan'
- import re
- import numpy as np
- startBinValue = 5060
- endBinValue = 5176
- binSize = 0.1
- bins = np.arange(startBinValue, endBinValue, binSize)
- x = [] # Column 1: HJD
- y = [] # Column 2: Tamuz-corrected magnitude
- numLine = 0
- with open("/Users/bigyan/Downloads/sample_data.txt") as file:
- for line in file:
- numLine += 1
- line = line.strip()
- if numLine >= 111:
- data = [colValue for colValue in re.split(" +", line) if len(colValue) > 0]
- x.append(float(data[0]))
- y.append(float(data[1]))
- x_binned = np.digitize(x, bins)
- y_numpyArray = np.array(y)
- y_means = np.array([
- y_numpyArray[x_binned == i].mean()
- if len(y_numpyArray[x_binned == i]) > 0
- else 0
- for i in range(1, len(bins))])
- binnedData = [(bins[i], bins[i + 1], y_means[i]) for i in range(len(y_means))]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement