|
ENLIGHTEN
Cross-platform desktop GUI for Wasatch Photonics spectrometers
|
This class represents the set of Measurement objects which have been saved during this session via the Acquire button or BatchCollection, or which have been loaded from disk via the Load button. More...
Public Member Functions | |
| __deepcopy__ (self, memo) | |
| __init__ (self, ctl) | |
| add (self, measurement) | |
| Add the new measurement to our on-screen list. | |
| count (self) | |
| create_from_file (self, pathname) | |
| This is the callback which the FileManager will call, one at a time, with delays, with each pathname selected by the user. | |
| create_from_spectrometer (self, spec, label=None) | |
| Use the MeasurementFactory to instantiate a new Measurement, including ThumbnailWidget, from the given spectrometer's latest ProcessedReading. | |
| delete_measurement (self, measurement) | |
| The user has clicked the "trash" icon on a ThumbnailWidget, or the "eraser" icon at the top of the capture layout, or we're doing a massive collection and the ringbuffer overflowed, so the Measurement is being destroyed. | |
| delete_oldest (self) | |
| Delete the oldest Measurement (Thumbnail layout can be inverted, not array order). | |
| erase_all (self) | |
| Clears the list of Measurements (does not delete from disk). | |
| erase_all_callback (self) | |
| export_by_column (self, csv_writer, visible_only=False) | |
| Export each Measurement in turn in a columnar CSV. | |
| export_by_row (self, csv_writer, visible_only=False) | |
| In the row-based export, try to follow historical Dash conventions, as there's no obvious justification not to. | |
| export_callback (self) | |
| export_session (self, filename=None, prompt=True) | |
| The user clicked the "Export" button at the bottom of the Thumbnail layout and wants to export every current Measurement into a single CSV (either row- or column-ordered, per SaveOptions). | |
| export_session_csv (self, directory, filename, visible_only=False) | |
| export_session_json (self, directory, filename, export) | |
| Should this generate a JSON dict of Measurements (keyed on MeasurementID) or a JSON list of Measurements? | |
| export_session_spc (self, directory, filename, visible_only=False) | |
| list[dict] | generate_export_dict (self, visible_only=False) |
| get (self, measurement_id) | |
| id_callback (self, measurement_id, declared_match) | |
| called by KnowItAll.Feature on receiving a MatchResponse from KIA.Wrapper which correponds to a MeasurementID. | |
| incompatible_axes (self, export_measurements) | |
| load_callback (self) | |
| display a file selection dialog, let the user select one or more files, then load them up (including thumbnail generation) | |
| read_measurements (self) | |
| register_observer (self, event, callback) | |
| Register the given callback (typically an instance method) if the named event occurs. | |
| rename_last_measurement (self) | |
| resize_callback (self) | |
| resort_callback (self) | |
| Essentially, cfu.verticalLayout_scope_capture_save.reverse() | |
| update_buttons (self) | |
| update_count (self) | |
| Update the "X spectra" label on the GUI, and dis/enable buttons. | |
| update_kia (self) | |
| Enable or disable the Identification button on all Measurement ThumbnailWidgets. | |
Public Attributes | |
| ctl = ctl | |
| erase_all_callback | |
| export_callback | |
| bool | insert_top = True |
| bool | is_collapsed = False |
| load_callback | |
| list | measurements = [] |
| dict | observers |
| resize_callback | |
| resort_callback | |
Protected Member Functions | |
| _get_spectrometer_settings (self, visible_only=False) | |
| Returns a list of all SpectrometerSettings (unique by serial_number) contributing to our current set of saved measurements, in order of initial appearance. | |
This class represents the set of Measurement objects which have been saved during this session via the Acquire button or BatchCollection, or which have been loaded from disk via the Load button.
It can be considered to be the set of ThumbnailWidgets which fill the left-hand capture column in the GUI.
| enlighten.measurement.Measurements.Measurements.__init__ | ( | self, | |
| ctl ) |
| enlighten.measurement.Measurements.Measurements.__deepcopy__ | ( | self, | |
| memo ) |
|
protected |
Returns a list of all SpectrometerSettings (unique by serial_number) contributing to our current set of saved measurements, in order of initial appearance.
To be perfectly clear, this returns a dictionary of wasatch.SpectrometerSettings by serial number. Be aware that different Measurement objects generated from the same spectrometer serial number may have different ROI and interpolation settings.
| enlighten.measurement.Measurements.Measurements.add | ( | self, | |
| measurement ) |
Add the new measurement to our on-screen list.
Kick-off old measurement if necessary.
| enlighten.measurement.Measurements.Measurements.count | ( | self | ) |
| enlighten.measurement.Measurements.Measurements.create_from_file | ( | self, | |
| pathname ) |
This is the callback which the FileManager will call, one at a time, with delays, with each pathname selected by the user.
Note that a given pathname may contain multiple spectra, which is why MeasurementFactory.create_from_file returns a list of Measurements rather than a single reference.
| enlighten.measurement.Measurements.Measurements.create_from_spectrometer | ( | self, | |
| spec, | |||
| label = None ) |
Use the MeasurementFactory to instantiate a new Measurement, including ThumbnailWidget, from the given spectrometer's latest ProcessedReading.
| enlighten.measurement.Measurements.Measurements.delete_measurement | ( | self, | |
| measurement ) |
The user has clicked the "trash" icon on a ThumbnailWidget, or the "eraser" icon at the top of the capture layout, or we're doing a massive collection and the ringbuffer overflowed, so the Measurement is being destroyed.
It DOES NOT delete anything from disk.
Measurements can only be deleted from disk by clicking on their individual Trash icons, which logic is entirely encapsulated within Measurement and ThumbnailWidget.
| enlighten.measurement.Measurements.Measurements.delete_oldest | ( | self | ) |
Delete the oldest Measurement (Thumbnail layout can be inverted, not array order).
| enlighten.measurement.Measurements.Measurements.erase_all | ( | self | ) |
Clears the list of Measurements (does not delete from disk).
| enlighten.measurement.Measurements.Measurements.erase_all_callback | ( | self | ) |
| enlighten.measurement.Measurements.Measurements.export_by_column | ( | self, | |
| csv_writer, | |||
| visible_only = False ) |
Export each Measurement in turn in a columnar CSV.
You might wonder if it's worth re-exporting every CSV_HEADER_FIELD atop each colujmn of spectra, given that so many of the values (wavecal coeffs, etc) don't change. The thing is, some do (integration time, note, detector and laser temperature, laser power, laser enabled etc). So bite the bullet and export them all for consistency.
If we're going to export data for 3 Measurements (A, B, C) taken from 2 spectrometers (S1 -> A, B; S2 -> C), and we're showing x-axis fields (px, wl) and ProcessedReading fields (proc, raw, dark), then we'd output this (m# indicating various metadata fields).
Enlighten ver MeasID A B C <-- Measurement.measurement_id Serial S1 S1 S2 Label Aa Bb Cc <-- so good it's printed twice m1 x y z m2 x y z S1 S2 Aa Bb Cc <-- Measurement.label px wl px wl pr rw dk pr rw dk pr rw dk
By default, exports are "collated" (grouped by MEASUREMENT).
If NOT SaveOptions.save_collated(), then the columns are grouped by each "subspectrum" (processed, raw, dark, reference etc). This changes the basic layout above to:
Enlighten ver MeasID A B C A B C A B C <-- metadata repeated for each subspectrum Serial S1 S1 S2 S1 S1 S2 S1 S1 S2 Label Aa Bb Cc Aa Bb Cc Aa Bb Cc m1 x y z x y z x y z m2 x y z x y z x y z S1 S2 Pr Rw Dk <-- a "blank column" is inserted between each grouping, with the label of that subspectrum px wl px wl Aa Bb Cc Aa Bb Cc Aa Bb Cc <-- the Measurement.label is used as the header within each grouping
There is a fundamental weakness here that we are assuming:
(1) SpectrometerSettings will not change for a given serial number over the course of the measurements, and (2) individual Measurement's ProcessedReading get_wavelengths() etc actually reflect the current SpectrometerSettings (and weren't trumped along the line by a plugin or whatever).
| enlighten.measurement.Measurements.Measurements.export_by_row | ( | self, | |
| csv_writer, | |||
| visible_only = False ) |
In the row-based export, try to follow historical Dash conventions, as there's no obvious justification not to.
Note that the Dash format didn't fully anticipate multiple spectrometers, so typically only listed one serial number on the file header. Just list them all.
A naive implementation of this would just be to re-save the first Measurement as csv_by_row, then forcibly append all the others atop it. However, that would go into the wrong directory, with the wrong filename. This is short enough that it doesn't matter.
It is believed that this exported file will match what you would have generated if you had initially saved the first Measurement as a row-ordered CSV, then appended subsequent Measurements.
| enlighten.measurement.Measurements.Measurements.export_callback | ( | self | ) |
| enlighten.measurement.Measurements.Measurements.export_session | ( | self, | |
| filename = None, | |||
| prompt = True ) |
The user clicked the "Export" button at the bottom of the Thumbnail layout and wants to export every current Measurement into a single CSV (either row- or column-ordered, per SaveOptions).
(Can also be triggered at end of BatchCollection batch, or perhaps from a future plugin.)
| filename | BatchCollection generates one so we needn't prompt user |
| prompt | prompt for verification (False for unattended operation) |
| enlighten.measurement.Measurements.Measurements.export_session_csv | ( | self, | |
| directory, | |||
| filename, | |||
| visible_only = False ) |
| enlighten.measurement.Measurements.Measurements.export_session_json | ( | self, | |
| directory, | |||
| filename, | |||
| export ) |
Should this generate a JSON dict of Measurements (keyed on MeasurementID) or a JSON list of Measurements?
Could argue either way, but I'm defaulting to list as it's slightly simpler for sender and receiver both.
| enlighten.measurement.Measurements.Measurements.export_session_spc | ( | self, | |
| directory, | |||
| filename, | |||
| visible_only = False ) |
| list[dict] enlighten.measurement.Measurements.Measurements.generate_export_dict | ( | self, | |
| visible_only = False ) |
| enlighten.measurement.Measurements.Measurements.get | ( | self, | |
| measurement_id ) |
| enlighten.measurement.Measurements.Measurements.id_callback | ( | self, | |
| measurement_id, | |||
| declared_match ) |
called by KnowItAll.Feature on receiving a MatchResponse from KIA.Wrapper which correponds to a MeasurementID.
| enlighten.measurement.Measurements.Measurements.incompatible_axes | ( | self, | |
| export_measurements ) |
| enlighten.measurement.Measurements.Measurements.load_callback | ( | self | ) |
display a file selection dialog, let the user select one or more files, then load them up (including thumbnail generation)
| enlighten.measurement.Measurements.Measurements.read_measurements | ( | self | ) |
| enlighten.measurement.Measurements.Measurements.register_observer | ( | self, | |
| event, | |||
| callback ) |
Register the given callback (typically an instance method) if the named event occurs.
| event | (Input) a string (supported values: Measurements.observers.keys()) |
| callback | (Input) a func or method to call if the named event occurs |
| enlighten.measurement.Measurements.Measurements.rename_last_measurement | ( | self | ) |
| enlighten.measurement.Measurements.Measurements.resize_callback | ( | self | ) |
| enlighten.measurement.Measurements.Measurements.resort_callback | ( | self | ) |
Essentially, cfu.verticalLayout_scope_capture_save.reverse()
| enlighten.measurement.Measurements.Measurements.update_buttons | ( | self | ) |
| enlighten.measurement.Measurements.Measurements.update_count | ( | self | ) |
Update the "X spectra" label on the GUI, and dis/enable buttons.
| enlighten.measurement.Measurements.Measurements.update_kia | ( | self | ) |
Enable or disable the Identification button on all Measurement ThumbnailWidgets.
| enlighten.measurement.Measurements.Measurements.ctl = ctl |
| enlighten.measurement.Measurements.Measurements.erase_all_callback |
| enlighten.measurement.Measurements.Measurements.export_callback |
| enlighten.measurement.Measurements.Measurements.insert_top = True |
| enlighten.measurement.Measurements.Measurements.is_collapsed = False |
| enlighten.measurement.Measurements.Measurements.load_callback |
| enlighten.measurement.Measurements.Measurements.measurements = [] |
| dict enlighten.measurement.Measurements.Measurements.observers |
| enlighten.measurement.Measurements.Measurements.resize_callback |
| enlighten.measurement.Measurements.Measurements.resort_callback |