Skip to content

Commit 8288c8a

Browse files
glwagnerclaude
andcommitted
Add tests for PrescribedOcean, ERA5PrescribedAtmosphere, and GLORYS Column
- PrescribedOcean: add display/summary and net_fluxes tests - ERA5PrescribedAtmosphere: add construction test in test_cds_downloading - GLORYS: expand test_glorys_downloading with Column Nearest/Linear downloads, BoundingBox Field construction - CI: add test_glorys_downloading to Data Downloading workflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 734e609 commit 8288c8a

File tree

4 files changed

+82
-7
lines changed

4 files changed

+82
-7
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ jobs:
189189
using Pkg;
190190
Pkg.test(; coverage=true,
191191
julia_args=["--check-bounds=yes", "--compiled-modules=yes", "-O0"],
192-
test_args=["--verbose", "test_cds_downloading", "test_downloading"])
192+
test_args=["--verbose", "test_cds_downloading", "test_downloading", "test_glorys_downloading"])
193193
'
194194
- uses: julia-actions/julia-processcoverage@v1
195195
- uses: codecov/codecov-action@v5

test/test_cds_downloading.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ using NCDatasets
77
using NumericalEarth.DataWrangling.ERA5
88
using NumericalEarth.DataWrangling.ERA5: ERA5Hourly, ERA5Monthly, ERA5_dataset_variable_names
99
using NumericalEarth.DataWrangling: metadata_path, download_dataset
10+
using NumericalEarth.Atmospheres: PrescribedAtmosphere
1011

1112
# Test date: Kyoto Protocol ratification date, February 16, 2005
1213
start_date = DateTime(2005, 2, 16, 12)
@@ -195,3 +196,24 @@ start_date = DateTime(2005, 2, 16, 12)
195196
end
196197
end
197198
end
199+
200+
@testset "ERA5PrescribedAtmosphere" begin
201+
for arch in test_architectures
202+
A = typeof(arch)
203+
204+
@testset "Construction with BoundingBox on $A" begin
205+
region = NumericalEarth.DataWrangling.BoundingBox(longitude=(0, 5), latitude=(40, 45))
206+
atmos = ERA5PrescribedAtmosphere(arch;
207+
start_date = DateTime(2005, 2, 16),
208+
end_date = DateTime(2005, 2, 16, 6),
209+
region)
210+
211+
@test atmos isa PrescribedAtmosphere
212+
@test length(atmos.times) > 0
213+
@test atmos.tracers.T isa FieldTimeSeries
214+
@test atmos.tracers.q isa FieldTimeSeries
215+
@test atmos.velocities.u isa FieldTimeSeries
216+
@test atmos.velocities.v isa FieldTimeSeries
217+
end
218+
end
219+
end

test/test_glorys_downloading.jl

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,54 @@
11
include("runtests_setup.jl")
22

33
using CopernicusMarine
4+
using NumericalEarth.DataWrangling: metadata_path, download_dataset,
5+
BoundingBox, Column, Nearest, Linear
6+
using NumericalEarth.DataWrangling.GLORYS: GLORYSDaily
47

58
@testset "Downloading GLORYS data" begin
69
variables = (:temperature, :salinity, :u_velocity, :v_velocity)
7-
region = NumericalEarth.DataWrangling.BoundingBox(longitude=(200, 202), latitude=(35, 37))
8-
dataset = NumericalEarth.DataWrangling.GLORYS.GLORYSDaily()
9-
for variable in variables
10-
metadatum = Metadatum(variable; dataset, region)
11-
filepath = NumericalEarth.DataWrangling.metadata_path(metadatum)
10+
region = BoundingBox(longitude=(200, 202), latitude=(35, 37))
11+
dataset = GLORYSDaily()
12+
13+
@testset "BoundingBox download" begin
14+
for variable in variables
15+
metadatum = Metadatum(variable; dataset, region)
16+
filepath = metadata_path(metadatum)
17+
isfile(filepath) && rm(filepath; force=true)
18+
download_dataset(metadatum)
19+
@test isfile(filepath)
20+
end
21+
end
22+
23+
@testset "Column Nearest download" begin
24+
col = Column(201.0, 36.0; interpolation=Nearest())
25+
metadatum = Metadatum(:temperature; dataset, region=col)
26+
filepath = metadata_path(metadatum)
27+
isfile(filepath) && rm(filepath; force=true)
28+
download_dataset(metadatum)
29+
@test isfile(filepath)
30+
rm(filepath; force=true)
31+
end
32+
33+
@testset "Column Linear download" begin
34+
col = Column(201.0, 36.0; interpolation=Linear())
35+
metadatum = Metadatum(:temperature; dataset, region=col)
36+
filepath = metadata_path(metadatum)
1237
isfile(filepath) && rm(filepath; force=true)
13-
NumericalEarth.DataWrangling.download_dataset(metadatum)
38+
download_dataset(metadatum)
39+
@test isfile(filepath)
40+
rm(filepath; force=true)
41+
end
42+
43+
for arch in test_architectures
44+
A = typeof(arch)
45+
@testset "GLORYS Field with BoundingBox on $A" begin
46+
metadatum = Metadatum(:temperature; dataset, region)
47+
filepath = metadata_path(metadatum)
48+
isfile(filepath) || download_dataset(metadatum)
49+
field = Field(metadatum, arch)
50+
@test field isa Field
51+
@allowscalar @test any(!=(0), interior(field))
52+
end
1453
end
1554
end

test/test_prescribed_ocean.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ include("runtests_setup.jl")
3030
end
3131
end
3232

33+
@testset "Display and net_fluxes on $A" begin
34+
grid = RectilinearGrid(arch; size = (), topology = (Flat, Flat, Flat))
35+
ocean = PrescribedOcean(grid, NamedTuple())
36+
37+
str = summary(ocean)
38+
@test occursin("PrescribedOcean", str)
39+
40+
buf = IOBuffer()
41+
show(buf, ocean)
42+
@test occursin("PrescribedOcean", String(take!(buf)))
43+
44+
@test NumericalEarth.EarthSystemModels.InterfaceComputations.net_fluxes(ocean) === nothing
45+
end
46+
3347
@testset "EarthSystemModel interface on $A" begin
3448
grid = RectilinearGrid(arch; size = (), topology = (Flat, Flat, Flat))
3549

0 commit comments

Comments
 (0)