Skip to content

Commit

Permalink
Merge #1313
Browse files Browse the repository at this point in the history
1313: Oh Calculus, my dear old friend. r=ilopezgp a=ilopezgp

This PR computes the average over two percentiles of a Gaussian analytically, resulting in perfect precision and a 3 order of magnitude reduction in the cost of computation versus the current method. 

This should probably be ported over ClimaAtmos as well.

Co-authored-by: ilopezgp <[email protected]>
  • Loading branch information
bors[bot] and ilopezgp authored Oct 11, 2022
2 parents 5fb0969 + 9e1bc70 commit 2bfeb1b
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 148 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TurbulenceConvection"
uuid = "8e072fc4-01f8-44fb-b9dc-f9336c367e6b"
authors = ["Climate Modeling Alliance"]
version = "1.3.2"
version = "1.3.3"

[deps]
ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884"
Expand Down
244 changes: 122 additions & 122 deletions post_processing/mse_tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,76 @@
all_best_mse = OrderedCollections.OrderedDict()
#
all_best_mse["ARM_SGP"] = OrderedCollections.OrderedDict()
all_best_mse["ARM_SGP"]["qt_mean"] = 0.25554871845679666
all_best_mse["ARM_SGP"]["updraft_area"] = 327.457628683474
all_best_mse["ARM_SGP"]["updraft_w"] = 154.41855120881237
all_best_mse["ARM_SGP"]["updraft_qt"] = 30.692228389988998
all_best_mse["ARM_SGP"]["updraft_thetal"] = 172.01239614127277
all_best_mse["ARM_SGP"]["qt_mean"] = 0.25528334093033034
all_best_mse["ARM_SGP"]["updraft_area"] = 327.37848532309175
all_best_mse["ARM_SGP"]["updraft_w"] = 154.36474347861437
all_best_mse["ARM_SGP"]["updraft_qt"] = 30.634008098522273
all_best_mse["ARM_SGP"]["updraft_thetal"] = 172.01233470959954
all_best_mse["ARM_SGP"]["u_mean"] = 1.3235797273549681e-5
all_best_mse["ARM_SGP"]["tke_mean"] = 1105.4431880317522
all_best_mse["ARM_SGP"]["temperature_mean"] = 0.00012762844224923316
all_best_mse["ARM_SGP"]["ql_mean"] = 212.62699308144104
all_best_mse["ARM_SGP"]["tke_mean"] = 1104.868595940813
all_best_mse["ARM_SGP"]["temperature_mean"] = 0.0001275543037664592
all_best_mse["ARM_SGP"]["ql_mean"] = 212.56891204136994
all_best_mse["ARM_SGP"]["qi_mean"] = "NA"
all_best_mse["ARM_SGP"]["thetal_mean"] = 0.00011942010345875462
all_best_mse["ARM_SGP"]["Hvar_mean"] = 2238.5465272126876
all_best_mse["ARM_SGP"]["QTvar_mean"] = 1363.002604703446
all_best_mse["ARM_SGP"]["thetal_mean"] = 0.00011934328696392314
all_best_mse["ARM_SGP"]["Hvar_mean"] = 1473.0456197295055
all_best_mse["ARM_SGP"]["QTvar_mean"] = 896.8491824493942
#
all_best_mse["Bomex"] = OrderedCollections.OrderedDict()
all_best_mse["Bomex"]["qt_mean"] = 0.09913609166603916
all_best_mse["Bomex"]["updraft_area"] = 127.50769391380337
all_best_mse["Bomex"]["updraft_w"] = 17.511442882350806
all_best_mse["Bomex"]["updraft_qt"] = 7.1474891453817895
all_best_mse["Bomex"]["updraft_thetal"] = 69.79502891318268
all_best_mse["Bomex"]["v_mean"] = 64.65419106975988
all_best_mse["Bomex"]["u_mean"] = 0.2644987774656898
all_best_mse["Bomex"]["tke_mean"] = 70.84054868716913
all_best_mse["Bomex"]["temperature_mean"] = 4.001263298676905e-5
all_best_mse["Bomex"]["ql_mean"] = 8.416703269186096
all_best_mse["Bomex"]["qt_mean"] = 0.09836690415657959
all_best_mse["Bomex"]["updraft_area"] = 127.51136284283429
all_best_mse["Bomex"]["updraft_w"] = 17.538215744776483
all_best_mse["Bomex"]["updraft_qt"] = 6.868360521278566
all_best_mse["Bomex"]["updraft_thetal"] = 69.79102060769345
all_best_mse["Bomex"]["v_mean"] = 64.65931673688068
all_best_mse["Bomex"]["u_mean"] = 0.26449847579905783
all_best_mse["Bomex"]["tke_mean"] = 70.8365690017622
all_best_mse["Bomex"]["temperature_mean"] = 3.9693713356706084e-5
all_best_mse["Bomex"]["ql_mean"] = 8.258554080159358
all_best_mse["Bomex"]["qi_mean"] = "NA"
all_best_mse["Bomex"]["thetal_mean"] = 4.0628428530155315e-5
all_best_mse["Bomex"]["Hvar_mean"] = 5601.260506164766
all_best_mse["Bomex"]["QTvar_mean"] = 1923.646741638184
all_best_mse["Bomex"]["thetal_mean"] = 4.0299259421866416e-5
all_best_mse["Bomex"]["Hvar_mean"] = 2206.189566891656
all_best_mse["Bomex"]["QTvar_mean"] = 809.1861697873306
#
all_best_mse["DryBubble"] = OrderedCollections.OrderedDict()
all_best_mse["DryBubble"]["updraft_area"] = 0.0
all_best_mse["DryBubble"]["updraft_w"] = 0.0
all_best_mse["DryBubble"]["updraft_thetal"] = 0.0
all_best_mse["DryBubble"]["updraft_area"] = 2.6722907697151347e-14
all_best_mse["DryBubble"]["updraft_w"] = 2.0462963653205416e-14
all_best_mse["DryBubble"]["updraft_thetal"] = 1.515894399656085e-20
all_best_mse["DryBubble"]["u_mean"] = 0.0
all_best_mse["DryBubble"]["tke_mean"] = 0.0
all_best_mse["DryBubble"]["temperature_mean"] = 0.0
all_best_mse["DryBubble"]["thetal_mean"] = 0.0
all_best_mse["DryBubble"]["Hvar_mean"] = 0.0
all_best_mse["DryBubble"]["tke_mean"] = 1.1349170640360493e-17
all_best_mse["DryBubble"]["temperature_mean"] = 3.77886777050048e-26
all_best_mse["DryBubble"]["thetal_mean"] = 2.657567978645415e-26
all_best_mse["DryBubble"]["Hvar_mean"] = 1.5192854515700307e-20
#
all_best_mse["DYCOMS_RF01"] = OrderedCollections.OrderedDict()
all_best_mse["DYCOMS_RF01"]["qt_mean"] = 0.03217501192315457
all_best_mse["DYCOMS_RF01"]["ql_mean"] = 35.34242561680415
all_best_mse["DYCOMS_RF01"]["updraft_area"] = 29.932305818012264
all_best_mse["DYCOMS_RF01"]["updraft_w"] = 6.1158261328590715
all_best_mse["DYCOMS_RF01"]["updraft_qt"] = 1.8888694230752003
all_best_mse["DYCOMS_RF01"]["updraft_thetal"] = 46.18766792687755
all_best_mse["DYCOMS_RF01"]["v_mean"] = 0.010546754053365012
all_best_mse["DYCOMS_RF01"]["u_mean"] = 0.10339082784999204
all_best_mse["DYCOMS_RF01"]["tke_mean"] = 17.21478288068383
all_best_mse["DYCOMS_RF01"]["temperature_mean"] = 9.935379312748594e-5
all_best_mse["DYCOMS_RF01"]["thetal_mean"] = 9.85575046379328e-5
all_best_mse["DYCOMS_RF01"]["Hvar_mean"] = 1280.4617529060388
all_best_mse["DYCOMS_RF01"]["QTvar_mean"] = 513.643131903757
all_best_mse["DYCOMS_RF01"]["qt_mean"] = 0.03217261911641978
all_best_mse["DYCOMS_RF01"]["ql_mean"] = 35.3382618288842
all_best_mse["DYCOMS_RF01"]["updraft_area"] = 29.92993370403924
all_best_mse["DYCOMS_RF01"]["updraft_w"] = 6.115824152470279
all_best_mse["DYCOMS_RF01"]["updraft_qt"] = 1.8888755316706864
all_best_mse["DYCOMS_RF01"]["updraft_thetal"] = 46.1876678400891
all_best_mse["DYCOMS_RF01"]["v_mean"] = 0.010544689570545858
all_best_mse["DYCOMS_RF01"]["u_mean"] = 0.10338922686505496
all_best_mse["DYCOMS_RF01"]["tke_mean"] = 17.2160644436642
all_best_mse["DYCOMS_RF01"]["temperature_mean"] = 9.935593095600486e-5
all_best_mse["DYCOMS_RF01"]["thetal_mean"] = 9.856059539479211e-5
all_best_mse["DYCOMS_RF01"]["Hvar_mean"] = 1280.461536881477
all_best_mse["DYCOMS_RF01"]["QTvar_mean"] = 513.6234151136576
#
all_best_mse["DYCOMS_RF02"] = OrderedCollections.OrderedDict()
all_best_mse["DYCOMS_RF02"]["qt_mean"] = 0.05233724294382554
all_best_mse["DYCOMS_RF02"]["ql_mean"] = 6.672851933748888
all_best_mse["DYCOMS_RF02"]["qr_mean"] = 20.28557498031968
all_best_mse["DYCOMS_RF02"]["updraft_area"] = 28.994746941439796
all_best_mse["DYCOMS_RF02"]["updraft_w"] = 9.852103127345803
all_best_mse["DYCOMS_RF02"]["updraft_qt"] = 4.690502223817181
all_best_mse["DYCOMS_RF02"]["updraft_thetal"] = 40.54538897239109
all_best_mse["DYCOMS_RF02"]["v_mean"] = 43.25757875198639
all_best_mse["DYCOMS_RF02"]["u_mean"] = 19.89543636465005
all_best_mse["DYCOMS_RF02"]["tke_mean"] = 11.964883637830626
all_best_mse["DYCOMS_RF02"]["temperature_mean"] = 2.2644791037361257e-5
all_best_mse["DYCOMS_RF02"]["thetal_mean"] = 1.8168568248828773e-5
all_best_mse["DYCOMS_RF02"]["Hvar_mean"] = 1190.6762793971188
all_best_mse["DYCOMS_RF02"]["QTvar_mean"] = 266.2926925739899
all_best_mse["DYCOMS_RF02"]["qt_mean"] = 0.05262315718787448
all_best_mse["DYCOMS_RF02"]["ql_mean"] = 6.791914738991459
all_best_mse["DYCOMS_RF02"]["qr_mean"] = 20.350089198234606
all_best_mse["DYCOMS_RF02"]["updraft_area"] = 28.89889324530766
all_best_mse["DYCOMS_RF02"]["updraft_w"] = 9.600287183180514
all_best_mse["DYCOMS_RF02"]["updraft_qt"] = 4.686512194787529
all_best_mse["DYCOMS_RF02"]["updraft_thetal"] = 40.54539237716875
all_best_mse["DYCOMS_RF02"]["v_mean"] = 43.2901473334659
all_best_mse["DYCOMS_RF02"]["u_mean"] = 19.892448660537866
all_best_mse["DYCOMS_RF02"]["tke_mean"] = 12.198816725835407
all_best_mse["DYCOMS_RF02"]["temperature_mean"] = 2.2527180527716307e-5
all_best_mse["DYCOMS_RF02"]["thetal_mean"] = 1.8033317445041802e-5
all_best_mse["DYCOMS_RF02"]["Hvar_mean"] = 1203.2640339605143
all_best_mse["DYCOMS_RF02"]["QTvar_mean"] = 277.3641069084317
#
all_best_mse["GABLS"] = OrderedCollections.OrderedDict()
all_best_mse["GABLS"]["updraft_thetal"] = 0.0
Expand All @@ -86,84 +86,84 @@ all_best_mse["GABLS"]["thetal_mean"] = 0.0
all_best_mse["GABLS"]["Hvar_mean"] = 0.0
#
all_best_mse["life_cycle_Tan2018"] = OrderedCollections.OrderedDict()
all_best_mse["life_cycle_Tan2018"]["qt_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["ql_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["updraft_area"] = 0.0
all_best_mse["life_cycle_Tan2018"]["updraft_w"] = 0.0
all_best_mse["life_cycle_Tan2018"]["updraft_qt"] = 0.0
all_best_mse["life_cycle_Tan2018"]["updraft_thetal"] = 0.0
all_best_mse["life_cycle_Tan2018"]["v_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["u_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["tke_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["temperature_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["thetal_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["Hvar_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["QTvar_mean"] = 0.0
all_best_mse["life_cycle_Tan2018"]["qt_mean"] = 3.8855890225727195e-6
all_best_mse["life_cycle_Tan2018"]["ql_mean"] = 0.005307514569472877
all_best_mse["life_cycle_Tan2018"]["updraft_area"] = 0.05980924507437552
all_best_mse["life_cycle_Tan2018"]["updraft_w"] = 0.011927673685734774
all_best_mse["life_cycle_Tan2018"]["updraft_qt"] = 6.382856250894262e-5
all_best_mse["life_cycle_Tan2018"]["updraft_thetal"] = 3.765707374577787e-8
all_best_mse["life_cycle_Tan2018"]["v_mean"] = 0.0030158800941392414
all_best_mse["life_cycle_Tan2018"]["u_mean"] = 4.601146770321818e-6
all_best_mse["life_cycle_Tan2018"]["tke_mean"] = 0.0012677750382851774
all_best_mse["life_cycle_Tan2018"]["temperature_mean"] = 1.1286359385931025e-9
all_best_mse["life_cycle_Tan2018"]["thetal_mean"] = 1.0938449208615709e-9
all_best_mse["life_cycle_Tan2018"]["Hvar_mean"] = 0.01025554419135785
all_best_mse["life_cycle_Tan2018"]["QTvar_mean"] = 0.011027178922698957
#
all_best_mse["Nieuwstadt"] = OrderedCollections.OrderedDict()
all_best_mse["Nieuwstadt"]["updraft_area"] = 98.81780389862554
all_best_mse["Nieuwstadt"]["updraft_w"] = 14.180582190454246
all_best_mse["Nieuwstadt"]["updraft_thetal"] = 117.60593052678261
all_best_mse["Nieuwstadt"]["u_mean"] = 13.555461549607154
all_best_mse["Nieuwstadt"]["tke_mean"] = 283.69553457951224
all_best_mse["Nieuwstadt"]["temperature_mean"] = 1.1367027379596748e-5
all_best_mse["Nieuwstadt"]["thetal_mean"] = 1.1155080618067573e-5
all_best_mse["Nieuwstadt"]["Hvar_mean"] = 717.6274568573217
all_best_mse["Nieuwstadt"]["updraft_area"] = 98.82439041981868
all_best_mse["Nieuwstadt"]["updraft_w"] = 14.18454981578538
all_best_mse["Nieuwstadt"]["updraft_thetal"] = 117.60593879768855
all_best_mse["Nieuwstadt"]["u_mean"] = 13.55551239626024
all_best_mse["Nieuwstadt"]["tke_mean"] = 283.63802716876
all_best_mse["Nieuwstadt"]["temperature_mean"] = 1.1368165684996336e-5
all_best_mse["Nieuwstadt"]["thetal_mean"] = 1.1156242824969201e-5
all_best_mse["Nieuwstadt"]["Hvar_mean"] = 718.0134424722411
#
all_best_mse["Rico"] = OrderedCollections.OrderedDict()
all_best_mse["Rico"]["qt_mean"] = 0.9867664190435843
all_best_mse["Rico"]["updraft_area"] = 477.98630005977486
all_best_mse["Rico"]["updraft_w"] = 78.19087384616584
all_best_mse["Rico"]["updraft_qt"] = 16.515209920100048
all_best_mse["Rico"]["updraft_thetal"] = 133.8725127835345
all_best_mse["Rico"]["v_mean"] = 0.5060012602557308
all_best_mse["Rico"]["u_mean"] = 0.4160322376506551
all_best_mse["Rico"]["tke_mean"] = 152.74397483604042
all_best_mse["Rico"]["temperature_mean"] = 0.0005226496891240316
all_best_mse["Rico"]["ql_mean"] = 6900.972756738989
all_best_mse["Rico"]["qt_mean"] = 0.9981879752220322
all_best_mse["Rico"]["updraft_area"] = 477.98314777307013
all_best_mse["Rico"]["updraft_w"] = 78.0495408629482
all_best_mse["Rico"]["updraft_qt"] = 16.420011232677655
all_best_mse["Rico"]["updraft_thetal"] = 133.8723534959998
all_best_mse["Rico"]["v_mean"] = 0.5067801936296004
all_best_mse["Rico"]["u_mean"] = 0.4163101870820697
all_best_mse["Rico"]["tke_mean"] = 152.7843514923918
all_best_mse["Rico"]["temperature_mean"] = 0.0005261381719374213
all_best_mse["Rico"]["ql_mean"] = 6881.495567919092
all_best_mse["Rico"]["qi_mean"] = "NA"
all_best_mse["Rico"]["qr_mean"] = 676.0253601833097
all_best_mse["Rico"]["thetal_mean"] = 0.0005227707740857464
all_best_mse["Rico"]["Hvar_mean"] = 47442.89262507444
all_best_mse["Rico"]["QTvar_mean"] = 10375.96065338343
all_best_mse["Rico"]["qr_mean"] = 676.3672038183391
all_best_mse["Rico"]["thetal_mean"] = 0.0005265627993092757
all_best_mse["Rico"]["Hvar_mean"] = 40634.86414473777
all_best_mse["Rico"]["QTvar_mean"] = 8972.865628810741
#
all_best_mse["Soares"] = OrderedCollections.OrderedDict()
all_best_mse["Soares"]["qt_mean"] = 0.14275826970408298
all_best_mse["Soares"]["updraft_area"] = 94.43400003039118
all_best_mse["Soares"]["updraft_w"] = 13.054997079984211
all_best_mse["Soares"]["updraft_qt"] = 23.63624216787402
all_best_mse["Soares"]["updraft_thetal"] = 65.72137749086569
all_best_mse["Soares"]["u_mean"] = 93.90570644417569
all_best_mse["Soares"]["tke_mean"] = 216.52658636812856
all_best_mse["Soares"]["temperature_mean"] = 1.3142927357827632e-5
all_best_mse["Soares"]["thetal_mean"] = 1.2067355595352583e-5
all_best_mse["Soares"]["Hvar_mean"] = 680.4262158563345
all_best_mse["Soares"]["qt_mean"] = 0.1427062125259489
all_best_mse["Soares"]["updraft_area"] = 94.41177778401888
all_best_mse["Soares"]["updraft_w"] = 13.05560985339973
all_best_mse["Soares"]["updraft_qt"] = 23.63881697052191
all_best_mse["Soares"]["updraft_thetal"] = 65.72137531939822
all_best_mse["Soares"]["u_mean"] = 93.90586019160715
all_best_mse["Soares"]["tke_mean"] = 216.5362996416272
all_best_mse["Soares"]["temperature_mean"] = 1.3143584648064229e-5
all_best_mse["Soares"]["thetal_mean"] = 1.206775101190889e-5
all_best_mse["Soares"]["Hvar_mean"] = 679.3803307920076
#
all_best_mse["TRMM_LBA"] = OrderedCollections.OrderedDict()
all_best_mse["TRMM_LBA"]["qt_mean"] = 2.1394782254214375
all_best_mse["TRMM_LBA"]["updraft_area"] = 1254.5677080494615
all_best_mse["TRMM_LBA"]["updraft_w"] = 9846.018165797323
all_best_mse["TRMM_LBA"]["updraft_qt"] = 263.76122673093846
all_best_mse["TRMM_LBA"]["updraft_thetal"] = 541.371613891133
all_best_mse["TRMM_LBA"]["v_mean"] = 71.07842418721964
all_best_mse["TRMM_LBA"]["u_mean"] = 30.39976756593095
all_best_mse["TRMM_LBA"]["tke_mean"] = 48605.6178180104
all_best_mse["TRMM_LBA"]["temperature_mean"] = 0.0005688531926823969
all_best_mse["TRMM_LBA"]["ql_mean"] = 247798.53914543334
all_best_mse["TRMM_LBA"]["qt_mean"] = 2.139211837624864
all_best_mse["TRMM_LBA"]["updraft_area"] = 1254.4455442791025
all_best_mse["TRMM_LBA"]["updraft_w"] = 9850.531207430944
all_best_mse["TRMM_LBA"]["updraft_qt"] = 263.81382172422684
all_best_mse["TRMM_LBA"]["updraft_thetal"] = 541.3754816948107
all_best_mse["TRMM_LBA"]["v_mean"] = 71.05805459105811
all_best_mse["TRMM_LBA"]["u_mean"] = 30.401967906463575
all_best_mse["TRMM_LBA"]["tke_mean"] = 48583.158778546356
all_best_mse["TRMM_LBA"]["temperature_mean"] = 0.0005679824019016333
all_best_mse["TRMM_LBA"]["ql_mean"] = 247546.07466905675
all_best_mse["TRMM_LBA"]["qi_mean"] = "NA"
all_best_mse["TRMM_LBA"]["qr_mean"] = "NA"
all_best_mse["TRMM_LBA"]["qs_mean"] = "NA"
all_best_mse["TRMM_LBA"]["thetal_mean"] = 0.0005008248757596867
all_best_mse["TRMM_LBA"]["Hvar_mean"] = 444931.6237907534
all_best_mse["TRMM_LBA"]["QTvar_mean"] = 6244.828727237164
all_best_mse["TRMM_LBA"]["thetal_mean"] = 0.0005002495277664155
all_best_mse["TRMM_LBA"]["Hvar_mean"] = 445363.5843574879
all_best_mse["TRMM_LBA"]["QTvar_mean"] = 6255.4171585017775
#
all_best_mse["LES_driven_SCM"] = OrderedCollections.OrderedDict()
all_best_mse["LES_driven_SCM"]["qt_mean"] = 3.0715485278478605
all_best_mse["LES_driven_SCM"]["v_mean"] = 0.6352636711890354
all_best_mse["LES_driven_SCM"]["u_mean"] = 0.1931300463888762
all_best_mse["LES_driven_SCM"]["temperature_mean"] = 0.0011957836462326932
all_best_mse["LES_driven_SCM"]["ql_mean"] = 7086.824440772947
all_best_mse["LES_driven_SCM"]["thetal_mean"] = 0.0013376413773120888
all_best_mse["LES_driven_SCM"]["qt_mean"] = 3.072654096054988
all_best_mse["LES_driven_SCM"]["v_mean"] = 0.6351380757470575
all_best_mse["LES_driven_SCM"]["u_mean"] = 0.1930744081565489
all_best_mse["LES_driven_SCM"]["temperature_mean"] = 0.0011960441821019143
all_best_mse["LES_driven_SCM"]["ql_mean"] = 7118.094566898472
all_best_mse["LES_driven_SCM"]["thetal_mean"] = 0.0013379568867523625
#
#################################
#################################
Expand Down
8 changes: 2 additions & 6 deletions src/EDMF_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,11 @@ function θ_surface_bc(surf::SurfaceBase{FT}, grid::Grid, state::State, edmf::ED
UnPack.@unpack ustar, zLL, oblength, ρLL = surface_helper(surf, grid, state)

surf.bflux > 0 || return FT(0)
set_src_seed = edmf.set_src_seed
a_total = edmf.surface_area
a_ = area_surface_bc(surf, edmf, i)
ρθ_liq_ice_flux = surf.ρθ_liq_ice_flux # assuming no ql,qi flux
h_var = get_surface_variance(ρθ_liq_ice_flux / ρLL, ρθ_liq_ice_flux / ρLL, ustar, zLL, oblength)
surface_scalar_coeff =
percentile_bounds_mean_norm(1 - a_total + (i - 1) * a_, 1 - a_total + i * a_, 1000, set_src_seed)
surface_scalar_coeff = percentile_bounds_mean_norm(1 - a_total + (i - 1) * a_, 1 - a_total + i * a_)
return aux_gm.θ_liq_ice[kc_surf] + surface_scalar_coeff * sqrt(h_var)
end
function q_surface_bc(surf::SurfaceBase{FT}, grid::Grid, state::State, edmf::EDMFModel, i::Int)::FT where {FT}
Expand All @@ -373,13 +371,11 @@ function q_surface_bc(surf::SurfaceBase{FT}, grid::Grid, state::State, edmf::EDM
kc_surf = kc_surface(grid)
surf.bflux > 0 || return aux_gm.q_tot[kc_surf]
a_total = edmf.surface_area
set_src_seed = edmf.set_src_seed
a_ = area_surface_bc(surf, edmf, i)
UnPack.@unpack ustar, zLL, oblength, ρLL = surface_helper(surf, grid, state)
ρq_tot_flux = surf.ρq_tot_flux
qt_var = get_surface_variance(ρq_tot_flux / ρLL, ρq_tot_flux / ρLL, ustar, zLL, oblength)
surface_scalar_coeff =
percentile_bounds_mean_norm(1 - a_total + (i - 1) * a_, 1 - a_total + i * a_, 1000, set_src_seed)
surface_scalar_coeff = percentile_bounds_mean_norm(1 - a_total + (i - 1) * a_, 1 - a_total + i * a_)
return aux_gm.q_tot[kc_surf] + surface_scalar_coeff * sqrt(qt_var)
end
function ql_surface_bc(surf::SurfaceBase{FT})::FT where {FT}
Expand Down
23 changes: 4 additions & 19 deletions src/utility_functions.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
# compute the mean of the values between two percentiles (0 to 1) for a standard normal distribution
# this gives the surface scalar coefficients for 1 to n-1 updrafts when using n updrafts
function percentile_bounds_mean_norm(
low_percentile::FT,
high_percentile::FT,
n_samples::Int,
set_src_seed,
) where {FT <: Real}
"""Compute average between two percentiles of a standard Gaussian"""
function percentile_bounds_mean_norm(low_percentile::FT, high_percentile::FT) where {FT <: Real}
D = Distributions
set_src_seed && Random.seed!(123)
∑samples = zero(FT)
gauss_int(x) = -exp(-x * x / 2) / sqrt(2 * pi)
xp_low = D.quantile(D.Normal(), low_percentile)
xp_high = D.quantile(D.Normal(), high_percentile)
n_filtered_samples = 0
@inbounds for i in 1:n_samples
x = rand(D.Normal())
if xp_low < x < xp_high
∑samples += x
n_filtered_samples += 1
end
end
return ∑samples / n_filtered_samples
return (gauss_int(xp_high) - gauss_int(xp_low)) / (D.cdf(D.Normal(), xp_high) - D.cdf(D.Normal(), xp_low))
end

function logistic(x, slope, mid)
Expand Down

2 comments on commit 2bfeb1b

@ilopezgp
Copy link
Contributor

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/69975

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.3.3 -m "<description of version>" 2bfeb1b543acf6271a00348ba50e0f21456d9306
git push origin v1.3.3

Please sign in to comment.