-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
STY: Apply black and ruff again after rebase
- Loading branch information
1 parent
526c211
commit 464791e
Showing
7 changed files
with
187 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,47 @@ | ||
import numpy as np | ||
from scipy.stats import binned_statistic | ||
|
||
|
||
def makeProfile(x, y, bins, range=None, spread=False): | ||
## NaN for empty bins are suppressed | ||
## using mean root(N) for non-empty bins to calculate 0 var weights | ||
## | ||
## spread=True to return standard deviation instead of standard error | ||
|
||
meansObj = binned_statistic(x, [y, y**2], bins=bins, range=range, statistic='mean') | ||
meansObj = binned_statistic(x, [y, y**2], bins=bins, range=range, statistic="mean") | ||
means, means2 = meansObj.statistic | ||
countsObj = binned_statistic(x, [y, y**2], bins=bins, range=(0,1), statistic='count') | ||
countsObj = binned_statistic(x, [y, y**2], bins=bins, range=(0, 1), statistic="count") | ||
bin_N = countsObj.statistic | ||
yErr = np.sqrt(means2 - means**2) | ||
if not spread: | ||
root_N = np.sqrt(bin_N) | ||
root_N[root_N==0] = root_N[root_N>0].mean() | ||
yErr = yErr/root_N | ||
root_N[root_N == 0] = root_N[root_N > 0].mean() | ||
yErr = yErr / root_N | ||
##yErr = yErr.clip(0, 6666666.) | ||
bin_edges = means_result.bin_edges | ||
bin_centers = (bin_edges[:-1] + bin_edges[1:])/2. | ||
usefulBins = bin_N>0 | ||
bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2.0 | ||
usefulBins = bin_N > 0 | ||
return bin_centers[usefulBins], means[usefulBins], yErr[usefulBins] | ||
|
||
|
||
def plotProfile(x, y, yErr): | ||
plt.errorbar(x=x, y=y, yerr=yErr, linestyle='none', marker='.') | ||
plt.errorbar(x=x, y=y, yerr=yErr, linestyle="none", marker=".") | ||
|
||
|
||
def selectedClusters(clusters, row, col, lowEnerygCut, highEnergyCut, nPixelCut=4, isSquare=1): | ||
pass | ||
|
||
|
||
def goodClusters(clusters, row, col, nPixelCut=4, isSquare=None): | ||
##print(clusters) | ||
pixelRowCol = np.bitwise_and((clusters[:,:,1] == row), | ||
(clusters[:,:,2] == col)) | ||
pixelRowCol = np.bitwise_and((clusters[:, :, 1] == row), (clusters[:, :, 2] == col)) | ||
if isSquare is None: | ||
small = clusters[:,:,3]<nPixelCut | ||
small = clusters[:, :, 3] < nPixelCut | ||
else: | ||
small = np.bitwise_and((clusters[:,:,3]<nPixelCut), (clusters[:,:,4]==isSquare)) | ||
small = np.bitwise_and((clusters[:, :, 3] < nPixelCut), (clusters[:, :, 4] == isSquare)) | ||
return clusters[np.bitwise_and(small, pixelRowCol)] | ||
|
||
|
||
def getClusterEnergies(clusters): | ||
##print(clusters) | ||
return clusters[:, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.