Skip to content

Commit 8698d13

Browse files
committed
Update 'area of interest' to 'space-time region' throughout
1 parent 7132766 commit 8698d13

File tree

6 files changed

+27
-26
lines changed

6 files changed

+27
-26
lines changed

src/virtualship/cli/_fetch.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ def hash_model(model: BaseModel, salt: int = 0) -> str:
3737
return create_hash(model.model_dump_json() + str(salt))
3838

3939

40-
def get_area_of_interest_hash(area_of_interest: SpaceTimeRegion) -> str:
41-
"""Get the hash of the area of interest."""
40+
def get_space_time_region_hash(space_time_region: SpaceTimeRegion) -> str:
4241
# Increment salt in the event of breaking data fetching changes with prior versions
4342
# of virtualship where you want to force new hashes (i.e., new data downloads)
4443
salt = 0
45-
return hash_model(area_of_interest, salt=salt)
44+
return hash_model(space_time_region, salt=salt)
4645

4746

4847
def filename_to_hash(filename: str) -> str:
@@ -83,7 +82,9 @@ def from_yaml(cls, file_path: str | Path) -> DownloadMetadata:
8382
return _generic_load_yaml(file_path, cls)
8483

8584

86-
def get_existing_download(data_folder: Path, aoi_hash: str) -> Path | None:
85+
def get_existing_download(
86+
data_folder: Path, space_time_region_hash: str
87+
) -> Path | None:
8788
"""Check if a download has already been completed. If so, return the path for existing download."""
8889
for download_path in data_folder.iterdir():
8990
try:
@@ -94,7 +95,7 @@ def get_existing_download(data_folder: Path, aoi_hash: str) -> Path | None:
9495
)
9596
continue
9697

97-
if hash == aoi_hash:
98+
if hash == space_time_region_hash:
9899
assert_complete_download(download_path)
99100
return download_path
100101

src/virtualship/cli/commands.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
DOWNLOAD_METADATA,
1212
DownloadMetadata,
1313
complete_download,
14-
get_area_of_interest_hash,
1514
get_existing_download,
15+
get_space_time_region_hash,
1616
hash_to_filename,
1717
)
1818
from virtualship.expedition.do_expedition import _get_schedule, do_expedition
@@ -68,7 +68,7 @@ def init(path):
6868
default=None,
6969
)
7070
def fetch(path: str | Path, username: str | None, password: str | None) -> None:
71-
"""Entrypoint for the tool to download data based on area of interest."""
71+
"""Entrypoint for the tool to download data based on space-time region."""
7272
if sum([username is None, password is None]) == 1:
7373
raise ValueError("Both username and password must be provided when using CLI.")
7474

@@ -79,31 +79,31 @@ def fetch(path: str | Path, username: str | None, password: str | None) -> None:
7979

8080
schedule = _get_schedule(path)
8181

82-
if schedule.area_of_interest is None:
82+
if schedule.space_time_region is None:
8383
raise ValueError(
84-
"Area of interest not found in schedule, please define it to fetch the data."
84+
"space_time_region not found in schedule, please define it to fetch the data."
8585
)
8686

87-
aoi_hash = get_area_of_interest_hash(schedule.area_of_interest)
87+
space_time_region_hash = get_space_time_region_hash(schedule.space_time_region)
8888

89-
existing_download = get_existing_download(data_folder, aoi_hash)
89+
existing_download = get_existing_download(data_folder, space_time_region_hash)
9090
if existing_download is not None:
9191
click.echo(
92-
f"Data download for area of interest already completed ('{existing_download}')."
92+
f"Data download for space-time region already completed ('{existing_download}')."
9393
)
9494
return
9595

9696
creds_path = path / creds.CREDENTIALS_FILE
9797
username, password = creds.get_credentials_flow(username, password, creds_path)
9898

