From ebe7acb8ab23b2c3650906204ab4bb4b992e5a69 Mon Sep 17 00:00:00 2001 From: Destination2Unknown <92536730+Destination2Unknown@users.noreply.github.com> Date: Tue, 30 Aug 2022 18:02:55 +0100 Subject: [PATCH] Added support for Negative Step in CV --- pytunelogix/_exampleCSVs/prc.csv | 2 +- pytunelogix/stage1/csvtuner.py | 33 +++++++++++++++++++++++++------- setup.py | 2 +- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/pytunelogix/_exampleCSVs/prc.csv b/pytunelogix/_exampleCSVs/prc.csv index e411312..064e41b 100644 --- a/pytunelogix/_exampleCSVs/prc.csv +++ b/pytunelogix/_exampleCSVs/prc.csv @@ -58,7 +58,7 @@ PV;CV;SP 15.9;0;25 15.9;0;25 15.9;0;25 -15.9;10;25 +15.9;0;25 15.9;0;25 15.9;0;25 15.9;0;25 diff --git a/pytunelogix/stage1/csvtuner.py b/pytunelogix/stage1/csvtuner.py index e6f3ee5..46b6a5d 100644 --- a/pytunelogix/stage1/csvtuner.py +++ b/pytunelogix/stage1/csvtuner.py @@ -84,12 +84,21 @@ def step2(filename): #Direction if df['PV'].iloc[1] > df['PV'].iloc[-1]: - direction="Reverse" + if df['CV'].idxmin()< df['CV'].idxmax(): + direction="Reverse" + else: + direction="Direct" else: - direction="Direct" + if df['CV'].idxmin()< df['CV'].idxmax(): + direction="Direct" + else: + direction="Reverse" #Find basic parameters - i_start=df['CV'].idxmax() + if df['CV'].idxmin()< df['CV'].idxmax(): + i_start=df['CV'].idxmax() + else: + i_start=df['CV'].idxmin() ambient.set(round(df['PV'].iloc[:i_start+onesecwindow].mean(axis = 0),2)) StartPV=df['PV'].iloc[i_start] InitCV=df['CV'].iloc[0] @@ -100,7 +109,7 @@ def step2(filename): RangeL=round(float(ambient.get()),2)*lololimit #Find DeadTime - if direction=="Reverse": + if (direction=="Reverse" and df['CV'].idxmin()< df['CV'].idxmax()) or (direction=="Direct" and df['CV'].idxmin()> df['CV'].idxmax()): for x in range(i_start,(len(df['PV'])-window)): if(df['PV'].iloc[x:x+twosecwindow:1].mean(axis = 0) df['CV'].idxmax()): j=df['PV'].idxmin() min_peak=df['PV'].min() else: @@ -128,7 +137,7 @@ def step2(filename): tc_low=tc_value*0.99 #Find Time Constant - if direction=="Reverse": + if (direction=="Reverse" and df['CV'].idxmin()< df['CV'].idxmax()) or (direction=="Direct" and df['CV'].idxmin()> df['CV'].idxmax()): z=df[df['PV']<=StartPV-(peak*0.1)].first_valid_index() for x in range(z,(len(df['PV'])-window)): if(df['PV'].iloc[x-twosecwindow:x+twosecwindow:1].mean(axis = 0) df['CV'].idxmax(): + modelgain.set(round(-Gain,2)) #Plot plt.figure() diff --git a/setup.py b/setup.py index acbbb29..819635b 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='pytunelogix', - version='1.1.18', + version='1.1.19', license='MIT', author="Destination2Unknown", author_email='destination0b10unknown@gmail.com',