0

I am working on a project for compiling and reporting testing data on a motor for my senior design and I am having difficulties getting my functions to pull data from my panda data frame. My lab data produces a .tdms file with all the parameters shown below in and I need to compare them to min and max conditions at Running, Start up, and accelerating. These test conditions are dependent on the speed(rpm) being between the min and max as well as the other 7 parameters being between the min and max. For a test condition to be running the IP (psig)","Tin1(deg)","FlowIN(gpm)","Return Flow(gpm)","H(psig)","D(psig)","speed(rpm)","2.2T(deg. F)" must all be between running min and max. If one of the 8 parameters don't match a condition it is considered transition,

import pandas as pd
test_conditions = ["running","start up","accelerating"]
test_parameters = ["IP (psig)","Tin1(deg)","FlowIN(gpm)","Return Flow(gpm)",
                   "H(psig)","D(psig)","speed(rpm)","2.2T(deg. F)"]
test_codes = [[0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2],[0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7]]
test_param_columns = ["Min","Max"]
data = [[10,25],[0,150],[3,5],[2,4.2],[45,10000],[440,555.3],[4250,4350],[0,10000],[10,25],[0,150],[69.69,85.58],
        [6.05,7.85],[96,10000],[1879,2222.3],[6969.69,7722.22],[0,10000],[10,25],[0,150],[17.77,21.21],[2.99,3.88],[75,10000],
        [660,799],[6200.3,6567],[0,10000]]
stcs = pd.MultiIndex(levels = [test_conditions,test_parameters], codes = test_codes)
test_conditions_df = pd.DataFrame(index = stcs, columns = test_param_columns, data= data)

enter image description here

np = 4509
def check_speed(np):
    if np > running_Speed_min and np < running_Speed_max:
        return "running"
    elif np > start_up_Speed_min and np < start_up_Speed_max:
        return "start up"
    elif np > accelerating_Speed_min and np < accelerating_Speed_max:
        return "accelerating"
    else:
        return "Transition"
def check_rpm(fn):
    np = check_speed(np)
    def wrapper(*args, **kwargs):
        flow_status = fn(*args, **kwargs) 
        if flow_status == np:
            return flow_status
        else:
            return transition
    return wrapper 
q = 5.99
@check_rpm
def check_retur_flow(q):
    if qd > running_return_Flow_min and qd < running_return_Flow_max:
        return "running"
    elif qd > start_up_return_Flow_min and qd < start_up_return_Flow_max:
        return "start up"
    elif qd > accelerating_return_Flow_min and qd < accelerating_return_Flow_max:
        return "accelerating"
    else:
        return "Transition"

I wrote a function that can determine what the test conditions are based on the speed but when I try to incorporate other conditions using classes or decorators I am running into problems. for example, with this code above I am receiving an unbound local error.

enter image description here

Mark
  • 7,785
  • 2
  • 14
  • 34
Dom
  • 21
  • 4

0 Answers0