@@ -14,31 +14,36 @@ import ClimaLand.Parameters as LP
14
14
using CairoMakie
15
15
import GeoMakie
16
16
using Dates
17
+ using Statistics
17
18
18
19
root_path = joinpath (pwd (), " snowy_land_longrun_gpu" )
19
20
! isdir (root_path) && mkdir (root_path)
20
21
# outdir = "snowy_land_longrun_gpu/output_active" # on local
21
22
# Set outdir to wherever diagnostics are saved
22
- outdir = " snowy_land_longrun_gpu-3720-a_larger2_ksat_alpha/output_active" # on local
23
+ # outdir = "snowy_land_longrun_gpu-3720-a_larger2_ksat_alpha/output_active" # on local
24
+ # outdir = "snowy_land_longrun_gpu-3761-alpha1/output_active" # on local
25
+ # outdir = "snowy_land_longrun_gpu-3771-new_default/output_active"
26
+ # outdir = "snowy_land_longrun_gpu-3761-new_default/output_active" # on local
27
+ outdir = " snowy_land_longrun_gpu-3777-alpha2/output_active" # on local
23
28
root_path = outdir
24
29
25
- short_names = [" lhf" , " shf" , " lwu" , " swu" ]
30
+ short_names = [" lhf" , " shf" , " lwu" , " swu" , " lwn " , " swn " ]
26
31
title_stubs = Dict (
27
32
" lhf" => " Latent heat flux" ,
28
33
" shf" => " Sensible heat flux" ,
29
34
" lwu" => " Upward longwave radiation" ,
30
35
" swu" => " Upward shortwave radiation" ,
36
+ " lwn" => " Net longwave radiation" ,
37
+ " swn" => " Net shortwave radiation" ,
31
38
)
32
39
# Define levels for contour colorbars
33
40
levels_dict = Dict (
34
- " lhf" => collect (0 : 5 : 40 ),
35
41
" lhf_bias" => collect (- 50 : 10 : 30 ),
36
- " shf" => collect (- 50 : 10 : 100 ),
37
42
" shf_bias" => collect (- 30 : 10 : 50 ),
38
- " lwu " => collect (500 : 10 : 600 ),
39
- " lwu_bias " => collect (- 40 : 5 : 5 ),
40
- " swu " => collect (0 : 2 : 15 ),
41
- " swu_bias " => collect (- 5 : 5 : 40 ),
43
+ " lwu_bias " => collect (- 40 : 5 : 20 ),
44
+ " swu_bias " => collect (- 20 : 5 : 40 ),
45
+ " lwn_bias " => collect (- 40 : 5 : 40 ),
46
+ " swn_bias " => collect (- 40 : 5 : 40 ),
42
47
)
43
48
44
49
include (" data_paper_plots.jl" )
@@ -50,7 +55,7 @@ function compute_global_average(masked_var)
50
55
land_data = ClimaAnalysis. apply_oceanmask (masked_var). data
51
56
lat_data = masked_var. dims[latitude_name]
52
57
mask = .~ isnan .(land_data)
53
- nlon = length (masked_var. dims[lon_name])
58
+ nlon = length (masked_var. dims[lon_name])µ
54
59
resized_lat_data = transpose (repeat (lat_data, 1 , nlon))
55
60
56
61
return sum (land_data[mask] .* cosd .(resized_lat_data[mask])) /
@@ -96,12 +101,12 @@ function make_paper_figures(
96
101
for i in 1 : 12
97
102
sim_slice_args =
98
103
ClimaAnalysis. has_altitude (sim_var) ?
99
- Dict (:z => 1 , :time => sim_var_times[i + 12 ]) :
100
- Dict (:time => sim_var_times[i + 12 ]) # if has altitude, take first layer
104
+ Dict (:z => 1 , :time => sim_var_times[i]) :
105
+ Dict (:time => sim_var_times[i]) # if has altitude, take first layer
101
106
obs_slice_args =
102
107
ClimaAnalysis. has_altitude (sim_var) ?
103
108
Dict (:z => 1 , :time => sim_var_times[i]) :
104
- Dict (:time => sim_var_times[i + 12 ]) # if has altitude, take first layer
109
+ Dict (:time => sim_var_times[i]) # if has altitude, take first layer
105
110
106
111
sim_var_sliced = ClimaAnalysis. slice (sim_var; sim_slice_args... )
107
112
sim_var_masked = ClimaAnalysis. apply_oceanmask (sim_var_sliced)
@@ -112,7 +117,7 @@ function make_paper_figures(
112
117
obs_var_global_average[i] = compute_global_average (obs_var_masked)
113
118
end
114
119
115
- i = 2 # use second year of simulation
120
+ i = 1 # use first year of simulation
116
121
kwarg_z = ClimaAnalysis. has_altitude (sim_var) ? Dict (:z => 1 ) : Dict () # if has altitude, take first layer
117
122
sim_var_sliced = ClimaAnalysis. slice (sim_var; kwarg_z... )
118
123
sim_var_window = ClimaAnalysis. window (
@@ -144,14 +149,30 @@ function make_paper_figures(
144
149
t = sim_var_times[1 ]
145
150
146
151
# Get colorbar limits to share between heatmaps
147
- # sim_var_no_nans = deepcopy(sim_var_annual_average.data)
148
- # sim_var_no_nans[isnan.(sim_var_no_nans)] .= 0 # TODO this is a hacky way to remove NaNs in data
152
+ sim_var_no_nans = deepcopy (sim_var_annual_average. data)
153
+ sim_var_no_nans[isnan .(sim_var_no_nans)] .= 0 # TODO this is a hacky way to remove NaNs in data
149
154
# sim_extrema = extrema(sim_var_no_nans)
150
155
# obs_extrema = extrema(obs_var_annual_average.data)
151
- # we MUST pass the same clims to the sim plot, obs plot, AND colorbars
152
- levels = levels_dict[short_name]
156
+
157
+ combined_data =
158
+ vcat (vec (sim_var_no_nans), vec (obs_var_annual_average. data))
159
+ min = Int (round (quantile (combined_data, 0.05 ); digits = - 1 ))
160
+ max = Int (round (quantile (combined_data, 0.95 ); digits = - 1 ))
161
+ diff = max - min
162
+ step_size = diff < 150 ? 10 : 40
163
+
164
+ # Increase max to be a multiple of step_size
165
+ max =
166
+ (diff % step_size != 0 ) ? max + step_size - (diff % step_size) : max
167
+ clims = (min, max)
168
+ levels = collect (min: step_size: max)
153
169
nlevels = length (levels)
154
- clims = (levels[1 ], levels[end ])
170
+
171
+ # extrema = (min(sim_extrema[1], obs_extrema[1]), max(sim_extrema[2], obs_extrema[2]))
172
+ # we MUST pass the same clims to the sim plot, obs plot, AND colorbars
173
+ # levels = levels_dict[short_name]
174
+ # nlevels = length(levels)
175
+ # clims = (levels[1], levels[end])
155
176
156
177
# make colorbar tick labels
157
178
ticklabels = map (x -> string (x), levels)# ; digits = digits_to_round)), levels)
@@ -210,7 +231,7 @@ function make_paper_figures(
210
231
rev = false ,
211
232
)
212
233
colors = colormap. colors. colors
213
- viz. contour2D_on_globe! (
234
+ contour = viz. contour2D_on_globe! (
214
235
fig,
215
236
sim_var_annual_average,
216
237
# ylabel = "$(sim_var.attributes["long_name"]) $units_label", # plot variable label on y-axis for leftmost column (sim)
@@ -223,7 +244,9 @@ function make_paper_figures(
223
244
rasterize = true ,
224
245
# colorrange = clims,
225
246
colormap = colormap,
226
- # levels = levels,
247
+ levels = levels,
248
+ extendhigh = :auto ,
249
+ extendlow = :auto ,
227
250
),
228
251
:axis => ClimaAnalysis. Utils. kwargs (
229
252
title = sim_title,
@@ -235,6 +258,7 @@ function make_paper_figures(
235
258
ylabel = " $(sim_var. attributes[" long_name" ]) $units_label " , # plot variable label on y-axis for leftmost column (sim)
236
259
ylabelpadding = - 5 ,
237
260
ylabelvisible = true ,
261
+ # limits = clims,
238
262
),
239
263
),
240
264
)
@@ -318,7 +342,9 @@ function make_paper_figures(
318
342
rasterize = true ,
319
343
# colorrange = clims,
320
344
colormap = colormap,
321
- # levels = levels,
345
+ levels = levels,
346
+ extendhigh = :auto ,
347
+ extendlow = :auto ,
322
348
),
323
349
:axis => ClimaAnalysis. Utils. kwargs (
324
350
title = obs_title,
@@ -486,7 +512,7 @@ function make_paper_figures(
486
512
end
487
513
save_name = joinpath (root_path, " combined_figures.pdf" )
488
514
save_name =
489
- plot_bias ? joinpath (root_path, " combined_figures_bias_contour-clims .pdf" ) : save_name
515
+ plot_bias ? joinpath (root_path, " combined_figures_bias .pdf" ) : save_name
490
516
save_name =
491
517
plot_seasonal ? joinpath (root_path, " combined_figures_seasonal.pdf" ) :
492
518
save_name
0 commit comments