-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ private/ | |
*$py.class | ||
*.nc | ||
changelog_update.md | ||
test_data/ | ||
|
||
# C extensions | ||
*.so | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import unittest | ||
import hypercoast | ||
import os | ||
import matplotlib | ||
|
||
matplotlib.use("Agg") # Use the Agg backend to suppress plots | ||
|
||
|
||
class TestHypercoastDesis(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.url = "https://github.com/opengeos/datasets/releases/download/hypercoast/desis.tif" | ||
cls.filepath = "test_data/desis.tif" | ||
os.makedirs("test_data", exist_ok=True) | ||
hypercoast.download_file(cls.url, cls.filepath) | ||
cls.dataset = hypercoast.read_desis(cls.filepath) | ||
|
||
def test_download_file(self): | ||
self.assertTrue(os.path.exists(self.filepath)) | ||
|
||
def test_read_desis(self): | ||
dataset = hypercoast.read_desis(self.filepath) | ||
self.assertIsNotNone(dataset) | ||
|
||
def test_map_add_desis_single_band(self): | ||
m = hypercoast.Map() | ||
self.assertIsNotNone(m) | ||
m.add_basemap("Hybrid") | ||
m.add_desis( | ||
self.filepath, | ||
wavelengths=[1000], | ||
vmin=0, | ||
vmax=5000, | ||
nodata=0, | ||
colormap="jet", | ||
) | ||
m.add_colormap(cmap="jet", vmin=0, vmax=0.5, label="Reflectance") | ||
html = m.to_html() | ||
assert "DESIS" in html | ||
|
||
def test_map_add_desis_rgb(self): | ||
m = hypercoast.Map() | ||
self.assertIsNotNone(m) | ||
m.add_basemap("Hybrid") | ||
m.add_desis( | ||
self.filepath, wavelengths=[900, 600, 525], vmin=0, vmax=1000, nodata=0 | ||
) | ||
m.add("spectral") | ||
html = m.to_html() | ||
assert "DESIS" in html | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import unittest | ||
import hypercoast | ||
import os | ||
|
||
|
||
class TestHypercoastEmit(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.url = "https://github.com/opengeos/datasets/releases/download/netcdf/EMIT_L2A_RFL_001_20240404T161230_2409511_009.nc" | ||
cls.filepath = "test_data/EMIT_L2A_RFL_001_20240404T161230_2409511_009.nc" | ||
os.makedirs("test_data", exist_ok=True) | ||
hypercoast.download_file(cls.url, cls.filepath) | ||
cls.dataset = hypercoast.read_emit(cls.filepath) | ||
|
||
def test_download_file(self): | ||
self.assertTrue(os.path.exists(self.filepath)) | ||
|
||
def test_read_emit(self): | ||
dataset = hypercoast.read_emit(self.filepath) | ||
self.assertIsNotNone(dataset) | ||
|
||
def test_map(self): | ||
m = hypercoast.Map() | ||
m.add_basemap("SATELLITE") | ||
wavelengths = [1000, 600, 500] | ||
m.add_emit(self.dataset, wavelengths, vmin=0, vmax=0.3, layer_name="EMIT") | ||
m.add("spectral") | ||
html = m.to_html() | ||
self.assertIsNotNone(m) | ||
assert "EMIT" in html | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import unittest | ||
import hypercoast | ||
import os | ||
|
||
|
||
class TestHypercoastNeon(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.url = "https://github.com/opengeos/datasets/releases/download/hypercoast/NEON_D02_SERC_DP3_368000_4306000_reflectance.h5" | ||
cls.filepath = "test_data/neon.h5" | ||
os.makedirs("test_data", exist_ok=True) | ||
hypercoast.download_file(cls.url, cls.filepath) | ||
cls.dataset = hypercoast.read_neon(cls.filepath) | ||
|
||
def test_download_file(self): | ||
self.assertTrue(os.path.exists(self.filepath)) | ||
|
||
def test_read_neon(self): | ||
dataset = hypercoast.read_neon(self.filepath) | ||
self.assertIsNotNone(dataset) | ||
|
||
def test_map_set_center(self): | ||
m = hypercoast.Map() | ||
m.set_center(-76.5134, 38.8973, 16) | ||
self.assertEqual(m.center, [38.8973, -76.5134]) | ||
self.assertEqual(m.zoom, 16) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import unittest | ||
import hypercoast | ||
import os | ||
import matplotlib | ||
|
||
matplotlib.use("Agg") # Use the Agg backend to suppress plots | ||
|
||
|
||
class TestHypercoast(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.url = "https://github.com/opengeos/datasets/releases/download/netcdf/PACE_OCI.20240423T184658.L2.OC_AOP.V1_0_0.NRT.nc" | ||
cls.filepath = "test_data/PACE_OCI.20240423T184658.L2.OC_AOP.V1_0_0.NRT.nc" | ||
os.makedirs("test_data", exist_ok=True) | ||
hypercoast.download_file(cls.url, cls.filepath) | ||
cls.dataset = hypercoast.read_pace(cls.filepath) | ||
|
||
def test_download_file(self): | ||
self.assertTrue(os.path.exists(self.filepath)) | ||
|
||
def test_view_pace_pixel_locations(self): | ||
plot = hypercoast.view_pace_pixel_locations(self.filepath, step=20) | ||
self.assertIsNotNone(plot) | ||
|
||
def test_read_pace(self): | ||
dataset = hypercoast.read_pace(self.filepath) | ||
self.assertIsNotNone(dataset) | ||
|
||
def test_map(self): | ||
m = hypercoast.Map() | ||
m.add_basemap("Hybrid") | ||
wavelengths = [450] | ||
m.add_pace( | ||
self.dataset, | ||
wavelengths, | ||
colormap="jet", | ||
vmin=0, | ||
vmax=0.02, | ||
layer_name="PACE", | ||
) | ||
m.add_colormap(cmap="jet", vmin=0, vmax=0.02, label="Reflectance") | ||
m.add("spectral") | ||
html = m.to_html() | ||
self.assertIsNotNone(m) | ||
assert "PACE" in html | ||
|
||
m = hypercoast.Map() | ||
m.add_basemap("Hybrid") | ||
wavelengths = [450, 550, 650] | ||
m.add_pace( | ||
self.dataset, | ||
wavelengths, | ||
indexes=[3, 2, 1], | ||
vmin=0, | ||
vmax=0.02, | ||
layer_name="PACE", | ||
) | ||
m.add("spectral") | ||
html = m.to_html() | ||
self.assertIsNotNone(m) | ||
assert "PACE" in html | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |