diff --git a/.dev/test_all.py b/.dev/test_all.py index 3e8ceeddf4d9b1a6486c4d4d75ec429e6fe6eadf..2f7d81a6394c5ae0f0ba574253198b23a92becff 100644 --- a/.dev/test_all.py +++ b/.dev/test_all.py @@ -33,10 +33,10 @@ print('---------- vmax ----------') k.run_measurement([1, 4, 2, 3], nb_stack=2, injection_duration=0.2, duty_cycle=0.5, strategy='vmax') print('---------- vmin ----------') k.run_measurement([1, 4, 2, 3], nb_stack=1, injection_duration=0.2, duty_cycle=0.3, strategy='vmin', vmn_req=0.02) -print('---------- constant ----------') -k.run_measurement([1, 4, 2, 3], nb_stack=1, injection_duration=0.2, duty_cycle=0.7, strategy='constant', vab_req=40) -print('---------- full_constant ----------') -k.run_measurement([1, 4, 2, 3], nb_stack=2, injection_duration=0.2, duty_cycle=1, strategy='full_constant', vab_req=7.3) +print('---------- safe ----------') +k.run_measurement([1, 4, 2, 3], nb_stack=1, injection_duration=0.2, duty_cycle=0.7, strategy='safe', vab_req=40) +print('---------- fixed ----------') +k.run_measurement([1, 4, 2, 3], nb_stack=2, injection_duration=0.2, duty_cycle=1, strategy='fixed', vab_req=7.3) print('---------- flex ----------') k.run_measurement([1, 4, 2, 3], nb_stack=2, injection_duration=0.2, duty_cycle=1, strategy='flex', pab_req=0.3) #k.plot_last_fw() diff --git a/CHANGELOG.txt b/CHANGELOG.txt index de628af0b4aa613365a61717bfda15c88c4adb2f..935b5363f46301106fc62cbf2f1bf35129e630a0 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,5 +3,5 @@ v2024.1.0 - Add checklist for field installation (doc/_static/ohmpi-checklist.pdf) - Add coverage.sh that runs .dev/test_all.py integration test (#263) - Rename headers (#239) - +- Rename strategies: "constant" -> "safe", "full_constant" -> "fixed" (#216) diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py index 8e2008b0cf3bba15de5a9f73b341373b1b679920..b17308197b22d802c88e23a12244bdd00eac7ebe 100644 --- a/ohmpi/hardware_system.py +++ b/ohmpi/hardware_system.py @@ -615,9 +615,7 @@ class OhmPiHardware: pulse_duration : float, optional Time in seconds for the pulse used to compute optimal Vab. vab_init : float, optional - Voltage to apply for guessing the best voltage. 5 V applied - by default. If strategy "constant" is chosen, constant voltage - to applied is "vab". + Initial voltage to search for best vab. vab_max : float, optional Maximum injection voltage to apply to tx (used by all strategies). vmn_max : float, optional diff --git a/ohmpi/ohmpi.py b/ohmpi/ohmpi.py index a64e0dbf8e8a3d35a66bde7a8b6df83a54fb0066..293a0c4cac4235433e44fa69152559519e6980d0 100644 --- a/ohmpi/ohmpi.py +++ b/ohmpi/ohmpi.py @@ -69,7 +69,7 @@ class OhmPi(object): Dictionary of parameters. Possible parameters with some suggested values: {'injection_duration': 0.2, 'nb_meas': 1, 'sequence_delay': 1, 'nb_stack': 1, 'sampling_interval': 2, 'vab_init': 5.0, 'vab_req': 5.0, 'duty_cycle': 0.5, - 'strategy': 'constant', 'export_path': None} + 'strategy': 'safe', 'export_path': None} sequence : str, optional Path of the .csv or .txt file with A, B, M and N electrodes. Electrode index starts at 1. See `OhmPi.load_sequence()` for full docstring. @@ -305,7 +305,7 @@ class OhmPi(object): ---------- which : str Which vab to keep, either "min", "max", "mean" (or other similar numpy method e.g. median) - If applying strategy "full_constant" based on vab_opt, safer to chose "min" + If applying strategy "fixed" based on vab_opt, safer to chose "min" n_samples: int Number of samples to keep within loaded sequence. kwargs : dict, optional @@ -709,13 +709,13 @@ class OhmPi(object): Injection time in seconds. duty_cycle : float, optional Duty cycle (default=0.5) of injection square wave. - strategy : str, optional, default: constant - Define injection strategy (if power is adjustable, otherwise constant vab, generally 12V battery is used). + strategy : str, optional, default: safe + Define injection strategy (if power is adjustable, otherwise safe vab, generally 12V battery is used). Either: - vmax : compute Vab to reach a maximum Vmn_max and Iab without exceeding vab_max - vmin : compute Vab to reach at least Vmn_min - - constant : apply given Vab but checks if expected readings not out-of-range - - full_constant: apply given Vab with no out-of-range checks for optimising duration at the risk of out-of-range readings + - safe : apply given Vab but checks if expected readings not out-of-range + - fixed: apply given Vab with no out-of-range checks for optimising duration at the risk of out-of-range readings Safety check (i.e. short voltage pulses) performed prior to injection to ensure injection within bounds defined in vab_max, iab_max, vmn_max or vmn_min. This can adapt Vab. To bypass safety check before injection, vab should be set equal to vab_max (not recommended) @@ -798,7 +798,7 @@ class OhmPi(object): vab_init = tx_volt # if vab_req is None: # vab_req = vab_init - if strategy == 'constant' and vab_req is None: + if strategy == 'safe' and vab_req is None: vab_req = tx_volt if vab_init is None and vab is not None: @@ -807,7 +807,7 @@ class OhmPi(object): vab_init = vab # if vab_req is None: # vab_req = vab_init - if strategy == 'constant' and vab_req is None: + if strategy == 'safe' and vab_req is None: vab_req = vab if vab_init is None and 'vab_init' in self.settings: vab_init = self.settings['vab_init'] @@ -843,7 +843,7 @@ class OhmPi(object): else: min_agg = False - if strategy == 'constant': + if strategy == 'safe': if vab_req is not None: vab_init = 0.9 * vab_req @@ -851,7 +851,7 @@ class OhmPi(object): d = {} if self.switch_mux_on(quad, bypass_check=bypass_check, cmd_id=cmd_id): - if strategy == 'constant': + if strategy == 'safe': kwargs_compute_vab = kwargs.get('compute_vab', {}) kwargs_compute_vab['vab_init'] = vab_init kwargs_compute_vab['vab_min'] = vab_min @@ -919,7 +919,7 @@ class OhmPi(object): kwargs_compute_vab['pab_max'] = pab_max kwargs_compute_vab['min_agg'] = min_agg - if strategy == 'full_constant': + if strategy == 'fixed': vab = vab_init else: vab = self._hw.compute_vab(**kwargs_compute_vab) @@ -996,7 +996,7 @@ class OhmPi(object): print('\r') self.data_logger.info(dd) - # if strategy not constant, then switch dps off (button) in case following measurement within sequence + # if strategy not safe, then switch dps off (button) in case following measurement within sequence # TODO: check if this is the right strategy to handle DPS pwr state on/off after measurement if (strategy == 'vmax' or strategy == 'vmin' or strategy == 'flex') and vab > vab_init : # if starting vab was higher actual vab, then turn pwr off self._hw.tx.pwr.pwr_state = 'off' @@ -1686,7 +1686,7 @@ class OhmPi(object): - nb_meas (total number of times the sequence will be run) - sequence_delay (delay in second between each sequence run) - nb_stack (number of stack for each quadrupole measurement) - - strategy (injection strategy: constant, vmax, vmin) + - strategy (injection strategy: safe, vmax, vmin) - duty_cycle (injection duty cycle comprised between 0.5 - 1) - export_path (path where to export the data, timestamp will be added to filename) diff --git a/settings/default.json b/settings/default.json index 3840dfd93622c4ea8ff2d86a7e4209ed702522a4..a88bd32e03621ca1585d4eb454edebe71394a7cf 100644 --- a/settings/default.json +++ b/settings/default.json @@ -7,7 +7,7 @@ "vab_init": 5.0, "vab_req": 5.0, "duty_cycle": 0.5, - "strategy": "constant", + "strategy": "safe", "fw_in_csv": false, "fw_in_zip": true, "export_path": "data/measurements.csv"