im having a problem with the below script where every time i call this function, it builds another Joulescope object takes up memory, and cannot delete the old one. Is there a way to create a single joulescope object that i can continuously use to to read from?
def GetPeakCurrent():
####################################################################
#Goal: use Joulescope to measure current average after 10 sec,
# and convert to Peak Current!
#
# I_Peak = (I_avg / 0.0225) mA ***0.0225 unless pulse width changes
####################################################################
#READ FROM JOULESCOPE:
print("read from joulescope:")
time.sleep(0.1)
with joulescope.scan_require_one(config='auto') as js:
data = js.read(contiguous_duration=args.measure_time)
I_avg, V_avg = np.mean(data, axis=0, dtype=np.float64)
I_avg = I_avg*1000 #convert current to mA
I_peak = round(I_avg / ((args.trigger_freq)*(args.pulse_width)/1000000000),3)
return I_peak