@@ -53,8 +53,11 @@ using ClimaLand.Canopy.PlantHydraulics
53
53
import ClimaLand. Simulations: LandSimulation, solve!
54
54
import ClimaLand
55
55
import ClimaLand. Parameters as LP
56
+ import ClimaDiagnostics
56
57
using DelimitedFiles
57
58
import ClimaLand. FluxnetSimulations as FluxnetSimulations
59
+ using CairoMakie, ClimaAnalysis, GeoMakie, Poppler_jll, Printf, StatsBase
60
+ import ClimaLand. LandSimVis as LandSimVis
58
61
59
62
# Define the floating point precision desired (64 or 32 bit), and get the
60
63
# parameter set holding constants used across CliMA Models:
@@ -228,16 +231,16 @@ function set_ic!(Y, p, t0, model)
228
231
evaluate! (Y. canopy. energy. T, atmos. T, t0)
229
232
end
230
233
231
- # Allocate the struct which stores the saved auxiliary state
232
- # and create the callback which saves it at each element in saveat .
233
-
234
- n = 16
235
- saveat = Array (start_date : Second (n * dt) : end_date);
236
- sv = ( ;
237
- t = Array {DateTime} (undef, length (saveat)) ,
238
- saveval = Array {NamedTuple} (undef, length (saveat)) ,
239
- )
240
- saving_cb = ClimaLand . NonInterpSavingCallback (sv, saveat );
234
+ # Set up the diagnostics writer, which will save model variables
235
+ # throughout the course of the simulation .
236
+ diag_writer = ClimaDiagnostics . Writers . DictWriter ();
237
+ diagnostics = ClimaLand . Diagnostics . default_diagnostics (
238
+ canopy,
239
+ start_date ;
240
+ output_vars = [ " gpp " , " trans " ] ,
241
+ output_writer = diag_writer ,
242
+ average_period = :hourly ,
243
+ );
241
244
242
245
# Create the callback function which updates the forcing variables,
243
246
# or drivers.
@@ -261,59 +264,18 @@ simulation = LandSimulation(
261
264
end_date,
262
265
dt,
263
266
canopy;
264
- set_ic! = set_ic!,
265
- updateat = updateat,
266
- solver_kwargs = (; saveat = deepcopy (saveat)),
267
+ set_ic!,
268
+ updateat,
267
269
timestepper = ode_algo,
268
- user_callbacks = (saving_cb,),
270
+ user_callbacks = (),
271
+ diagnostics,
269
272
);
270
273
274
+ # Now we can solve the simulation, which will run the model forward in time.
271
275
sol = solve! (simulation);
272
276
273
277
# # Create some plots
274
278
275
- # We can now plot the data produced in the simulation. For example, GPP:
276
-
277
- daily = FT .(sol. t) ./ 3600 ./ 24
278
- model_GPP = [
279
- parent (sv. saveval[k]. canopy. photosynthesis. GPP)[1 ] for
280
- k in 1 : length (sv. saveval)
281
- ]
282
-
283
- plt1 = Plots. plot (size = (600 , 700 ));
284
- Plots. plot! (
285
- plt1,
286
- daily,
287
- model_GPP .* 1e6 ,
288
- label = " Model" ,
289
- xlim = [minimum (daily), maximum (daily)],
290
- xlabel = " days" ,
291
- ylabel = " GPP [μmol/mol]" ,
292
- );
293
-
294
- # Transpiration plot:
295
-
296
- T = [
297
- parent (sv. saveval[k]. canopy. turbulent_fluxes. transpiration)[1 ] for
298
- k in 1 : length (sv. saveval)
299
- ]
300
- T = T .* (1e3 * 24 * 3600 )
301
-
302
- plt2 = Plots. plot (size = (500 , 700 ));
303
- Plots. plot! (
304
- plt2,
305
- daily,
306
- T,
307
- label = " Model" ,
308
- xlim = [minimum (daily), maximum (daily)],
309
- xlabel = " days" ,
310
- ylabel = " Vapor Flux [mm/day]" ,
311
- );
312
-
313
- # Show the two plots together:
314
-
315
- Plots. plot (plt1, plt2, layout = (2 , 1 ));
316
-
317
- # Save the output:
318
- savefig (" ozark_standalone_canopy_test.png" );
319
- # 
279
+ # We can now plot the data produced in the simulation. For example, GPP and transpiration:
280
+ LandSimVis. make_diurnal_timeseries (simulation; short_names = [" gpp" , " trans" ])
281
+ # 
0 commit comments