Skip to content

Commit

Permalink
Merge pull request #12 from emit-sds/wl_checks
Browse files Browse the repository at this point in the history
Wl checks
  • Loading branch information
pgbrodrick authored May 23, 2022
2 parents 44dad02 + 4b54588 commit 845c6f6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
20 changes: 19 additions & 1 deletion src/EndmemberLibrary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function nanargmin(input::Array)
return argmin(x);
end

function read_envi_wavelengths(filename::String)
function read_envi_wavelengths(filename::String, nm::Bool=true)
header_name = splitext(filename)[1] * ".hdr"
header = readlines(header_name)
found = false
Expand All @@ -55,6 +55,12 @@ function read_envi_wavelengths(filename::String)
end

wavelengths = [parse(Float64, strip(x)) for x in split(split(split(header, "{")[2], "}")[1],",")]

if nm && all(wavelengths .< 25)
wavelengths = wavelengths .* 1000
@info "Converting wavelengths read from $filename to nm from microns."
end

return wavelengths
end

Expand Down Expand Up @@ -128,6 +134,18 @@ function load_data!(library::SpectralLibrary)
good_bands = get_good_bands_mask(library.wavelengths, library.wavelength_regions_ignore)
library.good_bands = good_bands

ignore_regions_nm = false
for wri in library.wavelength_regions_ignore
if wri[1] > 25 || wri[2] > 25
ignore_regions_nm = true
end
end

if ignore_regions_nm && all(library.wavelengths .< 25)
library.wavelengths = library.wavelengths .* 1000
@info "Unit mismatch between library wavelengths and wavelength regions to ignore detected. Converting library wavelengths to nm from microns"
end

return library
end

Expand Down
6 changes: 3 additions & 3 deletions unmix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ function main()


if args.mode == "plots"
plot_mean_endmembers(endmember_library, string(args.output_file_base, "_mean_endmembers.png"))
plot_endmembers(endmember_library, string(args.output_file_base, "_endmembers.png"))
plot_endmembers_individually(endmember_library, string(args.output_file_base, "_endmembers_individually.png"))
plot_mean_endmembers(endmember_library, output_name=string(args.output_file_base, "_mean_endmembers.png"))
plot_endmembers(endmember_library, output_name=string(args.output_file_base, "_endmembers.png"))
plot_endmembers_individually(endmember_library, output_name=string(args.output_file_base, "_endmembers_individually.png"))
exit()
end

Expand Down

0 comments on commit 845c6f6

Please sign in to comment.