From ee93d4af82592ad0f7a33b34bf6296f83e3b2559 Mon Sep 17 00:00:00 2001 From: kmdeck Date: Fri, 22 Nov 2024 08:57:28 -0800 Subject: [PATCH] convert mass fluxes to volume fluxes --- experiments/benchmarks/richards.jl | 3 ++- experiments/standalone/Soil/richards_runoff.jl | 4 ++-- src/shared_utilities/drivers.jl | 7 ++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/experiments/benchmarks/richards.jl b/experiments/benchmarks/richards.jl index 11995a9b1b..aea4beb123 100644 --- a/experiments/benchmarks/richards.jl +++ b/experiments/benchmarks/richards.jl @@ -96,6 +96,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15)) # Below, the preprocess_func argument is used to # 1. Convert precipitation to be negative (as it is downwards) + # 2. Convert mass flux to equivalent liquid water flux # Precipitation: precip = TimeVaryingInput( joinpath(era5_artifact_path, "era5_2008_1.0x1.0.nc"), @@ -103,7 +104,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15)) surface_space; start_date, regridder_type, - file_reader_kwargs = (; preprocess_func = (data) -> -data), + file_reader_kwargs = (; preprocess_func = (data) -> -data / 1000), ) atmos = ClimaLand.PrescribedPrecipitation{FT, typeof(precip)}(precip) bottom_bc = ClimaLand.Soil.WaterFluxBC((p, t) -> 0.0) diff --git a/experiments/standalone/Soil/richards_runoff.jl b/experiments/standalone/Soil/richards_runoff.jl index 10bc23ed89..cd5db1f121 100644 --- a/experiments/standalone/Soil/richards_runoff.jl +++ b/experiments/standalone/Soil/richards_runoff.jl @@ -71,7 +71,7 @@ era5_artifact_path = # Below, the preprocess_func argument is used to # 1. Convert precipitation to be negative (as it is downwards) -# 2. Convert accumulations over an hour to a rate per second +# 2. Convert mass flux to equivalent liquid water flux start_date = DateTime(2008); # Precipitation: precip = TimeVaryingInput( @@ -80,7 +80,7 @@ precip = TimeVaryingInput( surface_space; start_date, regridder_type, - file_reader_kwargs = (; preprocess_func = (data) -> -data,), + file_reader_kwargs = (; preprocess_func = (data) -> -data / 1000,), ) atmos = ClimaLand.PrescribedPrecipitation{FT, typeof(precip)}(precip) bottom_bc = ClimaLand.Soil.WaterFluxBC((p, t) -> 0.0) diff --git a/src/shared_utilities/drivers.jl b/src/shared_utilities/drivers.jl index 884deb4cdb..feed5fce62 100644 --- a/src/shared_utilities/drivers.jl +++ b/src/shared_utilities/drivers.jl @@ -1029,24 +1029,25 @@ function prescribed_forcing_era5( regridder_type = :InterpolationsRegridder, ) + # Precip is provide as a mass flux; convert to volume flux of liquid water with ρ =1000 kg/m^3 precip = TimeVaryingInput( era5_ncdata_path, ["mtpr", "msr"], surface_space; start_date, regridder_type, - file_reader_kwargs = (; preprocess_func = (data) -> -data,), + file_reader_kwargs = (; preprocess_func = (data) -> -data / 1000,), method = time_interpolation_method, compose_function = (mtpr, msr) -> mtpr - msr, ) - + # Precip is provide as a mass flux; convert to volume flux of liquid water with ρ =1000 kg/m^3 snow_precip = TimeVaryingInput( era5_ncdata_path, "msr", surface_space; start_date, regridder_type, - file_reader_kwargs = (; preprocess_func = (data) -> -data,), + file_reader_kwargs = (; preprocess_func = (data) -> -data / 1000,), method = time_interpolation_method, )