Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/analyze_spectral.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ the values out as observations to get saved out. Can also print out a histogram
- label - Optional label parameter, modifies the variable name of observations recorded. (default `label="default"`)
- **Example use:**
- Below
- **Output data stored:** Data ('max_reflectance', 'min_reflectance', 'median_reflectance', 'spectral_std', 'spectral_frequencies', 'global_mean_reflectance', 'global_median_reflectance', 'global_spectral_std') automatically gets stored to the
- **Output data stored:** Data ('global_mean_reflectance', 'global_median_reflectance', 'global_spectral_std', 'wavelength_means', 'max_reflectance',
'min_reflectance', 'spectral_std', 'spectral_frequencies') automatically gets stored to the
[`Outputs` class](outputs.md) when this function is ran.
These data can always get accessed during a workflow (example below). For more detail about data output see [Summary of Output Observations](output_measurements.md#summary-of-output-observations)

Expand Down
12 changes: 6 additions & 6 deletions plantcv/plantcv/hyperspectral/analyze_spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def analyze_spectral(array, mask, histplot=None, label="default"):
wavelength_data = array_data[np.where(mask > 0)]

# Calculate mean reflectance across wavelengths
wavelength_freq = wavelength_data.mean(axis=0)
wavelength_means = wavelength_data.mean(axis=0)
max_per_band = wavelength_data.max(axis=0)
min_per_band = wavelength_data.min(axis=0)
std_per_band = wavelength_data.std(axis=0)
Expand All @@ -58,7 +58,7 @@ def analyze_spectral(array, mask, histplot=None, label="default"):

for i, wavelength in enumerate(array.wavelength_dict):
new_wavelengths.append(wavelength)
new_freq.append((wavelength_freq[i]).astype(float))
new_freq.append((wavelength_means[i]).astype(float))
new_std_per_band.append(std_per_band[i].astype(float))
new_max_per_band.append(max_per_band[i].astype(float))
new_min_per_band.append(min_per_band[i].astype(float))
Expand All @@ -83,9 +83,9 @@ def analyze_spectral(array, mask, histplot=None, label="default"):
trait='pixel-wise standard deviation per band',
method='plantcv.plantcv.hyperspectral.analyze_spectral', scale='None', datatype=float,
value=float(std_reflectance), label='reflectance')
outputs.add_observation(sample=label, variable='global_spectral_std', trait='pixel-wise standard deviation ',
method='plantcv.plantcv.hyperspectral.analyze_spectral', scale='None', datatype=float,
value=float(std_reflectance), label='reflectance')
outputs.add_observation(sample=label, variable='wavelength_means', trait='pixel-wise standard deviation ',
method='plantcv.plantcv.hyperspectral.analyze_spectral', scale='reflectance', datatype=list,
value=wavelength_means, label=wavelength_labels)
outputs.add_observation(sample=label, variable='max_reflectance', trait='maximum reflectance per band',
method='plantcv.plantcv.hyperspectral.analyze_spectral', scale='reflectance', datatype=list,
value=new_max_per_band, label=wavelength_labels)
Expand All @@ -100,7 +100,7 @@ def analyze_spectral(array, mask, histplot=None, label="default"):
value=new_freq, label=wavelength_labels)

dataset = pd.DataFrame({'Wavelength (' + array.wavelength_units + ')': new_wavelengths,
'Reflectance': wavelength_freq})
'Reflectance': wavelength_means})
mean_spectra = (ggplot(data=dataset,
mapping=aes(x='Wavelength (' + array.wavelength_units + ')', y='Reflectance'))
+ geom_line(color='purple')
Expand Down