Skip to content

Commit

Permalink
Rename ref_time/date -> start_date
Browse files Browse the repository at this point in the history
  • Loading branch information
Sbozzolo committed Sep 11, 2024
1 parent 9e40a84 commit a6591fe
Show file tree
Hide file tree
Showing 30 changed files with 214 additions and 214 deletions.
10 changes: 5 additions & 5 deletions docs/tutorials/shared_utilities/driver_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ lat = 38.7441; # degree
long = -92.2000; # degree
# Compute the reference time in UTC, and convert local datetime
# vector into a vector of seconds since the reference time
ref_time = local_datetime[1] + Dates.Hour(time_offset);
start_date = local_datetime[1] + Dates.Hour(time_offset);
data_dt = 3600.0;
seconds = 0:data_dt:((length(local_datetime) - 1) * data_dt);

Expand All @@ -81,16 +81,16 @@ earth_param_set = LP.LandParameters(Float64);
insol_params = earth_param_set.insol_params # parameters of Earth's orbit required to compute the insolation
function zenith_angle(
t,
ref_time;
start_date;
latitude = lat,
longitude = long,
insol_params = insol_params,
)
current_datetime = ref_time + Dates.Second(round(t)) # Time in UTC
current_datetime = start_date + Dates.Second(round(t)) # Time in UTC

d, δ, η_UTC = (Insolation.helper_instantaneous_zenith_angle(
current_datetime,
ref_time,
start_date,
insol_params,
))

Expand All @@ -110,7 +110,7 @@ radiation = ClimaLand.PrescribedRadiativeFluxes(
Float64,
SW_d,
LW_d,
ref_time;
start_date;
θs = zenith_angle,
);

Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/standalone/Bucket/bucket_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ bucket_parameters = BucketModelParameters(FT; albedo, z_0m, z_0b, τc);
# The PrescribedAtmosphere and PrescribedRadiation need to take in a reference
# time, the date of the start of the simulation. In this tutorial we will
# consider this January 1, 2005.
ref_time = DateTime(2005);
start_date = DateTime(2005);

# To drive the system in standalone mode,
# the user must provide
Expand Down Expand Up @@ -247,7 +247,7 @@ bucket_atmos = PrescribedAtmosphere(
TimeVaryingInput(u_atmos),
TimeVaryingInput(q_atmos),
TimeVaryingInput(P_atmos),
ref_time,
start_date,
h_atmos,
earth_param_set,
);
Expand All @@ -262,7 +262,7 @@ bucket_rad = PrescribedRadiativeFluxes(
FT,
TimeVaryingInput(SW_d),
TimeVaryingInput(LW_d),
ref_time,
start_date,
);


Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/standalone/Soil/evaporation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ thermo_params = LP.thermodynamic_parameters(earth_param_set);
# Our assumption is that in the lab experiment there was no radiative heating
# or cooling of the soil.

ref_time = DateTime(2005) # required argument, but not used in this case
start_date = DateTime(2005) # required argument, but not used in this case
SW_d = (t) -> 0
LW_d = (t) -> 301.15^4 * 5.67e-8
radiation = PrescribedRadiativeFluxes(
FT,
TimeVaryingInput(SW_d),
TimeVaryingInput(LW_d),
ref_time,
start_date,
);
# Set up atmospheric conditions that result in the potential evaporation
# rate obsereved in the experiment.
Expand Down Expand Up @@ -74,7 +74,7 @@ atmos = PrescribedAtmosphere(
TimeVaryingInput(u_atmos),
TimeVaryingInput(q_atmos),
TimeVaryingInput(P_atmos),
ref_time,
start_date,
h_atmos,
earth_param_set;
gustiness = gustiness,
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/standalone/Soil/evaporation_gilat_loess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ params = ClimaLand.Soil.EnergyHydrologyParameters(
d_ds,
);

ref_time = DateTime(2005)
start_date = DateTime(2005)
SW_d = (t) -> 0
LW_d = (t) -> 294.15^4 * 5.67e-8
radiation = PrescribedRadiativeFluxes(
FT,
TimeVaryingInput(SW_d),
TimeVaryingInput(LW_d),
ref_time,
start_date,
)
# Atmos
T_air = FT(301.15)
Expand All @@ -104,7 +104,7 @@ atmos = PrescribedAtmosphere(
TimeVaryingInput(u_atmos),
TimeVaryingInput(q_atmos),
TimeVaryingInput(P_atmos),
ref_time,
start_date,
h_atmos,
earth_param_set;
gustiness = gustiness,
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/standalone/Soil/sublimation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ FT = Float64;
earth_param_set = LP.LandParameters(FT)
thermo_params = LP.thermodynamic_parameters(earth_param_set);

ref_time = DateTime(2005)
start_date = DateTime(2005)
SW_d = (t) -> 0
LW_d = (t) -> 270.0^4 * 5.67e-8
radiation = PrescribedRadiativeFluxes(
FT,
TimeVaryingInput(SW_d),
TimeVaryingInput(LW_d),
ref_time,
start_date,
);
# Set up atmospheric conditions that result in the potential evaporation
# rate obsereved in the experiment.
Expand Down Expand Up @@ -60,7 +60,7 @@ atmos = PrescribedAtmosphere(
TimeVaryingInput(u_atmos),
TimeVaryingInput(q_atmos),
TimeVaryingInput(P_atmos),
ref_time,
start_date,
h_atmos,
earth_param_set;
gustiness = gustiness,
Expand Down
8 changes: 4 additions & 4 deletions experiments/benchmarks/bucket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function setup_prob(t0, tf, Δt; nelements = (100, 10))
npolynomial = 1,
dz_tuple = FT.((1.0, 0.05)),
)
ref_time = DateTime(2005)
start_date = DateTime(2005)

# Initialize parameters
σS_c = FT(0.2)
Expand All @@ -69,7 +69,7 @@ function setup_prob(t0, tf, Δt; nelements = (100, 10))

surface_space = bucket_domain.space.surface
# Construct albedo parameter object using temporal map
albedo = PrescribedSurfaceAlbedo{FT}(ref_time, t0, surface_space)
albedo = PrescribedSurfaceAlbedo{FT}(start_date, t0, surface_space)

bucket_parameters = BucketModelParameters(FT; albedo, z_0m, z_0b, τc)

Expand All @@ -91,7 +91,7 @@ function setup_prob(t0, tf, Δt; nelements = (100, 10))
TimeVaryingInput(u_atmos),
TimeVaryingInput(q_atmos),
TimeVaryingInput(P_atmos),
ref_time,
start_date,
h_atmos,
earth_param_set,
)
Expand All @@ -106,7 +106,7 @@ function setup_prob(t0, tf, Δt; nelements = (100, 10))
FT,
TimeVaryingInput(SW_d),
TimeVaryingInput(LW_d),
ref_time,
start_date,
)

