diff options
Diffstat (limited to 'examples/eit_with_vcsel.py')
-rw-r--r-- | examples/eit_with_vcsel.py | 87 |
1 files changed, 71 insertions, 16 deletions
diff --git a/examples/eit_with_vcsel.py b/examples/eit_with_vcsel.py index 913c4b7..daa021b 100644 --- a/examples/eit_with_vcsel.py +++ b/examples/eit_with_vcsel.py @@ -76,17 +76,51 @@ ai['coil_driver'] = ps logger.info('Setting magnetic field coils currents') -""" -Rough magnetic field calibration of the 3 axes coils -- Ch1: 70mA -> 650 kHz shift for delta m = 2 -- Ch2: 70mA -> 700 kHz shift for delta m = 2 -- Ch2: 70mA -> 659 kHz shift for delta m = 2 -""" -ps.setChanIout_mA(1, 70) -ps.setChanIout_mA(2, 0) -ps.setChanIout_mA(3, 0) +# ps.setChanIout_mA(1, 70) +# ps.setChanIout_mA(2, 0) +# ps.setChanIout_mA(3, 0) logger.info('Done setting magnetic field coils currents') +def setB(B=50e-6, theta=0, phi=0): + """ Sets B field currents based on B (in T) and angles theta, and phi """ + + """ + Rough magnetic field calibration of the 3 axes coils in large magnetic shield + - Ch1: 70mA -> 650 kHz shift for delta m = 2 + - Ch2: 70mA -> 700 kHz shift for delta m = 2 + - Ch2: 70mA -> 659 kHz shift for delta m = 2 + A better calibration obtained on 20220601 see file + 20220601.magnetic_field_callibration/calibration_currentToB.dat + """ + # B response to current in a given channel + Bslope_TperA = { + 1: 0.0006574710928926532, + 2: 0.0007064314754023079, + 3: 0.0006635058865577695 + } + + Bx = B*np.sin(theta)*np.cos(phi) + By = B*np.sin(theta)*np.sin(phi) + Bz = B*np.cos(theta) + + # assuming that Ch1 controls Bz, Ch2 -> By, Ch3 -> Bx + chX=3; chY=2; chZ=1 + + Ix = Bx / Bslope_TperA[chX] + Iy = By / Bslope_TperA[chY] + Iz = Bz / Bslope_TperA[chZ] + + logger.info(f"Setting {chX=} to {Ix}") + logger.info(f"Setting {chY=} to {Iy}") + logger.info(f"Setting {chZ=} to {Iz}") + # ps.setChanIout(chX, Ix) + # ps.setChanIout(chY, Iy) + # ps.setChanIout(chZ, Iz) + return Ix, Iy, Iz + +def setBdegrees(B=50e-6, theta=0, phi=0): + return setB(B=B, theta=theta/180*np.pi, phi=phi/180*np.pi) + def eitSweep(central_frequency, frequency_span, Np, Nsweeps=1): frList = np.linspace(central_frequency-frequency_span/2, central_frequency+frequency_span/2, Np) trFreq=Trace('Frequency') @@ -118,7 +152,7 @@ def eitSweep(central_frequency, frequency_span, Np, Nsweeps=1): return trEIT -def eitVsCurrent(ch=1): +def getCurrentCalibrationData(ch=1): curList = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110] ps.setChanIout_mA(1, 0) ps.setChanIout_mA(2, 0) @@ -133,16 +167,37 @@ def eitVsCurrent(ch=1): logger.info(f'Data saved to {fn=}') trEIT.save(fn) +def calibrateCoilsCurrent(): + Np=1000 + Nsweeps=5 + getCurrentCalibrationData(ch=1) + getCurrentCalibrationData(ch=2) + getCurrentCalibrationData(ch=3) + +def rotateBandGetEITtrace(): + Np=100 + Nsweeps=1 + B=50e-6 # earth magnetic field in Tesla (0.5 G) + phiStep = 5 + thetaStep = 5 + phiSet = range(0,90+phiStep, phiStep) + thetaSet = range(0,90+thetaStep, thetaStep) + for phi in phiSet: + for theta in thetaSet: + setBdegrees(B=B, theta=theta, phi=phi) + trEIT = eitSweep(central_frequency, frequency_span, Np, Nsweeps=Nsweeps) + fn = apparatus.getNextDataFile() + logger.info(f'Data ready for {B=} in {theta=} {phi=}') + logger.info(f'Data saved to {fn=}') + trEIT.save(fn) + + central_frequency = 6.83468e9 frequency_span = 2500e3 dwellTime=0.1 -Np=1000 -Nsweeps=5 - +Np=100 +Nsweeps=1 -eitVsCurrent(ch=1) -eitVsCurrent(ch=2) -eitVsCurrent(ch=3) tsdb_ingester.commit() |