Skip to content

Commit

Permalink
extend to 365 days with periodic calendar [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
kmdeck committed Sep 12, 2024
1 parent a942910 commit 4ed399d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
16 changes: 13 additions & 3 deletions experiments/long_runs/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import ClimaAnalysis
import ClimaAnalysis.Visualize as viz
import ClimaUtilities

import ClimaUtilities.TimeVaryingInputs: TimeVaryingInput
import ClimaUtilities.TimeVaryingInputs:
TimeVaryingInput, LinearInterpolation, PeriodicCalendar
import ClimaUtilities.SpaceVaryingInputs: SpaceVaryingInput
import ClimaUtilities.Regridders: InterpolationsRegridder
import ClimaUtilities.ClimaArtifacts: @clima_artifact
Expand All @@ -47,7 +48,7 @@ using Dates
import NCDatasets

const FT = Float64;

time_interpolation_method = LinearInterpolation(PeriodicCalendar())
regridder_type = :InterpolationsRegridder
context = ClimaComms.context()
device = ClimaComms.device()
Expand Down Expand Up @@ -85,6 +86,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
method = time_interpolation_method,
)

snow_precip = TimeVaryingInput(
Expand All @@ -95,6 +97,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
method = time_interpolation_method,
)

u_atmos = TimeVaryingInput(
Expand All @@ -104,6 +107,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
reference_date = ref_time,
t_start,
regridder_type,
method = time_interpolation_method,
)
q_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"),
Expand All @@ -112,6 +116,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
reference_date = ref_time,
t_start,
regridder_type,
method = time_interpolation_method,
)
P_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
Expand All @@ -120,6 +125,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
reference_date = ref_time,
t_start,
regridder_type,
method = time_interpolation_method,
)

T_atmos = TimeVaryingInput(
Expand All @@ -129,6 +135,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
reference_date = ref_time,
t_start,
regridder_type,
method = time_interpolation_method,
)
h_atmos = FT(10)

Expand All @@ -153,6 +160,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
method = time_interpolation_method,
)
LW_d = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
Expand All @@ -162,6 +170,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
method = time_interpolation_method,
)

function zenith_angle(
Expand Down Expand Up @@ -489,6 +498,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
file_reader_kwargs = (;
preprocess_func = (data) -> data > 0.05 ? data : 0.0,
),
method = time_interpolation_method,
)
ai_parameterization =
Canopy.PrescribedSiteAreaIndex{FT}(LAIfunction, SAI, RAI)
Expand Down Expand Up @@ -629,7 +639,7 @@ end
function setup_and_solve_problem(; greet = false)

t0 = 0.0
tf = 60 * 60.0 * 24 * 340
tf = 60 * 60.0 * 24 * 365
Δt = 900.0
nelements = (101, 15)
if greet
Expand Down
15 changes: 12 additions & 3 deletions experiments/long_runs/soil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ using ClimaAnalysis
import ClimaAnalysis.Visualize as viz
using ClimaUtilities

import ClimaUtilities.TimeVaryingInputs: TimeVaryingInput
import ClimaUtilities.TimeVaryingInputs:
TimeVaryingInput, LinearInterpolation, PeriodicCalendar
import ClimaUtilities.SpaceVaryingInputs: SpaceVaryingInput
import ClimaUtilities.Regridders: InterpolationsRegridder
import ClimaUtilities.ClimaArtifacts: @clima_artifact
Expand All @@ -45,7 +46,7 @@ using Dates
import NCDatasets

const FT = Float64;

time_interpolation_method = LinearInterpolation(PeriodicCalendar())
regridder_type = :InterpolationsRegridder
context = ClimaComms.context()
device = ClimaComms.device()
Expand Down Expand Up @@ -83,6 +84,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
method = time_interpolation_method,
)

snow_precip = TimeVaryingInput(
Expand All @@ -93,6 +95,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
method = time_interpolation_method,
)

u_atmos = TimeVaryingInput(
Expand All @@ -102,6 +105,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
reference_date = ref_time,
t_start,
regridder_type,
method = time_interpolation_method,
)
q_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"),
Expand All @@ -110,6 +114,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
reference_date = ref_time,
t_start,
regridder_type,
method = time_interpolation_method,
)
P_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
Expand All @@ -118,6 +123,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
reference_date = ref_time,
t_start,
regridder_type,
method = time_interpolation_method,
)

T_atmos = TimeVaryingInput(
Expand All @@ -127,6 +133,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
reference_date = ref_time,
t_start,
regridder_type,
method = time_interpolation_method,
)
h_atmos = FT(10)

Expand All @@ -151,6 +158,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
method = time_interpolation_method,
)
LW_d = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
Expand All @@ -160,6 +168,7 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
method = time_interpolation_method,
)

function zenith_angle(
Expand Down Expand Up @@ -440,7 +449,7 @@ end
function setup_and_solve_problem(; greet = false)

t0 = 0.0
tf = 60 * 60.0 * 24 * 340
tf = 60 * 60.0 * 24 * 365
Δt = 900.0
nelements = (101, 15)
if greet
Expand Down

0 comments on commit 4ed399d

Please sign in to comment.