-
Notifications
You must be signed in to change notification settings - Fork 4
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
Basic test #33
Merged
Merged
Basic test #33
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
16159dc
Move deployments and postprocessing into sailship function and make d…
surgura a41afab
ignore .vscode/
surgura dbb7f0d
ignore .vscode/
surgura 34a44a7
Crudely move fieldset creation out of sailship and onto the user, pas…
surgura 56f44b5
Create sensors module, starting with argos. create basic test for argos.
surgura fd6f84e
Use argo sensor in sailship function
surgura 17948e1
rename sensors to instruments
surgura 0a6ab7a
rename sensors to instruments
surgura c2bb72f
Resolved codetools errors
surgura 528d1b3
Make constants individual parameters for argos
surgura 02ee54d
update sailship to use new argo function
surgura a694733
whitespace
surgura 635110e
whitespace
surgura 72a83cd
comment
surgura ad173e2
Add running tests with codecov
surgura 89f88a6
Add missing dependency
surgura 49c7d50
Add missing dependencies
surgura e566bdb
fix dependency?
surgura 9ad6008
fix dependency?
surgura c4d4555
Add missing newline
surgura 87b040f
Comments update
surgura 3e42563
Docstring update
surgura 01ffb83
Rename argos to argo floats
surgura 1e1267f
Create proper init.py
surgura 3b65eca
make outputdf a parameters for argos
surgura 36ead1b
Minor docstring update
surgura 5186d7e
minor variable renaming
surgura 8bb7ee2
Run codetools on tests
surgura 1cf2082
Use new parcels particle api
surgura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ on: [push, pull_request] | |
|
||
env: | ||
PACKAGE: virtual_ship | ||
TESTS: tests | ||
|
||
jobs: | ||
codetools: | ||
|
@@ -19,7 +20,7 @@ jobs: | |
- name: install | ||
run: pip install ".[dev]" | ||
- name: flake8 | ||
run: flake8 ./$PACKAGE | ||
run: flake8 ./$PACKAGE ./$TESTS | ||
- name: pydocstyle | ||
run: pydocstyle ./$PACKAGE | ||
- name: sort-all | ||
|
@@ -28,6 +29,18 @@ jobs: | |
[[ -z $(git status -s) ]] | ||
git checkout -- . | ||
- name: black | ||
run: black --diff --check ./$PACKAGE | ||
run: black --diff --check ./$PACKAGE ./$TESTS | ||
- name: isort | ||
run: isort --check-only --diff ./$PACKAGE | ||
run: isort --check-only --diff ./$PACKAGE ./$TESTS | ||
|
||
tests: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/[email protected] | ||
with: | ||
python-version: 3.12 | ||
- name: install | ||
run: pip install ".[dev]" | ||
- name: run_tests | ||
run: pytest --cov=virtual_ship tests | ||
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 |
---|---|---|
|
@@ -172,3 +172,5 @@ cython_debug/ | |
|
||
# Auto generated by setuptools scm | ||
virtual_ship/_version_setup.py | ||
|
||
.vscode/ |
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 | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,5 @@ | ||||||
#!/bin/sh | ||||||
|
||||||
# Runs the tests and creates a code coverage report. | ||||||
|
||||||
pytest --cov=virtual_ship --cov-report=html tests | ||||||
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. Also here add extra verbose/debug output
Suggested change
|
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,7 @@ | ||
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): | ||
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,48 @@ | ||
"""Test the simulation of Argo floats.""" | ||
|
||
from datetime import timedelta | ||
|
||
import numpy as np | ||
from parcels import FieldSet | ||
|
||
from virtual_ship.instruments import Location | ||
from virtual_ship.instruments.argo_float import ArgoFloat, simulate_argo_floats | ||
|
||
|
||
def test_simulate_argo_floats() -> None: | ||
DRIFT_DEPTH = -1000 | ||
MAX_DEPTH = -2000 | ||
VERTICLE_SPEED = -0.10 | ||
CYCLE_DAYS = 10 | ||
DRIFT_DAYS = 9 | ||
|
||
fieldset = FieldSet.from_data( | ||
{"U": 0, "V": 0, "T": 0, "S": 0}, | ||
{ | ||
"lon": 0, | ||
"lat": 0, | ||
"time": [np.datetime64("1950-01-01") + np.timedelta64(632160, "h")], | ||
}, | ||
) | ||
|
||
min_depth = -fieldset.U.depth[0] | ||
|
||
argo_floats = [ | ||
ArgoFloat( | ||
location=Location(latitude=0, longitude=0), | ||
deployment_time=0, | ||
min_depth=min_depth, | ||
max_depth=MAX_DEPTH, | ||
drift_depth=DRIFT_DEPTH, | ||
vertical_speed=VERTICLE_SPEED, | ||
cycle_days=CYCLE_DAYS, | ||
drift_days=DRIFT_DAYS, | ||
) | ||
] | ||
|
||
simulate_argo_floats( | ||
argo_floats=argo_floats, | ||
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,40 @@ | ||
{ | ||
"region_of_interest": { | ||
"North": 64, | ||
"East": -23, | ||
"South": 59, | ||
"West": -43 | ||
}, | ||
"requested_ship_time": { | ||
"start": "2022-01-01T00:00:00", | ||
"end": "2022-01-2T00:00:00" | ||
}, | ||
"route_coordinates": [ | ||
[-23.071289, 63.743631], [-23.081289, 63.743631], [-23.091289, 63.743631] | ||
], | ||
"underway_data": true, | ||
"ADCP_data": false, | ||
"ADCP_settings": { | ||
"max_depth": -1000, | ||
"bin_size_m": 24 | ||
}, | ||
"CTD_locations": [ | ||
[-23.071289, 63.743631] | ||
], | ||
"CTD_settings": { | ||
"max_depth": "max" | ||
}, | ||
"drifter_deploylocations": [ | ||
|
||
], | ||
"argo_deploylocations": [ | ||
[-23.081289, 63.743631] | ||
], | ||
"argo_characteristics": { | ||
"driftdepth": -1000, | ||
"maxdepth": -2000, | ||
"vertical_speed": -0.10, | ||
"cycle_days" : 10, | ||
"drift_days": 9 | ||
} | ||
} |
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,43 @@ | ||
"""Performs a complete cruise with virtual ship.""" | ||
|
||
import numpy as np | ||
from parcels import FieldSet | ||
|
||
from virtual_ship.sailship import sailship | ||
from virtual_ship.virtual_ship_configuration import VirtualShipConfiguration | ||
|
||
|
||
def test_sailship() -> None: | ||
ctd_fieldset = FieldSet.from_data( | ||
{"U": 0, "V": 0, "S": 0, "T": 0, "bathymetry": 0}, | ||
{"lon": 0, "lat": 0}, | ||
) | ||
ctd_fieldset.add_constant("maxtime", ctd_fieldset.U.grid.time_full[-1]) | ||
ctd_fieldset.add_constant("mindepth", -ctd_fieldset.U.depth[0]) | ||
ctd_fieldset.add_constant("max_depth", -ctd_fieldset.U.depth[-1]) | ||
|
||
drifter_fieldset = FieldSet.from_data( | ||
{ | ||
"U": 0, | ||
"V": 0, | ||
}, | ||
{"lon": 0, "lat": 0}, | ||
) | ||
|
||
argo_float_fieldset = FieldSet.from_data( | ||
{"U": 0, "V": 0, "T": 0, "S": 0}, | ||
{ | ||
"lon": 0, | ||
"lat": 0, | ||
"time": [np.datetime64("1950-01-01") + np.timedelta64(632160, "h")], | ||
}, | ||
) | ||
|
||
config = VirtualShipConfiguration( | ||
"sailship_config.json", | ||
ctd_fieldset=ctd_fieldset, | ||
drifter_fieldset=drifter_fieldset, | ||
argo_float_fieldset=argo_float_fieldset, | ||
) | ||
|
||
sailship(config) |
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 +1,5 @@ | ||
"""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 | ||
|
||
__all__ = ["instruments", "sailship"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add extra verbose/debug output to pytest