@@ -348,8 +348,7 @@ function compute_spectrum(var::ClimaAnalysis.OutputVar; mass_weight = nothing)
348348
349349 FT = eltype (var. data)
350350
351- mass_weight =
352- isnothing (mass_weight) ? ones (FT, length (var. dims[dim3])) : mass_weight
351+ mass_weight = isnothing (mass_weight) ? ones (FT, length (var. dims[dim3])) : mass_weight
353352
354353 # Number of spherical wave numbers, excluding the first and the last
355354 # This number was reverse-engineered from ClimaCoreSpectra
@@ -358,18 +357,14 @@ function compute_spectrum(var::ClimaAnalysis.OutputVar; mass_weight = nothing)
358357 mesh_info = nothing
359358
360359 if ! isempty (times)
361- output_spectrum =
362- zeros ((length (times), num_output, length (var. dims[dim3])))
360+ output_spectrum = zeros ((length (times), num_output, length (var. dims[dim3])))
363361 dims = Dict (time => times)
364362 dim_attributes = Dict (time => var. dim_attributes[time])
365363 for index in 1 : length (times)
366364 spectrum_data, _wave_numbers, _spherical, mesh_info =
367365 power_spectrum_2d (FT, var. data[index, :, :, :], mass_weight)
368366 output_spectrum[index, :, :] .=
369- dropdims (sum (spectrum_data, dims = 1 ), dims = 1 )[
370- (begin + 1 ): (end - 1 ),
371- :,
372- ]
367+ dropdims (sum (spectrum_data, dims = 1 ), dims = 1 )[(begin + 1 ): (end - 1 ), :]
373368 end
374369 else
375370 dims = Dict {String, Vector{FT}} ()
@@ -378,10 +373,7 @@ function compute_spectrum(var::ClimaAnalysis.OutputVar; mass_weight = nothing)
378373 spectrum_data, _wave_numbers, _spherical, mesh_info =
379374 power_spectrum_2d (FT, var. data[:, :, :], mass_weight)
380375 output_spectrum[:, :] .=
381- dropdims (sum (spectrum_data, dims = 1 ), dims = 1 )[
382- (begin + 1 ): (end - 1 ),
383- :,
384- ]
376+ dropdims (sum (spectrum_data, dims = 1 ), dims = 1 )[(begin + 1 ): (end - 1 ), :]
385377 end
386378
387379 w_numbers = collect (1 : 1 : (mesh_info. num_spherical - 1 ))
@@ -392,19 +384,17 @@ function compute_spectrum(var::ClimaAnalysis.OutputVar; mass_weight = nothing)
392384 dim_attributes[dim3] = var. dim_attributes[dim3]
393385
394386 attributes = Dict (
395- " short_name" => " log_spectrum_" * var . attributes[ " short_name" ] ,
396- " long_name" => " Spectrum of " * var . attributes[ " long_name" ] ,
387+ " short_name" => " log_spectrum_" * short_name (var) ,
388+ " long_name" => " Spectrum of " * long_name (var) ,
397389 " units" => " " ,
398390 )
399391
400392 return ClimaAnalysis. OutputVar (
401- attributes,
402- dims,
403- dim_attributes,
404- log10 .(output_spectrum),
393+ attributes, dims, dim_attributes, log10 .(output_spectrum),
405394 )
406395end
407396
397+
408398"""
409399 map_comparison(func, simdirs, args)
410400
@@ -1287,13 +1277,15 @@ Helper function for `make_plots_generic`. Takes a list of variables and plots
12871277them on the same axis.
12881278"""
12891279function plot_les_vert_profile! (grid_loc, var_group)
1290- z = var_group[1 ]. dims[" z" ]
1291- units = var_group[1 ]. attributes[" units" ]
1280+ var1 = var_group[1 ]
1281+ units = var1. attributes[" units" ]
1282+ z = var1. dims[" z" ]
1283+ z_units = var1. dim_attributes[" z" ][" units" ]
12921284 ax = CairoMakie. Axis (
12931285 grid_loc[1 , 1 ],
1294- ylabel = " z [$(var_group[ 1 ] . dim_attributes[ " z " ][ " units " ]) ]" ,
1295- xlabel = " $(short_name (var_group[ 1 ] )) [$units ]" ,
1296- title = parse_var_attributes (var_group[ 1 ] ),
1286+ ylabel = " z [$z_units ]" ,
1287+ xlabel = " $(short_name (var1 )) [$units ]" ,
1288+ title = parse_var_attributes (var1 ),
12971289 )
12981290
12991291 for var in var_group
@@ -1315,48 +1307,41 @@ function make_plots(
13151307 " Dh_smag" , " strainh_smag" , # smag horizontal
13161308 " Dv_smag" , " strainv_smag" , # smag vertical
13171309 " edt" , # DecayWithHeight vertical diffusivity
1310+ " husra" , " hussn" , # 1M microphysics
1311+ " cdnc" , " ncra" , # 2M microphysics
13181312 ]
1319- short_names = short_names ∩ collect (keys (simdirs[1 ]. vars))
1313+ short_names_xyzt = short_names_xyzt ∩ collect (keys (simdirs[1 ]. vars))
13201314
13211315 # Window average from instantaneous snapshots?
1322- function horizontal_average (var)
1323- return average_xy (var)
1324- end
1325- function windowed_reduction (var)
1326- hours = 3600.0
1316+ function average_t_last2hrs (var)
13271317 window_end = last (var. dims[" time" ])
1328- window_start = window_end - 2 hours
1329- var_window = ClimaAnalysis. window (
1330- var, " time " ; left = window_start, right = window_end,
1318+ window_start = window_end - CA . time_to_seconds ( " 2hours" )
1319+ var_window = ClimaAnalysis. window (var, " time " ;
1320+ left = window_start, right = window_end,
13311321 )
1332- var_reduced = horizontal_average (average_time (var_window))
1333- return var_reduced
1322+ return average_xy (average_time (var_window))
13341323 end
13351324
1336- var_groups_xyt_reduced =
1337- map_comparison (simdirs, short_names) do simdir, short_name
1338- return [get (simdir; short_name, reduction) |> windowed_reduction]
1339- end
1325+ var_groups_z_avg_xyt = map_comparison (simdirs, short_names_xyzt) do simdir, short_name
1326+ return [get (simdir; short_name, reduction) |> average_t_last2hrs]
1327+ end
13401328
1341- var_groups_xy_reduced =
1342- map_comparison (simdirs, short_names) do simdir, short_name
1343- return [get (simdir; short_name, reduction) |> horizontal_average]
1344- end
1329+ var_groups_tz_avg_xy = map_comparison (simdirs, short_names_xyzt) do simdir, short_name
1330+ return [get (simdir; short_name, reduction) |> average_xy]
1331+ end
13451332
1346- tmp_file = make_plots_generic (
1347- output_paths,
1348- var_groups_xyt_reduced,
1349- output_name = " tmp" ;
1333+ tmp_file = make_plots_generic (output_paths, var_groups_z_avg_xyt;
1334+ output_name = " tmp" ,
13501335 plot_fn = plot_les_vert_profile!,
1351- MAX_NUM_COLS = 2 ,
1352- MAX_NUM_ROWS = 4 ,
1336+ MAX_NUM_COLS = 2 , MAX_NUM_ROWS = 4 ,
13531337 )
13541338
1355- make_plots_generic (
1356- output_paths,
1357- vcat (var_groups_xy_reduced... ),
1339+ summary_file = make_plots_generic (output_paths, vcat (var_groups_tz_avg_xy... );
13581340 plot_fn = plot_parsed_attribute_title!,
13591341 summary_files = [tmp_file],
1342+ MAX_NUM_COLS = 2 , MAX_NUM_ROWS = 4 ,
1343+ )
1344+
13601345 MAX_NUM_COLS = 2 ,
13611346 MAX_NUM_ROWS = 4 ,
13621347 )
0 commit comments