Skip to content

Commit ad61114

Browse files
committed
Merge branch 'main' into teacher-content-permissions
2 parents 8b199cf + 6e69bba commit ad61114

File tree

6 files changed

+25
-10
lines changed

6 files changed

+25
-10
lines changed

docs/user-guide/teacher-content/UU-dyoc/example_expedition.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ In this guide we will conduct an example virtual expedition. This expedition is
55
---
66

77
```{important}
8-
This guide assumes you have already logged into and set up (initialised conda) the SURF virtual environment.
8+
This guide assumes you have already logged into and set up (initialised conda) the SURF virtual environment. If not, please follow the instructions in the [SURF virtual environment guide](https://virtualship.readthedocs.io/en/latest/user-guide/tutorials/surf_research_cloud_setup.html) to do so.
99
```
1010

1111
## 1) Create a new directory for your VirtualShip expeditions
1212

13-
First, you should navigate to the shared storage directory on the virtual machine (e.g. `cd data/virtualship-storage/`). If you have not done so already, please create a new directory for your group's VirtualShip expeditions (e.g. `mkdir {your-group_name}`, replacing `{your-group_name}` with your actual group name). This is where you will run your expeditions and store the results.
13+
First, you should navigate to the shared storage directory on the virtual machine (e.g. `cd data/virtualship-storage/`). If you have not done so already, please create a new directory for your group's VirtualShip expeditions (e.g. `mkdir GROUP{your-group_letter}`, replacing `{your-group_letter}` with the letter of your actual group name). This is where you will run your expeditions and store the results.
1414

1515
## 2) Expedition initialisation
1616

1717
```{note}
1818
For your real expeditions, there will be a more involved expedition planning stage before this, including route planning and scheduling. Here, we are just going to use the default VirtualShip example expedition route and schedule.
1919
```
2020

21-
You should now navigate to your group's directory (i.e. `cd data/virtualship_storage/{group_name}/`). Then run the following command in the terminal:
21+
You should now navigate to your group's directory (i.e. `cd data/virtualship_storage/GROUP{your-group_letter}/`). Then run the following command in the terminal:
2222

2323
```
2424
virtualship init EXPEDITION_NAME
@@ -72,4 +72,4 @@ Why not browse through previous real-life [blogs and expedition reports](https:/
7272

7373
Upon successfully completing the simulation, results from the expedition will be stored in the `EXPEDITION_NAME/results` directory, written as [Zarr](https://zarr.dev/) files.
7474

75-
From here you will be able to carry on your analysis. We won't go into this here for the example expedition, but when it comes to your own expeditions, you will be expected to analyse, derive quantities and visualise your results, and to ultimately present your findings.
75+
From here you will be able to carry on your analysis. We won't go into this here for the example expedition, but when it comes to your own expeditions, you will be expected to analyse, compute derived quantities and visualise your results, and to ultimately present your findings.

docs/user-guide/tutorials/working_with_expedition_yaml.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ This section contains a list of `waypoints` that define the expedition's route.
7878
Full list of instruments supported for deployment at waypoints (case-sensitive): `CTD`, `CTD_BGC`, `DRIFTER`, `ARGO_FLOAT`, `XBT` (or `null`).
7979
```
8080

81+
```{tip}
82+
You can do multiple `DRIFTER` deployments at the same waypoint by adding multiple `DRIFTER` entries in the list (on separate lines). Note, this is not the case for other instruments, e.g. `CTD`, which can only be deployed once at a given waypoint.
83+
```
84+
8185
- **Location (`location`)**: The geographical coordinates (latitude and longitude) of the waypoint. These must be in decimal degrees (DD) format and within valid ranges: latitude between -90 and 90, longitude between -180 and 180.
8286

8387
- **Time (`time`)**: The scheduled time for reaching the waypoint, specifically in YYYY-MM-DD HH:MM:SS format.

