Created
May 1, 2018 13:22
-
-
Save danclewley/61807ea764f80647151333fd1e31bb0c to your computer and use it in GitHub Desktop.
Example of reading a spectra from a BIL file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Example of reading the spectra from a single pixel using | |
arsf_envi_reader (https://github.com/pmlrsg/arsf_tools) | |
Dan Clewley, NERC-ARF-DAN | |
2018-05-01 | |
""" | |
from arsf_envi_reader import numpy_bin_reader | |
from arsf_envi_reader import envi_header | |
from matplotlib import pyplot as plt | |
# Open header file | |
header = envi_header.read_hdr_file("f168051b.bil.hdr") | |
# Read wavelengths and convert to a list of floats | |
wavelengths = [float(w) for w in header["wavelength"].split(",")] | |
# Open bil file | |
bil = numpy_bin_reader.BilReader("f168051b.bil") | |
# Read in spectra | |
spectra = bil.read_pixel(332, 4658) | |
# Plot spectra | |
plt.plot(wavelengths, spectra) | |
plt.show() | |
# Close bil | |
bil = None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment