From 7d0bf3eb40a15edb272fe4ef16d6e20141c35a20 Mon Sep 17 00:00:00 2001 From: Zhaoyi Shen <11598433+szy21@users.noreply.github.com> Date: Wed, 14 Aug 2024 17:24:22 -0700 Subject: [PATCH 1/2] add downward sw fluxes to leaderboard --- experiments/ClimaEarth/run_amip.jl | 3 ++- .../ClimaEarth/user_io/leaderboard/compare_with_obs.jl | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/experiments/ClimaEarth/run_amip.jl b/experiments/ClimaEarth/run_amip.jl index 74dea35bc4..542e77b5fc 100644 --- a/experiments/ClimaEarth/run_amip.jl +++ b/experiments/ClimaEarth/run_amip.jl @@ -932,12 +932,13 @@ if ClimaComms.iamroot(comms_ctx) include("user_io/leaderboard.jl") ClimaAnalysis = Leaderboard.ClimaAnalysis - compare_vars_biases = ["pr", "rsut", "rlut", "rsutcs", "rlutcs"] + compare_vars_biases = ["pr", "rsut", "rlut", "rsdt", "rsutcs", "rlutcs"] compare_vars_biases_plot_extrema = Dict( "pr" => (-5.0, 5.0), "rsut" => (-50.0, 50.0), "rlut" => (-50.0, 50.0), + "rsdt" => (-10.0, 10.0), "rsutcs" => (-20.0, 20.0), "rlutcs" => (-20.0, 20.0), ) diff --git a/experiments/ClimaEarth/user_io/leaderboard/compare_with_obs.jl b/experiments/ClimaEarth/user_io/leaderboard/compare_with_obs.jl index 1b33933d0c..323070a670 100644 --- a/experiments/ClimaEarth/user_io/leaderboard/compare_with_obs.jl +++ b/experiments/ClimaEarth/user_io/leaderboard/compare_with_obs.jl @@ -56,6 +56,12 @@ OBS_DS["rsutcs"] = ObsDataSource(; ) SIM_DS_KWARGS["rsutcs"] = (;) +OBS_DS["rsdt"] = ObsDataSource(; + path = joinpath(@clima_artifact("radiation_obs"), "CERES_EBAF-TOA_Ed4.2_Subset_200003-202303.g025.nc"), + var_name = "solar_mon", +) +SIM_DS_KWARGS["rsdt"] = (;) + OBS_DS["rlutcs"] = ObsDataSource(; path = joinpath(@clima_artifact("radiation_obs"), "CERES_EBAF-TOA_Ed4.2_Subset_200003-202303.g025.nc"), var_name = "toa_lw_clr_c_mon", From 615b0675249c53ec00400f043fadf0723a2f6d15 Mon Sep 17 00:00:00 2001 From: Gabriele Bozzola Date: Wed, 14 Aug 2024 17:16:51 -0700 Subject: [PATCH 2/2] Add option to shift ObsDataSources to end of month This helps with comparing with our model because observations are typically defined on the 15th, but our model is defined at the end of the month. Since we always find the closest data available, this can lead to comparisons across months. --- .../user_io/leaderboard/data_sources.jl | 15 ++++++++++++++- .../ClimaEarth/user_io/leaderboard/utils.jl | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/experiments/ClimaEarth/user_io/leaderboard/data_sources.jl b/experiments/ClimaEarth/user_io/leaderboard/data_sources.jl index d4593d10a1..ce126a6df9 100644 --- a/experiments/ClimaEarth/user_io/leaderboard/data_sources.jl +++ b/experiments/ClimaEarth/user_io/leaderboard/data_sources.jl @@ -24,6 +24,9 @@ struct ObsDataSource """The NCDataset associated to the file""" ncdataset::NCDatasets.NCDataset + + """Shift dates so that they are at the end of month?""" + shift_to_end_of_month::Bool end function ObsDataSource(; @@ -33,11 +36,21 @@ function ObsDataSource(; lon_name = "lon", lat_name = "lat", preprocess_data_fn = identity, + shift_to_end_of_month = true, ) ncdataset = NCDatasets.NCDataset(path) - return ObsDataSource(path, var_name, time_name, lon_name, lat_name, preprocess_data_fn, ncdataset) + return ObsDataSource( + path, + var_name, + time_name, + lon_name, + lat_name, + preprocess_data_fn, + ncdataset, + shift_to_end_of_month, + ) end """ diff --git a/experiments/ClimaEarth/user_io/leaderboard/utils.jl b/experiments/ClimaEarth/user_io/leaderboard/utils.jl index bb76c8c72d..0a42b5d4c8 100644 --- a/experiments/ClimaEarth/user_io/leaderboard/utils.jl +++ b/experiments/ClimaEarth/user_io/leaderboard/utils.jl @@ -197,6 +197,10 @@ function find_and_resample( available_times = obs.ncdataset[observed_data.time_name] + if observed_data.shift_to_end_of_month + available_times = Dates.DateTime.(Dates.lastdayofmonth.(available_times)) + end + time_index = ClimaAnalysis.Utils.nearest_index(available_times, date) # NOTE: We are hardcoding that the time index is the last one and that there are three