99-
# Extract area_of_interest details from the schedule
100-
spatial_range = schedule.area_of_interest.spatial_range
101-
time_range = schedule.area_of_interest.time_range
99+
# Extract space_time_region details from the schedule
100+
spatial_range = schedule.space_time_region.spatial_range
101+
time_range = schedule.space_time_region.time_range
102102
start_datetime = time_range.start_time
103103
end_datetime = time_range.end_time
104104

105105
# Create download folder and set download metadata
106-
download_folder = data_folder / hash_to_filename(aoi_hash)
106+
download_folder = data_folder / hash_to_filename(space_time_region_hash)
107107
download_folder.mkdir()
108108
DownloadMetadata(download_complete=False).to_yaml(
109109
download_folder / DOWNLOAD_METADATA
@@ -134,7 +134,7 @@ def fetch(path: str | Path, username: str | None, password: str | None) -> None:
134134
},
135135
}
136136

137-
# Iterate over all datasets and download each based on area_of_interest
137+
# Iterate over all datasets and download each based on space_time_region
138138
try:
139139
for dataset in download_dict.values():
140140
copernicusmarine.subset(
@@ -160,7 +160,7 @@ def fetch(path: str | Path, username: str | None, password: str | None) -> None:
160160
raise e
161161

162162
complete_download(download_folder)
163-
click.echo("Data download based on area of interest completed.")
163+
click.echo("Data download based on space-time region completed.")
164164

165165

166166
@click.command(help="Do the expedition.")

src/virtualship/expedition/do_expedition.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pyproj
88

9-
from virtualship.cli._fetch import get_area_of_interest_hash, get_existing_download
9+
from virtualship.cli._fetch import get_existing_download, get_space_time_region_hash
1010
from virtualship.utils import CHECKPOINT, SCHEDULE, SHIP_CONFIG
1111

1212
from .checkpoint import Checkpoint
@@ -139,8 +139,8 @@ def _load_input_data(
139139
:rtype: InputData
140140
"""
141141
if input_data is None:
142-
aoi_hash = get_area_of_interest_hash(schedule.area_of_interest)
143-
input_data = get_existing_download(expedition_dir, aoi_hash)
142+
space_time_region_hash = get_space_time_region_hash(schedule.space_time_region)
143+
input_data = get_existing_download(expedition_dir, space_time_region_hash)
144144

145145
return InputData.load(
146146
directory=input_data,

src/virtualship/expedition/schedule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Schedule(pydantic.BaseModel):
1515
"""Schedule of the virtual ship."""
1616

1717
waypoints: list[Waypoint]
18-
area_of_interest: SpaceTimeRegion | None = None
18+
space_time_region: SpaceTimeRegion | None = None
1919

2020
model_config = pydantic.ConfigDict(extra="forbid")
2121

src/virtualship/expedition/space_time_region.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
class SpatialRange(BaseModel):
15-
"""Defines the geographic boundaries for an area of interest."""
15+
"""Defines geographic boundaries."""
1616

1717
minimum_longitude: Longitude
1818
maximum_longitude: Longitude
@@ -40,7 +40,7 @@ def _check_lon_lat_domain(self) -> Self:
4040

4141

4242
class TimeRange(BaseModel):
43-
"""Defines the temporal boundaries for an area of interest."""
43+
"""Defines the temporal boundaries for a space-time region."""
4444

4545
start_time: datetime
4646
end_time: datetime
@@ -53,7 +53,7 @@ def _check_time_range(self) -> Self:
5353

5454

5555
class SpaceTimeRegion(BaseModel):
56-
"""An area of interest with spatial and temporal boundaries."""
56+
"""An space-time region with spatial and temporal boundaries."""
5757

5858
spatial_range: SpatialRange
5959
time_range: TimeRange

src/virtualship/static/schedule.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
area_of_interest:
1+
space_time_region:
22
spatial_range:
33
minimum_longitude: -5
44
maximum_longitude: 5

0 commit comments

Comments
 (0)