Concatenate #733
-
Hi, I am trying to concatenate a serie of NDDataset using
I have tried with How can I concatenate maintaining the name of each NDDataset so that I know which spectra is which? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @valentinavan , Thank you for your message. To indentify the individual spectra, you can use the label property, for instance: all_spectra = scp.concatenate([ds1, ds2], axis='y')
for spectrum_labels in ds1.y.labels:
print(spectrum_labels)
print('---')
for spectrum_labels in s2.y.labels:
print(spectrum_labels)
print('---')
for spectrum_labels in all_spectra.y.labels:
print(lspectrum_labels) The concatenation preserves the original order of the spectra, i.e. the first spectrum of Note also that the s1.y.labels = [f"spectrum #{i}" for i in range(s1.shape[0])] will add new labels to the existing ones, s1.y._labels = [f"spectrum {i}" for i in range(s1.shape[0])] will replace the existing labels by the new ones, I hope this helps. Let us know if this answers your question, Best |
Beta Was this translation helpful? Give feedback.
Hi @valentinavan ,
Thank you for your message. To indentify the individual spectra, you can use the label property, for instance:
The concatenation preserves the original order of the spectra, i.e. the first spectrum of
all_spectra
is the first spectrum ofds1
and the last spectrum ofall_spectra
is the last ofds2
.Note also that the
labels
attribute is protected, so that: