diff --git a/pyproject.toml b/pyproject.toml index aef0881..0a4fb65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [features] # defines the plugin features contained into this plugin instruments = true # true if plugin contains instrument classes (else false, notice the lowercase for toml files) extensions = true # true if plugins contains dashboard extensions -models = false # true if plugins contains pid models +models = true # true if plugins contains models h5exporters = false # true if plugin contains custom h5 file exporters scanners = false # true if plugin contains custom scan layout (daq_scan extensions) @@ -23,7 +23,7 @@ authors = [ {name='Sebastien J. Weber', email='sebastien.weber@cnrs.fr'} ] dependencies = [ - "pymodaq>5.0" + "pymodaq>5.0.0" ] classifiers = [ "Development Status :: 5 - Production/Stable", diff --git a/src/pymodaq_plugins_datamixer/extensions/data_mixer.py b/src/pymodaq_plugins_datamixer/extensions/data_mixer.py index 6707856..bb765a2 100644 --- a/src/pymodaq_plugins_datamixer/extensions/data_mixer.py +++ b/src/pymodaq_plugins_datamixer/extensions/data_mixer.py @@ -125,7 +125,6 @@ def snap(self): self.modules_manager.grab_data() def create_computed_detectors(self): - # Now that we have the module manager, load PID if it is checked in managers try: self.dashboard.add_det_from_extension('DataMixer', 'DAQ0D', 'DataMixer', self) self.set_action_enabled('create_computed_detectors', False) diff --git a/src/pymodaq_plugins_datamixer/models/harmonics_model.py b/src/pymodaq_plugins_datamixer/models/harmonics_model.py new file mode 100644 index 0000000..e90a72c --- /dev/null +++ b/src/pymodaq_plugins_datamixer/models/harmonics_model.py @@ -0,0 +1,79 @@ +import numpy as np + +from pymodaq_plugins_datamixer.extensions.utils.model import DataMixerModel, np # np will be used in method eval of the formula + +from pymodaq_utils.math_utils import gauss1D, my_moment + +from pymodaq_data.data import DataToExport, DataWithAxes +from pymodaq_gui.parameter import Parameter + +from pymodaq_plugins_datamixer.extensions.utils.parser import ( + extract_data_names, split_formulae, replace_names_in_formula) + + +from scipy.signal import find_peaks + + + +class DataMixerModelFit(DataMixerModel): + params = [ + {'title': 'Find Peaks', 'name': 'find_peaks', 'type': 'group', 'children': [ + {'title': 'Highest Peak', 'name': 'highest_peak', 'type': 'float', 'value': 0, 'readonly': True}, + {'title': 'Options', 'name': 'options', 'type': 'bool', 'value': False, 'children': [ + {'title': 'Height', 'name': 'height', 'type': 'float', 'value': 0}, + {'title': 'Distance', 'name': 'distance', 'type': 'int', 'value': 1, 'max': 1}, + ]}, + ]}, + {'title': 'Cropping', 'name': 'cropping', 'type': 'group', 'children': [ + {'title': 'Index min from peak', 'name': 'ind_min', 'type': 'int', 'value': 0}, + {'title': 'Index max from peak', 'name': 'ind_max', 'type': 'int', 'value': 100}, + + ]}, + ] + + def ini_model(self): + pass + + def update_settings(self, param: Parameter): + pass + + def process_dte(self, dte: DataToExport): + dte_processed = DataToExport('computed') + dwa = dte[0].deepcopy() + + options = {} + if self.settings['find_peaks', 'options']: + for param in self.settings.child('find_peaks', 'options'): + options[param.name()] = param.value() + + peaks_indices, _ = find_peaks(dwa[0], **options) + + heights = [float(dwa.isig[index][0][0]) for index in peaks_indices] + ind_max = peaks_indices[np.argmax(heights)] + self.settings.child('find_peaks', 'highest_peak').setValue(dwa.axes[0].get_data()[ind_max]) + + dwa_indexed = dwa.isig[ind_max + self.settings['cropping', 'ind_min']: + ind_max + self.settings['cropping', 'ind_max']] + dwa_indexed.axes = [] + dwa_indexed.create_missing_axes() + + dte_processed.append(dwa_indexed) + + return dte_processed + + +def main(): + from pymodaq_gui.utils.utils import mkQApp + from pymodaq.utils.gui_utils.loader_utils import load_dashboard_with_preset + + app = mkQApp('DataMixer') + + preset_file_name = 'harmonics' + dashboard, extension, win = load_dashboard_with_preset(preset_file_name, 'Data Mixer') + app.exec() + + return dashboard, extension, win + + +if __name__ == '__main__': + main() diff --git a/src/pymodaq_plugins_datamixer/resources/config_template.toml b/src/pymodaq_plugins_datamixer/resources/config_template.toml index 6b910c7..465bf7a 100644 --- a/src/pymodaq_plugins_datamixer/resources/config_template.toml +++ b/src/pymodaq_plugins_datamixer/resources/config_template.toml @@ -1,3 +1,3 @@ -title = 'this is the configuration file of the plugin XXX' +title = 'this is the configuration file of the plugin DataMixer' preset = '' \ No newline at end of file