diff --git a/.dev/test_all.py b/.dev/test_all.py index a10f572ce4ee7cdf73d04c0655679b5bfb9bdff2..22f57f3ed42b1274def83c65d45b78776573911e 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 c19bb01b6463820fe31018789d8e897188563831..93d91a699d77582ad6e9e44f4eec7c18d197713a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -2,5 +2,5 @@ v2024.1.0 - Add OhmPi.test() (#261) - Add checklist for field installation (doc/_static/ohmpi-checklist.pdf) - Add coverage.sh that runs .dev/test_all.py integration test (#263) - +- 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 e39801190adf11c228f4d6d695a951dc3c3a2df4..655ead65abd92c6b2bbe4488dd435ee8f7d969b3 100644 --- a/ohmpi/ohmpi.py +++ b/ohmpi/ohmpi.py @@ -68,7 +68,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. @@ -318,7 +318,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 @@ -722,13 +722,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) @@ -811,7 +811,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: @@ -820,7 +820,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'] @@ -856,7 +856,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 @@ -864,7 +864,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 @@ -932,7 +932,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) @@ -1003,7 +1003,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' @@ -1741,7 +1741,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"