Comparison of analytical spectra#270
Open
Nicolass67 wants to merge 3 commits into
Open
Conversation
- Set figure DPI to 200 for improved image quality. - Introduced global x-axis limits based on data range. - Added handling for peak plotting with error management. - Improved marker handling for different plot types.
There was a problem hiding this comment.
Pull request overview
This PR updates the “combined spectrum” rendering paths so that annotations/overlays (peaks, integrations, multiplicity, info box) are drawn only for the active spectrum (jcamp_idx) rather than for all stacked curves, and factors that overlay logic into a reusable NIComposer.plot_overlays() helper.
Changes:
- Extract overlay plotting from
NIComposer.tf_img()intoNIComposer.plot_overlays()and add_ensure_itg_mpy_from_core_tables()to hydrate integration/multiplicity from JCAMP tables as needed. - Update
TransformerModel.tf_combine()andBagItBaseConverter.__combine_images()to apply overlays only to the active spectrum and to use higher DPI output. - Improve combined plot axis handling (global x-limits/orientation) and remove ad-hoc cyclic voltammetry ref-peak plotting from the combined transformer path.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
chem_spectra/model/transformer.py |
Combined-image generation now selects an active spectrum and applies overlays only to that curve; adds global x-limit/orientation logic. |
chem_spectra/lib/converter/bagit/base.py |
BagIt combined-image generation now selects an active composer and applies overlays only to that spectrum. |
chem_spectra/lib/composer/ni.py |
Refactors overlay rendering into plot_overlays() and adds lazy loading of integration/multiplicity data from core tables. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
278
to
284
| plt.rcParams['figure.figsize'] = [16, 9] | ||
| plt.rcParams['figure.dpi'] = 200 | ||
| plt.rcParams['font.size'] = 14 | ||
| plt.rcParams['legend.loc'] = 'upper left' | ||
| curve_idx = self.params.get('jcamp_idx', 0) | ||
|
|
||
| xlabel, ylabel = '', '' |
Comment on lines
92
to
+96
| cv_mode = False | ||
| cv_abs_max = 0.0 | ||
| active_idx = self.params.get('jcamp_idx', 0) or 0 | ||
| active_composer = None | ||
| active_y_values = None |
Comment on lines
+393
to
408
| if (len(self.mpys) == 0 and len(self.core.mpy_itg_table) > 0 | ||
| and not self.core.params['integration'].get('edited') | ||
| and ('originStack' not in self.core.params['integration'])): | ||
| tmp_dic_mpy_peaks = {} | ||
| core_mpy_pks_table = self.core.mpy_pks_table[0] | ||
| for peak in core_mpy_pks_table.split('\n'): | ||
| clear_peak = peak.replace('(', '').replace(')', '') | ||
| split_peak = clear_peak.split(',') | ||
| idx_peakStr = split_peak[0].strip() | ||
| if idx_peakStr not in tmp_dic_mpy_peaks: | ||
| tmp_dic_mpy_peaks[idx_peakStr] = [] | ||
| tmp_dic_mpy_peaks[idx_peakStr].append({ | ||
| 'x': float(split_peak[1].strip()), | ||
| 'y': float(split_peak[2].strip()), | ||
| }) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Combined spectrum views (multi-file transform and BagIt) now show annotations for the active spectrum, not just raw curves.
NIComposer.tf_img()into reusableplot_overlays()(peaks, integrations, multiplicity, info box)_ensure_itg_mpy_from_core_tables())jcamp_idx) inTransformerModel.tf_combine()andBagItBaseConverter.__combine_images()