Commit 3557e98c authored by Forquet Nicolas's avatar Forquet Nicolas
Browse files

Add a function for the quadripole file import that features a test to verify...

Add a function for the quadripole file import that features a test to verify that electrode index do not exceed the maximum number of electrodes (issue #2)
parent 8f5bc3c5
"""
29/10/2019
OHMPY_code is a program to control the low-cost and open source resistivity meter
OHMPY, it has been developed by Rémi CLEMENT, Nicolas FORQUET (IRSTEA) and Yannick FARGIER (IFSTTAR).
Version 1.01 23/08/2019 modified by Remi CLEMENT
multiplexer development for electrode selection for each quadripole
from the quadripole file ABMN4.txt
OHMPY, it has been developed by Rémi CLEMENT,Vivien DUBOIS, Nicolas FORQUET (IRSTEA) and Yannick FARGIER (IFSTTAR).
"""
print 'OHMPI start'
print MyDateTime.isoformat()
print 'Import library'
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import datetime
import board
import busio
import numpy
import os
import sys
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
print('Import library')
"""
parameters
"""
nb_eletrodes = 32 # maximum number of electrodes on the resistivity meter
"""
functions
......@@ -30,6 +37,20 @@ def switch_mux(quadripole):
GPIO.output(int(quadmux[i,j]), bool(path2elec[quadripole[i]-1,j]))
def read_quad(filename, nb_elec):
output = numpy.loadtxt(filename, delimiter=" ",dtype=int) # load quadripole file
# locate lines where the electrode index exceeds the maximum number of electrodes
test_index_elec = numpy.array(numpy.where(output > 32))
# rajouter un test pour le deuxième cas du ticket #2
# if statement with exit cases (rajouter un else if pour le deuxième cas du ticket #2)
if test_index_elec.size != 0:
for i in range(len(test_index_elec[0,:])):
print("An electrode index at line "+ str(test_index_elec[0,i]+1)+" exceeds the maximum number of electrodes")
sys.exit(1)
else:
return output
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
......@@ -55,7 +76,7 @@ stack= 1 # repetition of the current injection for each quadrupole
"""
Reading the quadripole file
"""
N=numpy.loadtxt("ABMN.txt", delimiter=" ",dtype=int) # load quadripole file
N=read_quad("ABMN.txt",nb_electrodes) # load quadripole file
for g in range(0,nbr_meas): # for time-lapse monitoring
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment