<jupyter_start><jupyter_text>Processing a single SpectrumSpecdal provides readers which loads [.asd, .sig, .sed] files into a common Spectrum object.<jupyter_code>s = specdal.Spectrum(filepath="/home/young/data/specdal/aidan_data/SVC/ACPA_F_B_SU_20160617_003.sig")
print(s)<jupyter_output>name:		ACPA_F_B_SU_20160617_003,
measure_type:	pct_reflect
measurements:	wave  |measurement
		------|-----------
		 337.9|0.146
		   ...|...
		2508.3|0.075
metadata:	file:/home/young/data/specdal/aidan_data/SVC/ACPA_F_B_SU_20160617_003.sig
		instrument_type:SIG
		integration_time:37.5
		measurement_type:Radiance
		gps_time_tgt:None
		gps_time_ref:None
		wavelength_range:(337.89999999999998, 2508.3000000000002)<jupyter_text>The print output shows the four components of the Spectrum object. For example, we can access the measurements as follows.<jupyter_code>print(type(s.measurement))
print(s.measurement.head())<jupyter_output><class 'pandas.core.series.Series'>
wavelength
337.9    0.1455
339.4    0.1422
340.9    0.1391
342.4    0.1541
344.0    0.1475
Name: pct_reflect, dtype: float64<jupyter_text>Spectrum object provides several methods for processing the measurements. Let's start by linearly resampling to the nearest integer (nm) wavelengths.<jupyter_code>s.interpolate(method='linear')
print(s.measurement.head())<jupyter_output>wavelength
338.0    0.14440
339.0    0.14330
340.0    0.14065
341.0    0.14410
342.0    0.14910
Name: pct_reflect, dtype: float64<jupyter_text>We can visualize the spectrum using pyplot. spectrum.plot is just a wrapper around spectrum.measurements.plot, so you can pass any arguments for plotting pandas.Series objects.<jupyter_code>s.plot()
plt.show()<jupyter_output><empty_output><jupyter_text>There are folds in the spectrum near 1000 and 1900 wavelengths. This happens because the three bands in the spectrometer has overlapping wavelengths. We can fix this using the stitch method of the Spectrum class.<jupyter_code>s.stitch(method='mean')
s.plot()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10404339250493097, 'fraction_numerical': 0.09566074950690336, 'mean_word_length': 5.281733746130031, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '502588', 'license': 'MIT', 'n_tokens_mistral': 858, 'n_tokens_neox': 702, 'n_words': 166, 'path': 'specdal/examples/process_spectrum.ipynb', 'repo_name': 'amrutavidwans/SpecDAL', 'size': '2028'}