diff --git a/src/Datasets.jl b/src/Datasets.jl index 7f3c6d8..a3a8fd6 100644 --- a/src/Datasets.jl +++ b/src/Datasets.jl @@ -112,7 +112,7 @@ function load_line(reflectance_file::String, reflectance_uncertainty_file::Strin good_data = .!all(img_dat .== refl_nodata, dims=2)[:,1] img_dat = img_dat[good_data,:] - if sum(good_data) > 1 + if sum(good_data) >= 1 if reflectance_uncertainty_file != "" unc_dat = convert(Array{Float64},ArchGDAL.readraster(reflectance_uncertainty_file)[:,line,:]) unc_dat = unc_dat[:, good_bands] diff --git a/src/EndmemberLibrary.jl b/src/EndmemberLibrary.jl index f9fcbb6..13d24be 100644 --- a/src/EndmemberLibrary.jl +++ b/src/EndmemberLibrary.jl @@ -106,7 +106,8 @@ function load_data!(library::SpectralLibrary) try library.classes = convert(Array{AbstractString}, df[!,library.class_header_name]) catch e - throw(ArgumentError("Could not read classes from endmember library. Try adjusting class_header_name, or reworking the library.")) + throw(ArgumentError("Could not read classes from endmember library using class key "*library.class_header_name * + ". Try adjusting class_header_name, or reworking the library.")) end try diff --git a/src/SpectralUnmixing.jl b/src/SpectralUnmixing.jl index 99f5735..a0fb9a6 100644 --- a/src/SpectralUnmixing.jl +++ b/src/SpectralUnmixing.jl @@ -150,7 +150,7 @@ function unmix_pixel(library::SpectralLibrary, img_dat_input::Array{Float64}, un if occursin("sma", mode) perm = get_sma_permutation(class_idx, num_endmembers, combination_type, size(library.spectra)[1]) - G = library.spectra[perm,:] + G = library.spectra[perm, library.good_bands] G = scale_data(G, library.wavelengths[library.good_bands], normalization)' @@ -190,7 +190,7 @@ function unmix_pixel(library::SpectralLibrary, img_dat_input::Array{Float64}, un for (_comb, comb) in enumerate(options[perm]) comb = [c for c in comb] #G = hcat(library.spectra[comb,:], ones(size(library.spectra[comb,:])[1],1)) - G = scale_data(library.spectra[comb,:], library.wavelengths[library.good_bands], normalization)' + G = scale_data(library.spectra[comb, library.good_bands], library.wavelengths[library.good_bands], normalization)' x0 = dolsq(G, d') ls = nothing diff --git a/unmix.jl b/unmix.jl index b0ae69a..b3fd94b 100644 --- a/unmix.jl +++ b/unmix.jl @@ -102,8 +102,6 @@ function main() end - endmember_library.spectra = endmember_library.spectra[:,endmember_library.good_bands] - n_classes = length(unique(endmember_library.classes)) output_bands = [n_classes + 1] output_files = [string(args.output_file_base , "_fractional_cover")]