src/virtualship/cli/_run.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def _run(
8383
expedition = _get_expedition(expedition_dir)
8484

8585
# unique id to determine if an expedition has 'changed' since last run (to avoid re-selecting problems when user makes tweaks to schedule to deal with problems encountered)
86-
expedition_id = _unique_id(expedition, expedition_dir)
86+
cache_dir = expedition_dir.joinpath(CACHE)
87+
expedition_id = _unique_id(expedition, cache_dir)
8788

8889
# dedicated problems directory for this expedition
8990
problems_dir = expedition_dir.joinpath(
@@ -234,6 +235,10 @@ def _run(
234235
if os.path.exists(expedition_dir.joinpath(CHECKPOINT)):
235236
os.remove(expedition_dir.joinpath(CHECKPOINT))
236237

238+
# delete cache dir if when --difficulty-level is 'easy' (no useful information to cache in this case, and can interfere with re-runs)
239+
if difficulty_level == "easy" and os.path.exists(cache_dir):
240+
shutil.rmtree(cache_dir)
241+
237242
print("\n------------- END -------------\n")
238243

239244
# end timing
@@ -242,7 +247,7 @@ def _run(
242247
print(f"[TIMER] Expedition completed in {elapsed / 60.0:.2f} minutes.")
243248

244249

245-
def _unique_id(expedition: Expedition, expedition_dir: Path) -> str:
250+
def _unique_id(expedition: Expedition, cache_dir: Path) -> str:
246251
"""
247252
Return a unique id for the expedition (marked by datetime), which can be used to determine whether the expedition has 'changed' since the last run.
248253
@@ -252,7 +257,6 @@ def _unique_id(expedition: Expedition, expedition_dir: Path) -> str:
252257
new_id = datetime.now().strftime("%Y%m%d%H%M%S")
253258
previous_id = None
254259

255-
cache_dir = expedition_dir.joinpath(CACHE)
256260
if not cache_dir.exists():
257261
cache_dir.mkdir()
258262
id_path = cache_dir.joinpath(EXPEDITION_IDENTIFIER)

src/virtualship/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def _find_files_in_timerange(
569569
return [fname for _, fname in files_with_dates]
570570

571571

572-
def _random_noise(scale: float = 0.01, limit: float = 0.03) -> float:
572+
def _random_noise(scale: float = 0.05, limit: float = 0.1) -> float:
573573
"""Generate a small random noise value for drifter seeding locations."""
574574
value = np.random.normal(loc=0.0, scale=scale)
575575
return np.clip(value, -limit, limit) # ensure noise is within limits

tests/cli/test_run.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def execute(self, measurements, out_path):
3333

3434
def test_run(tmp_path, monkeypatch):
3535
"""Testing as if using pre-downloaded, local data."""
36+
difficulty_level = "easy"
37+
3638
expedition_dir = tmp_path / "expedition_dir"
3739
expedition_dir.mkdir()
3840
(expedition_dir / EXPEDITION).write_text(get_example_expedition())
@@ -54,7 +56,7 @@ def test_run(tmp_path, monkeypatch):
5456
fake_data_dir.mkdir()
5557

5658
_run(
57-
expedition_dir, difficulty_level="easy", from_data=fake_data_dir
59+
expedition_dir, difficulty_level=difficulty_level, from_data=fake_data_dir
5860
) # problems turned off here
5961

6062
results_dir = expedition_dir / "results"
@@ -64,3 +66,8 @@ def test_run(tmp_path, monkeypatch):
6466
assert cost_file.exists()
6567
content = cost_file.read_text()
6668
assert "cost:" in content
69+
70+
# check cache dir is deleted at end of expedition when difficulty-level is easy
71+
if difficulty_level == "easy":
72+
cache_dir = expedition_dir / "cache"
73+
assert not cache_dir.exists()

tests/instruments/test_drifter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_simulate_drifters(tmpdir) -> None:
3939
drifters = [
4040
Drifter(
4141
spacetime=Spacetime(
42-
location=Location(latitude=0.05, longitude=0.05),
42+
location=Location(latitude=0.5, longitude=0.5),
4343
time=base_time + datetime.timedelta(days=0),
4444
),
4545
depth=0.0,

0 commit comments

Comments
 (0)