From 081a11d915e7ebb956bfef3dc343966323eb9ab4 Mon Sep 17 00:00:00 2001 From: Zhaoyi Shen <11598433+szy21@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:49:59 -0700 Subject: [PATCH] use linear interpolation in leaderboard --- experiments/ClimaEarth/run_amip.jl | 5 +++-- experiments/ClimaEarth/user_io/leaderboard/utils.jl | 2 +- test/experiment_tests/leaderboard.jl | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/experiments/ClimaEarth/run_amip.jl b/experiments/ClimaEarth/run_amip.jl index 5b13e7aacb..d70cb4c4a4 100644 --- a/experiments/ClimaEarth/run_amip.jl +++ b/experiments/ClimaEarth/run_amip.jl @@ -944,7 +944,7 @@ if ClimaComms.iamroot(comms_ctx) "pr" => (-5.0, 5.0), "rsut" => (-50.0, 50.0), "rlut" => (-50.0, 50.0), - "rsdt" => (-10.0, 10.0), + "rsdt" => (-2.0, 2.0), "rsutcs" => (-20.0, 20.0), "rlutcs" => (-20.0, 20.0), ) @@ -957,7 +957,8 @@ if ClimaComms.iamroot(comms_ctx) diagnostics_times = ClimaAnalysis.times(first_var) # Remove the first `spinup_months` months from the leaderboard spinup_months = 6 - spinup_cutoff = spinup_months * 30 * 86400.0 + # The monthly average output is at the end of the month, so this is safe + spinup_cutoff = spinup_months * 31 * 86400.0 if diagnostics_times[end] > spinup_cutoff filter!(x -> x > spinup_cutoff, diagnostics_times) end diff --git a/experiments/ClimaEarth/user_io/leaderboard/utils.jl b/experiments/ClimaEarth/user_io/leaderboard/utils.jl index 0a42b5d4c8..bf6472f75f 100644 --- a/experiments/ClimaEarth/user_io/leaderboard/utils.jl +++ b/experiments/ClimaEarth/user_io/leaderboard/utils.jl @@ -37,7 +37,7 @@ function resample( vec_to_range(v) = range(v[begin], v[end], length = length(v)) src_lonlat_ranges = vec_to_range.(src_lonlat) - itp = Interpolations.constant_interpolation( + itp = Interpolations.linear_interpolation( src_lonlat_ranges, data, extrapolation_bc = (Interpolations.Periodic(), Interpolations.Flat()), diff --git a/test/experiment_tests/leaderboard.jl b/test/experiment_tests/leaderboard.jl index 75f8afe2cf..03e55571fd 100644 --- a/test/experiment_tests/leaderboard.jl +++ b/test/experiment_tests/leaderboard.jl @@ -17,7 +17,7 @@ include(joinpath(pkgdir(ClimaCoupler), "artifacts", "artifact_funcs.jl")) input_matrix = reshape(1.0:16, (4, 4)) - @test Leaderboard.resample(input_matrix, (1.0:4, 1.0:4), ([2.8], [3.7]))[1] == 15.0 + @test Leaderboard.resample(input_matrix, (1.0:4, 1.0:4), ([2.8], [3.7]))[1] == 13.6 @test_throws ErrorException Leaderboard.integration_weights(([1.0], [10.0])) @test_throws ErrorException Leaderboard.integration_weights(([10.0], [1.0]))