Created
August 27, 2019 17:22
-
-
Save ariannarocchetti/c41e20e189097ebeb78d11b4f989e173 to your computer and use it in GitHub Desktop.
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
class S1AreaFractionTop_he(Lichen): | |
"""Cut between the 0.05th and the 99.9th percentile of the population in the parameter space Z vs S1AFT | |
Note: https://xe1t-wiki.lngs.infn.it/doku.php?id=xenon:xenon1t:arianna:s1_aft_highenergy | |
Contact: arianna.rocchetti@physik.uni-freiburg.de Arianna Rocchetti. | |
Cut defined above cs1>200. | |
""" | |
version = 1 | |
def _process(df): | |
print("Warning: Cut defined above cs1>200. ") | |
def f1(x): | |
f1 = -280.1*x**2 + 463.3 * x - 148.2 | |
return f1 | |
def f2(x): | |
f2 = -984.9*x**2 + 668.3* x - 114.8 | |
return f2 | |
df['f1_x'] = f1(df.x) | |
df['f2_x'] = f2(df.x) | |
df =df[df.y > df.f1_x ] | |
df =df[df.y < df.f2_x ] | |
return df | |
I return the dataframe that passes the cuts. I would like to get the same dataframe with another variable for each row, bool, that is it passes the cut it’s True, if not, False. | |
example: | |
df['f1_x'] = f1(df.x) | |
df['f2_x'] = f2(df.x) | |
if ((df.y > df.f1_x) & (df.y < df.f2_x )): | |
df['cut_bool'] = True | |
else: | |
df['cut_bool'] = False | |
return df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment