Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate calibration pipeline into ClimaLand #621

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AlexisRenchon
Copy link
Member

@AlexisRenchon AlexisRenchon commented May 22, 2024

This PR adds calibration experiments, starting with a minimal working example.

This commit adds a simple calibration example, with detailed
explanations. We calibrate two parameters, g1 and g0, on
canopy transpiration data target, using EnsembleKalmanProcesses.jl.
We use a single site model, at the ozark site, and calibrate on
simulation output, with the goal of demonstrating the ability to
recover the original parameters and demonstrate a simple calibration
framework.
# Packages
import ClimaLandSimulations.Fluxnet as CLS # to run the model
import EnsembleKalmanProcesses as EKP # to perform the calibration
import Random # we need it for ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can update this

params = CLS.ozark_default_params(; conductance = CLS.conductance_ozark(; g1 = g1, g0 = g0)),
)[1];

inputs = CLS.make_inputs_df("US-MOz")[1];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these inputs and outputs? Can we access transpiration directly from sv?


simulation_output = CLS.make_output_df("US-MOz", sv, inputs);

transpiration = simulation_output.transpiration .* 1e9 # 1e9 because very small otherwise
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the 1e9? Is there an issue with floating point precision, or is there an error in the output?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also changes the float type


# parameters prior
prior_g1 = EKP.constrained_gaussian("g1", 221, 100, 0, Inf) # mean of 221 sqrt(Pa) = 7 sqrt(kPa), std of 100 (3 kPa)
# Ollie: why does it return μ=5.3, σ=0.4? Are the values transformed? Is this to be of same order of magnitude?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this ok now?

# generate the initial ensemble and set up the ensemble Kalman inversion
N_ensemble = 5
N_iterations = 5
rng_seed = 41 # Ollie: why 41?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can erase? I dont think this matters too much

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general - maybe should remove "Ollie" questions for now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I should've left a comment - this PR is not ready to be merged as I want to discuss these fews questions with Ollie first, but I think he is away at the moment.

But I still thought it would be valuable to review at this stage

theta_true = [141.0, 0.0001]
fig = Figure()
ax = Axis(fig[1, 1])
trange = 1:1:length(transpiration_target)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could note that this is not a physical time? "trange"

@@ -0,0 +1,96 @@
# This script describes the simplest possible calibration of ClimaLand,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add this to buildkite? and upload plots

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or this could be a tutorial?



# Plot
using GLMakie
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use CairoMakie? It is the more robust backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Calibration enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants