-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ISSUE #134 Support ECOStress Spectral Library #153
Changes from 8 commits
1c9ee8d
74194c8
8fb6108
3d424dd
21154db
d83b86a
97d82d7
3deab28
52af7f8
833d66a
e1289eb
0031a0e
56721ef
f4c7a23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#Copyright (C) 2017-2018 COAL Developers | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; version 2. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty | ||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public | ||
# License along with this program; if not, write to the Free | ||
# Software Foundation, Inc., 51 Franklin Street, Fifth | ||
# Floor, Boston, MA 02110-1301, USA. | ||
# encoding: utf-8 | ||
|
||
''' | ||
example_ecostress.py -- a script which will generate envi .sli and .hdr convolved library | ||
files of `ECOStress Spectral Library <https://speclib.jpl.nasa.gov/>`_ | ||
|
||
Dependencies | ||
`ECOStress Spectral Library <https://speclib.jpl.nasa.gov/>`_ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should be more descriptive here.
Which of the above do we download? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ALL Spectra, I have now made a comment in the code to specify |
||
must be downloaded to the examples directory | ||
|
||
All files generated will be located in the examples directory | ||
|
||
|
||
@author: COAL Developers | ||
|
||
@copyright: 2018 COAL Developers. All rights reserved. | ||
|
||
@license: GNU General Public License version 2 | ||
|
||
@contact: [email protected] | ||
''' | ||
|
||
#!/usr/bin/python | ||
|
||
import os | ||
import sys | ||
import pycoal | ||
sys.path.insert(0, '../pycoal') | ||
import mineral | ||
import fnmatch | ||
|
||
#Path to EcoStress Spectral Library | ||
if (len(sys.argv) == 1): | ||
raise Exception('Must pass in location of EcoStress Spectral Library') | ||
library_filename = sys.argv[1] | ||
#Loop through and edit all .spectrum.txt files | ||
for root, dir, files in os.walk(library_filename): | ||
dir[:] = [d for d in dir] | ||
for items in fnmatch.filter(files, "*spectrum.txt"): | ||
#Remove vegation files because their format causes errors in the Spectral class | ||
if "vegetation" in items: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remind me again why we are not using the vegetation indexes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On lines 4 & 5 Vegetation Spectra has Genus and Species instead of Subclass and Particle Size entries like other Spectra. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. manmade.concrete.constructionconcrete.solid.all.0598uuucnc.jhu.becknic.spectrum.txt Name: Construction Concrete There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nonphotosyntheticvegetation.bark.abies.concolor.all.vh311.ucsb.asdnicolet.spectrum.txt Name: Abies concolor bark There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, ideally we want to be able to use every spectra from the entire ECOSTRESS library. If you could implement the suggested workaround for including the vegetation files it would be appreciated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lewismc Ok, I fixed it so it works with Vegetation files. I added the Subclass and Particle Size and removed the Genus and Species. It can now convert the entire EcoStress library |
||
os.remove(library_filename + '/' + items); | ||
else: | ||
input_file = open(library_filename + '/' + items, "r", encoding="utf8", errors='ignore') | ||
contents = input_file.readlines() | ||
input_file.close() | ||
#Add 5 '\n' after description | ||
contents.insert(11, '\n\n\n\n\n') | ||
input_file = open(library_filename + '/' + items, "w", encoding="utf8", errors='ignore') | ||
contents = "".join(contents) | ||
input_file.write(contents) | ||
input_file.close() | ||
|
||
ecoStress = mineral.AsterConversion() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once you address this then we can think about ripping this code out of the example and embedding it in |
||
ecoStress.convert(library_filename,'dataEcoStress.db','ECO_01_SPLIB.envi') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add the following