Created
June 28, 2016 20:23
-
-
Save forstater/3277f38b22efa2eafb33d2b67ce282cd to your computer and use it in GitHub Desktop.
Function to query and filter multistate events.
This file contains hidden or 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
''' | |
Author: Jacob Forstater | |
Description: Workflow to clean up multistate events | |
- Filters out NStates <2 | |
- Filters out any event with StateResTime < minValue | |
- Supplys this back as a 2D flattened Array | |
Log: | |
JF 20160602 initial version | |
''' | |
def multistateFilter(myDB, myQueryArgs="NStates>=2 and NStates <6 and ResTime> 0.02", minStateLength=0.02): | |
tempData=pd.DataFrame(query(myDB,"select BlockDepth, StateResTime from metadata where ProcessingStatus='normal' and "+str(myQueryArgs))) | |
tempData=tempData.rename(columns={0:'BD',1:'StateResTime'}) | |
minLenFilter=lambda x: np.min(x)>=minStateLength | |
bdReturn=np.hstack(tempData[tempData.StateResTime.map(minLenFilter)].BD) | |
stateResReturn=np.hstack(tempData[tempData.StateResTime.map(minLenFilter)].StateResTime) | |
return np.stack([bdReturn,stateResReturn],axis=-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment