From 6613dbf814a96973baf042d6f214e0ee61baa785 Mon Sep 17 00:00:00 2001 From: xans Date: Sun, 5 May 2024 22:45:05 +0200 Subject: [PATCH] Delete U180-ToolKit.py --- U180-ToolKit.py | 105 ------------------------------------------------ 1 file changed, 105 deletions(-) delete mode 100644 U180-ToolKit.py diff --git a/U180-ToolKit.py b/U180-ToolKit.py deleted file mode 100644 index c8e3bb4..0000000 --- a/U180-ToolKit.py +++ /dev/null @@ -1,105 +0,0 @@ -#import gpibprologix -import os -import json -import time -import csv -import pandas as pd -from plotly.subplots import make_subplots -import plotly.graph_objects as go -import datetime -import numpy -import GPIBPrologix - -GPIB = GPIBPrologix.ResourceManager("/dev/ttyACM0") -instObj = GPIB.open_resource(22) -instObj.write("BEEP") -instObj.write("CAL? 72") -print(instObj.read()) -print(instObj.query("CAL? 72")) -time.sleep(60) -## user customisable functions -def readFunc(instObj): - return instObj.read() - -def writeFunc(instObj, input): - instObj.write(input) - -def queryFunc(instObj, input): - time.sleep(0.1) - return instObj.query(input) - -## the main program functionalities, should not be adjusted -def readRunningConfigs(): - searchPath = os.path.realpath(os.path.dirname(__file__))+'/RunningConfigs/' - filenames = next(os.walk(searchPath), (None, None, []))[2] - filenames = [item for item in filenames if str.endswith(item,'.json')] - return filenames - -def doACAL(dcACAL, ohmACAL, acACAL): - output = queryFunc(instObj, "TEMP?") - if dcACAL == "yes": - writeFunc(instObj, "ACAL DCV") - time.sleep(140+20) - if acACAL == "yes": - writeFunc(instObj, "ACAL ACV") - time.sleep(140+20) - if ohmACAL == "yes": - writeFunc(instObj, "ACAL OHMS") - time.sleep(600+60) - return output - -def interrogate3458A(instObj): - output = [] - d = datetime.datetime.now() - dx = d - datetime.timedelta(microseconds=d.microsecond) - output.append(dx.strftime("%d-%m-%y %H:%M:%S")) - output.append(queryFunc(instObj,"TEMP?")) # get temperature in device - output.append(queryFunc(instObj,"CAL? 1,1")) # get RREF cal value - output.append(queryFunc(instObj,"CAL? 2,1")) # get VREF cal value - output.append(queryFunc(instObj,"CAL? 78")) # get 10kohm ACAL gain constrant - output.append(queryFunc(instObj,"CAL? 79")) # get 100kohm ACAL gain constrant - output.append(queryFunc(instObj,"CAL? 71")) # get 1v0 ACAL gain constrant - output.append(queryFunc(instObj,"CAL? 70")) # get 0v1 ACAL gain constrant - output.append(queryFunc(instObj,"CAL? 86")) # get 1kohm ACAL ocomp constrant - output.append(queryFunc(instObj,"CAL? 87")) # get 10kohm ACAL ocomp constrant - output.append(queryFunc(instObj,"CAL? 176")) # get acal temperature for ohms - output.append(queryFunc(instObj,"CAL? 59")) # get temperature from during calibration - output.append(queryFunc(instObj,"CAL? 97")) # get 1mamp ACAL gain constrant - output.append(queryFunc(instObj,"CAL? 72")) # get 10v ACAL gain constrant - return output - -## main program -# read the config file and do the folder setup -for file in readRunningConfigs(): - dataPath = os.path.realpath(os.path.dirname(__file__))+'/RunningConfigs/'+file - with open(dataPath, "r") as read_file: - configData = json.load(read_file) - serialPath = os.path.realpath(os.path.dirname(__file__))+'/data/'+configData['serial']+'/' - if not os.path.exists(serialPath): - os.makedirs(serialPath) - with open(serialPath+configData['serial']+'.csv', 'a') as g: - writer = csv.writer(g) - writer.writerow(["DateTime","TEMP","CAL RREF","CAL VREF","G10K","G100K", "G1V0","G0V1","OCOMP1K","OCOMP10K", "ACALTEMP", "CALTEMP", "G1mA", "G10V"]) - doACAL(configData['ACAL-DCV'],configData['ACAL-OHMS'],configData['ACAL-ACV']) - with open(serialPath+configData['serial']+'.csv', 'a') as f: - writer = csv.writer(f) - writer.writerow((interrogate3458A(instObj))) - writeFunc(instObj,"DISP OFF,''") - -## do the plotting -for file in readRunningConfigs(): - dataPath = os.path.realpath(os.path.dirname(__file__))+'/RunningConfigs/'+file - with open(dataPath, "r") as read_file: - configData = json.load(read_file) - serialPath = os.path.realpath(os.path.dirname(__file__))+'/data/'+configData['serial']+'/' - df = pd.read_csv(serialPath+configData['serial']+'.csv') - - time_x = pd.to_datetime(df['DateTime'],format='%d-%m-%y %H:%M:%S') - coefficients = numpy.polyfit(df['TEMP'], df['G10V'], 1, rcond=None, full=False, w=None, cov=False) - polynomial = numpy.poly1d(coefficients) - - fig = make_subplots(rows=1, cols=2) - fig.add_trace(go.Scatter(x=time_x, y=df['G10V']-polynomial(df['TEMP']),mode='lines+markers',name='time vs cal72 w tempcomp'),row=1, col=1) - fig.add_trace(go.Scatter(x=df['TEMP'], y=df['G10V'],mode='lines+markers',name='temp vs cal72'),row=1, col=2) - fig.write_html(serialPath+configData['serial']+'.html') - fig.write_image(serialPath+configData['serial']+'.png') \ No newline at end of file