Skip to content

Comparison of analytical spectra#270

Open
Nicolass67 wants to merge 3 commits into
masterfrom
comparison-of-analytical-spectra
Open

Comparison of analytical spectra#270
Nicolass67 wants to merge 3 commits into
masterfrom
comparison-of-analytical-spectra

Conversation

@Nicolass67

Copy link
Copy Markdown
Contributor

Summary

Combined spectrum views (multi-file transform and BagIt) now show annotations for the active spectrum, not just raw curves.

  • Extract overlay plotting from NIComposer.tf_img() into reusable plot_overlays() (peaks, integrations, multiplicity, info box)
  • Load integration/multiplicity data from JCAMP tables when needed (_ensure_itg_mpy_from_core_tables())
  • Apply overlays only to the active spectrum (jcamp_idx) in TransformerModel.tf_combine() and BagItBaseConverter.__combine_images()

- 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() into NIComposer.plot_overlays() and add _ensure_itg_mpy_from_core_tables() to hydrate integration/multiplicity from JCAMP tables as needed.
  • Update TransformerModel.tf_combine() and BagItBaseConverter.__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()),
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants