Skip to content

Commit

Permalink
Merge #195
Browse files Browse the repository at this point in the history
195: Update Insolation to latest release r=valeriabarra a=valeriabarra

## Purpose 
The purpose of this PR is to update the `compat` entry for Insolation, given its latest release. 

This should fix compatibility issues downstream in the Coupler

## Todo / Related PRs
- [x] This is blocking this Coupler PR CliMA/ClimaCoupler.jl#306

## Content
- Updated Insolation compat entry in the top-level Project.toml file
- Applied necessary API changes


Review checklist

I have:
- followed the codebase contribution guide: https://clima.github.io/ClimateMachine.jl/latest/Contributing/
- followed the style guide: https://clima.github.io/ClimateMachine.jl/latest/DevDocs/CodeStyle/
- followed the documentation policy: https://github.com/CliMA/policies/wiki/Documentation-Policy
- checked that this PR does not duplicate an open PR.

In the Content, I have included 
- relevant unit tests, and integration tests, 
- appropriate docstrings on all functions, structs, and modules, and included relevant documentation.


- [x] I have read and checked the items on the review checklist.


Co-authored-by: Valeria Barra <[email protected]>
Co-authored-by: Charles Kawczynski <[email protected]>
  • Loading branch information
3 people authored May 16, 2023
2 parents 162fb2d + 8c8c4d2 commit 3f426a1
Show file tree
Hide file tree
Showing 17 changed files with 271 additions and 141 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ClimaComms = "0.3, 0.4"
ClimaCore = "0.10"
ClimaCoreTempestRemap = "0.3.5, 0.3.6, 0.3.7"
DocStringExtensions = "0.8, 0.9"
Insolation = "0.3"
Insolation = "0.5"
IntervalSets = "0.5, 0.6, 0.7"
JLD2 = "0.4"
NCDatasets = "0.11, 0.12"
Expand Down
2 changes: 2 additions & 0 deletions artifacts/Artifacts.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[orb_params_dataset]
git-tree-sha1 = "4fda5e46a91c2a0cf12c9b46dad3a4189ebcfb37"
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Insolation = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Expand All @@ -18,6 +19,7 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
[compat]
CLIMAParameters = "0.7.0"
ClimaCore = "0.10"
Insolation = "0.5"
SciMLBase = "<1.51"
SurfaceFluxes = "0.5, 0.6"
Thermodynamics = "0.9.2, 0.10"
Expand Down
18 changes: 14 additions & 4 deletions docs/tutorials/Bucket/bucket_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
# ``

# ``
# G_{undersnow} = (R_n+ SHF + LHF)_{snow} - F_{intosnow}
# G_{undersnow} = (R_n+ SHF + LHF)_{snow} - F_{intosnow}
# ``

# ``
Expand Down Expand Up @@ -89,7 +89,7 @@
# Turbulent surface fluxes of sensible heat, latent heat, and water vapor
# (`SHF, LHF, E`) are computed using Monin-Obukhov theory; `SW↓` and `LW↓`
# are the downward fluxes in short and long wavelength bands. We use the same
# roughness lengths for snow and soil.
# roughness lengths for snow and soil.
# Note that with the exception of precipitation and downwelling radiation,
# all fluxes are defined
# such that positive is towards the atmosphere.
Expand Down Expand Up @@ -131,6 +131,9 @@ using ClimaCore
# more seamless.
import CLIMAParameters as CP

# We also use Insolation to calculate solar zenith angle and solar insolation.
using Insolation

# Lastly, let's bring in the bucket model types (from ClimaLSM) that we
# will need access to.

Expand Down Expand Up @@ -216,7 +219,14 @@ bucket_domain =
# Here we define the model drivers, starting with downward radiation.
SW_d = (t) -> eltype(t)(300);
LW_d = (t) -> eltype(t)(300);
bucket_rad = PrescribedRadiativeFluxes(FT, SW_d, LW_d);
bucket_rad = PrescribedRadiativeFluxes(
FT,
SW_d,
LW_d;
orbital_data = Insolation.OrbitalData(
joinpath(pkgdir(ClimaLSM), "artifacts"),
),
);

# Prescribed atmospheric variables

Expand Down Expand Up @@ -267,7 +277,7 @@ ClimaLSM.auxiliary_vars(model)
p.bucket |> propertynames


# Next is to set initial conditions.
# Next is to set initial conditions.
Y.bucket.T .= FT(270);
Y.bucket.W .= FT(0.05);
Y.bucket.Ws .= FT(0.0);
Expand Down
16 changes: 14 additions & 2 deletions experiments/LSM/ozark/ozark_met_drivers_FLUXNET.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,23 @@ lat = FT(38.7441) # degree
long = FT(-92.2000) # degree

function zenith_angle(
t::FT;
t::FT,
orbital_data;
latitude = lat,
longitude = long,
insol_params = earth_param_set.insol_params,
) where {FT}
# This should be time in UTC
dt = DateTime("2004-01-01-06", "yyyy-mm-dd-HH") + Dates.Second(t)
FT(instantaneous_zenith_angle(dt, longitude, latitude, insol_params)[1])
FT(
instantaneous_zenith_angle(
dt,
orbital_data,
longitude,
latitude,
insol_params,
)[1],
)
end


Expand All @@ -123,6 +132,9 @@ radiation = ClimaLSM.PrescribedRadiativeFluxes(
SW_IN_spline,
LW_IN_spline;
θs = zenith_angle,
orbital_data = Insolation.OrbitalData(
joinpath(pkgdir(ClimaLSM), "artifacts"),
),
)

transpiration = DiagnosticTranspiration{FT}()
Loading

0 comments on commit 3f426a1

Please sign in to comment.