-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1336f65
commit b1ef4ee
Showing
5 changed files
with
81 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import ClimaDiagnostics as CD | ||
import ClimaCoupler: Interfacer | ||
import Dates | ||
|
||
""" | ||
amip_diagnostics(cs::Interfacer.CoupledSimulation) | ||
Create and return a list of default diagnostics for AMIP simulations, | ||
using ClimaDiagnostics The diagnostics are saved to NetCDF files. | ||
Currently, this just includes a diagnostic for turbulent energy fluxes. | ||
""" | ||
function amip_diagnostics(cs::Interfacer.CoupledSimulation) | ||
# Create schedules and writer | ||
schedule_everystep = CD.Schedules.EveryStepSchedule(Dates.Hour(1)) | ||
schedule_12hour = CD.Schedules.EveryCalendarDtSchedule(Dates.Hour(12)) | ||
netcdf_writer = CD.Writers.NetCDFWriter(axes(cs.fields.F_turb_energy), output_dir = cs.dirs.artifacts_dir) | ||
average = (x) -> sum(x) / length(x) | ||
|
||
# Create the diagnostic for turbulent energy fluxes | ||
F_turb_energy_diag = CD.DiagnosticVariable(; | ||
short_name = "F_turb_energy", | ||
long_name = "Turbulent energy fluxes", | ||
standard_name = "F_turb_energy", | ||
units = "W m^-2", | ||
comments = "When using partitioned surface fluxes, turbulent energy fluxes are calculated as | ||
the sum of sensible and latent heat fluxes, weighted by surface simulation area. | ||
When using combined surface fluxes, turbulent energy fluxes are calculated using | ||
the surface conditions calculated in ClimaAtmos.", | ||
compute! = (out, state, cache, time) -> begin | ||
if isnothing(out) | ||
return state.fields.F_turb_energy | ||
else | ||
out .= state.fields.F_turb_energy | ||
end | ||
end, | ||
) | ||
|
||
# Schedule the turbulent energy fluxes to save at every step, and output the average every 12 hours | ||
F_turb_energy_diag_sched = CD.ScheduledDiagnostic( | ||
F_turb_energy_diag, | ||
compute_schedule_func = schedule_everystep, | ||
output_schedule_func = schedule_12hour, | ||
output_writer = netcdf_writer, | ||
reduction_time_func = average, | ||
descriptive_short_name = "F_turb_energy_12hourly", | ||
descriptive_long_name = "Turbulent energy fluxes calculated in the coupler, averaged every 12 hours of simulation", | ||
) | ||
|
||
return [F_turb_energy_diag_sched] | ||
end | ||
|
||
""" | ||
amip_diagnostics_setup(cs::Interfacer.CoupledSimulation) | ||
Set up the default diagnostics for an AMIP simulation. Return a DiagnosticsHandler | ||
object to coordinate the diagnostics, as well as a NamedTuple containing simulation | ||
information strucuted as expected by ClimaDiagnostics. | ||
""" | ||
function amip_diagnostics_setup(cs::Interfacer.CoupledSimulation) | ||
scheduled_diags = amip_diagnostics(cs) | ||
amip_diags_handler = CD.DiagnosticsHandler(scheduled_diags, cs, nothing, cs.t) | ||
|
||
# Wrap the CoupledSimulation object in a NamedTuple to match the ClimaDiagnostics interface | ||
cs_nt = (; out = nothing, u = cs, p = nothing, t = cs.t) | ||
|
||
return amip_diags_handler, cs_nt | ||
end |
This file was deleted.
Oops, something went wrong.