-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip drifters * drifters instrument. just missing test * drifter test * Remove old drifter file and fix errors * codetools * outputdf wherever i forgot to use it * added todo list * ctd instrument * CTDtest * use new ctd instrument in sailship * fix typo * codetools * use new parcels api for particle class * add ctd to init * comments * first try adcp * adcp test * use adcp instrument in sailship * cleanup * instrument ship s t * use ship st in sailship * cleanup * refactor sailship ctd cast * cleanup * large cleanup * add checks that all drifter and argo floats are deployed * comments * docstrings and other codetools fixes * rename SamplePoint to Spacetime and move them one dir up * rm todo * run pydocstyle on tests * fix some names * Update virtual_ship/instruments/ctd.py Co-authored-by: Erik van Sebille <[email protected]> * removed comment about ctd * fix incorrect docstring * renamed ship_st to ship_underwater_st * remove sailship create fieldset commented out function * ship underway st docstring improvement * minor docstring change * minor docstring change --------- Co-authored-by: Erik van Sebille <[email protected]>
- Loading branch information
1 parent
92d0838
commit fcb36d7
Showing
22 changed files
with
740 additions
and
452 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
"""Test configuration that is ran for every test.""" | ||
|
||
import pytest | ||
|
||
|
||
# Set the working directory for each test to the directory of that test. | ||
@pytest.fixture(autouse=True) | ||
def change_test_dir(request, monkeypatch): | ||
""" | ||
Set the working directory for each test to the directory of that test. | ||
:param request: - | ||
:param monkeypatch: - | ||
""" | ||
monkeypatch.chdir(request.fspath.dirname) |
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,33 @@ | ||
"""Test the simulation of ADCP instruments.""" | ||
|
||
import numpy as np | ||
from parcels import FieldSet | ||
|
||
from virtual_ship import Location, Spacetime | ||
from virtual_ship.instruments.adcp import simulate_adcp | ||
|
||
|
||
def test_simulate_adcp() -> None: | ||
MAX_DEPTH = -1000 | ||
MIN_DEPTH = -5 | ||
BIN_SIZE = 24 | ||
|
||
fieldset = FieldSet.from_data( | ||
{"U": 0, "V": 0}, | ||
{ | ||
"lon": 0, | ||
"lat": 0, | ||
"time": [np.datetime64("1950-01-01") + np.timedelta64(632160, "h")], | ||
}, | ||
) | ||
|
||
sample_points = [Spacetime(Location(0, 0), 0)] | ||
|
||
simulate_adcp( | ||
fieldset=fieldset, | ||
out_file_name="test", | ||
max_depth=MAX_DEPTH, | ||
min_depth=MIN_DEPTH, | ||
bin_size=BIN_SIZE, | ||
sample_points=sample_points, | ||
) |
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,38 @@ | ||
"""Test the simulation of CTD instruments.""" | ||
|
||
from datetime import timedelta | ||
|
||
import numpy as np | ||
from parcels import FieldSet | ||
|
||
from virtual_ship import Location, Spacetime | ||
from virtual_ship.instruments.ctd import CTD, simulate_ctd | ||
|
||
|
||
def test_simulate_ctds() -> None: | ||
fieldset = FieldSet.from_data( | ||
{"U": 0, "V": 0, "T": 0, "S": 0, "bathymetry": 100}, | ||
{ | ||
"lon": 0, | ||
"lat": 0, | ||
"time": [np.datetime64("1950-01-01") + np.timedelta64(632160, "h")], | ||
}, | ||
) | ||
|
||
min_depth = -fieldset.U.depth[0] | ||
max_depth = -fieldset.U.depth[-1] | ||
|
||
ctds = [ | ||
CTD( | ||
spacetime=Spacetime(location=Location(latitude=0, longitude=0), time=0), | ||
min_depth=min_depth, | ||
max_depth=max_depth, | ||
) | ||
] | ||
|
||
simulate_ctd( | ||
ctds=ctds, | ||
fieldset=fieldset, | ||
out_file_name="test", | ||
outputdt=timedelta(seconds=10), | ||
) |
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,36 @@ | ||
"""Test the simulation of drifters.""" | ||
|
||
from datetime import timedelta | ||
|
||
import numpy as np | ||
from parcels import FieldSet | ||
|
||
from virtual_ship import Location, Spacetime | ||
from virtual_ship.instruments.drifter import Drifter, simulate_drifters | ||
|
||
|
||
def test_simulate_drifters() -> None: | ||
fieldset = FieldSet.from_data( | ||
{"U": 0, "V": 0, "T": 0}, | ||
{ | ||
"lon": 0, | ||
"lat": 0, | ||
"time": [np.datetime64("1950-01-01") + np.timedelta64(632160, "h")], | ||
}, | ||
) | ||
|
||
min_depth = -fieldset.U.depth[0] | ||
|
||
drifters = [ | ||
Drifter( | ||
spacetime=Spacetime(location=Location(latitude=0, longitude=0), time=0), | ||
min_depth=min_depth, | ||
) | ||
] | ||
|
||
simulate_drifters( | ||
drifters=drifters, | ||
fieldset=fieldset, | ||
out_file_name="test", | ||
outputdt=timedelta(minutes=5), | ||
) |
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,29 @@ | ||
"""Test the simulation of ship salinity temperature measurements.""" | ||
|
||
import numpy as np | ||
from parcels import FieldSet | ||
|
||
from virtual_ship import Location, Spacetime | ||
from virtual_ship.instruments.ship_underwater_st import simulate_ship_underwater_st | ||
|
||
|
||
def test_simulate_ship_underwater_st() -> None: | ||
DEPTH = -2 | ||
|
||
fieldset = FieldSet.from_data( | ||
{"U": 0, "V": 0, "S": 0, "T": 0}, | ||
{ | ||
"lon": 0, | ||
"lat": 0, | ||
"time": [np.datetime64("1950-01-01") + np.timedelta64(632160, "h")], | ||
}, | ||
) | ||
|
||
sample_points = [Spacetime(Location(0, 0), 0)] | ||
|
||
simulate_ship_underwater_st( | ||
fieldset=fieldset, | ||
out_file_name="test", | ||
depth=DEPTH, | ||
sample_points=sample_points, | ||
) |
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,5 +1,7 @@ | ||
"""Code for the Virtual Ship Classroom, where Marine Scientists can combine Copernicus Marine Data with an OceanParcels ship to go on a virtual expedition.""" | ||
|
||
from . import instruments, sailship | ||
from .location import Location | ||
from .spacetime import Spacetime | ||
|
||
__all__ = ["instruments", "sailship"] | ||
__all__ = ["Location", "Spacetime", "instruments", "sailship"] |
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
Oops, something went wrong.