model = BucketModel(
Expand Down
30 changes: 15 additions & 15 deletions experiments/benchmarks/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
surface_space = domain.space.surface
subsurface_space = domain.space.subsurface

ref_time = DateTime(2021)
start_date = DateTime(2021)

# Forcing data
era5_artifact_path =
Expand All @@ -80,7 +80,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"),
"rf",
surface_space;
reference_date = ref_time,
reference_date = start_date,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand All @@ -89,7 +89,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"sf",
surface_space;
reference_date = ref_time,
reference_date = start_date,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand All @@ -98,29 +98,29 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"),
"ws",
surface_space;
reference_date = ref_time,
reference_date = start_date,
regridder_type,
)
q_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"),
"q",
surface_space;
reference_date = ref_time,
reference_date = start_date,
regridder_type,
)
P_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"sp",
surface_space;
reference_date = ref_time,
reference_date = start_date,
regridder_type,
)

T_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"t2m",
surface_space;
reference_date = ref_time,
reference_date = start_date,
regridder_type,
)
h_atmos = FT(10)
Expand All @@ -132,7 +132,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
u_atmos,
q_atmos,
P_atmos,
ref_time,
start_date,
h_atmos,
earth_param_set,
)
Expand All @@ -142,35 +142,35 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"ssrd",
surface_space;
reference_date = ref_time,
reference_date = start_date,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
)
LW_d = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"strd",
surface_space;
reference_date = ref_time,
reference_date = start_date,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
)

function zenith_angle(
t,
ref_time;
start_date;
latitude = ClimaCore.Fields.coordinate_field(surface_space).lat,
longitude = ClimaCore.Fields.coordinate_field(surface_space).long,
insol_params::Insolation.Parameters.InsolationParameters{FT} = earth_param_set.insol_params,
) where {FT}
# This should be time in UTC
current_datetime = ref_time + Dates.Second(round(t))
current_datetime = start_date + Dates.Second(round(t))

# Orbital Data uses Float64, so we need to convert to our sim FT
d, δ, η_UTC =
FT.(
Insolation.helper_instantaneous_zenith_angle(
current_datetime,
ref_time,
start_date,
insol_params,
)
)
Expand All @@ -184,7 +184,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
).:1
end
radiation =
PrescribedRadiativeFluxes(FT, SW_d, LW_d, ref_time; θs = zenith_angle)
PrescribedRadiativeFluxes(FT, SW_d, LW_d, start_date; θs = zenith_angle)

soil_params_artifact_path =
ClimaLand.Artifacts.soil_params_artifact_folder_path(; context)
Expand Down Expand Up @@ -483,7 +483,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
joinpath(era5_artifact_path, "era5_lai_2021_0.9x1.25_clima.nc"),
"lai",
surface_space;
reference_date = ref_time,
reference_date = start_date,
regridder_type,
file_reader_kwargs = (;
preprocess_func = (data) -> data > 0.05 ? data : 0.0,
Expand Down
6 changes: 3 additions & 3 deletions experiments/benchmarks/richards.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
surface_space = domain.space.surface
subsurface_space = domain.space.subsurface

ref_time = DateTime(2021)
start_date = DateTime(2021)

# Read in f_max data and land sea mask
infile_path = ClimaLand.Artifacts.topmodel_data_path()
Expand Down Expand Up @@ -195,13 +195,13 @@ 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 accumulations over an hour to a rate per second
ref_time = DateTime(2021)
start_date = DateTime(2021)
# Precipitation:
precip = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"tp",
surface_space;
reference_date = ref_time,
reference_date = start_date,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand Down
6 changes: 3 additions & 3 deletions experiments/integrated/fluxnet/met_drivers_FLUXNET.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,20 @@ atmos = ClimaLand.PrescribedAtmosphere(

function zenith_angle(
t,
ref_time;
start_date;
latitude = lat,
longitude = long,
insol_params::Insolation.Parameters.InsolationParameters{FT} = earth_param_set.insol_params,
) where {FT}
# This should be time in UTC
current_datetime = ref_time + Dates.Second(round(t))
current_datetime = start_date + Dates.Second(round(t))

# Orbital Data uses Float64, so we need to convert to our sim FT
d, δ, η_UTC =
FT.(
Insolation.helper_instantaneous_zenith_angle(
current_datetime,
ref_time,
start_date,
insol_params,
)
)
Expand Down
Loading

0 comments on commit a6591fe

Please sign in to comment.