def process_tare_torque(nrun, plot=False): """Process a single tare torque run.""" print("Processing tare torque run", nrun) times = {0 : (35, 86), 1 : (12, 52), 2 : (11, 32), 3 : (7, 30)} nidata = loadhdf("Data/Raw/Tare-torque/" + str(nrun) + "/nidata.h5") # Compute RPM time_ni = nidata["time"] angle = nidata["turbine_angle"] rpm_ni = fdiff.second_order_diff(angle, time_ni)/6.0 rpm_ni = ts.smooth(rpm_ni, 8) try: t1, t2 = times[nrun] except KeyError: t1, t2 = times[3] meanrpm, _ = ts.calcstats(rpm_ni, t1, t2, 2000) torque = nidata["torque_trans"] meantorque, _ = ts.calcstats(torque, t1, t2, 2000) print("Tare torque =", meantorque, "Nm at", meanrpm, "RPM") if plot: plt.figure() plt.plot(time_ni, torque) plt.xlabel("Time (s)") plt.ylabel("Torque (Nm)") plt.tight_layout() plt.show() return meanrpm, -meantorque
def process_strut_torque(nrun, zero_torque=0.0, plot=False, covers=False, verbose=False): """Process a single strut torque run.""" testplan = pd.read_csv("Config/Test plan/Strut-torque.csv", index_col="run") ref_speed = testplan.ref_speed.iloc[nrun] tsr_nom = testplan.tsr.iloc[nrun] revs = testplan.revs.iloc[nrun] rpm_nom = tsr_nom*ref_speed/R/(2*np.pi)*60 dur = revs/rpm_nom*60 if covers: if verbose: print("Processing strut torque with covers run", nrun) nidata = loadhdf("Data/Raw/Strut-torque-covers/" + str(nrun) + \ "/nidata.h5") else: if verbose: print("Processing strut torque run", nrun) nidata = loadhdf("Data/Raw/Strut-torque/" + str(nrun) + "/nidata.h5") # Compute RPM time_ni = nidata["time"] angle = nidata["turbine_angle"] rpm_ni = fdiff.second_order_diff(angle, time_ni)/6.0 rpm_ni = ts.smooth(rpm_ni, 8) t1, t2 = 9, dur meanrpm, _ = ts.calcstats(rpm_ni, t1, t2, 2000) torque = nidata["torque_trans"] torque += calc_tare_torque(rpm_ni) meantorque, _ = ts.calcstats(torque, t1, t2, 2000) tsr_ref = meanrpm/60.0*2*np.pi*R/ref_speed if verbose: print("Reference TSR =", np.round(tsr_ref, decimals=4)) print("Strut torque =", meantorque, "Nm at", meanrpm, "RPM") if plot: plt.figure() plt.plot(time_ni, torque) plt.xlabel("Time (s)") plt.ylabel("Torque (Nm)") plt.tight_layout() plt.show() meantorque -= zero_torque ct = meantorque/(0.5*rho*A*R*ref_speed**2) cp = ct*tsr_ref summary = pd.Series() summary["run"] = nrun summary["tsr_ref"] = tsr_ref summary["cp"] = cp summary["mean_torque"] = meantorque summary["mean_rpm"] = meanrpm return summary
def process_tare_drag(nrun, plot=False): """Process a single tare drag run.""" print("Processing tare drag run", nrun) times = {0.2: (15, 120), 0.3: (10, 77), 0.4: (10, 56), 0.5: (8, 47), 0.6: (10, 40), 0.7: (8, 33), 0.8: (5, 31), 0.9: (8, 27), 1.0: (6, 24), 1.1: (9, 22), 1.2: (8, 21), 1.3: (7, 19), 1.4: (6, 18)} rdpath = os.path.join(raw_data_dir, "Tare-drag", str(nrun)) with open(os.path.join(rdpath, "metadata.json")) as f: metadata = json.load(f) speed = float(metadata["Tow speed (m/s)"]) nidata = loadhdf(os.path.join(rdpath, "nidata.h5")) time_ni = nidata["time"] drag = nidata["drag_left"] + nidata["drag_right"] drag = drag - np.mean(drag[:2000]) t1, t2 = times[speed] meandrag, x = ts.calcstats(drag, t1, t2, 2000) print("Tare drag =", meandrag, "N at", speed, "m/s") if plot: plt.figure() plt.plot(time_ni, drag, 'k') plt.show() return speed, meandrag