-
Notifications
You must be signed in to change notification settings - Fork 0
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
5 changed files
with
36 additions
and
62 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
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
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
""" Unit test for CTD simulator | ||
Author: Yaolin Ge | ||
Email: [email protected] | ||
Date: 2023-08-30 | ||
""" | ||
|
||
from unittest import TestCase | ||
|
@@ -17,14 +21,23 @@ | |
class TestCTDSimulator(TestCase): | ||
|
||
def setUp(self) -> None: | ||
self.ctd = CTDSimulator(random_seed=13) | ||
filepath_sinmod = os.getcwd() + "/../sinmod/samples_2022.05.11.nc" | ||
self.ctd = CTDSimulator(random_seed=14, filepath=filepath_sinmod, sigma=1.) | ||
self.sinmod = SINMOD(filepath_sinmod) | ||
|
||
def test_get_salinity_at_time_loc(self) -> None: | ||
# c1, whole region | ||
# x, y, depth = self.sinmod.get_coordinates() | ||
# loc = np.vstack((x.flatten(), y.flatten())).T | ||
x, y, depth = self.sinmod.get_coordinates() | ||
loc = np.vstack((x.flatten(), y.flatten())).T | ||
|
||
dt = 1200 | ||
for i in range(10): | ||
salinity = self.ctd.get_salinity_at_dt_loc(dt, loc) | ||
plt.figure() | ||
plt.scatter(loc[:, 1], loc[:, 0], c=salinity, cmap=get_cmap("BrBG", 10), vmin=10, vmax=30) | ||
plt.colorbar() | ||
plt.title("Time: " + datetime.fromtimestamp(self.ctd.timestamp).strftime("%Y-%m-%d %H:%M:%S")) | ||
plt.show() | ||
|
||
# c2, regional locations | ||
xx = np.linspace(2000, 4000, 100) | ||
|