From 9ef2d1a237de3204c7e2ce6fb84a84fc75854edd Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 9 Dec 2022 15:27:05 +0100 Subject: [PATCH 01/51] multiply by rhod for refined arrays --- UWLCM_plotters/include/Plotter3d.hpp | 25 ++++++-- UWLCM_plotters/include/PlotterCommon.hpp | 7 +++ UWLCM_plotters/include/PlotterMicro.hpp | 20 +++++++ drawbicyc/include/plot_series.hpp | 72 ++++++++++++------------ 4 files changed, 83 insertions(+), 41 deletions(-) diff --git a/UWLCM_plotters/include/Plotter3d.hpp b/UWLCM_plotters/include/Plotter3d.hpp index 9d80fed..d481604 100644 --- a/UWLCM_plotters/include/Plotter3d.hpp +++ b/UWLCM_plotters/include/Plotter3d.hpp @@ -18,7 +18,7 @@ class Plotter_t<3> : public PlotterCommon using parent_t = PlotterCommon; hsize_t n[3]; enum {x, y, z}; - arr_t tmp, tmp_srfc; + arr_t tmp, tmp_srfc, tmp_ref; blitz::Range yrange; public: @@ -36,15 +36,17 @@ class Plotter_t<3> : public PlotterCommon cnt[3] = { n[x], n[y], srfc ? 1 : n[z] }, off[3] = { 0, 0, 0 }; this->h5s.selectHyperslab( H5S_SELECT_SET, cnt, off); + + arr_t &arr(tmp.extent(0) == n[x] ? tmp : tmp_ref); // crude check if it is refined or normal data; assume surface data is never refined hsize_t ext[3] = { - hsize_t(tmp.extent(0)), - hsize_t(tmp.extent(1)), - hsize_t(srfc ? tmp_srfc.extent(2) : tmp.extent(2)) + hsize_t(arr.extent(0)), + hsize_t(arr.extent(1)), + hsize_t(srfc ? tmp_srfc.extent(2) : arr.extent(2)) }; - this->h5d.read(srfc ? tmp_srfc.data() : tmp.data(), H5::PredType::NATIVE_FLOAT, H5::DataSpace(3, ext), h5s); + this->h5d.read(srfc ? tmp_srfc.data() : arr.data(), H5::PredType::NATIVE_FLOAT, H5::DataSpace(3, ext), h5s); - return blitz::safeToReturn((srfc ? tmp_srfc : tmp) + 0); + return blitz::safeToReturn((srfc ? tmp_srfc : arr) + 0); } auto h5load_timestep( @@ -235,6 +237,17 @@ class Plotter_t<3> : public PlotterCommon // other dataset are of the size x*z, resize tmp tmp.resize(n[0]-1, n[1]-1, n[2]-1); tmp_srfc.resize(n[0]-1, n[1]-1, 1); + + // init refined data + h5load(file + "/const.h5", "X refined"); + this->map["dx refined"] = tmp(1,0,0) - tmp(0,0,0); + h5load(file + "/const.h5", "Y refined"); + this->map["dy refined"] = tmp(0,1,0) - tmp(0,0,0); + h5load(file + "/const.h5", "Z refined"); + this->map["dz refined"] = tmp(0,0,1) - tmp(0,0,0); + this->CellVol_ref = this->map["dx refined"] * this->map["dy refined"] * this->map["dz refined"]; + this->h5f.openDataSet("X refined").getSpace().getSimpleExtentDims(n, NULL); + tmp_ref.resize(n[0]-1, n[1]-1, n[2]-1); } }; diff --git a/UWLCM_plotters/include/PlotterCommon.hpp b/UWLCM_plotters/include/PlotterCommon.hpp index 1c75c83..29dfd2c 100644 --- a/UWLCM_plotters/include/PlotterCommon.hpp +++ b/UWLCM_plotters/include/PlotterCommon.hpp @@ -93,6 +93,7 @@ class PlotterCommon map["dt"] = h5load_attr(file + "/const.h5", "dt", "advection"); map["outfreq"] = h5load_attr(file + "/const.h5", "outfreq", "user_params"); map["MPI_compiler"] = h5load_attr(file + "/const.h5", "MPI compiler (true/false)", "MPI details"); + map["n_fra_iter"] = h5load_attr(file + "/const.h5", "n_fra_iter", "fractal"); // read number of timesteps hsize_t n; @@ -120,6 +121,12 @@ class PlotterCommon h5s.getSimpleExtentDims(&n, NULL); map_prof.emplace("rhod", arr_prof_t(n)); h5d.read(map_prof["rhod"].data(), H5::PredType::NATIVE_FLOAT); + + // read dry air density profile on refined grid + h5load(file + "/const.h5", "refined rhod"); + h5s.getSimpleExtentDims(&n, NULL); + map_prof.emplace("refined rhod", arr_prof_t(n)); + h5d.read(map_prof["refined rhod"].data(), H5::PredType::NATIVE_FLOAT); } } }; diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index 1945a10..e920d81 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -20,6 +20,26 @@ class PlotterMicro_t : public Plotter_t const double L_evap = 2264.76e3; // latent heat of evaporation [J/kg] public: + void multiply_by_rhod(arr_t &arr) + { + if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) + arr *= this->map_prof["rhod"](this->LastIndex); + else if(arr.extent(NDims-1) == this->map_prof["rhod refined"].extent(0)) + arr *= this->map_prof["rhod refined"](this->LastIndex); + else + throw std::runtime_error("multiply_by_rhod: input array is neither normal grid size nor refined grid size"); + } + + void multiply_by_CellVol(arr_t &arr) + { + if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) + arr *= this->CellVol; + else if(arr.extent(NDims-1) == this->map_prof["rhod refined"].extent(0)) + arr *= this->CellVol_ref; + else + throw std::runtime_error("multiply_by_CellVol: input array is neither normal grid size nor refined grid size"); + } + // functions for diagnosing fields // // aerosol droplets mixing ratio diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index 24d3f31..2577dc3 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -129,7 +129,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]) * 1e3; //g/kg typename Plotter_t::arr_t snap(tmp); snap += plotter.h5load_rr_timestep(at * n["outfreq"]) * 1e3; //g/kg - snap *= rhod; // water per cubic metre (should be wet density...) + plotter.multiply_by_rhod(snap); plotter.k_i = blitz::sum(snap, plotter.LastIndex) * n["dz"]; // LWP [g/m2] in the column plotter.k_i = where(plotter.k_i > 20 , 1 , 0); // cloudiness as in Ackermann et al. res_series[plt](at) = blitz::mean(plotter.k_i); @@ -224,19 +224,19 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { auto tmp = plotter.h5load_timestep("cloud_rw_mom3", at * n["outfreq"]) * 4./3. * 3.1416 * 1e3; typename Plotter_t::arr_t snap(tmp); - snap *= rhod; + plotter.multiply_by_rhod(snap); res_series[plt](at) += blitz::mean(snap); } { auto tmp = plotter.h5load_timestep("rain_rw_mom3", at * n["outfreq"]) * 4./3. * 3.1416 * 1e3; typename Plotter_t::arr_t snap(tmp); - snap *= rhod; + plotter.multiply_by_rhod(snap); res_series[plt](at) += blitz::mean(snap); } { auto tmp = plotter.h5load_timestep("rv", at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); - snap *= rhod; + plotter.multiply_by_rhod(snap); res_series[plt](at) += blitz::mean(snap); } } @@ -321,7 +321,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) auto tmp2 = plotter.h5load_timestep("actrw_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap_mom(tmp2); com_N_c(at) = snap_mom(com_x_idx(at), com_z_idx(at)); // 0th raw moment / mass [1/kg] - snap_mom *= rhod; // now per m^3 + plotter.multiply_by_rhod(snap); res_series[plt](at) = snap_mom(com_x_idx(at), com_z_idx(at)); } else @@ -436,7 +436,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap /= 1e6; // per cm^3 - snap *= rhod; // b4 it was per milligram + plotter.multiply_by_rhod(snap); res_series[plt](at) = blitz::mean(snap); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -449,7 +449,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) auto tmp = plotter.h5load_timestep("all_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap /= 1e6; // per cm^3 - snap *= rhod; // b4 it was per milligram + plotter.multiply_by_rhod(snap); res_series[plt](at) = blitz::mean(snap); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -462,7 +462,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) auto tmp = plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap /= 1e6; // per cm^3 - snap *= rhod; // b4 it was per milligram + plotter.multiply_by_rhod(snap); res_series[plt](at) = blitz::mean(snap); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -475,7 +475,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // cloud fraction (cloudy if N_c > 20/cm^3) auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 typename Plotter_t::arr_t snap2; snap2.resize(snap.shape()); @@ -501,7 +501,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux typename Plotter_t::arr_t snap2(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - snap2 *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; @@ -520,12 +520,12 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // cloud fraction (cloudy if N_c > 20/cm^3) auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask auto tmp2 = plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap2(tmp2); - snap2 *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; if(blitz::sum(snap) > 0) @@ -548,7 +548,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) auto tmp2 = plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap2(tmp2); - snap2 *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; @@ -567,7 +567,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // cloud fraction (cloudy if N_c > 20/cm^3) auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux @@ -592,7 +592,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // cloud fraction (cloudy if N_c > 20/cm^3) auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux @@ -691,7 +691,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { auto tmp = plotter.h5load_timestep("rd_rng000_mom3", at * n["outfreq"]) * 4./3. * 3.14 * rho_dry * 1e3; typename Plotter_t::arr_t snap(tmp); - snap *= rhod * plotter.CellVol; // turn mixing ratio in g/kg to total mass in g + plotter.multiply_by_rhod(snap); + plotter.multiply_by_CellVol(snap); res_series[plt](at) = blitz::sum(snap); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -724,7 +725,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { // cloud fraction (cloudy if N_c > 20/cm^3) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask @@ -750,7 +751,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { // cloud fraction (cloudy if N_c > 20/cm^3) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask @@ -823,7 +824,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]) * 1e3; //g/kg typename Plotter_t::arr_t snap(tmp); snap += plotter.h5load_rr_timestep(at * n["outfreq"]) * 1e3; //g/kg - snap *= rhod; // water per cubic metre (should be wet density...) + plotter.multiply_by_rhod(snap); res_series[plt](at) = blitz::mean(snap); } } @@ -836,7 +837,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { { typename Plotter_t::arr_t snap(plotter.h5load_rr_timestep(at * n["outfreq"])); - snap *= rhod * 1e3; // water per cubic metre (should be wet density...) & g/kg + snap *= 1e3; + plotter.multiply_by_rhod(snap); res_series[plt](at) = blitz::mean(snap); } } @@ -1069,11 +1071,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { // cloud fraction (cloudy if N_c > 20/cm^3) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask typename Plotter_t::arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); - snap2 *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; if(blitz::sum(snap) > 0) @@ -1090,11 +1092,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { // cloud fraction (cloudy if N_c > 20/cm^3) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask typename Plotter_t::arr_t snap2(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); - snap2 *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; if(blitz::sum(snap) > 0) @@ -1110,7 +1112,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { // cloud fraction (cloudy if N_c > 20/cm^3) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask typename Plotter_t::arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); @@ -1133,7 +1135,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { // cloud fraction (cloudy if N_c > 20/cm^3) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask typename Plotter_t::arr_t snap_m0(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); @@ -1155,7 +1157,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { typename Plotter_t::arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); snap2 /= 1e6; // per cm^3 - snap2 *= rhod; // b4 it was per milligram + plotter.multiply_by_rhod(snap2); res_series[plt](at) = blitz::mean(snap2); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -1167,7 +1169,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { typename Plotter_t::arr_t snap2(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); snap2 /= 1e6; // per cm^3 - snap2 *= rhod; // b4 it was per milligram + plotter.multiply_by_rhod(snap2); res_series[plt](at) = blitz::mean(snap2); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -1181,11 +1183,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { // cloud fraction (cloudy if N_c > 20/cm^3) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask typename Plotter_t::arr_t snap2(plotter.h5load_timestep("rd_geq_0.8um_rw_mom0", at * n["outfreq"])); - snap2 *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; if(blitz::sum(snap) > 0) @@ -1202,7 +1204,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { typename Plotter_t::arr_t snap2(plotter.h5load_timestep("rd_geq_0.8um_rw_mom0", at * n["outfreq"])); snap2 /= 1e6; // per cm^3 - snap2 *= rhod; // b4 it was per milligram + plotter.multiply_by_rhod(snap2); res_series[plt](at) = blitz::mean(snap2); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -1215,11 +1217,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { // cloud fraction (cloudy if N_c > 20/cm^3) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask typename Plotter_t::arr_t snap2(plotter.h5load_timestep("rd_lt_0.8um_rw_mom0", at * n["outfreq"])); - snap2 *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; if(blitz::sum(snap) > 0) @@ -1235,7 +1237,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { typename Plotter_t::arr_t snap2(plotter.h5load_timestep("rd_lt_0.8um_rw_mom0", at * n["outfreq"])); snap2 /= 1e6; // per cm^3 - snap2 *= rhod; // b4 it was per milligram + plotter.multiply_by_rhod(snap2); res_series[plt](at) = blitz::mean(snap2); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -1248,7 +1250,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { // cloud fraction (cloudy if N_c > 20/cm^3) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - snap *= rhod; // b4 it was specific moment + plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy(snap); // cloudiness mask typename Plotter_t::arr_t snap_m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); From 15ed230456bd6dd5b2e36532db279b5db5843663 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 9 Dec 2022 16:03:58 +0100 Subject: [PATCH 02/51] rico series fixes --- drawbicyc/include/cases/RICO11/plots.hpp | 4 ++-- drawbicyc/include/gnuplot_series_set_labels.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index e841b4f..72cd397 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -18,8 +18,8 @@ const std::vector series_rico({ "rwp", "surf_precip", "acc_precip" -,"nc" -,"nr" +//,"nc" +//,"nr" ,"cl_nc_rico" ,"cl_nr_rico" ,"cloud_avg_supersat" diff --git a/drawbicyc/include/gnuplot_series_set_labels.hpp b/drawbicyc/include/gnuplot_series_set_labels.hpp index b258c9d..2720752 100644 --- a/drawbicyc/include/gnuplot_series_set_labels.hpp +++ b/drawbicyc/include/gnuplot_series_set_labels.hpp @@ -151,7 +151,7 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) gp << "set title 'average cloud drop conc [1/cm^3]'\n"; else if (plt == "ntot") gp << "set title 'average particle conc [1/cm^3]'\n"; - else if (plt == "cl_nc") + else if (plt == "cl_nc" || plt == "cl_nc_rico") { gp << "set title 'average cloud drop conc [1/cm^3] in cloudy cells'\n"; gp << "set xlabel ''\n"; @@ -163,7 +163,7 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) gp << "set xlabel ''\n"; gp << "set ylabel ''\n"; } - else if (plt == "cl_nr") + else if (plt == "cl_nr" || plt == "cl_nr_rico") { gp << "set title 'average rain drop conc [1/cm^3] in cloudy cells'\n"; gp << "set xlabel ''\n"; From 45ed9737450ba8eb225d06b30e61feeb3e2cc913 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 9 Dec 2022 18:37:08 +0100 Subject: [PATCH 03/51] refined plotting wip' --- UWLCM_plotters/include/Plotter3d.hpp | 13 ++++--- UWLCM_plotters/include/PlotterCommon.hpp | 2 +- UWLCM_plotters/include/PlotterMicro.hpp | 45 +++++++++++++----------- drawbicyc/include/cases/RICO11/plots.hpp | 26 +++++++------- 4 files changed, 46 insertions(+), 40 deletions(-) diff --git a/UWLCM_plotters/include/Plotter3d.hpp b/UWLCM_plotters/include/Plotter3d.hpp index d481604..e2738e5 100644 --- a/UWLCM_plotters/include/Plotter3d.hpp +++ b/UWLCM_plotters/include/Plotter3d.hpp @@ -239,15 +239,14 @@ class Plotter_t<3> : public PlotterCommon tmp_srfc.resize(n[0]-1, n[1]-1, 1); // init refined data - h5load(file + "/const.h5", "X refined"); - this->map["dx refined"] = tmp(1,0,0) - tmp(0,0,0); - h5load(file + "/const.h5", "Y refined"); - this->map["dy refined"] = tmp(0,1,0) - tmp(0,0,0); - h5load(file + "/const.h5", "Z refined"); - this->map["dz refined"] = tmp(0,0,1) - tmp(0,0,0); - this->CellVol_ref = this->map["dx refined"] * this->map["dy refined"] * this->map["dz refined"]; this->h5f.openDataSet("X refined").getSpace().getSimpleExtentDims(n, NULL); tmp_ref.resize(n[0]-1, n[1]-1, n[2]-1); + this->map["refined dx"] = tmp(1,0,0) - tmp(0,0,0); + this->h5f.openDataSet("Y refined").getSpace().getSimpleExtentDims(n, NULL); + this->map["refined dy"] = tmp(0,1,0) - tmp(0,0,0); + this->h5f.openDataSet("Z refined").getSpace().getSimpleExtentDims(n, NULL); + this->map["refined dz"] = tmp(0,0,1) - tmp(0,0,0); + this->CellVol_ref = this->map["refined dx"] * this->map["refined dy"] * this->map["refined dz"]; } }; diff --git a/UWLCM_plotters/include/PlotterCommon.hpp b/UWLCM_plotters/include/PlotterCommon.hpp index 29dfd2c..3f763bb 100644 --- a/UWLCM_plotters/include/PlotterCommon.hpp +++ b/UWLCM_plotters/include/PlotterCommon.hpp @@ -14,7 +14,7 @@ class PlotterCommon std::map map; std::map map_prof; blitz::Array timesteps; - double CellVol, DomainSurf, DomainVol; + double CellVol, DomainSurf, DomainVol, CellVol_ref; protected: H5::H5File h5f; diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index e920d81..5e60852 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -24,8 +24,8 @@ class PlotterMicro_t : public Plotter_t { if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) arr *= this->map_prof["rhod"](this->LastIndex); - else if(arr.extent(NDims-1) == this->map_prof["rhod refined"].extent(0)) - arr *= this->map_prof["rhod refined"](this->LastIndex); + else if(arr.extent(NDims-1) == this->map_prof["refined rhod"].extent(0)) + arr *= this->map_prof["refined rhod"](this->LastIndex); else throw std::runtime_error("multiply_by_rhod: input array is neither normal grid size nor refined grid size"); } @@ -34,7 +34,7 @@ class PlotterMicro_t : public Plotter_t { if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) arr *= this->CellVol; - else if(arr.extent(NDims-1) == this->map_prof["rhod refined"].extent(0)) + else if(arr.extent(NDims-1) == this->map_prof["refined rhod"].extent(0)) arr *= this->CellVol_ref; else throw std::runtime_error("multiply_by_CellVol: input array is neither normal grid size nor refined grid size"); @@ -45,41 +45,43 @@ class PlotterMicro_t : public Plotter_t // aerosol droplets mixing ratio auto h5load_ra_timestep( int at - ) -> decltype(blitz::safeToReturn(arr_t() + 0)) + ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { if(this->micro == "lgrngn") - res = this->h5load_timestep("aerosol_rw_mom3", at) * 4./3. * 3.1416 * 1e3; + return arr_t(this->h5load_timestep("aerosol_rw_mom3", at) * 4./3. * 3.1416 * 1e3); + else if(this->micro == "blk_1m") + { res = 0; - return blitz::safeToReturn(res + 0); + return res; + // return blitz::safeToReturn(res + 0); + } } // cloud droplets mixing ratio auto h5load_rc_timestep( int at - ) -> decltype(blitz::safeToReturn(arr_t() + 0)) + ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { if(this->micro == "lgrngn") - res = this->h5load_timestep("cloud_rw_mom3", at) * 4./3. * 3.1416 * 1e3; + return arr_t(this->h5load_timestep("cloud_rw_mom3", at) * 4./3. * 3.1416 * 1e3); else if(this->micro == "blk_1m") - res = this->h5load_timestep("rc", at); + return arr_t(this->h5load_timestep("rc", at)); else if(this->micro == "blk_2m") - res = this->h5load_timestep("rc", at); - return blitz::safeToReturn(res + 0); + return arr_t(this->h5load_timestep("rc", at)); } // rain droplets mixing ratio auto h5load_rr_timestep( int at - ) -> decltype(blitz::safeToReturn(arr_t() + 0)) + ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { if(this->micro == "lgrngn") - res = this->h5load_timestep("rain_rw_mom3", at) * 4./3. * 3.1416 * 1e3; + return arr_t(this->h5load_timestep("rain_rw_mom3", at) * 4./3. * 3.1416 * 1e3); else if(this->micro == "blk_1m") - res = this->h5load_timestep("rr", at); + return arr_t(this->h5load_timestep("rr", at)); else if(this->micro == "blk_2m") - res = this->h5load_timestep("rr", at); - return blitz::safeToReturn(res + 0); + return arr_t(this->h5load_timestep("rr", at)); } // activated drops mixing ratio @@ -108,15 +110,18 @@ class PlotterMicro_t : public Plotter_t // cloud droplets concentration [1/kg] auto h5load_nc_timestep( int at - ) -> decltype(blitz::safeToReturn(arr_t() + 0)) + ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { if(this->micro == "lgrngn") - res = this->h5load_timestep("cloud_rw_mom0", at); + return arr_t(this->h5load_timestep("cloud_rw_mom0", at)); else if(this->micro == "blk_1m") + { res = 0; + return res; + // return blitz::safeToReturn(res + 0); + } else if(this->micro == "blk_2m") - res = this->h5load_timestep("nc", at); - return blitz::safeToReturn(res + 0); + return arr_t(this->h5load_timestep("nc", at); } // precipitation flux [W/m2] diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index 72cd397..e0828a4 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -1,30 +1,33 @@ #pragma once const std::vector series_rico({ -// "clb_bigrain_mean_rd", -// "clb_bigrain_mean_kappa", -// "clb_bigrain_mean_conc", -// "clb_bigrain_mean_inclt", -//, "clb_bigrain_mean_gccn_fraction" - -//"cl_acnv25_rico", -//"cl_accr25_rico", "RH_max", "cloud_cover_rico", -"min_cloud_base_rico", +"min_cloud_base_rico" "inversion_height_rico", "tot_water", "lwp", "rwp", "surf_precip", "acc_precip" -//,"nc" -//,"nr" ,"cl_nc_rico" ,"cl_nr_rico" ,"cloud_avg_supersat" ,"wvarmax" ,"cl_meanr" //TODO: zmienic maske na rico +,"sd_conc" + + +// "clb_bigrain_mean_rd", +// "clb_bigrain_mean_kappa", +// "clb_bigrain_mean_conc", +// "clb_bigrain_mean_inclt", +//, "clb_bigrain_mean_gccn_fraction" + +//"cl_acnv25_rico", +//"cl_accr25_rico", +//,"nc" +//,"nr" //TODO (po usprawnieniu cloud mask i ujednoliceniu tego: /* ,"cl_avg_cloud_rad" @@ -34,7 +37,6 @@ const std::vector series_rico({ //,"rd_geq_0.8um_conc" //,"cl_rd_lt_0.8um_conc" //,"cl_rd_geq_0.8um_conc" -,"sd_conc" /* "cloud_base", From 274bdca897efb75c8099f593e1e73dd9da687cc2 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Mon, 12 Dec 2022 12:07:21 +0100 Subject: [PATCH 04/51] compilation fix --- UWLCM_plotters/include/PlotterMicro.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index 5e60852..a3a4f4d 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -121,7 +121,7 @@ class PlotterMicro_t : public Plotter_t // return blitz::safeToReturn(res + 0); } else if(this->micro == "blk_2m") - return arr_t(this->h5load_timestep("nc", at); + return arr_t(this->h5load_timestep("nc", at)); } // precipitation flux [W/m2] From bfc92a43ab9fd73ed8a76121012990b36f6d0daf Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Mon, 12 Dec 2022 12:20:05 +0100 Subject: [PATCH 05/51] plotter micro return without res cd --- UWLCM_plotters/include/PlotterMicro.hpp | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index a3a4f4d..0ec057a 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -87,12 +87,14 @@ class PlotterMicro_t : public Plotter_t // activated drops mixing ratio auto h5load_ract_timestep( int at - ) -> decltype(blitz::safeToReturn(arr_t() + 0)) + ) { if(this->micro == "lgrngn") { - res = this->h5load_timestep("cloud_rw_mom3", at) * 4./3. * 3.1416 * 1e3; - res += arr_t(this->h5load_timestep("rain_rw_mom3", at) * 4./3. * 3.1416 * 1e3); + return arr_t( + arr_t(this->h5load_timestep("cloud_rw_mom3", at) * 4./3. * 3.1416 * 1e3) + + arr_t(this->h5load_timestep("rain_rw_mom3", at) * 4./3. * 3.1416 * 1e3) + ); } else if(this->micro == "blk_1m") { @@ -104,7 +106,8 @@ class PlotterMicro_t : public Plotter_t res = this->h5load_timestep("rc", at); res += arr_t(this->h5load_timestep("rr", at)); } - return blitz::safeToReturn(res + 0); + // return blitz::safeToReturn(res + 0); + return res; } // cloud droplets concentration [1/kg] @@ -127,14 +130,14 @@ class PlotterMicro_t : public Plotter_t // precipitation flux [W/m2] auto h5load_prflux_timestep( int at - ) -> decltype(blitz::safeToReturn(arr_t() + 0)) + )// -> decltype(blitz::safeToReturn(arr_t() + 0)) { if(this->micro == "lgrngn") { - res = this->h5load_timestep("precip_rate", at) + return arr_t(this->h5load_timestep("precip_rate", at) * 4./3 * 3.14 * 1e3 // to get mass / this->CellVol // averaged over cell volume, TODO: make precip rate return specific moment? wouldnt need the dx and dy - * L_evap; + * L_evap); } else if(this->micro == "blk_1m") try @@ -150,19 +153,21 @@ class PlotterMicro_t : public Plotter_t { res = 0; } - return blitz::safeToReturn(res + 0); + // return blitz::safeToReturn(res + 0); + return res; } // RH auto h5load_RH_timestep( int at - ) -> decltype(blitz::safeToReturn(arr_t() + 0)) + ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { if(this->micro == "lgrngn") - res = this->h5load_timestep("RH", at); + return arr_t(this->h5load_timestep("RH", at)); else if(this->micro == "blk_1m") res = 0; - return blitz::safeToReturn(res + 0); + // return blitz::safeToReturn(res + 0); + return res; } From a62b28fc14198379ddf75cc990279ffcbcfc4419 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Mon, 12 Dec 2022 13:24:01 +0100 Subject: [PATCH 06/51] fixes for refined plotting --- UWLCM_plotters/include/Plotter3d.hpp | 26 ++++++++++++++++++------ UWLCM_plotters/include/PlotterCommon.hpp | 2 +- drawbicyc/include/cases/RICO11/plots.hpp | 16 +++++++-------- drawbicyc/include/plot_series.hpp | 10 ++++----- 4 files changed, 34 insertions(+), 20 deletions(-) diff --git a/UWLCM_plotters/include/Plotter3d.hpp b/UWLCM_plotters/include/Plotter3d.hpp index e2738e5..86692f7 100644 --- a/UWLCM_plotters/include/Plotter3d.hpp +++ b/UWLCM_plotters/include/Plotter3d.hpp @@ -240,13 +240,27 @@ class Plotter_t<3> : public PlotterCommon // init refined data this->h5f.openDataSet("X refined").getSpace().getSimpleExtentDims(n, NULL); - tmp_ref.resize(n[0]-1, n[1]-1, n[2]-1); - this->map["refined dx"] = tmp(1,0,0) - tmp(0,0,0); - this->h5f.openDataSet("Y refined").getSpace().getSimpleExtentDims(n, NULL); - this->map["refined dy"] = tmp(0,1,0) - tmp(0,0,0); - this->h5f.openDataSet("Z refined").getSpace().getSimpleExtentDims(n, NULL); - this->map["refined dz"] = tmp(0,0,1) - tmp(0,0,0); + this->map["refined x"] = n[0]-1; + this->map["refined y"] = n[1]-1; + this->map["refined z"] = n[2]-1; + tmp_ref.resize(n[0], n[1], n[2]); + h5load(file + "/const.h5", "X refined"); + this->map["refined dx"] = tmp_ref(1,0,0) - tmp_ref(0,0,0); + h5load(file + "/const.h5", "Y refined"); + this->map["refined dy"] = tmp_ref(0,1,0) - tmp_ref(0,0,0); + h5load(file + "/const.h5", "Z refined"); + this->map["refined dz"] = tmp_ref(0,0,1) - tmp_ref(0,0,0); this->CellVol_ref = this->map["refined dx"] * this->map["refined dy"] * this->map["refined dz"]; + tmp_ref.resize(n[0]-1, n[1]-1, n[2]-1); + + for (auto const& x : this->map) +{ + std::cout << x.first // string (key) + << ':' + << x.second // string's value + << std::endl; +} + } }; diff --git a/UWLCM_plotters/include/PlotterCommon.hpp b/UWLCM_plotters/include/PlotterCommon.hpp index 3f763bb..0110c5d 100644 --- a/UWLCM_plotters/include/PlotterCommon.hpp +++ b/UWLCM_plotters/include/PlotterCommon.hpp @@ -61,6 +61,7 @@ class PlotterCommon auto attr = h5g.openAttribute(attr_name); notice_macro(std::string("about to read attribute value")) attr.read(attr.getDataType(), &ret); + notice_macro(std::string("attribute value read: ") + std::to_string(ret)) return ret; } @@ -93,7 +94,6 @@ class PlotterCommon map["dt"] = h5load_attr(file + "/const.h5", "dt", "advection"); map["outfreq"] = h5load_attr(file + "/const.h5", "outfreq", "user_params"); map["MPI_compiler"] = h5load_attr(file + "/const.h5", "MPI compiler (true/false)", "MPI details"); - map["n_fra_iter"] = h5load_attr(file + "/const.h5", "n_fra_iter", "fractal"); // read number of timesteps hsize_t n; diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index e0828a4..0a4ccd3 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -3,19 +3,19 @@ const std::vector series_rico({ "RH_max", "cloud_cover_rico", -"min_cloud_base_rico" +"min_cloud_base_rico", "inversion_height_rico", "tot_water", "lwp", "rwp", "surf_precip", -"acc_precip" -,"cl_nc_rico" -,"cl_nr_rico" -,"cloud_avg_supersat" -,"wvarmax" -,"cl_meanr" //TODO: zmienic maske na rico -,"sd_conc" +"acc_precip", +"cl_nc_rico", +"cl_nr_rico", +"cloud_avg_supersat", +"wvarmax", +"cl_meanr", //TODO: zmienic maske na rico +"sd_conc" // "clb_bigrain_mean_rd", diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index 2577dc3..054b4f4 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -130,7 +130,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(tmp); snap += plotter.h5load_rr_timestep(at * n["outfreq"]) * 1e3; //g/kg plotter.multiply_by_rhod(snap); - plotter.k_i = blitz::sum(snap, plotter.LastIndex) * n["dz"]; // LWP [g/m2] in the column + plotter.k_i = blitz::sum(snap, plotter.LastIndex) * n["refined dz"]; // LWP [g/m2] in the column plotter.k_i = where(plotter.k_i > 20 , 1 , 0); // cloudiness as in Ackermann et al. res_series[plt](at) = blitz::mean(plotter.k_i); } @@ -577,7 +577,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) cloudy_column = where(cloudy_column > 0, 1, 0); plotter.k_i = where(cloudy_column == 0, 0, plotter.k_i); if(blitz::sum(cloudy_column) > 0) - res_series[plt](at) = double(blitz::sum(plotter.k_i)) / blitz::sum(cloudy_column) * n["dz"]; + res_series[plt](at) = double(blitz::sum(plotter.k_i)) / blitz::sum(cloudy_column) * n["refined dz"]; else res_series[plt](at) = 0; } @@ -633,7 +633,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) cloudy_column = where(cloudy_column > 0, 1, 0); plotter.k_i = where(cloudy_column == 0, 1e6, plotter.k_i); // 1e6 denotes no clouds in the column if(blitz::sum(cloudy_column) > 0) - res_series[plt](at) = blitz::min(plotter.k_i) * n["dz"]; + res_series[plt](at) = blitz::min(plotter.k_i) * n["refined dz"]; else res_series[plt](at) = 0; } @@ -1828,11 +1828,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } else if (plt == "lwp") { - res_series[plt] *= (n["z"] - 1) * n["dz"]; // top and bottom cells are smaller + res_series[plt] *= (n["refined z"] - 1) * n["refined dz"]; // top and bottom cells are smaller } else if (plt == "rwp") { - res_series[plt] *= (n["z"] - 1) * n["dz"]; // top and bottom cells are smaller + res_series[plt] *= (n["refined z"] - 1) * n["refined dz"]; // top and bottom cells are smaller } else if (plt == "er") { From 428c88cbddfc9371bb515e5b66adeb779f9b31d6 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Mon, 12 Dec 2022 13:33:58 +0100 Subject: [PATCH 07/51] lwp plot fix --- drawbicyc/include/plot_series.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index 054b4f4..2e48c77 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -821,11 +821,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]) * 1e3; //g/kg - typename Plotter_t::arr_t snap(tmp); - snap += plotter.h5load_rr_timestep(at * n["outfreq"]) * 1e3; //g/kg - plotter.multiply_by_rhod(snap); - res_series[plt](at) = blitz::mean(snap); + typename Plotter_t::arr_t rl(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t rr(plotter.h5load_rr_timestep(at * n["outfreq"])); + rl = (rl + rr) * 1e3; // g/kg + plotter.multiply_by_rhod(rl); + res_series[plt](at) = blitz::mean(rl); } } catch(...) {if(at==first_timestep) data_found[plt]=0;} From 226658dd2a7fed9cfa28be3c2676e46e8ef6b52a Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Wed, 14 Dec 2022 13:48:12 +0100 Subject: [PATCH 08/51] wip on plotter rework --- UWLCM_plotters/include/Plotter.hpp | 315 ++++++++++++++++ UWLCM_plotters/include/Plotter2d.hpp | 8 +- UWLCM_plotters/include/Plotter3d.hpp | 4 +- UWLCM_plotters/include/PlotterCommon.hpp | 451 ++++++++++++++++++----- UWLCM_plotters/include/PlotterH5.hpp | 133 +++++++ UWLCM_plotters/include/PlotterMicro.hpp | 90 +---- 6 files changed, 814 insertions(+), 187 deletions(-) create mode 100644 UWLCM_plotters/include/Plotter.hpp create mode 100644 UWLCM_plotters/include/PlotterH5.hpp diff --git a/UWLCM_plotters/include/Plotter.hpp b/UWLCM_plotters/include/Plotter.hpp new file mode 100644 index 0000000..eb8e68a --- /dev/null +++ b/UWLCM_plotters/include/Plotter.hpp @@ -0,0 +1,315 @@ +#pragma once +#include "PlotterMicro.hpp" + +// TODO: make two: plotterlgrngn and plotter blk1m +template +class Plotter : public PlotterMicro +{ + protected: + using parent_t = PlotterMicro; + + public: + using arr_t = typename parent_t::arr_t; + + public: + + // functions for diagnosing statistics + // mean and std dev [g/kg] of the mixing ratio of activated dropelts in cloudy cells (characteristics of the spatial distribution at this timestep) + std::pair cloud_ract_stats_timestep(int at) + { + // read activated droplets mixing ratio + arr_t ract(h5load_ract_timestep(at)); + ract *= 1e3; // turn it into g/kg + return cloud_hlpr(ract, at); + } + + // mean and std_dev of concentration of activated droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) + std::pair cloud_actconc_stats_timestep(int at) + { + arr_t actconc; + // read concentration of activated droplets + if(this->micro == "blk_1m") return {0,0}; + // TODO: fix stupid copying of arrays + else if(this->micro == "lgrngn") { + arr_t tmp(this->h5load_timestep("actrw_rw_mom0", at)); + actconc.resize(tmp.shape()); + actconc = tmp; + } + else if(this->micro == "blk_2m") { + arr_t tmp(arr_t(this->h5load_timestep("nc", at)) + arr_t(this->h5load_timestep("nr", at))); + actconc.resize(tmp.shape()); + actconc = tmp; + } + actconc *= rhod; // b4 it was specific moment + actconc /= 1e6; // per cm^3 + return cloud_hlpr(actconc, at); + } + + // mean and std_dev of supersaturation in cells with positive supersaturation [%] (characteristics of the spatial distribution at this timestep) + std::pair positive_supersat_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + std::pair res; + + // read RH + arr_t RH(this->h5load_timestep("RH", at)); + RH -= 1.; + arr_t sat(RH.copy()); + sat = iscloudy_sat(RH); + RH *= sat; //apply the cloudiness mask + RH *= 100; // to get % + if(blitz::sum(sat) > 0) + res.first = blitz::sum(RH) / blitz::sum(sat); + else + res.first = 0; + + RH = pow(RH - res.first, 2); + RH *= sat; // apply filter + if(res.first>0) + res.second = sqrt(blitz::sum(RH) / blitz::sum(sat)); + else + res.second = 0.; + + return res; + } + + // mean and std_dev of supersaturation at droplet locations (i.e. supersat weighted by the number of droplets) + std::pair drop_supersat_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + std::pair res; + + // read supersat + arr_t ssat(this->h5load_timestep("RH", at)); + ssat -= 1.; + + // read number of droplets per cell + arr_t nc(this->h5load_timestep("cloud_rw_mom0", at)); + nc *= rhod; // [1/m^3] + nc *= this->dv; + + + if(blitz::sum(nc) > 0) + { + res.first = blitz::sum(ssat * nc) / blitz::sum(nc); + ssat = pow(ssat - res.first, 2); + res.second = sqrt(blitz::sum(ssat * nc) / blitz::sum(nc)); + } + else + { + res.first = 0; + res.second = 0; + } + + return res; + } + + // mean and std_dev of number of SDs (characteristics of the spatial distribution at this timestep) + std::pair sdconc_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + arr_t sdconc(this->h5load_timestep("sd_conc", at)); + return hlpr(sdconc, at); + } + + // mean and std_dev of number of SDs in cloudy cells (characteristics of the spatial distribution at this timestep) + std::pair cloud_sdconc_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + arr_t sdconc(this->h5load_timestep("sd_conc", at)); + return cloud_hlpr(sdconc, at); + } + + // mean and std_dev of number of activated SDs in cloudy cells (characteristics of the spatial distribution at this timestep) + std::pair cloud_sdconc_act_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + arr_t sdconc_act(this->h5load_timestep("sd_conc_act", at)); + return cloud_hlpr(sdconc_act, at); + } + + // mean and std_dev of mean radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) + std::pair cloud_meanr_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + // read act drop 0th raw moment / mass [1/kg] + arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); + // read act drop 1st raw moment / mass [um/kg] + arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); + // calculate mean radius, store in act1st + act1st = where(act0th > 0, act1st / act0th, 0.); + return cloud_hlpr(act1st, at); + } + + // mean and std_dev of std_dev of radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) + std::pair cloud_stddevr_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + // read act drop 0th raw moment / mass [1/kg] + arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); + // read act drop 1st raw moment / mass [um/kg] + arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); + // read act drop 2nd raw moment / mass [um^2/kg] + arr_t act2nd(this->h5load_timestep("actrw_rw_mom2", at) * 1e12); + // calculate stddev of radius, store in act1st + act1st = where(act0th > 0, + act2nd / act0th - act1st / act0th * act1st / act0th, 0.); + // might be slightly negative due to numerical errors + act1st = where(act1st < 0, 0, act1st); + act1st = sqrt(act1st); + return cloud_hlpr(act1st, at); + } + + // mean and std_dev of temperature [K] (characteristics of the spatial distribution at this timestep, without near-wall cells) + std::pair T_stats_timestep(int at) + { + // read theta away from walls + //arr_t tht(this->nowall(arr_t(this->h5load_timestep("th", at)), distance_from_walls)); + arr_t tht(arr_t(this->h5load_timestep("th", at))); + tht *= pow(this->map_prof["p_e"](this->LastIndex) / p_1000, R_d / c_pd); // tht -> T + return hlpr(tht, at); + } + + // mean and std_dev of r_v [1] (characteristics of the spatial distribution at this timestep) + std::pair rv_stats_timestep(int at) + { + arr_t rv(arr_t(this->h5load_timestep("rv", at))); + return hlpr(rv, at); + } + + // mean and std_dev of RH [1] (characteristics of the spatial distribution at this timestep) + std::pair RH_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + std::pair res; + + arr_t RH(this->h5load_timestep("RH", at)); + return hlpr(RH, at); + } + + // surface precipitation since last output [mm/day] + double calc_surf_precip(double prec_vol_diff) + { + if(this->micro == "lgrngn") + return prec_vol_diff / this->DomainSurf / (double(this->map["outfreq"]) * this->map["dt"] / 3600. / 24.) * 1e3; // SDM + if(this->micro == "blk_1m" || this->micro == "blk_2m") + return prec_vol_diff / double(this->map["outfreq"]) // flux in [kg / m^3 / s] averaged over time since last output and over cells on the bottom + / (this->map["x"] * this->map["y"]) + * 3600. * 24. // per day + * this->map["dz"] // per m^2 + / 1e3 // to m^3 of water + * 1e3; // to mm + } + + // accumulated surface precipitation [mm] + double calc_acc_surf_precip(double prec_vol) + { + if(this->micro == "lgrngn") + return prec_vol / this->DomainSurf * 1e3; + if(this->micro == "blk_1m" || this->micro == "blk_2m") + return prec_vol * this->map["dt"] + / (this->map["x"] * this->map["y"]) + * this->map["dz"] // per m^2 + / 1e3 // to m^3 of water + * 1e3; // to mm + } + // accumulated volume precipitation [m^3] + double calc_acc_surf_precip_volume(double prec_vol) + { + if(this->micro == "lgrngn") + return calc_acc_surf_precip(prec_vol) * this->DomainSurf / 1000.; + if(this->micro == "blk_1m") + return calc_acc_surf_precip(prec_vol) * this->DomainSurf / 1000.;// to m^3 of water + } + // droplet removal rate (at boundaries) since last output [1/(cm^3 s)] + double calc_prtcl_removal(double prtcl_removal_diff) + { + if(this->micro == "lgrngn") + return prtcl_removal_diff / this->DomainVol / (double(this->map["outfreq"]) * this->map["dt"]) / 1e6; + if(this->micro == "blk_1m") + return 0; + } + + // heat flux thru boundary since last output [W/m^2] + double calc_heat_flux(double tot_th_diff, int z_idx) // input in [K] + { + if(this->micro == "lgrngn") + { + tot_th_diff *= pow(this->map_prof["p_e"](z_idx) / p_1000, R_d / c_pd); // tht -> T + double ret = tot_th_diff * c_pd * this->map_prof["rhod"](z_idx) // sum of th diff over boundary cells since last output (K) * c_pd * density + * this->map["dz"] / ((this->map["x"]-1) * (this->map["y"]-1)) // multiply by cell volume and divide by domain surface area (without walls) + * (double(this->map["outfreq"]) * this->map["dt"]); // divide by time since last output + return ret; + } + if(this->micro == "blk_1m") + return 0; + } + + double calc_heat_flux_top(double mean_th_diff, bool errfix) + { + double tot_th_diff = mean_th_diff * this->map["x"] * this->map["y"]; + if(errfix) + { + // th_diff += (this->map["x"] * this->map["y"] - 1) * 280; // to counter to error in tot_th_diff calculation in UWLCM + tot_th_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (280 - 285); // dont count side wall + } + return calc_heat_flux(tot_th_diff, this->map["z"]-1); + } + + double calc_heat_flux_bot(double mean_th_diff, bool errfix) + { + double tot_th_diff = mean_th_diff * this->map["x"] * this->map["y"]; + if(errfix) + { + // th_diff += (this->map["x"] * this->map["y"] - 1) * 299; + tot_th_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (299 - 285); + } + return calc_heat_flux(tot_th_diff, 0); + } + + // kinematic rv flux thru boundary since last output [kg/kg * m / s] + double calc_moist_flux(double tot_rv_diff) // rv change summed over horizontal plane [kg/kg] + { + if(this->micro == "lgrngn") + { + return tot_rv_diff * this->map["dz"] + * (double(this->map["outfreq"]) * this->map["dt"]); // divide by time since last output + } + if(this->micro == "blk_1m") + return 0; + } + + double calc_moist_flux_top(double mean_rv_diff, bool errfix) + { + // 3D assumed here! + double tot_rv_diff = mean_rv_diff * this->map["x"] * this->map["y"]; + if(errfix) + { +// rv_diff += (this->map["x"] * this->map["y"] - 1) * 0.0062192674278; // to counter to error in tot_rv_diff calculation in UWLCM + tot_rv_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (0.0062192674278 - 0.00611718803008); // dont count side wall + } + return calc_moist_flux(tot_rv_diff); + } + + double calc_moist_flux_bot(double mean_rv_diff, bool errfix) + { + // 3D assumed here! + double tot_rv_diff = mean_rv_diff * this->map["x"] * this->map["y"]; + if(errfix) + { +// rv_diff += (this->map["x"] * this->map["y"] - 1) * 0.0213489271007; // to counter to error in tot_rv_diff calculation in UWLCM + tot_rv_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (0.0213489271007 - 0.00611718803008); // dont count side wall + } + return calc_moist_flux(tot_rv_diff); + } + + //ctor + Plotter(const string &file, const string µ): + parent_t(file), + micro(micro), + res(this->tmp.shape()), + rhod(this->h5load(file + "/const.h5", "G")) + { + } +}; + diff --git a/UWLCM_plotters/include/Plotter2d.hpp b/UWLCM_plotters/include/Plotter2d.hpp index 2bed638..6b92228 100644 --- a/UWLCM_plotters/include/Plotter2d.hpp +++ b/UWLCM_plotters/include/Plotter2d.hpp @@ -1,13 +1,13 @@ #pragma once #include "common.hpp" -#include "PlotterCommon.hpp" +#include "PlotterH5.hpp" template -class Plotter_t : public PlotterCommon {}; +class Plotter_t : public PlotterH5 {}; // 2d version template<> -class Plotter_t<2> : public PlotterCommon +class Plotter_t<2> : public PlotterH5 { public: static const int n_dims = 2; @@ -18,7 +18,7 @@ class Plotter_t<2> : public PlotterCommon arr_t dv; protected: - using parent_t = PlotterCommon; + using parent_t = PlotterH5; hsize_t n[2]; enum {x, z}; arr_t tmp, tmp_srfc; diff --git a/UWLCM_plotters/include/Plotter3d.hpp b/UWLCM_plotters/include/Plotter3d.hpp index 86692f7..d2b9f07 100644 --- a/UWLCM_plotters/include/Plotter3d.hpp +++ b/UWLCM_plotters/include/Plotter3d.hpp @@ -4,7 +4,7 @@ // 3d version template<> -class Plotter_t<3> : public PlotterCommon +class Plotter_t<3> : public PlotterH5 { public: static const int n_dims = 3; @@ -15,7 +15,7 @@ class Plotter_t<3> : public PlotterCommon arr_t dv; protected: - using parent_t = PlotterCommon; + using parent_t = PlotterH5; hsize_t n[3]; enum {x, y, z}; arr_t tmp, tmp_srfc, tmp_ref; diff --git a/UWLCM_plotters/include/PlotterCommon.hpp b/UWLCM_plotters/include/PlotterCommon.hpp index 0110c5d..87d25e7 100644 --- a/UWLCM_plotters/include/PlotterCommon.hpp +++ b/UWLCM_plotters/include/PlotterCommon.hpp @@ -1,133 +1,380 @@ #pragma once +#include "Plotter2d.hpp" +#include "Plotter3d.hpp" +//#include -#include -#include -#include -#include - -class PlotterCommon +template +class PlotterCommon : public Plotter_t { - public: - using arr_prof_t = blitz::Array; + protected: + using parent_t = Plotter_t; - const string file; - std::map map; - std::map map_prof; - blitz::Array timesteps; - double CellVol, DomainSurf, DomainVol, CellVol_ref; + public: + using arr_t = typename parent_t::arr_t; protected: - H5::H5File h5f; - H5::DataSet h5d; - H5::Group h5g; - H5::DataSpace h5s; - - void h5load( - const string &file, - const string &dataset, - bool srfc = false - ) - { - if(h5f.getFileName() != file) - { - notice_macro("about to close current file: " << h5f.getFileName()) - h5f.close(); + const double L_evap = 2264.76e3; // latent heat of evaporation [J/kg] - notice_macro("about to open file: " << file) - h5f.openFile(file, H5F_ACC_RDONLY); - } + public: + void multiply_by_rhod(arr_t &arr) + { + if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) + arr *= this->map_prof["rhod"](this->LastIndex); + else if(arr.extent(NDims-1) == this->map_prof["refined rhod"].extent(0)) + arr *= this->map_prof["refined rhod"](this->LastIndex); + else + throw std::runtime_error("multiply_by_rhod: input array is neither normal grid size nor refined grid size"); + } - notice_macro("about to read dataset: " << dataset) - h5d = h5f.openDataSet(dataset); - h5s = h5d.getSpace(); + void multiply_by_CellVol(arr_t &arr) + { + if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) + arr *= this->CellVol; + else if(arr.extent(NDims-1) == this->map_prof["refined rhod"].extent(0)) + arr *= this->CellVol_ref; + else + throw std::runtime_error("multiply_by_CellVol: input array is neither normal grid size nor refined grid size"); } - float h5load_attr(const string &file, const string &attr_name, const string &group_name) + // ---- functions for diagnosing statistics ---- + + // helper function that calculates staistics (mean and std_dev) of a field + std::pair hlpr(arr_t arr, int at) { - if(h5f.getFileName() != file) - { - notice_macro("about to close current file: " << h5f.getFileName()) - h5f.close(); + std::pair res; + res.first = blitz::mean(arr); + arr = pow(arr - res.first, 2); + res.second = sqrt(blitz::mean(arr)); + return res; + } + + // helper function that calculates staistics (mean and std_dev) of a field only in cloudy cells + std::pair cloud_hlpr(arr_t arr, int at) + { + std::pair res; + // read activated droplets mixing ratio + arr_t mask(h5load_ract_timestep(at)); + mask = iscloudy_rc(mask); + arr *= mask; // apply filter + + if(blitz::sum(mask) > 0.) + res.first = blitz::sum(arr) / blitz::sum(mask); + else + res.first = 0.; + + arr = pow(arr - res.first, 2); + arr *= mask; // apply filter + if(res.first>0) + res.second = sqrt(blitz::sum(arr) / blitz::sum(mask)); + else + res.second = 0.; + + return res; + } - notice_macro("about to open file: " << file) - h5f.openFile(file, H5F_ACC_RDONLY); + // height [m] of the center of mass of activated droplets + double act_com_z_timestep(int at) + { + arr_t ract(h5load_ract_timestep(at)); + arr_t weighted(ract.copy()); + weighted = weighted * this->LastIndex * this->map["dz"]; + if(blitz::sum(ract) > 1e-3) + return blitz::sum(weighted) / blitz::sum(ract); + else + return 0.; + } + + // mean and std dev [g/kg] of the mixing ratio of activated dropelts in cloudy cells (characteristics of the spatial distribution at this timestep) + std::pair cloud_ract_stats_timestep(int at) + { + // read activated droplets mixing ratio + arr_t ract(h5load_ract_timestep(at)); + ract *= 1e3; // turn it into g/kg + return cloud_hlpr(ract, at); + } + + // mean and std_dev of concentration of activated droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) + std::pair cloud_actconc_stats_timestep(int at) + { + arr_t actconc; + // read concentration of activated droplets + if(this->micro == "blk_1m") return {0,0}; + // TODO: fix stupid copying of arrays + else if(this->micro == "lgrngn") { + arr_t tmp(this->h5load_timestep("actrw_rw_mom0", at)); + actconc.resize(tmp.shape()); + actconc = tmp; + } + else if(this->micro == "blk_2m") { + arr_t tmp(arr_t(this->h5load_timestep("nc", at)) + arr_t(this->h5load_timestep("nr", at))); + actconc.resize(tmp.shape()); + actconc = tmp; } + actconc *= rhod; // b4 it was specific moment + actconc /= 1e6; // per cm^3 + return cloud_hlpr(actconc, at); + } + + // mean and std_dev of supersaturation in cells with positive supersaturation [%] (characteristics of the spatial distribution at this timestep) + std::pair positive_supersat_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + std::pair res; + + // read RH + arr_t RH(this->h5load_timestep("RH", at)); + RH -= 1.; + arr_t sat(RH.copy()); + sat = iscloudy_sat(RH); + RH *= sat; //apply the cloudiness mask + RH *= 100; // to get % + if(blitz::sum(sat) > 0) + res.first = blitz::sum(RH) / blitz::sum(sat); + else + res.first = 0; - notice_macro(std::string("about to read group: " + group_name)) - h5g = h5f.openGroup(group_name); + RH = pow(RH - res.first, 2); + RH *= sat; // apply filter + if(res.first>0) + res.second = sqrt(blitz::sum(RH) / blitz::sum(sat)); + else + res.second = 0.; + + return res; + } + + // mean and std_dev of supersaturation at droplet locations (i.e. supersat weighted by the number of droplets) + std::pair drop_supersat_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + std::pair res; + + // read supersat + arr_t ssat(this->h5load_timestep("RH", at)); + ssat -= 1.; + + // read number of droplets per cell + arr_t nc(this->h5load_timestep("cloud_rw_mom0", at)); + nc *= rhod; // [1/m^3] + nc *= this->dv; + + + if(blitz::sum(nc) > 0) + { + res.first = blitz::sum(ssat * nc) / blitz::sum(nc); + ssat = pow(ssat - res.first, 2); + res.second = sqrt(blitz::sum(ssat * nc) / blitz::sum(nc)); + } + else + { + res.first = 0; + res.second = 0; + } + + return res; + } + + // mean and std_dev of number of SDs (characteristics of the spatial distribution at this timestep) + std::pair sdconc_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + arr_t sdconc(this->h5load_timestep("sd_conc", at)); + return hlpr(sdconc, at); + } + + // mean and std_dev of number of SDs in cloudy cells (characteristics of the spatial distribution at this timestep) + std::pair cloud_sdconc_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + arr_t sdconc(this->h5load_timestep("sd_conc", at)); + return cloud_hlpr(sdconc, at); + } - float ret; - notice_macro(std::string("about to open attribute: " + attr_name)) - auto attr = h5g.openAttribute(attr_name); - notice_macro(std::string("about to read attribute value")) - attr.read(attr.getDataType(), &ret); - notice_macro(std::string("attribute value read: ") + std::to_string(ret)) - return ret; + // mean and std_dev of number of activated SDs in cloudy cells (characteristics of the spatial distribution at this timestep) + std::pair cloud_sdconc_act_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + arr_t sdconc_act(this->h5load_timestep("sd_conc_act", at)); + return cloud_hlpr(sdconc_act, at); } - template - void plot(gp_t &gp) + // mean and std_dev of mean radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) + std::pair cloud_meanr_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + // read act drop 0th raw moment / mass [1/kg] + arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); + // read act drop 1st raw moment / mass [um/kg] + arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); + // calculate mean radius, store in act1st + act1st = where(act0th > 0, act1st / act0th, 0.); + return cloud_hlpr(act1st, at); + } + + // mean and std_dev of std_dev of radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) + std::pair cloud_stddevr_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + // read act drop 0th raw moment / mass [1/kg] + arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); + // read act drop 1st raw moment / mass [um/kg] + arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); + // read act drop 2nd raw moment / mass [um^2/kg] + arr_t act2nd(this->h5load_timestep("actrw_rw_mom2", at) * 1e12); + // calculate stddev of radius, store in act1st + act1st = where(act0th > 0, + act2nd / act0th - act1st / act0th * act1st / act0th, 0.); + // might be slightly negative due to numerical errors + act1st = where(act1st < 0, 0, act1st); + act1st = sqrt(act1st); + return cloud_hlpr(act1st, at); + } + + // mean and std_dev of temperature [K] (characteristics of the spatial distribution at this timestep, without near-wall cells) + std::pair T_stats_timestep(int at) + { + // read theta away from walls + //arr_t tht(this->nowall(arr_t(this->h5load_timestep("th", at)), distance_from_walls)); + arr_t tht(arr_t(this->h5load_timestep("th", at))); + tht *= pow(this->map_prof["p_e"](this->LastIndex) / p_1000, R_d / c_pd); // tht -> T + return hlpr(tht, at); + } + + // mean and std_dev of r_v [1] (characteristics of the spatial distribution at this timestep) + std::pair rv_stats_timestep(int at) + { + arr_t rv(arr_t(this->h5load_timestep("rv", at))); + return hlpr(rv, at); + } + + // mean and std_dev of RH [1] (characteristics of the spatial distribution at this timestep) + std::pair RH_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + std::pair res; + + arr_t RH(this->h5load_timestep("RH", at)); + return hlpr(RH, at); + } + + // surface precipitation since last output [mm/day] + double calc_surf_precip(double prec_vol_diff) { - //gp << "set cbtics format \"%.2tE%+03T\"\n"; - gp << "set cbtics font \", 8\"\n"; - // gp << "set rmargin 2cm\n"; + if(this->micro == "lgrngn") + return prec_vol_diff / this->DomainSurf / (double(this->map["outfreq"]) * this->map["dt"] / 3600. / 24.) * 1e3; // SDM + if(this->micro == "blk_1m" || this->micro == "blk_2m") + return prec_vol_diff / double(this->map["outfreq"]) // flux in [kg / m^3 / s] averaged over time since last output and over cells on the bottom + / (this->map["x"] * this->map["y"]) + * 3600. * 24. // per day + * this->map["dz"] // per m^2 + / 1e3 // to m^3 of water + * 1e3; // to mm } - public: + // accumulated surface precipitation [mm] + double calc_acc_surf_precip(double prec_vol) + { + if(this->micro == "lgrngn") + return prec_vol / this->DomainSurf * 1e3; + if(this->micro == "blk_1m" || this->micro == "blk_2m") + return prec_vol * this->map["dt"] + / (this->map["x"] * this->map["y"]) + * this->map["dz"] // per m^2 + / 1e3 // to m^3 of water + * 1e3; // to mm + } - float h5load_attr_timestep(int at, const std::string attr_name, const std::string group_name = "/") + // droplet removal rate (at boundaries) since last output [1/(cm^3 s)] + double calc_prtcl_removal(double prtcl_removal_diff) { - string timestep_file = file + "/timestep" + zeropad(at, 10) + ".h5"; - return h5load_attr(timestep_file, attr_name, group_name); + if(this->micro == "lgrngn") + return prtcl_removal_diff / this->DomainVol / (double(this->map["outfreq"]) * this->map["dt"]) / 1e6; + if(this->micro == "blk_1m") + return 0; } - //ctor - PlotterCommon(const string &file): - file(file) + // heat flux thru boundary since last output [W/m^2] + double calc_heat_flux(double tot_th_diff, int z_idx) // input in [K] { - // init h5f - notice_macro("about to open file: " << file << "/const.h5") - h5f.openFile(file + "/const.h5", H5F_ACC_RDONLY); + if(this->micro == "lgrngn") + { + tot_th_diff *= pow(this->map_prof["p_e"](z_idx) / p_1000, R_d / c_pd); // tht -> T + double ret = tot_th_diff * c_pd * this->map_prof["rhod"](z_idx) // sum of th diff over boundary cells since last output (K) * c_pd * density + * this->map["dz"] / ((this->map["x"]-1) * (this->map["y"]-1)) // multiply by cell volume and divide by domain surface area (without walls) + * (double(this->map["outfreq"]) * this->map["dt"]); // divide by time since last output + return ret; + } + if(this->micro == "blk_1m") + return 0; + } - // init dt and outfreq + double calc_heat_flux_top(double mean_th_diff, bool errfix) + { + double tot_th_diff = mean_th_diff * this->map["x"] * this->map["y"]; + if(errfix) { - map["dt"] = h5load_attr(file + "/const.h5", "dt", "advection"); - map["outfreq"] = h5load_attr(file + "/const.h5", "outfreq", "user_params"); - map["MPI_compiler"] = h5load_attr(file + "/const.h5", "MPI compiler (true/false)", "MPI details"); - - // read number of timesteps - hsize_t n; - h5load(file + "/const.h5", "T"); - h5s.getSimpleExtentDims(&n, NULL); - this->map["t"] = n; - // read timesteps - timesteps.resize(n); - h5d.read(timesteps.data(), H5::PredType::NATIVE_FLOAT); - - // read environmental pressure profile - h5load(file + "/const.h5", "p_e"); - h5s.getSimpleExtentDims(&n, NULL); - map_prof.emplace("p_e", arr_prof_t(n)); - h5d.read(map_prof["p_e"].data(), H5::PredType::NATIVE_FLOAT); - - // read SGS mixing length profile - h5load(file + "/const.h5", "mix_len"); - h5s.getSimpleExtentDims(&n, NULL); - map_prof.emplace("mix_len", arr_prof_t(n)); - h5d.read(map_prof["mix_len"].data(), H5::PredType::NATIVE_FLOAT); - - // read dry air density profile - h5load(file + "/const.h5", "rhod"); - h5s.getSimpleExtentDims(&n, NULL); - map_prof.emplace("rhod", arr_prof_t(n)); - h5d.read(map_prof["rhod"].data(), H5::PredType::NATIVE_FLOAT); - - // read dry air density profile on refined grid - h5load(file + "/const.h5", "refined rhod"); - h5s.getSimpleExtentDims(&n, NULL); - map_prof.emplace("refined rhod", arr_prof_t(n)); - h5d.read(map_prof["refined rhod"].data(), H5::PredType::NATIVE_FLOAT); + // th_diff += (this->map["x"] * this->map["y"] - 1) * 280; // to counter to error in tot_th_diff calculation in UWLCM + tot_th_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (280 - 285); // dont count side wall } + return calc_heat_flux(tot_th_diff, this->map["z"]-1); + } + + double calc_heat_flux_bot(double mean_th_diff, bool errfix) + { + double tot_th_diff = mean_th_diff * this->map["x"] * this->map["y"]; + if(errfix) + { + // th_diff += (this->map["x"] * this->map["y"] - 1) * 299; + tot_th_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (299 - 285); + } + return calc_heat_flux(tot_th_diff, 0); + } + + // kinematic rv flux thru boundary since last output [kg/kg * m / s] + double calc_moist_flux(double tot_rv_diff) // rv change summed over horizontal plane [kg/kg] + { + if(this->micro == "lgrngn") + { + return tot_rv_diff * this->map["dz"] + * (double(this->map["outfreq"]) * this->map["dt"]); // divide by time since last output + } + if(this->micro == "blk_1m") + return 0; + } + + double calc_moist_flux_top(double mean_rv_diff, bool errfix) + { + // 3D assumed here! + double tot_rv_diff = mean_rv_diff * this->map["x"] * this->map["y"]; + if(errfix) + { +// rv_diff += (this->map["x"] * this->map["y"] - 1) * 0.0062192674278; // to counter to error in tot_rv_diff calculation in UWLCM + tot_rv_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (0.0062192674278 - 0.00611718803008); // dont count side wall + } + return calc_moist_flux(tot_rv_diff); + } + + double calc_moist_flux_bot(double mean_rv_diff, bool errfix) + { + // 3D assumed here! + double tot_rv_diff = mean_rv_diff * this->map["x"] * this->map["y"]; + if(errfix) + { +// rv_diff += (this->map["x"] * this->map["y"] - 1) * 0.0213489271007; // to counter to error in tot_rv_diff calculation in UWLCM + tot_rv_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (0.0213489271007 - 0.00611718803008); // dont count side wall + } + return calc_moist_flux(tot_rv_diff); + } + + //ctor + /* + PlotterCommon(const string &file, const string µ): + parent_t(file), + micro(micro), + res(this->tmp.shape()), + rhod(this->h5load(file + "/const.h5", "G")) + */ + { } }; diff --git a/UWLCM_plotters/include/PlotterH5.hpp b/UWLCM_plotters/include/PlotterH5.hpp new file mode 100644 index 0000000..0b60dfe --- /dev/null +++ b/UWLCM_plotters/include/PlotterH5.hpp @@ -0,0 +1,133 @@ +#pragma once + +#include +#include +#include +#include + +class PlotterH5 +{ + public: + using arr_prof_t = blitz::Array; + + const string file; + std::map map; + std::map map_prof; + blitz::Array timesteps; + double CellVol, DomainSurf, DomainVol, CellVol_ref; + + protected: + H5::H5File h5f; + H5::DataSet h5d; + H5::Group h5g; + H5::DataSpace h5s; + + void h5load( + const string &file, + const string &dataset, + bool srfc = false + ) + { + if(h5f.getFileName() != file) + { + notice_macro("about to close current file: " << h5f.getFileName()) + h5f.close(); + + notice_macro("about to open file: " << file) + h5f.openFile(file, H5F_ACC_RDONLY); + } + + notice_macro("about to read dataset: " << dataset) + h5d = h5f.openDataSet(dataset); + h5s = h5d.getSpace(); + } + + float h5load_attr(const string &file, const string &attr_name, const string &group_name) + { + if(h5f.getFileName() != file) + { + notice_macro("about to close current file: " << h5f.getFileName()) + h5f.close(); + + notice_macro("about to open file: " << file) + h5f.openFile(file, H5F_ACC_RDONLY); + } + + notice_macro(std::string("about to read group: " + group_name)) + h5g = h5f.openGroup(group_name); + + float ret; + notice_macro(std::string("about to open attribute: " + attr_name)) + auto attr = h5g.openAttribute(attr_name); + notice_macro(std::string("about to read attribute value")) + attr.read(attr.getDataType(), &ret); + notice_macro(std::string("attribute value read: ") + std::to_string(ret)) + return ret; + } + + template + void plot(gp_t &gp) + { + //gp << "set cbtics format \"%.2tE%+03T\"\n"; + gp << "set cbtics font \", 8\"\n"; + // gp << "set rmargin 2cm\n"; + } + + public: + + float h5load_attr_timestep(int at, const std::string attr_name, const std::string group_name = "/") + { + string timestep_file = file + "/timestep" + zeropad(at, 10) + ".h5"; + return h5load_attr(timestep_file, attr_name, group_name); + } + + //ctor + PlotterH5(const string &file): + file(file) + { + // init h5f + notice_macro("about to open file: " << file << "/const.h5") + h5f.openFile(file + "/const.h5", H5F_ACC_RDONLY); + + // init dt and outfreq + { + map["dt"] = h5load_attr(file + "/const.h5", "dt", "advection"); + map["outfreq"] = h5load_attr(file + "/const.h5", "outfreq", "user_params"); + map["MPI_compiler"] = h5load_attr(file + "/const.h5", "MPI compiler (true/false)", "MPI details"); + + // read number of timesteps + hsize_t n; + h5load(file + "/const.h5", "T"); + h5s.getSimpleExtentDims(&n, NULL); + this->map["t"] = n; + // read timesteps + timesteps.resize(n); + h5d.read(timesteps.data(), H5::PredType::NATIVE_FLOAT); + + // read environmental pressure profile + h5load(file + "/const.h5", "p_e"); + h5s.getSimpleExtentDims(&n, NULL); + map_prof.emplace("p_e", arr_prof_t(n)); + h5d.read(map_prof["p_e"].data(), H5::PredType::NATIVE_FLOAT); + + // read SGS mixing length profile + h5load(file + "/const.h5", "mix_len"); + h5s.getSimpleExtentDims(&n, NULL); + map_prof.emplace("mix_len", arr_prof_t(n)); + h5d.read(map_prof["mix_len"].data(), H5::PredType::NATIVE_FLOAT); + + // read dry air density profile + h5load(file + "/const.h5", "rhod"); + h5s.getSimpleExtentDims(&n, NULL); + map_prof.emplace("rhod", arr_prof_t(n)); + h5d.read(map_prof["rhod"].data(), H5::PredType::NATIVE_FLOAT); + + // read dry air density profile on refined grid + h5load(file + "/const.h5", "refined rhod"); + h5s.getSimpleExtentDims(&n, NULL); + map_prof.emplace("refined rhod", arr_prof_t(n)); + h5d.read(map_prof["refined rhod"].data(), H5::PredType::NATIVE_FLOAT); + } + } +}; + diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index e4a2aa4..4af945f 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -1,14 +1,12 @@ #pragma once -#include "Plotter2d.hpp" -#include "Plotter3d.hpp" -#include +#include "PlotterCommon.hpp" // TODO: make two: plotterlgrngn and plotter blk1m template -class PlotterMicro_t : public Plotter_t +class PlotterMicro_t : public PlotterCommon { protected: - using parent_t = Plotter_t; + using parent_t = PlotterCommon; public: using arr_t = typename parent_t::arr_t; @@ -20,30 +18,11 @@ class PlotterMicro_t : public Plotter_t const double L_evap = 2264.76e3; // latent heat of evaporation [J/kg] public: - void multiply_by_rhod(arr_t &arr) - { - if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) - arr *= this->map_prof["rhod"](this->LastIndex); - else if(arr.extent(NDims-1) == this->map_prof["refined rhod"].extent(0)) - arr *= this->map_prof["refined rhod"](this->LastIndex); - else - throw std::runtime_error("multiply_by_rhod: input array is neither normal grid size nor refined grid size"); - } - - void multiply_by_CellVol(arr_t &arr) - { - if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) - arr *= this->CellVol; - else if(arr.extent(NDims-1) == this->map_prof["refined rhod"].extent(0)) - arr *= this->CellVol_ref; - else - throw std::runtime_error("multiply_by_CellVol: input array is neither normal grid size nor refined grid size"); - } // functions for diagnosing fields // // aerosol droplets mixing ratio - auto h5load_ra_timestep( + auto load_ra_timestep( int at ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { @@ -59,7 +38,7 @@ class PlotterMicro_t : public Plotter_t } // cloud droplets mixing ratio - auto h5load_rc_timestep( + auto load_rc_timestep( int at ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { @@ -72,7 +51,7 @@ class PlotterMicro_t : public Plotter_t } // rain droplets mixing ratio - auto h5load_rr_timestep( + auto load_rr_timestep( int at ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { @@ -85,7 +64,7 @@ class PlotterMicro_t : public Plotter_t } // activated drops mixing ratio - auto h5load_ract_timestep( + auto load_ract_timestep( int at ) { @@ -111,7 +90,7 @@ class PlotterMicro_t : public Plotter_t } // cloud droplets concentration [1/kg] - auto h5load_nc_timestep( + auto load_nc_timestep( int at ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { @@ -128,7 +107,7 @@ class PlotterMicro_t : public Plotter_t } // precipitation flux [W/m2] - auto h5load_prflux_timestep( + auto load_prflux_timestep( int at )// -> decltype(blitz::safeToReturn(arr_t() + 0)) { @@ -158,7 +137,7 @@ class PlotterMicro_t : public Plotter_t } // RH - auto h5load_RH_timestep( + auto load_RH_timestep( int at ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { @@ -172,58 +151,11 @@ class PlotterMicro_t : public Plotter_t // functions for diagnosing statistics - - // helper function that calculates staistics (mean and std_dev) of a field - std::pair hlpr(arr_t arr, int at) - { - std::pair res; - res.first = blitz::mean(arr); - arr = pow(arr - res.first, 2); - res.second = sqrt(blitz::mean(arr)); - return res; - } - - // helper function that calculates staistics (mean and std_dev) of a field only in cloudy cells - std::pair cloud_hlpr(arr_t arr, int at) - { - std::pair res; - // read activated droplets mixing ratio - arr_t mask(h5load_ract_timestep(at)); - mask = iscloudy_rc(mask); - arr *= mask; // apply filter - - if(blitz::sum(mask) > 0.) - res.first = blitz::sum(arr) / blitz::sum(mask); - else - res.first = 0.; - - arr = pow(arr - res.first, 2); - arr *= mask; // apply filter - if(res.first>0) - res.second = sqrt(blitz::sum(arr) / blitz::sum(mask)); - else - res.second = 0.; - - return res; - } - - // height [m] of the center of mass of activated droplets - double act_com_z_timestep(int at) - { - arr_t ract(h5load_ract_timestep(at)); - arr_t weighted(ract.copy()); - weighted = weighted * this->LastIndex * this->map["dz"]; - if(blitz::sum(ract) > 1e-3) - return blitz::sum(weighted) / blitz::sum(ract); - else - return 0.; - } - // mean and std dev [g/kg] of the mixing ratio of activated dropelts in cloudy cells (characteristics of the spatial distribution at this timestep) std::pair cloud_ract_stats_timestep(int at) { // read activated droplets mixing ratio - arr_t ract(h5load_ract_timestep(at)); + arr_t ract(load_ract_timestep(at)); ract *= 1e3; // turn it into g/kg return cloud_hlpr(ract, at); } From 84c5a6fd7f00ee74492d415b4687bc444f5f05cc Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Wed, 14 Dec 2022 15:41:10 +0100 Subject: [PATCH 09/51] handle output from non-refined UWLCM --- UWLCM_plotters/include/Plotter3d.hpp | 40 ++++++++++++++++-------- UWLCM_plotters/include/PlotterCommon.hpp | 16 +++++++--- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/UWLCM_plotters/include/Plotter3d.hpp b/UWLCM_plotters/include/Plotter3d.hpp index 86692f7..4f99ed8 100644 --- a/UWLCM_plotters/include/Plotter3d.hpp +++ b/UWLCM_plotters/include/Plotter3d.hpp @@ -239,19 +239,33 @@ class Plotter_t<3> : public PlotterCommon tmp_srfc.resize(n[0]-1, n[1]-1, 1); // init refined data - this->h5f.openDataSet("X refined").getSpace().getSimpleExtentDims(n, NULL); - this->map["refined x"] = n[0]-1; - this->map["refined y"] = n[1]-1; - this->map["refined z"] = n[2]-1; - tmp_ref.resize(n[0], n[1], n[2]); - h5load(file + "/const.h5", "X refined"); - this->map["refined dx"] = tmp_ref(1,0,0) - tmp_ref(0,0,0); - h5load(file + "/const.h5", "Y refined"); - this->map["refined dy"] = tmp_ref(0,1,0) - tmp_ref(0,0,0); - h5load(file + "/const.h5", "Z refined"); - this->map["refined dz"] = tmp_ref(0,0,1) - tmp_ref(0,0,0); - this->CellVol_ref = this->map["refined dx"] * this->map["refined dy"] * this->map["refined dz"]; - tmp_ref.resize(n[0]-1, n[1]-1, n[2]-1); + try + { + this->h5f.openDataSet("X refined").getSpace().getSimpleExtentDims(n, NULL); + this->map["refined x"] = n[0]-1; + this->map["refined y"] = n[1]-1; + this->map["refined z"] = n[2]-1; + tmp_ref.resize(n[0], n[1], n[2]); + h5load(file + "/const.h5", "X refined"); + this->map["refined dx"] = tmp_ref(1,0,0) - tmp_ref(0,0,0); + h5load(file + "/const.h5", "Y refined"); + this->map["refined dy"] = tmp_ref(0,1,0) - tmp_ref(0,0,0); + h5load(file + "/const.h5", "Z refined"); + this->map["refined dz"] = tmp_ref(0,0,1) - tmp_ref(0,0,0); + this->CellVol_ref = this->map["refined dx"] * this->map["refined dy"] * this->map["refined dz"]; + tmp_ref.resize(n[0]-1, n[1]-1, n[2]-1); + } + catch(...) // for pre-refinement simulations that didnt store refined stuff + { + this->map["refined x"] = this->map["x"]; + this->map["refined y"] = this->map["y"]; + this->map["refined z"] = this->map["z"]; + this->map["refined dx"] = this->map["dx"]; + this->map["refined dy"] = this->map["dy"]; + this->map["refined dz"] = this->map["dz"]; + this->CellVol_ref = this->CellVol; + tmp_ref.resize(tmp.shape()); + } for (auto const& x : this->map) { diff --git a/UWLCM_plotters/include/PlotterCommon.hpp b/UWLCM_plotters/include/PlotterCommon.hpp index 0110c5d..5501425 100644 --- a/UWLCM_plotters/include/PlotterCommon.hpp +++ b/UWLCM_plotters/include/PlotterCommon.hpp @@ -123,10 +123,18 @@ class PlotterCommon h5d.read(map_prof["rhod"].data(), H5::PredType::NATIVE_FLOAT); // read dry air density profile on refined grid - h5load(file + "/const.h5", "refined rhod"); - h5s.getSimpleExtentDims(&n, NULL); - map_prof.emplace("refined rhod", arr_prof_t(n)); - h5d.read(map_prof["refined rhod"].data(), H5::PredType::NATIVE_FLOAT); + try + { + h5load(file + "/const.h5", "refined rhod"); + h5s.getSimpleExtentDims(&n, NULL); + map_prof.emplace("refined rhod", arr_prof_t(n)); + h5d.read(map_prof["refined rhod"].data(), H5::PredType::NATIVE_FLOAT); + } + catch(...) // for pre-refinement simulations, use rhod as refined rhod + { + map_prof.emplace("refined rhod", map_prof["rhod"].copy()); + std::cerr << "refined rhod as copy of rhod: " << map_prof["refined rhod"]; + } } } }; From 1ddb63a43ed9b4daa8707f6431ec53d8a95223cc Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Wed, 14 Dec 2022 16:29:08 +0100 Subject: [PATCH 10/51] plottermask --- UWLCM_plotters/include/Plotter.hpp | 315 ----------------------- UWLCM_plotters/include/PlotterCommon.hpp | 24 -- UWLCM_plotters/include/PlotterMask.hpp | 144 +++++++++++ UWLCM_plotters/include/PlotterMicro.hpp | 89 +------ 4 files changed, 148 insertions(+), 424 deletions(-) delete mode 100644 UWLCM_plotters/include/Plotter.hpp create mode 100644 UWLCM_plotters/include/PlotterMask.hpp diff --git a/UWLCM_plotters/include/Plotter.hpp b/UWLCM_plotters/include/Plotter.hpp deleted file mode 100644 index eb8e68a..0000000 --- a/UWLCM_plotters/include/Plotter.hpp +++ /dev/null @@ -1,315 +0,0 @@ -#pragma once -#include "PlotterMicro.hpp" - -// TODO: make two: plotterlgrngn and plotter blk1m -template -class Plotter : public PlotterMicro -{ - protected: - using parent_t = PlotterMicro; - - public: - using arr_t = typename parent_t::arr_t; - - public: - - // functions for diagnosing statistics - // mean and std dev [g/kg] of the mixing ratio of activated dropelts in cloudy cells (characteristics of the spatial distribution at this timestep) - std::pair cloud_ract_stats_timestep(int at) - { - // read activated droplets mixing ratio - arr_t ract(h5load_ract_timestep(at)); - ract *= 1e3; // turn it into g/kg - return cloud_hlpr(ract, at); - } - - // mean and std_dev of concentration of activated droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) - std::pair cloud_actconc_stats_timestep(int at) - { - arr_t actconc; - // read concentration of activated droplets - if(this->micro == "blk_1m") return {0,0}; - // TODO: fix stupid copying of arrays - else if(this->micro == "lgrngn") { - arr_t tmp(this->h5load_timestep("actrw_rw_mom0", at)); - actconc.resize(tmp.shape()); - actconc = tmp; - } - else if(this->micro == "blk_2m") { - arr_t tmp(arr_t(this->h5load_timestep("nc", at)) + arr_t(this->h5load_timestep("nr", at))); - actconc.resize(tmp.shape()); - actconc = tmp; - } - actconc *= rhod; // b4 it was specific moment - actconc /= 1e6; // per cm^3 - return cloud_hlpr(actconc, at); - } - - // mean and std_dev of supersaturation in cells with positive supersaturation [%] (characteristics of the spatial distribution at this timestep) - std::pair positive_supersat_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - std::pair res; - - // read RH - arr_t RH(this->h5load_timestep("RH", at)); - RH -= 1.; - arr_t sat(RH.copy()); - sat = iscloudy_sat(RH); - RH *= sat; //apply the cloudiness mask - RH *= 100; // to get % - if(blitz::sum(sat) > 0) - res.first = blitz::sum(RH) / blitz::sum(sat); - else - res.first = 0; - - RH = pow(RH - res.first, 2); - RH *= sat; // apply filter - if(res.first>0) - res.second = sqrt(blitz::sum(RH) / blitz::sum(sat)); - else - res.second = 0.; - - return res; - } - - // mean and std_dev of supersaturation at droplet locations (i.e. supersat weighted by the number of droplets) - std::pair drop_supersat_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - std::pair res; - - // read supersat - arr_t ssat(this->h5load_timestep("RH", at)); - ssat -= 1.; - - // read number of droplets per cell - arr_t nc(this->h5load_timestep("cloud_rw_mom0", at)); - nc *= rhod; // [1/m^3] - nc *= this->dv; - - - if(blitz::sum(nc) > 0) - { - res.first = blitz::sum(ssat * nc) / blitz::sum(nc); - ssat = pow(ssat - res.first, 2); - res.second = sqrt(blitz::sum(ssat * nc) / blitz::sum(nc)); - } - else - { - res.first = 0; - res.second = 0; - } - - return res; - } - - // mean and std_dev of number of SDs (characteristics of the spatial distribution at this timestep) - std::pair sdconc_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - arr_t sdconc(this->h5load_timestep("sd_conc", at)); - return hlpr(sdconc, at); - } - - // mean and std_dev of number of SDs in cloudy cells (characteristics of the spatial distribution at this timestep) - std::pair cloud_sdconc_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - arr_t sdconc(this->h5load_timestep("sd_conc", at)); - return cloud_hlpr(sdconc, at); - } - - // mean and std_dev of number of activated SDs in cloudy cells (characteristics of the spatial distribution at this timestep) - std::pair cloud_sdconc_act_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - arr_t sdconc_act(this->h5load_timestep("sd_conc_act", at)); - return cloud_hlpr(sdconc_act, at); - } - - // mean and std_dev of mean radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) - std::pair cloud_meanr_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - // read act drop 0th raw moment / mass [1/kg] - arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); - // read act drop 1st raw moment / mass [um/kg] - arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); - // calculate mean radius, store in act1st - act1st = where(act0th > 0, act1st / act0th, 0.); - return cloud_hlpr(act1st, at); - } - - // mean and std_dev of std_dev of radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) - std::pair cloud_stddevr_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - // read act drop 0th raw moment / mass [1/kg] - arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); - // read act drop 1st raw moment / mass [um/kg] - arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); - // read act drop 2nd raw moment / mass [um^2/kg] - arr_t act2nd(this->h5load_timestep("actrw_rw_mom2", at) * 1e12); - // calculate stddev of radius, store in act1st - act1st = where(act0th > 0, - act2nd / act0th - act1st / act0th * act1st / act0th, 0.); - // might be slightly negative due to numerical errors - act1st = where(act1st < 0, 0, act1st); - act1st = sqrt(act1st); - return cloud_hlpr(act1st, at); - } - - // mean and std_dev of temperature [K] (characteristics of the spatial distribution at this timestep, without near-wall cells) - std::pair T_stats_timestep(int at) - { - // read theta away from walls - //arr_t tht(this->nowall(arr_t(this->h5load_timestep("th", at)), distance_from_walls)); - arr_t tht(arr_t(this->h5load_timestep("th", at))); - tht *= pow(this->map_prof["p_e"](this->LastIndex) / p_1000, R_d / c_pd); // tht -> T - return hlpr(tht, at); - } - - // mean and std_dev of r_v [1] (characteristics of the spatial distribution at this timestep) - std::pair rv_stats_timestep(int at) - { - arr_t rv(arr_t(this->h5load_timestep("rv", at))); - return hlpr(rv, at); - } - - // mean and std_dev of RH [1] (characteristics of the spatial distribution at this timestep) - std::pair RH_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - std::pair res; - - arr_t RH(this->h5load_timestep("RH", at)); - return hlpr(RH, at); - } - - // surface precipitation since last output [mm/day] - double calc_surf_precip(double prec_vol_diff) - { - if(this->micro == "lgrngn") - return prec_vol_diff / this->DomainSurf / (double(this->map["outfreq"]) * this->map["dt"] / 3600. / 24.) * 1e3; // SDM - if(this->micro == "blk_1m" || this->micro == "blk_2m") - return prec_vol_diff / double(this->map["outfreq"]) // flux in [kg / m^3 / s] averaged over time since last output and over cells on the bottom - / (this->map["x"] * this->map["y"]) - * 3600. * 24. // per day - * this->map["dz"] // per m^2 - / 1e3 // to m^3 of water - * 1e3; // to mm - } - - // accumulated surface precipitation [mm] - double calc_acc_surf_precip(double prec_vol) - { - if(this->micro == "lgrngn") - return prec_vol / this->DomainSurf * 1e3; - if(this->micro == "blk_1m" || this->micro == "blk_2m") - return prec_vol * this->map["dt"] - / (this->map["x"] * this->map["y"]) - * this->map["dz"] // per m^2 - / 1e3 // to m^3 of water - * 1e3; // to mm - } - // accumulated volume precipitation [m^3] - double calc_acc_surf_precip_volume(double prec_vol) - { - if(this->micro == "lgrngn") - return calc_acc_surf_precip(prec_vol) * this->DomainSurf / 1000.; - if(this->micro == "blk_1m") - return calc_acc_surf_precip(prec_vol) * this->DomainSurf / 1000.;// to m^3 of water - } - // droplet removal rate (at boundaries) since last output [1/(cm^3 s)] - double calc_prtcl_removal(double prtcl_removal_diff) - { - if(this->micro == "lgrngn") - return prtcl_removal_diff / this->DomainVol / (double(this->map["outfreq"]) * this->map["dt"]) / 1e6; - if(this->micro == "blk_1m") - return 0; - } - - // heat flux thru boundary since last output [W/m^2] - double calc_heat_flux(double tot_th_diff, int z_idx) // input in [K] - { - if(this->micro == "lgrngn") - { - tot_th_diff *= pow(this->map_prof["p_e"](z_idx) / p_1000, R_d / c_pd); // tht -> T - double ret = tot_th_diff * c_pd * this->map_prof["rhod"](z_idx) // sum of th diff over boundary cells since last output (K) * c_pd * density - * this->map["dz"] / ((this->map["x"]-1) * (this->map["y"]-1)) // multiply by cell volume and divide by domain surface area (without walls) - * (double(this->map["outfreq"]) * this->map["dt"]); // divide by time since last output - return ret; - } - if(this->micro == "blk_1m") - return 0; - } - - double calc_heat_flux_top(double mean_th_diff, bool errfix) - { - double tot_th_diff = mean_th_diff * this->map["x"] * this->map["y"]; - if(errfix) - { - // th_diff += (this->map["x"] * this->map["y"] - 1) * 280; // to counter to error in tot_th_diff calculation in UWLCM - tot_th_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (280 - 285); // dont count side wall - } - return calc_heat_flux(tot_th_diff, this->map["z"]-1); - } - - double calc_heat_flux_bot(double mean_th_diff, bool errfix) - { - double tot_th_diff = mean_th_diff * this->map["x"] * this->map["y"]; - if(errfix) - { - // th_diff += (this->map["x"] * this->map["y"] - 1) * 299; - tot_th_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (299 - 285); - } - return calc_heat_flux(tot_th_diff, 0); - } - - // kinematic rv flux thru boundary since last output [kg/kg * m / s] - double calc_moist_flux(double tot_rv_diff) // rv change summed over horizontal plane [kg/kg] - { - if(this->micro == "lgrngn") - { - return tot_rv_diff * this->map["dz"] - * (double(this->map["outfreq"]) * this->map["dt"]); // divide by time since last output - } - if(this->micro == "blk_1m") - return 0; - } - - double calc_moist_flux_top(double mean_rv_diff, bool errfix) - { - // 3D assumed here! - double tot_rv_diff = mean_rv_diff * this->map["x"] * this->map["y"]; - if(errfix) - { -// rv_diff += (this->map["x"] * this->map["y"] - 1) * 0.0062192674278; // to counter to error in tot_rv_diff calculation in UWLCM - tot_rv_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (0.0062192674278 - 0.00611718803008); // dont count side wall - } - return calc_moist_flux(tot_rv_diff); - } - - double calc_moist_flux_bot(double mean_rv_diff, bool errfix) - { - // 3D assumed here! - double tot_rv_diff = mean_rv_diff * this->map["x"] * this->map["y"]; - if(errfix) - { -// rv_diff += (this->map["x"] * this->map["y"] - 1) * 0.0213489271007; // to counter to error in tot_rv_diff calculation in UWLCM - tot_rv_diff -= (2*this->map["x"] + 2*(this->map["y"] - 1)) * (0.0213489271007 - 0.00611718803008); // dont count side wall - } - return calc_moist_flux(tot_rv_diff); - } - - //ctor - Plotter(const string &file, const string µ): - parent_t(file), - micro(micro), - res(this->tmp.shape()), - rhod(this->h5load(file + "/const.h5", "G")) - { - } -}; - diff --git a/UWLCM_plotters/include/PlotterCommon.hpp b/UWLCM_plotters/include/PlotterCommon.hpp index 87d25e7..32f7db8 100644 --- a/UWLCM_plotters/include/PlotterCommon.hpp +++ b/UWLCM_plotters/include/PlotterCommon.hpp @@ -47,30 +47,6 @@ class PlotterCommon : public Plotter_t res.second = sqrt(blitz::mean(arr)); return res; } - - // helper function that calculates staistics (mean and std_dev) of a field only in cloudy cells - std::pair cloud_hlpr(arr_t arr, int at) - { - std::pair res; - // read activated droplets mixing ratio - arr_t mask(h5load_ract_timestep(at)); - mask = iscloudy_rc(mask); - arr *= mask; // apply filter - - if(blitz::sum(mask) > 0.) - res.first = blitz::sum(arr) / blitz::sum(mask); - else - res.first = 0.; - - arr = pow(arr - res.first, 2); - arr *= mask; // apply filter - if(res.first>0) - res.second = sqrt(blitz::sum(arr) / blitz::sum(mask)); - else - res.second = 0.; - - return res; - } // height [m] of the center of mass of activated droplets double act_com_z_timestep(int at) diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp new file mode 100644 index 0000000..9d79755 --- /dev/null +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -0,0 +1,144 @@ +#pragma once +#include "PlotterMicro.hpp" + +// TODO: make two: plotterlgrngn and plotter blk1m +template +class PlotterMask : public PlotterMicro +{ + protected: + using parent_t = PlotterMicro; + + private: + + arr_t mask; + + lgrngn_droplet_prefix + cloud_mask + + + public: + using arr_t = typename parent_t::arr_t; + + private: + // helper function that calculates staistics (mean and std_dev) of a field only in cloudy cells + std::pair cloud_hlpr(arr_t arr, int at) + { + std::pair res; + // read activated droplets mixing ratio + arr_t mask(h5load_ract_timestep(at)); + mask = iscloudy_rc(mask); + arr *= mask; // apply filter + + if(blitz::sum(mask) > 0.) + res.first = blitz::sum(arr) / blitz::sum(mask); + else + res.first = 0.; + + arr = pow(arr - res.first, 2); + arr *= mask; // apply filter + if(res.first>0) + res.second = sqrt(blitz::sum(arr) / blitz::sum(mask)); + else + res.second = 0.; + + return res; + } + + public: + + + + // functions for diagnosing statistics + // mean and std dev [g/kg] of the mixing ratio of activated dropelts in cloudy cells (characteristics of the spatial distribution at this timestep) + std::pair cloud_ract_stats_timestep(int at) + { + // read activated droplets mixing ratio + arr_t ract(load_ract_timestep(at)); + ract *= 1e3; // turn it into g/kg + return cloud_hlpr(ract, at); + } + + // mean and std_dev of concentration of activated droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) + std::pair cloud_actconc_stats_timestep(int at) + { + arr_t actconc; + // read concentration of activated droplets + if(this->micro == "blk_1m") return {0,0}; + // TODO: fix stupid copying of arrays + else if(this->micro == "lgrngn") { + arr_t tmp(this->h5load_timestep("actrw_rw_mom0", at)); + actconc.resize(tmp.shape()); + actconc = tmp; + } + else if(this->micro == "blk_2m") { + arr_t tmp(arr_t(this->h5load_timestep("nc", at)) + arr_t(this->h5load_timestep("nr", at))); + actconc.resize(tmp.shape()); + actconc = tmp; + } + actconc *= rhod; // b4 it was specific moment + actconc /= 1e6; // per cm^3 + return cloud_hlpr(actconc, at); + } + + + + + // mean and std_dev of number of SDs in cloudy cells (characteristics of the spatial distribution at this timestep) + std::pair cloud_sdconc_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + arr_t sdconc(this->h5load_timestep("sd_conc", at)); + return cloud_hlpr(sdconc, at); + } + + // mean and std_dev of number of activated SDs in cloudy cells (characteristics of the spatial distribution at this timestep) + std::pair cloud_sdconc_act_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + arr_t sdconc_act(this->h5load_timestep("sd_conc_act", at)); + return cloud_hlpr(sdconc_act, at); + } + + // mean and std_dev of mean radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) + std::pair cloud_meanr_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + // read act drop 0th raw moment / mass [1/kg] + arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); + // read act drop 1st raw moment / mass [um/kg] + arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); + // calculate mean radius, store in act1st + act1st = where(act0th > 0, act1st / act0th, 0.); + return cloud_hlpr(act1st, at); + } + + // mean and std_dev of std_dev of radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) + std::pair cloud_stddevr_stats_timestep(int at) + { + if(this->micro == "blk_1m") return {0,0}; + // read act drop 0th raw moment / mass [1/kg] + arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); + // read act drop 1st raw moment / mass [um/kg] + arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); + // read act drop 2nd raw moment / mass [um^2/kg] + arr_t act2nd(this->h5load_timestep("actrw_rw_mom2", at) * 1e12); + // calculate stddev of radius, store in act1st + act1st = where(act0th > 0, + act2nd / act0th - act1st / act0th * act1st / act0th, 0.); + // might be slightly negative due to numerical errors + act1st = where(act1st < 0, 0, act1st); + act1st = sqrt(act1st); + return cloud_hlpr(act1st, at); + } + + + //ctor + PlotterMask(const string &file, const string µ): + parent_t(file), + micro(micro), + res(this->tmp.shape()), + rhod(this->h5load(file + "/const.h5", "G")) + { + } +}; + diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index 4af945f..ef651f9 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -149,39 +149,6 @@ class PlotterMicro_t : public PlotterCommon return res; } - - // functions for diagnosing statistics - // mean and std dev [g/kg] of the mixing ratio of activated dropelts in cloudy cells (characteristics of the spatial distribution at this timestep) - std::pair cloud_ract_stats_timestep(int at) - { - // read activated droplets mixing ratio - arr_t ract(load_ract_timestep(at)); - ract *= 1e3; // turn it into g/kg - return cloud_hlpr(ract, at); - } - - // mean and std_dev of concentration of activated droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) - std::pair cloud_actconc_stats_timestep(int at) - { - arr_t actconc; - // read concentration of activated droplets - if(this->micro == "blk_1m") return {0,0}; - // TODO: fix stupid copying of arrays - else if(this->micro == "lgrngn") { - arr_t tmp(this->h5load_timestep("actrw_rw_mom0", at)); - actconc.resize(tmp.shape()); - actconc = tmp; - } - else if(this->micro == "blk_2m") { - arr_t tmp(arr_t(this->h5load_timestep("nc", at)) + arr_t(this->h5load_timestep("nr", at))); - actconc.resize(tmp.shape()); - actconc = tmp; - } - actconc *= rhod; // b4 it was specific moment - actconc /= 1e6; // per cm^3 - return cloud_hlpr(actconc, at); - } - // mean and std_dev of supersaturation in cells with positive supersaturation [%] (characteristics of the spatial distribution at this timestep) std::pair positive_supersat_stats_timestep(int at) { @@ -246,55 +213,7 @@ class PlotterMicro_t : public PlotterCommon { if(this->micro == "blk_1m") return {0,0}; arr_t sdconc(this->h5load_timestep("sd_conc", at)); - return hlpr(sdconc, at); - } - - // mean and std_dev of number of SDs in cloudy cells (characteristics of the spatial distribution at this timestep) - std::pair cloud_sdconc_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - arr_t sdconc(this->h5load_timestep("sd_conc", at)); - return cloud_hlpr(sdconc, at); - } - - // mean and std_dev of number of activated SDs in cloudy cells (characteristics of the spatial distribution at this timestep) - std::pair cloud_sdconc_act_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - arr_t sdconc_act(this->h5load_timestep("sd_conc_act", at)); - return cloud_hlpr(sdconc_act, at); - } - - // mean and std_dev of mean radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) - std::pair cloud_meanr_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - // read act drop 0th raw moment / mass [1/kg] - arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); - // read act drop 1st raw moment / mass [um/kg] - arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); - // calculate mean radius, store in act1st - act1st = where(act0th > 0, act1st / act0th, 0.); - return cloud_hlpr(act1st, at); - } - - // mean and std_dev of std_dev of radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) - std::pair cloud_stddevr_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - // read act drop 0th raw moment / mass [1/kg] - arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); - // read act drop 1st raw moment / mass [um/kg] - arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); - // read act drop 2nd raw moment / mass [um^2/kg] - arr_t act2nd(this->h5load_timestep("actrw_rw_mom2", at) * 1e12); - // calculate stddev of radius, store in act1st - act1st = where(act0th > 0, - act2nd / act0th - act1st / act0th * act1st / act0th, 0.); - // might be slightly negative due to numerical errors - act1st = where(act1st < 0, 0, act1st); - act1st = sqrt(act1st); - return cloud_hlpr(act1st, at); + return this->hlpr(sdconc, at); } // mean and std_dev of temperature [K] (characteristics of the spatial distribution at this timestep, without near-wall cells) @@ -304,14 +223,14 @@ class PlotterMicro_t : public PlotterCommon //arr_t tht(this->nowall(arr_t(this->h5load_timestep("th", at)), distance_from_walls)); arr_t tht(arr_t(this->h5load_timestep("th", at))); tht *= pow(this->map_prof["p_e"](this->LastIndex) / p_1000, R_d / c_pd); // tht -> T - return hlpr(tht, at); + return this->hlpr(tht, at); } // mean and std_dev of r_v [1] (characteristics of the spatial distribution at this timestep) std::pair rv_stats_timestep(int at) { arr_t rv(arr_t(this->h5load_timestep("rv", at))); - return hlpr(rv, at); + return this->hlpr(rv, at); } // mean and std_dev of RH [1] (characteristics of the spatial distribution at this timestep) @@ -321,7 +240,7 @@ class PlotterMicro_t : public PlotterCommon std::pair res; arr_t RH(this->h5load_timestep("RH", at)); - return hlpr(RH, at); + return this->hlpr(RH, at); } // surface precipitation since last output [mm/day] From 86102d2a0e5899334cca9b34c129283cfe5a50af Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 15 Dec 2022 13:29:07 +0100 Subject: [PATCH 11/51] wip --- UWLCM_plotters/include/PlotterCommon.hpp | 97 +-------------------- UWLCM_plotters/include/PlotterMask.hpp | 48 +++++++--- UWLCM_plotters/include/PlotterMicro.hpp | 4 +- drawbicyc/drawbicyc.cpp | 20 ++--- drawbicyc/include/plot_fields.hpp | 2 +- drawbicyc/include/plot_lgrngn_spec.hpp | 2 +- drawbicyc/include/plot_prof.hpp | 2 +- drawbicyc/include/plot_qv_qc_2_6_10_min.hpp | 2 +- drawbicyc/include/plot_series.hpp | 2 +- 9 files changed, 56 insertions(+), 123 deletions(-) diff --git a/UWLCM_plotters/include/PlotterCommon.hpp b/UWLCM_plotters/include/PlotterCommon.hpp index 32f7db8..fdd5924 100644 --- a/UWLCM_plotters/include/PlotterCommon.hpp +++ b/UWLCM_plotters/include/PlotterCommon.hpp @@ -47,49 +47,6 @@ class PlotterCommon : public Plotter_t res.second = sqrt(blitz::mean(arr)); return res; } - - // height [m] of the center of mass of activated droplets - double act_com_z_timestep(int at) - { - arr_t ract(h5load_ract_timestep(at)); - arr_t weighted(ract.copy()); - weighted = weighted * this->LastIndex * this->map["dz"]; - if(blitz::sum(ract) > 1e-3) - return blitz::sum(weighted) / blitz::sum(ract); - else - return 0.; - } - - // mean and std dev [g/kg] of the mixing ratio of activated dropelts in cloudy cells (characteristics of the spatial distribution at this timestep) - std::pair cloud_ract_stats_timestep(int at) - { - // read activated droplets mixing ratio - arr_t ract(h5load_ract_timestep(at)); - ract *= 1e3; // turn it into g/kg - return cloud_hlpr(ract, at); - } - - // mean and std_dev of concentration of activated droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) - std::pair cloud_actconc_stats_timestep(int at) - { - arr_t actconc; - // read concentration of activated droplets - if(this->micro == "blk_1m") return {0,0}; - // TODO: fix stupid copying of arrays - else if(this->micro == "lgrngn") { - arr_t tmp(this->h5load_timestep("actrw_rw_mom0", at)); - actconc.resize(tmp.shape()); - actconc = tmp; - } - else if(this->micro == "blk_2m") { - arr_t tmp(arr_t(this->h5load_timestep("nc", at)) + arr_t(this->h5load_timestep("nr", at))); - actconc.resize(tmp.shape()); - actconc = tmp; - } - actconc *= rhod; // b4 it was specific moment - actconc /= 1e6; // per cm^3 - return cloud_hlpr(actconc, at); - } // mean and std_dev of supersaturation in cells with positive supersaturation [%] (characteristics of the spatial distribution at this timestep) std::pair positive_supersat_stats_timestep(int at) @@ -131,8 +88,8 @@ class PlotterCommon : public Plotter_t // read number of droplets per cell arr_t nc(this->h5load_timestep("cloud_rw_mom0", at)); - nc *= rhod; // [1/m^3] - nc *= this->dv; + multiply_by_rhod(nc); + multiply_by_CellVol(nc); if(blitz::sum(nc) > 0) @@ -158,54 +115,6 @@ class PlotterCommon : public Plotter_t return hlpr(sdconc, at); } - // mean and std_dev of number of SDs in cloudy cells (characteristics of the spatial distribution at this timestep) - std::pair cloud_sdconc_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - arr_t sdconc(this->h5load_timestep("sd_conc", at)); - return cloud_hlpr(sdconc, at); - } - - // mean and std_dev of number of activated SDs in cloudy cells (characteristics of the spatial distribution at this timestep) - std::pair cloud_sdconc_act_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - arr_t sdconc_act(this->h5load_timestep("sd_conc_act", at)); - return cloud_hlpr(sdconc_act, at); - } - - // mean and std_dev of mean radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) - std::pair cloud_meanr_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - // read act drop 0th raw moment / mass [1/kg] - arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); - // read act drop 1st raw moment / mass [um/kg] - arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); - // calculate mean radius, store in act1st - act1st = where(act0th > 0, act1st / act0th, 0.); - return cloud_hlpr(act1st, at); - } - - // mean and std_dev of std_dev of radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) - std::pair cloud_stddevr_stats_timestep(int at) - { - if(this->micro == "blk_1m") return {0,0}; - // read act drop 0th raw moment / mass [1/kg] - arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); - // read act drop 1st raw moment / mass [um/kg] - arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); - // read act drop 2nd raw moment / mass [um^2/kg] - arr_t act2nd(this->h5load_timestep("actrw_rw_mom2", at) * 1e12); - // calculate stddev of radius, store in act1st - act1st = where(act0th > 0, - act2nd / act0th - act1st / act0th * act1st / act0th, 0.); - // might be slightly negative due to numerical errors - act1st = where(act1st < 0, 0, act1st); - act1st = sqrt(act1st); - return cloud_hlpr(act1st, at); - } - // mean and std_dev of temperature [K] (characteristics of the spatial distribution at this timestep, without near-wall cells) std::pair T_stats_timestep(int at) { @@ -349,8 +258,8 @@ class PlotterCommon : public Plotter_t micro(micro), res(this->tmp.shape()), rhod(this->h5load(file + "/const.h5", "G")) - */ { } + */ }; diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index 9d79755..777e64f 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -1,17 +1,31 @@ #pragma once #include "PlotterMicro.hpp" -// TODO: make two: plotterlgrngn and plotter blk1m +enum class mask_type_t{Rico11}; + template class PlotterMask : public PlotterMicro { protected: using parent_t = PlotterMicro; + using arr_t = parent_t::arr_t; private: + mask_type_t mask_type; arr_t mask; + void calc_mask(int at) + { + // RICO mask; TODO: add other masks + if(mask_type == mask_type_t::Rico11) + { + mask = load_ract_timestep(at); + mask = iscloudy_rc(mask); + } + else throw std::runtime_error("Invalid mask type"); + } + lgrngn_droplet_prefix cloud_mask @@ -24,10 +38,10 @@ class PlotterMask : public PlotterMicro std::pair cloud_hlpr(arr_t arr, int at) { std::pair res; - // read activated droplets mixing ratio - arr_t mask(h5load_ract_timestep(at)); - mask = iscloudy_rc(mask); - arr *= mask; // apply filter + + // apply mask + calc_mask(at); + arr *= mask; if(blitz::sum(mask) > 0.) res.first = blitz::sum(arr) / blitz::sum(mask); @@ -81,8 +95,6 @@ class PlotterMask : public PlotterMicro } - - // mean and std_dev of number of SDs in cloudy cells (characteristics of the spatial distribution at this timestep) std::pair cloud_sdconc_stats_timestep(int at) { @@ -131,13 +143,25 @@ class PlotterMask : public PlotterMicro return cloud_hlpr(act1st, at); } + + // height [m] of the center of mass of activated droplets + double act_com_z_timestep(int at) + { + arr_t ract(h5load_ract_timestep(at)); + arr_t weighted(ract.copy()); + weighted = weighted * this->LastIndex * this->map["dz"]; + if(blitz::sum(ract) > 1e-3) + return blitz::sum(weighted) / blitz::sum(ract); + else + return 0.; + } + //ctor - PlotterMask(const string &file, const string µ): - parent_t(file), - micro(micro), - res(this->tmp.shape()), - rhod(this->h5load(file + "/const.h5", "G")) + PlotterMask(const string &file, const string µ, const mask_type_t _mt): + parent_t(file, micro), + mask(this->tmp_ref.shape()), + mask_type(_mt) { } }; diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index ef651f9..0ab7f0e 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -3,7 +3,7 @@ // TODO: make two: plotterlgrngn and plotter blk1m template -class PlotterMicro_t : public PlotterCommon +class PlotterMicro : public PlotterCommon { protected: using parent_t = PlotterCommon; @@ -360,7 +360,7 @@ class PlotterMicro_t : public PlotterCommon } //ctor - PlotterMicro_t(const string &file, const string µ): + PlotterMicro(const string &file, const string µ): parent_t(file), micro(micro), res(this->tmp.shape()), diff --git a/drawbicyc/drawbicyc.cpp b/drawbicyc/drawbicyc.cpp index 2bb53ba..74e3b77 100644 --- a/drawbicyc/drawbicyc.cpp +++ b/drawbicyc/drawbicyc.cpp @@ -73,20 +73,20 @@ int main(int argc, char** argv) if(NDims == 2) { - if(flag_series) plot_series(PlotterMicro_t<2>(h5, micro), plots, type); - if(flag_profiles) plot_profiles(PlotterMicro_t<2>(h5, micro), plots, type, normalize_prof); -// if(flag_fields) plot_fields(PlotterMicro_t<2>(h5, micro), plots, type); -// if(flag_qv_qc_2_6_10_min) plot_qv_qc_2_6_10_min(PlotterMicro_t<2>(h5, micro)); + if(flag_series) plot_series(PlotterMask<2>(h5, micro, mask_type_t::Rico11), plots, type); + if(flag_profiles) plot_profiles(PlotterMask<2>(h5, micro, mask_type_t::Rico11), plots, type, normalize_prof); +// if(flag_fields) plot_fields(PlotterMask<2>(h5, micro), plots, type); +// if(flag_qv_qc_2_6_10_min) plot_qv_qc_2_6_10_min(PlotterMask<2>(h5, micro)); } else if(NDims == 3) { - if(flag_series) plot_series(PlotterMicro_t<3>(h5, micro), plots, type); - if(flag_profiles) plot_profiles(PlotterMicro_t<3>(h5, micro), plots, type, normalize_prof); -// if(flag_fields) plot_fields(PlotterMicro_t<3>(h5, micro), plots, type); -// if(flag_qv_qc_2_6_10_min) plot_qv_qc_2_6_10_min(PlotterMicro_t<2>(h5, micro)); + if(flag_series) plot_series(PlotterMask<3>(h5, micro, mask_type_t::Rico11), plots, type); + if(flag_profiles) plot_profiles(PlotterMask<3>(h5, micro, mask_type_t::Rico11), plots, type, normalize_prof); +// if(flag_fields) plot_fields(PlotterMask<3>(h5, micro), plots, type); +// if(flag_qv_qc_2_6_10_min) plot_qv_qc_2_6_10_min(PlotterMask<2>(h5, micro)); // if(flag_lgrngn_spec) { -// plot_lgrngn_spec_positions(PlotterMicro_t<3>(h5, "lgrngn")); -// plot_lgrngn_spec(PlotterMicro_t<3>(h5, "lgrngn")); +// plot_lgrngn_spec_positions(PlotterMask<3>(h5, "lgrngn")); +// plot_lgrngn_spec(PlotterMask<3>(h5, "lgrngn")); // } } else diff --git a/drawbicyc/include/plot_fields.hpp b/drawbicyc/include/plot_fields.hpp index 81f66c6..c1e253c 100644 --- a/drawbicyc/include/plot_fields.hpp +++ b/drawbicyc/include/plot_fields.hpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include "plots.hpp" #include "gnuplot.hpp" diff --git a/drawbicyc/include/plot_lgrngn_spec.hpp b/drawbicyc/include/plot_lgrngn_spec.hpp index eea73e3..f643b5b 100644 --- a/drawbicyc/include/plot_lgrngn_spec.hpp +++ b/drawbicyc/include/plot_lgrngn_spec.hpp @@ -1,5 +1,5 @@ #include -#include +#include #include "plots.hpp" #include "focus.hpp" #include "gnuplot.hpp" diff --git a/drawbicyc/include/plot_prof.hpp b/drawbicyc/include/plot_prof.hpp index 2e7d086..2d9e9a1 100644 --- a/drawbicyc/include/plot_prof.hpp +++ b/drawbicyc/include/plot_prof.hpp @@ -1,4 +1,4 @@ -#include +#include #include //#include #include "plots.hpp" diff --git a/drawbicyc/include/plot_qv_qc_2_6_10_min.hpp b/drawbicyc/include/plot_qv_qc_2_6_10_min.hpp index 8542acf..191eb31 100644 --- a/drawbicyc/include/plot_qv_qc_2_6_10_min.hpp +++ b/drawbicyc/include/plot_qv_qc_2_6_10_min.hpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include "plots.hpp" #include "gnuplot.hpp" diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index c4dffa2..1327ac1 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -1,4 +1,4 @@ -#include +#include #include #include "plots.hpp" #include "gnuplot_series_set_labels.hpp" From e6325990010142ef338dbe5ba3cb08c346ff3ff6 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 15 Dec 2022 13:35:18 +0100 Subject: [PATCH 12/51] wip --- UWLCM_plotters/include/PlotterMask.hpp | 19 +++---- drawbicyc/drawbicyc.cpp | 4 +- drawbicyc/include/plot_fields.hpp | 2 +- drawbicyc/include/plot_lgrngn_spec.hpp | 4 +- drawbicyc/include/plot_prof.hpp | 56 +++++++++---------- drawbicyc/include/plot_qv_qc_2_6_10_min.hpp | 6 +-- drawbicyc/include/plot_series.hpp | 60 ++++++++++----------- 7 files changed, 73 insertions(+), 78 deletions(-) diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index 777e64f..24d0610 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -6,9 +6,9 @@ enum class mask_type_t{Rico11}; template class PlotterMask : public PlotterMicro { - protected: + public: using parent_t = PlotterMicro; - using arr_t = parent_t::arr_t; + using arr_t = typename parent_t::arr_t; private: @@ -20,18 +20,13 @@ class PlotterMask : public PlotterMicro // RICO mask; TODO: add other masks if(mask_type == mask_type_t::Rico11) { - mask = load_ract_timestep(at); + mask = this->load_ract_timestep(at); mask = iscloudy_rc(mask); } else throw std::runtime_error("Invalid mask type"); } - lgrngn_droplet_prefix - cloud_mask - - - public: - using arr_t = typename parent_t::arr_t; + //lgrngn_droplet_prefix private: // helper function that calculates staistics (mean and std_dev) of a field only in cloudy cells @@ -67,7 +62,7 @@ class PlotterMask : public PlotterMicro std::pair cloud_ract_stats_timestep(int at) { // read activated droplets mixing ratio - arr_t ract(load_ract_timestep(at)); + arr_t ract(this->load_ract_timestep(at)); ract *= 1e3; // turn it into g/kg return cloud_hlpr(ract, at); } @@ -89,7 +84,7 @@ class PlotterMask : public PlotterMicro actconc.resize(tmp.shape()); actconc = tmp; } - actconc *= rhod; // b4 it was specific moment + this->multiply_by_rhod(actconc); // b4 it was specific moment actconc /= 1e6; // per cm^3 return cloud_hlpr(actconc, at); } @@ -147,7 +142,7 @@ class PlotterMask : public PlotterMicro // height [m] of the center of mass of activated droplets double act_com_z_timestep(int at) { - arr_t ract(h5load_ract_timestep(at)); + arr_t ract(this->load_ract_timestep(at)); arr_t weighted(ract.copy()); weighted = weighted * this->LastIndex * this->map["dz"]; if(blitz::sum(ract) > 1e-3) diff --git a/drawbicyc/drawbicyc.cpp b/drawbicyc/drawbicyc.cpp index 74e3b77..d987f18 100644 --- a/drawbicyc/drawbicyc.cpp +++ b/drawbicyc/drawbicyc.cpp @@ -73,8 +73,8 @@ int main(int argc, char** argv) if(NDims == 2) { - if(flag_series) plot_series(PlotterMask<2>(h5, micro, mask_type_t::Rico11), plots, type); - if(flag_profiles) plot_profiles(PlotterMask<2>(h5, micro, mask_type_t::Rico11), plots, type, normalize_prof); +// if(flag_series) plot_series(PlotterMask<2>(h5, micro, mask_type_t::Rico11), plots, type); +// if(flag_profiles) plot_profiles(PlotterMask<2>(h5, micro, mask_type_t::Rico11), plots, type, normalize_prof); // if(flag_fields) plot_fields(PlotterMask<2>(h5, micro), plots, type); // if(flag_qv_qc_2_6_10_min) plot_qv_qc_2_6_10_min(PlotterMask<2>(h5, micro)); } diff --git a/drawbicyc/include/plot_fields.hpp b/drawbicyc/include/plot_fields.hpp index c1e253c..0c26edf 100644 --- a/drawbicyc/include/plot_fields.hpp +++ b/drawbicyc/include/plot_fields.hpp @@ -36,7 +36,7 @@ void plot_fields(Plotter_t plotter, Plots plots, std::string type) { try{ // cloud water content - auto tmp = plotter.h5load_ract_timestep(at * n["outfreq"]) * 1e3; + auto tmp = plotter.load_ract_timestep(at * n["outfreq"]) * 1e3; std::string title = "cloud water mixing ratio [g/kg]"; gp << "set title '" + title + " t = " << std::fixed << std::setprecision(2) << (double(at) * n["outfreq"] * n["dt"] / 60.) << "min'\n"; diff --git a/drawbicyc/include/plot_lgrngn_spec.hpp b/drawbicyc/include/plot_lgrngn_spec.hpp index f643b5b..8eb9095 100644 --- a/drawbicyc/include/plot_lgrngn_spec.hpp +++ b/drawbicyc/include/plot_lgrngn_spec.hpp @@ -26,7 +26,7 @@ void plot_lgrngn_spec_positions(Plotter_t plotter) try{ // cloud water content - auto tmp = plotter.h5load_ract_timestep(spectra_step * n["outfreq"]) * 1e3; + auto tmp = plotter.load_ract_timestep(spectra_step * n["outfreq"]) * 1e3; std::string title = "cloud water mixing ratio [g/kg]"; gp << "set title '" + title + " t = " << std::fixed << std::setprecision(2) << (double(spectra_step) * n["outfreq"] * n["dt"] / 60.) << "min'\n"; @@ -121,7 +121,7 @@ void plot_lgrngn_spec(Plotter_t plotter) // calc ratio of water content to adiabatic water content { - auto tmp = plotter.h5load_ract_timestep(spectra_step * n["outfreq"]) * 1e3; + auto tmp = plotter.load_ract_timestep(spectra_step * n["outfreq"]) * 1e3; double ratio = mean(tmp(focusBox)) / r_c_adiab; gp << "set label 4 'AF = " << std::fixed << std::setprecision(2) << ratio << "' at graph .2, .63 font \",15\"\n"; } diff --git a/drawbicyc/include/plot_prof.hpp b/drawbicyc/include/plot_prof.hpp index 2d9e9a1..f2564c8 100644 --- a/drawbicyc/include/plot_prof.hpp +++ b/drawbicyc/include/plot_prof.hpp @@ -87,9 +87,9 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool if (plt == "rliq") { // liquid water content - // res += plotter.h5load_ra_timestep(at * n["outfreq"]) * 1e3; // aerosol - res += plotter.h5load_rc_timestep(at * n["outfreq"]) * 1e3; // cloud - res += plotter.h5load_rr_timestep(at * n["outfreq"]) * 1e3; // rain + // res += plotter.load_ra_timestep(at * n["outfreq"]) * 1e3; // aerosol + res += plotter.load_rc_timestep(at * n["outfreq"]) * 1e3; // cloud + res += plotter.load_rr_timestep(at * n["outfreq"]) * 1e3; // rain res_prof_hlpr = plotter.horizontal_mean(res); // average in x } if (plt == "gccn_conc") @@ -132,7 +132,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp = where(res_tmp > 0 , res_tmp / snap, res_tmp); } { - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); res_tmp2 = iscloudy_rc_rico(snap); res_tmp *= res_tmp2; } @@ -149,7 +149,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp = where(res_tmp > 0 , res_tmp / snap, res_tmp); // mean radius } { - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); res_tmp2 = iscloudy_rc_rico(snap); res_tmp *= res_tmp2; } @@ -206,7 +206,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp2 = isdowndraught(snap); } { // cloudy - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); res_tmp = iscloudy_rc_rico(snap); res_tmp2 *= res_tmp; } @@ -235,7 +235,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp2 = isdowndraught(snap); } { // cloudy - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); res_tmp = iscloudy_rc_rico(snap); res_tmp2 *= res_tmp; } @@ -264,7 +264,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp2 = isupdraught(snap); } { // cloudy - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); res_tmp = iscloudy_rc_rico(snap); res_tmp2 *= res_tmp; } @@ -401,7 +401,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp = where(res_tmp > 0 , res_tmp / snap, res_tmp); } { - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); res_tmp2 = iscloudy_rc_rico(snap); res_tmp *= res_tmp2; } @@ -423,7 +423,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp = where(res_tmp > 0 , res_tmp / snap, res_tmp); } { - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); res_tmp2 = iscloudy_rc_rico(snap); res_tmp *= res_tmp2; } @@ -443,7 +443,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool prof_tmp = plotter.horizontal_sum(res_tmp2); // number of downdraft cells on a given level { - auto tmp = plotter.h5load_nc_timestep(at * n["outfreq"]); + auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); res_tmp = snap; res_tmp *= rhod / 1e6; // per cm^3 @@ -462,7 +462,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool } { - auto tmp = plotter.h5load_nc_timestep(at * n["outfreq"]); + auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap *= rhod; // b4 it was specific moment snap /= 1e6; // per cm^3 @@ -490,7 +490,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool prof_tmp = plotter.horizontal_sum(res_tmp2); // number of downdraft cells on a given level { - auto tmp = plotter.h5load_nc_timestep(at * n["outfreq"]); + auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); res_tmp = snap; res_tmp *= rhod / 1e6; // per cm^3 @@ -605,19 +605,19 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool } else if (plt == "sat_RH") { - res = plotter.h5load_RH_timestep(at * n["outfreq"]); + res = plotter.load_RH_timestep(at * n["outfreq"]); res = (res -1) * 100; res_prof_hlpr = plotter.horizontal_mean(res); // average in x } else if (plt == "RH") { - res = plotter.h5load_RH_timestep(at * n["outfreq"]); + res = plotter.load_RH_timestep(at * n["outfreq"]); res_prof_hlpr = plotter.horizontal_mean(res) * 100; // average in x; [%] } else if (plt == "sat_RH_up") { { - auto tmp = plotter.h5load_RH_timestep(at * n["outfreq"]); + auto tmp = plotter.load_RH_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); res_tmp = (snap -1) * 100; } @@ -637,9 +637,9 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool } else if (plt == "00rtot") { - // res = plotter.h5load_ra_timestep(at * n["outfreq"]) * 1e3; // aerosol - res = plotter.h5load_rc_timestep(at * n["outfreq"]) * 1e3; // cloud - res += plotter.h5load_rr_timestep(at * n["outfreq"]) * 1e3; // rain + // res = plotter.load_ra_timestep(at * n["outfreq"]) * 1e3; // aerosol + res = plotter.load_rc_timestep(at * n["outfreq"]) * 1e3; // cloud + res += plotter.load_rr_timestep(at * n["outfreq"]) * 1e3; // rain res += plotter.h5load_timestep("rv", at * n["outfreq"]) * 1e3; // vapour res_prof_hlpr = plotter.horizontal_mean(res); // average in x @@ -659,7 +659,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool else if (plt == "N_c") { // cloud drops concentration [1/cm^3] - res = plotter.h5load_nc_timestep(at * n["outfreq"]) * rhod / 1e6; // from sepcific to normal moment + per cm^3 + res = plotter.load_nc_timestep(at * n["outfreq"]) * rhod / 1e6; // from sepcific to normal moment + per cm^3 res_prof_hlpr = plotter.horizontal_mean(res); // average in x } else if (plt == "rd_geq_0.8um_conc") @@ -680,7 +680,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool try { // cloud fraction (cloudy if N_c > 20/cm^3) - auto tmp = plotter.h5load_nc_timestep(at * n["outfreq"]); + auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap *= rhod; // b4 it was specific moment snap /= 1e6; // per cm^3 @@ -701,9 +701,9 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool // liquid potential temp [K] { auto &ql(res_tmp2); - ql = plotter.h5load_rc_timestep(at * n["outfreq"]); // cloud -// ql += plotter.h5load_ra_timestep(at * n["outfreq"]); // aerosol - ql += plotter.h5load_rr_timestep(at * n["outfreq"]); // rain + ql = plotter.load_rc_timestep(at * n["outfreq"]); // cloud +// ql += plotter.load_ra_timestep(at * n["outfreq"]); // aerosol + ql += plotter.load_rr_timestep(at * n["outfreq"]); // rain // ql is now q_l (liq water content) // auto tmp = plotter.h5load_timestep("th", at * n["outfreq"]); // typename Plotter_t::arr_t th_d(tmp); @@ -737,7 +737,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool { // cloud fraction (cloudy if N_c > 20/cm^3) { - auto tmp = plotter.h5load_nc_timestep(at * n["outfreq"]); + auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap *= rhod; // b4 it was specific moment snap /= 1e6; // per cm^3 @@ -751,14 +751,14 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool { res_prof_hlpr = 0; // cloudy cells (cloudy if q_c > 0.01 g/kg as in RICO paper. NOTE: also add q_r ?) - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc_rico(snap); // cloudiness mask plotter.k_i = blitz::sum(snap, plotter.LastIndex); // sum in the vertical, assumes that all cloudy cells in a column belong to the same cloud plotter.tmp_int_hrzntl_slice = blitz::first(snap > 0, plotter.LastIndex); // cloud base hgt over dz // precipitation flux(doesnt include vertical velocity w!) - res = plotter.h5load_prflux_timestep(at * n["outfreq"]); + res = plotter.load_prflux_timestep(at * n["outfreq"]); plotter.tmp_float_hrzntl_slice = plotter.get_value_at_hgt(res, plotter.tmp_int_hrzntl_slice); // precip flux at cloud base // NOTE: we assume that k_i and tmp_float_hr... is contiguous in memory @@ -776,7 +776,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool { // precipitation flux(doesnt include vertical volicty w!) { - res = plotter.h5load_prflux_timestep(at * n["outfreq"]); + res = plotter.load_prflux_timestep(at * n["outfreq"]); res_prof_hlpr = plotter.horizontal_mean(res); // average in x } // add vertical velocity to precipitation flux (3rd mom of cloud drops * w) diff --git a/drawbicyc/include/plot_qv_qc_2_6_10_min.hpp b/drawbicyc/include/plot_qv_qc_2_6_10_min.hpp index 191eb31..8bfb01a 100644 --- a/drawbicyc/include/plot_qv_qc_2_6_10_min.hpp +++ b/drawbicyc/include/plot_qv_qc_2_6_10_min.hpp @@ -103,7 +103,7 @@ void plot_qv_qc_2_6_10_min(Plotter_t plotter) gp << "set title offset 0, -0.8 '$q_c$ [g/kg], t = 2 min'\n"; try{ // cloud water content - typename Plotter_t::arr_t tmp(plotter.h5load_ract_timestep(60) * 1e3); + typename Plotter_t::arr_t tmp(plotter.load_ract_timestep(60) * 1e3); std::cout << tmp; plotter.plot(gp, tmp); } @@ -118,7 +118,7 @@ void plot_qv_qc_2_6_10_min(Plotter_t plotter) gp << "set title offset 0, -0.8 '$q_c$ [g/kg], t = 6 min'\n"; try{ // cloud water content - typename Plotter_t::arr_t tmp(plotter.h5load_ract_timestep(360) * 1e3); + typename Plotter_t::arr_t tmp(plotter.load_ract_timestep(360) * 1e3); std::cout << tmp; plotter.plot(gp, tmp); } @@ -133,7 +133,7 @@ void plot_qv_qc_2_6_10_min(Plotter_t plotter) gp << "set title offset 0, -0.8 '$q_c$ [g/kg], t = 10 min'\n"; try{ // cloud water content - typename Plotter_t::arr_t tmp (plotter.h5load_ract_timestep(600) * 1e3); + typename Plotter_t::arr_t tmp (plotter.load_ract_timestep(600) * 1e3); std::cout << tmp; plotter.plot(gp, tmp); } diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index 1327ac1..7f27fef 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -126,9 +126,9 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]) * 1e3; //g/kg + auto tmp = plotter.load_rc_timestep(at * n["outfreq"]) * 1e3; //g/kg typename Plotter_t::arr_t snap(tmp); - snap += plotter.h5load_rr_timestep(at * n["outfreq"]) * 1e3; //g/kg + snap += plotter.load_rr_timestep(at * n["outfreq"]) * 1e3; //g/kg plotter.multiply_by_rhod(snap); plotter.k_i = blitz::sum(snap, plotter.LastIndex) * n["refined dz"]; // LWP [g/m2] in the column plotter.k_i = where(plotter.k_i > 20 , 1 , 0); // cloudiness as in Ackermann et al. @@ -141,7 +141,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (fraction of columns with at least one cloudy cell, i.e. cell with q_c > 0.01 g/kg) - auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]); + auto tmp = plotter.load_rc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap = iscloudy_rc_rico(snap); // find cells with rc>1e-5 snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux @@ -182,7 +182,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if ql > 1e-5)) - auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]); + auto tmp = plotter.load_rc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap = iscloudy_rc_rico(snap); plotter.k_i = blitz::last((snap == 1), plotter.LastIndex); @@ -277,7 +277,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // vertical velocity at the center of mass of activated droplets try { - auto tmp = plotter.h5load_ract_timestep(at * n["outfreq"]); + auto tmp = plotter.load_ract_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); typename Plotter_t::arr_t snap2(tmp); typename Plotter_t::arr_t snap3(tmp); @@ -302,7 +302,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // supersaturation at the center of mass of activated droplets try { - auto tmp = plotter.h5load_ract_timestep(at * n["outfreq"]); + auto tmp = plotter.load_ract_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); typename Plotter_t::arr_t snap2(tmp); typename Plotter_t::arr_t snap3(tmp); @@ -327,7 +327,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // 0th moment of rw distribution at the center of mass of activated droplets (particles concentration), 2D only try { - auto tmp = plotter.h5load_ract_timestep(at * n["outfreq"]); + auto tmp = plotter.load_ract_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); typename Plotter_t::arr_t snap2(tmp); typename Plotter_t::arr_t snap3(tmp); @@ -516,7 +516,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // rico cloud mask - auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]); + auto tmp = plotter.load_rc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap = iscloudy_rc_rico(snap); // find cells with rc>1e-5 snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux @@ -562,7 +562,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // rico cloud mask - auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]); + auto tmp = plotter.load_rc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap = iscloudy_rc_rico(snap); // find cells with rc>1e-5 snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux @@ -644,7 +644,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) else { // -- precipitation at this height averaged over all cells, cloudy or not -- - auto prflux = plotter.h5load_prflux_timestep(at * n["outfreq"]); // prflux in [W/m^2] + auto prflux = plotter.load_prflux_timestep(at * n["outfreq"]); // prflux in [W/m^2] res_series[plt](at) = blitz::mean(prflux(plotter.hrzntl_slice(cloud_base_idx))) / 2264.705 * 3.6 * 24; // convert to [mm/day] } } @@ -656,7 +656,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if r_c > 1e-5) - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc_rico(snap); snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); @@ -817,7 +817,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if r_c > 1e-5) - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc_rico(snap); typename Plotter_t::arr_t acc_acnv(plotter.h5load_timestep("acc_acnv25", at * n["outfreq"])); @@ -841,7 +841,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if r_c > 1e-5) - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc_rico(snap); typename Plotter_t::arr_t acc_accr(plotter.h5load_timestep("acc_accr25", at * n["outfreq"])); @@ -862,8 +862,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - typename Plotter_t::arr_t rl(plotter.h5load_rc_timestep(at * n["outfreq"])); - typename Plotter_t::arr_t rr(plotter.h5load_rr_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t rl(plotter.load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t rr(plotter.load_rr_timestep(at * n["outfreq"])); rl = (rl + rr) * 1e3; // g/kg plotter.multiply_by_rhod(rl); res_series[plt](at) = blitz::mean(rl); @@ -877,7 +877,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - typename Plotter_t::arr_t snap(plotter.h5load_rr_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rr_timestep(at * n["outfreq"])); snap *= 1e3; plotter.multiply_by_rhod(snap); res_series[plt](at) = blitz::mean(snap); @@ -891,7 +891,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap *= rhod * 1e3; // water per cubic metre (should be wet density...) & g/kg res_series[plt](at) = blitz::mean(snap); } @@ -904,9 +904,9 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]) * rhod; + auto tmp = plotter.load_rc_timestep(at * n["outfreq"]) * rhod; typename Plotter_t::arr_t snap(tmp); - snap += plotter.h5load_rr_timestep(at * n["outfreq"]) * rhod; + snap += plotter.load_rr_timestep(at * n["outfreq"]) * rhod; snap *= plotter.CellVol; snap(plotter.hrzntl_slice(0)) = snap(plotter.hrzntl_slice(0))/2; snap(plotter.hrzntl_slice(-1)) = snap(plotter.hrzntl_slice(-1))/2; @@ -921,7 +921,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]); + auto tmp = plotter.load_rc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap *= rhod * plotter.CellVol; snap(plotter.hrzntl_slice(0)) = snap(plotter.hrzntl_slice(0))/2; @@ -937,7 +937,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - auto tmp = plotter.h5load_rr_timestep(at * n["outfreq"]); + auto tmp = plotter.load_rr_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); snap *= rhod * plotter.CellVol; snap(plotter.hrzntl_slice(0)) = snap(plotter.hrzntl_slice(0))/2; @@ -976,9 +976,9 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - auto tmp = plotter.h5load_rc_timestep(at * n["outfreq"]) * 1e3; //g/kg + auto tmp = plotter.load_rc_timestep(at * n["outfreq"]) * 1e3; //g/kg typename Plotter_t::arr_t snap(tmp); - snap += plotter.h5load_rr_timestep(at * n["outfreq"]) * 1e3; //g/kg + snap += plotter.load_rr_timestep(at * n["outfreq"]) * 1e3; //g/kg rtot = snap; } { @@ -1374,7 +1374,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc(snap); // cloudiness mask //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux @@ -1403,7 +1403,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc(snap); // cloudiness mask //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux @@ -1432,7 +1432,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc(snap); // cloudiness mask //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux @@ -1461,7 +1461,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc(snap); // cloudiness mask //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux @@ -1487,7 +1487,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - typename Plotter_t::arr_t snap(plotter.h5load_rc_timestep(at * n["outfreq"])); + typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc(snap); // cloudiness mask //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux @@ -1547,7 +1547,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t lwc(plotter.h5load_rc_timestep(at * n["outfreq"])); // cloud water, no rain water in pi chamber icmw + typename Plotter_t::arr_t lwc(plotter.load_rc_timestep(at * n["outfreq"])); // cloud water, no rain water in pi chamber icmw //res_series[plt](at) = blitz::mean(typename Plotter_t::arr_t(plotter.nowall(lwc, distance_from_walls))); res_series[plt](at) = blitz::mean(lwc); } @@ -1558,7 +1558,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t lwc(plotter.h5load_rc_timestep(at * n["outfreq"])); // cloud water, no rain water in pi chamber icmw + typename Plotter_t::arr_t lwc(plotter.load_rc_timestep(at * n["outfreq"])); // cloud water, no rain water in pi chamber icmw lwc *= rhod; res_series[plt](at) = blitz::mean(lwc); } From 6d2257ca01e31f732d7424ab5108e330e4b0fd4f Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 15 Dec 2022 13:40:09 +0100 Subject: [PATCH 13/51] wip --- UWLCM_plotters/include/PlotterCommon.hpp | 6 ++++-- UWLCM_plotters/include/PlotterMicro.hpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/UWLCM_plotters/include/PlotterCommon.hpp b/UWLCM_plotters/include/PlotterCommon.hpp index fdd5924..5aeeca2 100644 --- a/UWLCM_plotters/include/PlotterCommon.hpp +++ b/UWLCM_plotters/include/PlotterCommon.hpp @@ -11,11 +11,15 @@ class PlotterCommon : public Plotter_t public: using arr_t = typename parent_t::arr_t; + using parent_t::parent_t; protected: const double L_evap = 2264.76e3; // latent heat of evaporation [J/kg] public: + + // ---- functions for diagnosing statistics ---- + // void multiply_by_rhod(arr_t &arr) { if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) @@ -35,8 +39,6 @@ class PlotterCommon : public Plotter_t else throw std::runtime_error("multiply_by_CellVol: input array is neither normal grid size nor refined grid size"); } - - // ---- functions for diagnosing statistics ---- // helper function that calculates staistics (mean and std_dev) of a field std::pair hlpr(arr_t arr, int at) diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index 0ab7f0e..199499e 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -363,8 +363,8 @@ class PlotterMicro : public PlotterCommon PlotterMicro(const string &file, const string µ): parent_t(file), micro(micro), - res(this->tmp.shape()), - rhod(this->h5load(file + "/const.h5", "G")) + res(this->tmp.shape()) + //,rhod(this->h5load(file + "/const.h5", "G")) { } }; From a15337c5cb4334c4d92078f4fb58d47691e4cf6c Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 15 Dec 2022 14:57:42 +0100 Subject: [PATCH 14/51] wip --- UWLCM_plotters/include/PlotterCommon.hpp | 6 ++++-- UWLCM_plotters/include/PlotterMask.hpp | 9 ++++++-- UWLCM_plotters/include/PlotterMicro.hpp | 6 +++--- UWLCM_plotters/include/common_filters.hpp | 4 ++-- drawbicyc/include/plot_prof.hpp | 16 ++++---------- drawbicyc/include/plot_series.hpp | 26 +++++++++++------------ 6 files changed, 33 insertions(+), 34 deletions(-) diff --git a/UWLCM_plotters/include/PlotterCommon.hpp b/UWLCM_plotters/include/PlotterCommon.hpp index 5aeeca2..77495ce 100644 --- a/UWLCM_plotters/include/PlotterCommon.hpp +++ b/UWLCM_plotters/include/PlotterCommon.hpp @@ -20,7 +20,7 @@ class PlotterCommon : public Plotter_t // ---- functions for diagnosing statistics ---- // - void multiply_by_rhod(arr_t &arr) + arr_t& multiply_by_rhod(arr_t arr) { if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) arr *= this->map_prof["rhod"](this->LastIndex); @@ -28,9 +28,10 @@ class PlotterCommon : public Plotter_t arr *= this->map_prof["refined rhod"](this->LastIndex); else throw std::runtime_error("multiply_by_rhod: input array is neither normal grid size nor refined grid size"); + return arr; } - void multiply_by_CellVol(arr_t &arr) + arr_t& multiply_by_CellVol(arr_t arr) { if(arr.extent(NDims-1) == this->map_prof["rhod"].extent(0)) arr *= this->CellVol; @@ -38,6 +39,7 @@ class PlotterCommon : public Plotter_t arr *= this->CellVol_ref; else throw std::runtime_error("multiply_by_CellVol: input array is neither normal grid size nor refined grid size"); + return arr; } // helper function that calculates staistics (mean and std_dev) of a field diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index 24d0610..42f1624 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -1,7 +1,7 @@ #pragma once #include "PlotterMicro.hpp" -enum class mask_type_t{Rico11}; +enum class mask_type_t{Rico11, Dycoms_rf02}; template class PlotterMask : public PlotterMicro @@ -21,7 +21,12 @@ class PlotterMask : public PlotterMicro if(mask_type == mask_type_t::Rico11) { mask = this->load_ract_timestep(at); - mask = iscloudy_rc(mask); + mask = iscloudy_rc_rico(mask); + } + else if(mask_type == mask_type_t::Dycoms_rf02) + { + mask = this->load_nc_timestep(at); + mask = iscloudy_nc_dycoms(mask); } else throw std::runtime_error("Invalid mask type"); } diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index 199499e..acd7e36 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -89,13 +89,13 @@ class PlotterMicro : public PlotterCommon return res; } - // cloud droplets concentration [1/kg] + // cloud droplets concentration [1/cm^3] auto load_nc_timestep( int at ) //-> decltype(blitz::safeToReturn(arr_t() + 0)) { if(this->micro == "lgrngn") - return arr_t(this->h5load_timestep("cloud_rw_mom0", at)); + return arr_t(this->multiply_by_rhod(arr_t(this->h5load_timestep("cloud_rw_mom0", at) / 1e6))); else if(this->micro == "blk_1m") { res = 0; @@ -103,7 +103,7 @@ class PlotterMicro : public PlotterCommon // return blitz::safeToReturn(res + 0); } else if(this->micro == "blk_2m") - return arr_t(this->h5load_timestep("nc", at)); + return arr_t(this->multiply_by_rhod(arr_t(this->h5load_timestep("nc", at) / 1e6))); } // precipitation flux [W/m2] diff --git a/UWLCM_plotters/include/common_filters.hpp b/UWLCM_plotters/include/common_filters.hpp index 1ad0b2e..9b8dd04 100644 --- a/UWLCM_plotters/include/common_filters.hpp +++ b/UWLCM_plotters/include/common_filters.hpp @@ -26,11 +26,11 @@ double is_th_prtrb(double x) } BZ_DECLARE_FUNCTION(is_th_prtrb) -double iscloudy(double x) +double iscloudy_nc_dycoms(double x) { return x > 20. ? 1. : 0.; } -BZ_DECLARE_FUNCTION(iscloudy) +BZ_DECLARE_FUNCTION(iscloudy_nc_dycoms) double iscloudy_sat(double x) { diff --git a/drawbicyc/include/plot_prof.hpp b/drawbicyc/include/plot_prof.hpp index f2564c8..2e99f17 100644 --- a/drawbicyc/include/plot_prof.hpp +++ b/drawbicyc/include/plot_prof.hpp @@ -446,7 +446,6 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); res_tmp = snap; - res_tmp *= rhod / 1e6; // per cm^3 } // updraft only res_tmp *= res_tmp2; @@ -464,10 +463,8 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool { auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); - snap *= rhod; // b4 it was specific moment - snap /= 1e6; // per cm^3 res_tmp = snap; - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask res_tmp2 *= snap; // cloudy updrafts only } @@ -493,7 +490,6 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); res_tmp = snap; - res_tmp *= rhod / 1e6; // per cm^3 } // updraft only res_tmp *= res_tmp2; @@ -659,7 +655,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool else if (plt == "N_c") { // cloud drops concentration [1/cm^3] - res = plotter.load_nc_timestep(at * n["outfreq"]) * rhod / 1e6; // from sepcific to normal moment + per cm^3 + res = plotter.load_nc_timestep(at * n["outfreq"]); // from sepcific to normal moment + per cm^3 res_prof_hlpr = plotter.horizontal_mean(res); // average in x } else if (plt == "rd_geq_0.8um_conc") @@ -682,12 +678,10 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool // cloud fraction (cloudy if N_c > 20/cm^3) auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); - snap *= rhod; // b4 it was specific moment - snap /= 1e6; // per cm^3 typename Plotter_t::arr_t snap2; snap2.resize(snap.shape()); snap2=snap; - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask snap2 *= snap; // mean only over cloudy cells @@ -739,9 +733,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool { auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); typename Plotter_t::arr_t snap(tmp); - snap *= rhod; // b4 it was specific moment - snap /= 1e6; // per cm^3 - snap = iscloudy(snap); + snap = iscloudy_nc_dycoms(snap); res += snap; } res_prof_hlpr = plotter.horizontal_mean(res); // average in x diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index 7f27fef..9bb2e12 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -501,7 +501,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap2; snap2.resize(snap.shape()); snap2=snap; - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask snap2 *= snap; if(blitz::sum(snap) > 0) res_series[plt](at) = blitz::sum(snap2) / blitz::sum(snap); @@ -543,7 +543,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(tmp); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask auto tmp2 = plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"]); typename Plotter_t::arr_t snap2(tmp2); plotter.multiply_by_rhod(snap2); @@ -601,7 +601,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(tmp); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); auto cloudy_column = plotter.k_i.copy(); @@ -626,7 +626,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(tmp); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); auto cloudy_column = plotter.k_i.copy(); @@ -768,7 +768,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask typename Plotter_t::arr_t acc_acnv(plotter.h5load_timestep("acc_acnv25", at * n["outfreq"])); auto tot_acc_acnv = blitz::sum(acc_acnv); @@ -794,7 +794,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask typename Plotter_t::arr_t acc_accr(plotter.h5load_timestep("acc_accr25", at * n["outfreq"])); double tot_acc_accr = blitz::sum(acc_accr); @@ -1176,7 +1176,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask typename Plotter_t::arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 @@ -1197,7 +1197,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask typename Plotter_t::arr_t snap2(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 @@ -1217,7 +1217,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask typename Plotter_t::arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); typename Plotter_t::arr_t snap3(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); @@ -1240,7 +1240,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask typename Plotter_t::arr_t snap_m0(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); typename Plotter_t::arr_t snap_m1(plotter.h5load_timestep("gccn_rw_mom1", at * n["outfreq"]) * 1e6); // in microns snap_m0 *= snap; @@ -1288,7 +1288,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask typename Plotter_t::arr_t snap2(plotter.h5load_timestep("rd_geq_0.8um_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 @@ -1322,7 +1322,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask typename Plotter_t::arr_t snap2(plotter.h5load_timestep("rd_lt_0.8um_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 @@ -1355,7 +1355,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 - snap = iscloudy(snap); // cloudiness mask + snap = iscloudy_nc_dycoms(snap); // cloudiness mask typename Plotter_t::arr_t snap_m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); typename Plotter_t::arr_t snap_m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])*1e6); // in microns snap_m0 *= snap; From 57f665135a47686fc9b657668afbf55e661a156c Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 15 Dec 2022 16:08:16 +0100 Subject: [PATCH 15/51] wip --- UWLCM_plotters/include/PlotterMask.hpp | 47 ++- drawbicyc/include/cases/RICO11/plots.hpp | 8 +- drawbicyc/include/plot_series.hpp | 372 +++++++++-------------- 3 files changed, 187 insertions(+), 240 deletions(-) diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index 42f1624..f086a9e 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -17,7 +17,6 @@ class PlotterMask : public PlotterMicro void calc_mask(int at) { - // RICO mask; TODO: add other masks if(mask_type == mask_type_t::Rico11) { mask = this->load_ract_timestep(at); @@ -29,6 +28,7 @@ class PlotterMask : public PlotterMicro mask = iscloudy_nc_dycoms(mask); } else throw std::runtime_error("Invalid mask type"); + mask(this->hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux } //lgrngn_droplet_prefix @@ -61,6 +61,11 @@ class PlotterMask : public PlotterMicro public: + arr_t get_mask(int at) + { + calc_mask(at); + return mask; + } // functions for diagnosing statistics // mean and std dev [g/kg] of the mixing ratio of activated dropelts in cloudy cells (characteristics of the spatial distribution at this timestep) @@ -73,25 +78,43 @@ class PlotterMask : public PlotterMicro } // mean and std_dev of concentration of activated droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) - std::pair cloud_actconc_stats_timestep(int at) + std::pair cloud_conc_stats_timestep_hlpr(int at, std::string lgrngn_prefix, std::string blk_2m_1, std::string blk_2m_2 = "") { - arr_t actconc; + arr_t conc; // read concentration of activated droplets if(this->micro == "blk_1m") return {0,0}; // TODO: fix stupid copying of arrays else if(this->micro == "lgrngn") { - arr_t tmp(this->h5load_timestep("actrw_rw_mom0", at)); - actconc.resize(tmp.shape()); - actconc = tmp; + arr_t tmp(this->h5load_timestep(lgrngn_prefix+"_mom0", at)); + conc.resize(tmp.shape()); + conc = tmp; } else if(this->micro == "blk_2m") { - arr_t tmp(arr_t(this->h5load_timestep("nc", at)) + arr_t(this->h5load_timestep("nr", at))); - actconc.resize(tmp.shape()); - actconc = tmp; + arr_t tmp(arr_t(this->h5load_timestep(blk_2m_1, at))); + if(blk_2m_2 != "") + tmp += arr_t(this->h5load_timestep(blk_2m_2, at)); + conc.resize(tmp.shape()); + conc = tmp; } - this->multiply_by_rhod(actconc); // b4 it was specific moment - actconc /= 1e6; // per cm^3 - return cloud_hlpr(actconc, at); + this->multiply_by_rhod(conc); // b4 it was specific moment + conc /= 1e6; // per cm^3 + return cloud_hlpr(conc, at); + } + + // mean and std_dev of concentration of activated droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) + std::pair cloud_actconc_stats_timestep(int at) + { + return cloud_conc_stats_timestep_hlpr(at, "act_rw", "nc", "nr"); + } + + std::pair cloud_cloudconc_stats_timestep(int at) + { + return cloud_conc_stats_timestep_hlpr(at, "cloud_rw", "nc"); + } + + std::pair cloud_rainconc_stats_timestep(int at) + { + return cloud_conc_stats_timestep_hlpr(at, "rain_rw", "nr"); } diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index 0a4ccd3..19fe652 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -2,16 +2,16 @@ const std::vector series_rico({ "RH_max", -"cloud_cover_rico", -"min_cloud_base_rico", +"cloud_cover", +"min_cloud_base", "inversion_height_rico", "tot_water", "lwp", "rwp", "surf_precip", "acc_precip", -"cl_nc_rico", -"cl_nr_rico", +"cl_nc", +"cl_nr", "cloud_avg_supersat", "wvarmax", "cl_meanr", //TODO: zmienic maske na rico diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index 9bb2e12..2bc7405 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -7,6 +7,8 @@ template void plot_series(Plotter_t plotter, Plots plots, std::string type) { + using arr_t = typename Plotter_t::arr_t; + auto& n = plotter.map; auto& n_prof = plotter.map_prof; for(auto elem : n) @@ -24,15 +26,15 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // read in density auto tmp = plotter.h5load(plotter.file + "/const.h5", "G"); - typename Plotter_t::arr_t rhod(tmp); - typename Plotter_t::arr_t rtot(rhod.shape()); + arr_t rhod(tmp); + arr_t rtot(rhod.shape()); - typename Plotter_t::arr_t res_tmp(rhod.shape()); + arr_t res_tmp(rhod.shape()); // for calculating running averages of u and w, needed in TKE calc in Pi chamber LES - std::vector prev_u_vec, prev_w_vec; + std::vector prev_u_vec, prev_w_vec; // container for the running sum - typename Plotter_t::arr_t run_sum_u(rhod.shape()), run_sum_w(rhod.shape()); + arr_t run_sum_u(rhod.shape()), run_sum_w(rhod.shape()); run_sum_u = 0; run_sum_w = 0; // number of timesteps over which the running avg of u and w is calculated (1 min interval) @@ -122,12 +124,13 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) for (auto &plt : plots.series) { + std::cerr << plt << std::endl; if (plt == "cloud_cover_dycoms") { try { auto tmp = plotter.load_rc_timestep(at * n["outfreq"]) * 1e3; //g/kg - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); snap += plotter.load_rr_timestep(at * n["outfreq"]) * 1e3; //g/kg plotter.multiply_by_rhod(snap); plotter.k_i = blitz::sum(snap, plotter.LastIndex) * n["refined dz"]; // LWP [g/m2] in the column @@ -136,15 +139,12 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cloud_cover_rico") + else if (plt == "cloud_cover") { try { // cloud fraction (fraction of columns with at least one cloudy cell, i.e. cell with q_c > 0.01 g/kg) - auto tmp = plotter.load_rc_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - snap = iscloudy_rc_rico(snap); // find cells with rc>1e-5 - snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux + arr_t snap(plotter.get_mask(at * n["outfreq"])); plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); plotter.k_i = blitz::sum(snap, plotter.LastIndex); plotter.k_i = where(plotter.k_i > 0, 1, 0); @@ -160,7 +160,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // read RH auto tmp = plotter.h5load_timestep("RH", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); res_series[plt](at) = blitz::max(snap); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -181,10 +181,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - // cloud fraction (cloudy if ql > 1e-5)) - auto tmp = plotter.load_rc_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - snap = iscloudy_rc_rico(snap); + arr_t snap(plotter.get_mask(at * n["outfreq"])); plotter.k_i = blitz::last((snap == 1), plotter.LastIndex); auto cloudy_column = plotter.k_i.copy(); cloudy_column = blitz::sum(snap, plotter.LastIndex); @@ -237,26 +234,26 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) /* { auto tmp = plotter.h5load_timestep("aerosol_rw_mom3", at * n["outfreq"]) * 4./3. * 3.1416 * 1e3; - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); snap *= rhod; res_series[plt](at) = blitz::mean(snap); } */ { auto tmp = plotter.h5load_timestep("cloud_rw_mom3", at * n["outfreq"]) * 4./3. * 3.1416 * 1e3; - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); plotter.multiply_by_rhod(snap); res_series[plt](at) += blitz::mean(snap); } { auto tmp = plotter.h5load_timestep("rain_rw_mom3", at * n["outfreq"]) * 4./3. * 3.1416 * 1e3; - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); plotter.multiply_by_rhod(snap); res_series[plt](at) += blitz::mean(snap); } { auto tmp = plotter.h5load_timestep("rv", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); plotter.multiply_by_rhod(snap); res_series[plt](at) += blitz::mean(snap); } @@ -278,9 +275,9 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.load_ract_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - typename Plotter_t::arr_t snap2(tmp); - typename Plotter_t::arr_t snap3(tmp); + arr_t snap(tmp); + arr_t snap2(tmp); + arr_t snap3(tmp); snap2 = snap2 * plotter.LastIndex; snap3 = snap3 * blitz::tensor::i; @@ -289,7 +286,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) int z_idx = blitz::sum(snap2) / blitz::sum(snap); int x_idx = blitz::sum(snap3) / blitz::sum(snap); auto tmp2 = plotter.h5load_timestep("w", at * n["outfreq"]); - typename Plotter_t::arr_t snap_mom(tmp2); + arr_t snap_mom(tmp2); res_series[plt](at) = snap_mom(x_idx, z_idx); } else @@ -303,9 +300,9 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.load_ract_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - typename Plotter_t::arr_t snap2(tmp); - typename Plotter_t::arr_t snap3(tmp); + arr_t snap(tmp); + arr_t snap2(tmp); + arr_t snap3(tmp); snap2 = snap2 * plotter.LastIndex; snap3 = snap3 * blitz::tensor::i; @@ -314,7 +311,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) int z_idx = blitz::sum(snap2) / blitz::sum(snap); int x_idx = blitz::sum(snap3) / blitz::sum(snap); auto tmp2 = plotter.h5load_timestep("RH", at * n["outfreq"]); - typename Plotter_t::arr_t snap_mom(tmp2); + arr_t snap_mom(tmp2); res_series[plt](at) = snap_mom(x_idx, z_idx) - 1; } else @@ -328,9 +325,9 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.load_ract_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - typename Plotter_t::arr_t snap2(tmp); - typename Plotter_t::arr_t snap3(tmp); + arr_t snap(tmp); + arr_t snap2(tmp); + arr_t snap3(tmp); snap2 = snap2 * plotter.LastIndex; snap3 = snap3 * blitz::tensor::i; @@ -340,7 +337,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) com_x_idx(at) = blitz::sum(snap3) / blitz::sum(snap); std::cout << at << ": (" << com_x_idx(at) << "," << com_z_idx(at) << ")" << std::endl; auto tmp2 = plotter.h5load_timestep("actrw_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t snap_mom(tmp2); + arr_t snap_mom(tmp2); com_N_c(at) = snap_mom(com_x_idx(at), com_z_idx(at)); // 0th raw moment / mass [1/kg] plotter.multiply_by_rhod(snap); res_series[plt](at) = snap_mom(com_x_idx(at), com_z_idx(at)); @@ -359,7 +356,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.h5load_timestep("actrw_rw_mom1", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); // 1st raw moment / mass [m / kg] + arr_t snap(tmp); // 1st raw moment / mass [m / kg] if(com_N_c(at) > 0) res_series[plt](at) = snap(com_x_idx(at), com_z_idx(at)) / com_N_c(at); else @@ -374,13 +371,13 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.h5load_timestep("actrw_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t zeroth_raw_mom(tmp); // 0th raw moment / mass [1 / kg] + arr_t zeroth_raw_mom(tmp); // 0th raw moment / mass [1 / kg] tmp = plotter.h5load_timestep("actrw_rw_mom1", at * n["outfreq"]); - typename Plotter_t::arr_t first_raw_mom(tmp); // 1st raw moment / mass [m / kg] + arr_t first_raw_mom(tmp); // 1st raw moment / mass [m / kg] tmp = plotter.h5load_timestep("actrw_rw_mom2", at * n["outfreq"]); - typename Plotter_t::arr_t second_raw_mom(tmp); // 2nd raw moment / mass [m^2 / kg] + arr_t second_raw_mom(tmp); // 2nd raw moment / mass [m^2 / kg] tmp = plotter.h5load_timestep("sd_conc", at * n["outfreq"]); - typename Plotter_t::arr_t sd_conc(tmp); // number of SDs + arr_t sd_conc(tmp); // number of SDs if(com_N_c(at) > 0) { double SD_no = sd_conc(com_x_idx(at), com_z_idx(at)); @@ -413,7 +410,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { tmp = plotter.h5load_timestep("sd_conc", at * n["outfreq"]); - typename Plotter_t::arr_t sd_conc(tmp); // number of SDs + arr_t sd_conc(tmp); // number of SDs res_series[plt](at) = sd_conc(com_x_idx(at), com_z_idx(at)); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -424,7 +421,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.h5load_timestep("th", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); res_tmp = is_th_prtrb(snap); // find cells with th>300.1 snap *= res_tmp; // apply filter @@ -442,7 +439,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // height of cells with largest gradient of theta try { - typename Plotter_t::arr_t th(plotter.h5load_timestep("th", at * n["outfreq"])); + arr_t th(plotter.h5load_timestep("th", at * n["outfreq"])); auto grad = plotter.cent_diff_vert(th); auto max_index = blitz::maxIndex(grad, plotter.LastIndex); res_series[plt](at) = (blitz::mean(max_index) + 1) * n["dz"]; @@ -455,7 +452,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); snap /= 1e6; // per cm^3 plotter.multiply_by_rhod(snap); res_series[plt](at) = blitz::mean(snap); @@ -468,7 +465,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.h5load_timestep("all_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); snap /= 1e6; // per cm^3 plotter.multiply_by_rhod(snap); res_series[plt](at) = blitz::mean(snap); @@ -481,7 +478,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); snap /= 1e6; // per cm^3 plotter.multiply_by_rhod(snap); res_series[plt](at) = blitz::mean(snap); @@ -493,43 +490,9 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // cloud droplet (0.5um < r < 25 um) concentration in cloudy grid cells try { - // cloud fraction (cloudy if N_c > 20/cm^3) - auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - typename Plotter_t::arr_t snap2; - snap2.resize(snap.shape()); - snap2=snap; - snap = iscloudy_nc_dycoms(snap); // cloudiness mask - snap2 *= snap; - if(blitz::sum(snap) > 0) - res_series[plt](at) = blitz::sum(snap2) / blitz::sum(snap); - else - res_series[plt](at) = 0; - } - catch(...) {if(at==first_timestep) data_found[plt]=0;} - } - else if (plt == "cl_nc_rico") - { - // cloud droplet (0.5um < r < 25 um) concentration in cloudy grid cells - try - { - // rico cloud mask - auto tmp = plotter.load_rc_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - snap = iscloudy_rc_rico(snap); // find cells with rc>1e-5 - snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux - - typename Plotter_t::arr_t snap2(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - plotter.multiply_by_rhod(snap2); - snap2 /= 1e6; // per cm^3 - - snap2 *= snap; - if(blitz::sum(snap) > 0) - res_series[plt](at) = blitz::sum(snap2) / blitz::sum(snap); - else - res_series[plt](at) = 0; + auto stats = plotter.cloud_cloudconc_stats_timestep(at * n["outfreq"]); + res_series[plt](at) = stats.first; + res_series_std_dev[plt](at) = stats.second; } catch(...) {if(at==first_timestep) data_found[plt]=0;} } @@ -538,45 +501,9 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // rain drop (25um < r) concentration in cloudy grid cells try { - // cloud fraction (cloudy if N_c > 20/cm^3) - auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask - auto tmp2 = plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t snap2(tmp2); - plotter.multiply_by_rhod(snap2); - snap2 /= 1e6; // per cm^3 - snap2 *= snap; - if(blitz::sum(snap) > 0) - res_series[plt](at) = blitz::sum(snap2) / blitz::sum(snap); - else - res_series[plt](at) = 0; - } - catch(...) {if(at==first_timestep) data_found[plt]=0;} - } - else if (plt == "cl_nr_rico") - { - // rain drop (25um < r) concentration in cloudy grid cells - try - { - // rico cloud mask - auto tmp = plotter.load_rc_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - snap = iscloudy_rc_rico(snap); // find cells with rc>1e-5 - snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux - - auto tmp2 = plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t snap2(tmp2); - plotter.multiply_by_rhod(snap2); - snap2 /= 1e6; // per cm^3 - - snap2 *= snap; - if(blitz::sum(snap) > 0) - res_series[plt](at) = blitz::sum(snap2) / blitz::sum(snap); - else - res_series[plt](at) = 0; + auto stats = plotter.cloud_rainconc_stats_timestep(at * n["outfreq"]); + res_series[plt](at) = stats.first; + res_series_std_dev[plt](at) = stats.second; } catch(...) {if(at==first_timestep) data_found[plt]=0;} } @@ -586,7 +513,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.h5load_timestep("actrw_rw_mom0", at *n["outfreq"]) * rhod; - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); res_series[plt](at) = blitz::sum(snap)*plotter.CellVol; } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -598,7 +525,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { // cloud fraction (cloudy if N_c > 20/cm^3) auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask @@ -623,7 +550,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // -- average cloud base, almost exactly as in "cloud_base_dycoms"... -- // cloud fraction (cloudy if N_c > 20/cm^3) auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask @@ -650,15 +577,12 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "min_cloud_base_rico") + else if (plt == "min_cloud_base") { // lowest cloud base in the domain try { - // cloud fraction (cloudy if r_c > 1e-5) - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - snap = iscloudy_rc_rico(snap); - snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux + arr_t snap(plotter.get_mask(at * n["outfreq"])); plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); auto cloudy_column = plotter.k_i.copy(); cloudy_column = blitz::sum(snap, plotter.LastIndex); @@ -722,7 +646,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.h5load_timestep("rd_rng000_mom3", at * n["outfreq"]) * 4./3. * 3.14 * rho_dry * 1e3; - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); plotter.multiply_by_rhod(snap); plotter.multiply_by_CellVol(snap); res_series[plt](at) = blitz::sum(snap); @@ -765,12 +689,12 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if N_c > 20/cm^3) - typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask - typename Plotter_t::arr_t acc_acnv(plotter.h5load_timestep("acc_acnv25", at * n["outfreq"])); + arr_t acc_acnv(plotter.h5load_timestep("acc_acnv25", at * n["outfreq"])); auto tot_acc_acnv = blitz::sum(acc_acnv); if(blitz::sum(snap) > 0) @@ -791,12 +715,12 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if N_c > 20/cm^3) - typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask - typename Plotter_t::arr_t acc_accr(plotter.h5load_timestep("acc_accr25", at * n["outfreq"])); + arr_t acc_accr(plotter.h5load_timestep("acc_accr25", at * n["outfreq"])); double tot_acc_accr = blitz::sum(acc_accr); if(blitz::sum(snap) > 0) @@ -817,10 +741,10 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if r_c > 1e-5) - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); + arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc_rico(snap); - typename Plotter_t::arr_t acc_acnv(plotter.h5load_timestep("acc_acnv25", at * n["outfreq"])); + arr_t acc_acnv(plotter.h5load_timestep("acc_acnv25", at * n["outfreq"])); auto tot_acc_acnv = blitz::sum(acc_acnv); if(blitz::sum(snap) > 0) @@ -841,10 +765,10 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if r_c > 1e-5) - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); + arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc_rico(snap); - typename Plotter_t::arr_t acc_accr(plotter.h5load_timestep("acc_accr25", at * n["outfreq"])); + arr_t acc_accr(plotter.h5load_timestep("acc_accr25", at * n["outfreq"])); double tot_acc_accr = blitz::sum(acc_accr); if(blitz::sum(snap) > 0) @@ -862,8 +786,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - typename Plotter_t::arr_t rl(plotter.load_rc_timestep(at * n["outfreq"])); - typename Plotter_t::arr_t rr(plotter.load_rr_timestep(at * n["outfreq"])); + arr_t rl(plotter.load_rc_timestep(at * n["outfreq"])); + arr_t rr(plotter.load_rr_timestep(at * n["outfreq"])); rl = (rl + rr) * 1e3; // g/kg plotter.multiply_by_rhod(rl); res_series[plt](at) = blitz::mean(rl); @@ -877,7 +801,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - typename Plotter_t::arr_t snap(plotter.load_rr_timestep(at * n["outfreq"])); + arr_t snap(plotter.load_rr_timestep(at * n["outfreq"])); snap *= 1e3; plotter.multiply_by_rhod(snap); res_series[plt](at) = blitz::mean(snap); @@ -891,7 +815,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); + arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap *= rhod * 1e3; // water per cubic metre (should be wet density...) & g/kg res_series[plt](at) = blitz::mean(snap); } @@ -905,7 +829,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { { auto tmp = plotter.load_rc_timestep(at * n["outfreq"]) * rhod; - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); snap += plotter.load_rr_timestep(at * n["outfreq"]) * rhod; snap *= plotter.CellVol; snap(plotter.hrzntl_slice(0)) = snap(plotter.hrzntl_slice(0))/2; @@ -922,7 +846,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { { auto tmp = plotter.load_rc_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); snap *= rhod * plotter.CellVol; snap(plotter.hrzntl_slice(0)) = snap(plotter.hrzntl_slice(0))/2; snap(plotter.hrzntl_slice(-1)) = snap(plotter.hrzntl_slice(-1))/2; @@ -938,7 +862,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { { auto tmp = plotter.load_rr_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); snap *= rhod * plotter.CellVol; snap(plotter.hrzntl_slice(0)) = snap(plotter.hrzntl_slice(0))/2; snap(plotter.hrzntl_slice(-1)) = snap(plotter.hrzntl_slice(-1))/2; @@ -952,7 +876,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - typename Plotter_t::arr_t snap(plotter.h5load_timestep("latent surface flux", at * n["outfreq"], true)); + arr_t snap(plotter.h5load_timestep("latent surface flux", at * n["outfreq"], true)); res_series[plt](at) = blitz::mean(snap); } } @@ -963,7 +887,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { { - typename Plotter_t::arr_t snap(plotter.h5load_timestep("sensible surface flux", at * n["outfreq"], true)); + arr_t snap(plotter.h5load_timestep("sensible surface flux", at * n["outfreq"], true)); res_series[plt](at) = blitz::mean(snap); } } @@ -977,13 +901,13 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { { auto tmp = plotter.load_rc_timestep(at * n["outfreq"]) * 1e3; //g/kg - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); snap += plotter.load_rr_timestep(at * n["outfreq"]) * 1e3; //g/kg rtot = snap; } { auto tmp = plotter.h5load_timestep("rv", at * n["outfreq"]) * 1e3; - typename Plotter_t::arr_t snap(tmp); // vapor mixing ratio [g/kg] + arr_t snap(tmp); // vapor mixing ratio [g/kg] rtot += snap; } plotter.k_i = 0; @@ -998,7 +922,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { auto tmp = plotter.h5load_timestep("w", at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); + arr_t snap(tmp); Array mean(n["z"]); snap = snap * snap; // 2nd power, w_mean = 0 // mean variance of w in horizontal @@ -1012,19 +936,19 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t u(plotter.h5load_timestep("u", at * n["outfreq"])); + arr_t u(plotter.h5load_timestep("u", at * n["outfreq"])); plotter.subtract_horizontal_mean(u); u = u * u; res_series[plt](at) = blitz::mean(plotter.horizontal_mean(u)); - typename Plotter_t::arr_t w(plotter.h5load_timestep("w", at * n["outfreq"])); + arr_t w(plotter.h5load_timestep("w", at * n["outfreq"])); plotter.subtract_horizontal_mean(w); w = w * w; res_series[plt](at) += blitz::mean(plotter.horizontal_mean(w)); if (Plotter_t::n_dims > 2) { - typename Plotter_t::arr_t v(plotter.h5load_timestep("v", at * n["outfreq"])); + arr_t v(plotter.h5load_timestep("v", at * n["outfreq"])); plotter.subtract_horizontal_mean(v); v = v * v; res_series[plt](at) += blitz::mean(plotter.horizontal_mean(v)); @@ -1032,8 +956,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) res_series[plt](at) *= 0.5; // * n["dz"]; - typename Plotter_t::arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); - typename Plotter_t::arr_t snap; + arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); + arr_t snap; snap.reference(tke); res_series[plt](at) += blitz::mean(plotter.horizontal_mean(snap)); @@ -1044,19 +968,19 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t u(plotter.h5load_timestep("u", at * n["outfreq"])); + arr_t u(plotter.h5load_timestep("u", at * n["outfreq"])); plotter.subtract_horizontal_mean(u); u = u * u; res_series[plt](at) = blitz::mean(plotter.horizontal_mean(u)); - typename Plotter_t::arr_t w(plotter.h5load_timestep("w", at * n["outfreq"])); + arr_t w(plotter.h5load_timestep("w", at * n["outfreq"])); plotter.subtract_horizontal_mean(w); w = w * w; res_series[plt](at) += blitz::mean(plotter.horizontal_mean(w)); res_series[plt](at) *= 0.5;// * n["dz"]; - typename Plotter_t::arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); + arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); if (Plotter_t::n_dims == 3) { // assume that sgs tke is isotropic, hence 2/3 are in the uw plane @@ -1074,8 +998,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t u(plotter.h5load_timestep("u", at * n["outfreq"])); - typename Plotter_t::arr_t w(plotter.h5load_timestep("w", at * n["outfreq"])); + arr_t u(plotter.h5load_timestep("u", at * n["outfreq"])); + arr_t w(plotter.h5load_timestep("w", at * n["outfreq"])); int step_no = at - first_timestep; if(step_no == 0) // the first step { @@ -1125,7 +1049,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) res_series[plt](at) *= 0.5;// * n["dz"]; - typename Plotter_t::arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); + arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); if (Plotter_t::n_dims == 3) { // assume that sgs tke is isotropic, hence 2/3 are in the uw plane @@ -1142,7 +1066,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); + arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); res_series[plt](at) = blitz::mean(plotter.horizontal_mean(tke)); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -1151,15 +1075,15 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t tot_m0(plotter.h5load_timestep("aerosol_rw_mom0", at * n["outfreq"])); - tot_m0 += typename Plotter_t::arr_t(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - tot_m0 += typename Plotter_t::arr_t(plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"])); + arr_t tot_m0(plotter.h5load_timestep("aerosol_rw_mom0", at * n["outfreq"])); + tot_m0 += arr_t(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + tot_m0 += arr_t(plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"])); - typename Plotter_t::arr_t tke(plotter.h5load_timestep("all_up_mom2", at * n["outfreq"])); - tke += typename Plotter_t::arr_t(plotter.h5load_timestep("all_wp_mom2", at * n["outfreq"])); + arr_t tke(plotter.h5load_timestep("all_up_mom2", at * n["outfreq"])); + tke += arr_t(plotter.h5load_timestep("all_wp_mom2", at * n["outfreq"])); if (Plotter_t::n_dims > 2) - tke += typename Plotter_t::arr_t(plotter.h5load_timestep("all_vp_mom2", at * n["outfreq"])); + tke += arr_t(plotter.h5load_timestep("all_vp_mom2", at * n["outfreq"])); tke = blitz::where(tot_m0 > 0., 0.5 * tke / tot_m0, 0); // tke in each cell @@ -1173,11 +1097,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if N_c > 20/cm^3) - typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask - typename Plotter_t::arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); + arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; @@ -1194,11 +1118,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if N_c > 20/cm^3) - typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask - typename Plotter_t::arr_t snap2(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); + arr_t snap2(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; @@ -1214,12 +1138,12 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if N_c > 20/cm^3) - typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask - typename Plotter_t::arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); - typename Plotter_t::arr_t snap3(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); + arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); + arr_t snap3(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); snap2 = where(snap3 > 0, snap2 / snap3, 0); // even if snap3=0, they are noncloudy anyway snap2 *= snap; @@ -1237,12 +1161,12 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if N_c > 20/cm^3) - typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask - typename Plotter_t::arr_t snap_m0(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); - typename Plotter_t::arr_t snap_m1(plotter.h5load_timestep("gccn_rw_mom1", at * n["outfreq"]) * 1e6); // in microns + arr_t snap_m0(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); + arr_t snap_m1(plotter.h5load_timestep("gccn_rw_mom1", at * n["outfreq"]) * 1e6); // in microns snap_m0 *= snap; snap_m1 *= snap; auto tot_gccn_m0 = blitz::sum(snap_m0); @@ -1258,7 +1182,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // gccn (r_d > 2 um) concentration try { - typename Plotter_t::arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); + arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); snap2 /= 1e6; // per cm^3 plotter.multiply_by_rhod(snap2); res_series[plt](at) = blitz::mean(snap2); @@ -1270,7 +1194,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // gccn (r_d > 2 um) concentration try { - typename Plotter_t::arr_t snap2(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); + arr_t snap2(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); snap2 /= 1e6; // per cm^3 plotter.multiply_by_rhod(snap2); res_series[plt](at) = blitz::mean(snap2); @@ -1285,11 +1209,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if N_c > 20/cm^3) - typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask - typename Plotter_t::arr_t snap2(plotter.h5load_timestep("rd_geq_0.8um_rw_mom0", at * n["outfreq"])); + arr_t snap2(plotter.h5load_timestep("rd_geq_0.8um_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; @@ -1305,7 +1229,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // gccn (r_d >= 0.8 um) concentration try { - typename Plotter_t::arr_t snap2(plotter.h5load_timestep("rd_geq_0.8um_rw_mom0", at * n["outfreq"])); + arr_t snap2(plotter.h5load_timestep("rd_geq_0.8um_rw_mom0", at * n["outfreq"])); snap2 /= 1e6; // per cm^3 plotter.multiply_by_rhod(snap2); res_series[plt](at) = blitz::mean(snap2); @@ -1319,11 +1243,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if N_c > 20/cm^3) - typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask - typename Plotter_t::arr_t snap2(plotter.h5load_timestep("rd_lt_0.8um_rw_mom0", at * n["outfreq"])); + arr_t snap2(plotter.h5load_timestep("rd_lt_0.8um_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 snap2 *= snap; @@ -1338,7 +1262,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t snap2(plotter.h5load_timestep("rd_lt_0.8um_rw_mom0", at * n["outfreq"])); + arr_t snap2(plotter.h5load_timestep("rd_lt_0.8um_rw_mom0", at * n["outfreq"])); snap2 /= 1e6; // per cm^3 plotter.multiply_by_rhod(snap2); res_series[plt](at) = blitz::mean(snap2); @@ -1352,12 +1276,12 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // cloud fraction (cloudy if N_c > 20/cm^3) - typename Plotter_t::arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap); snap /= 1e6; // per cm^3 snap = iscloudy_nc_dycoms(snap); // cloudiness mask - typename Plotter_t::arr_t snap_m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - typename Plotter_t::arr_t snap_m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])*1e6); // in microns + arr_t snap_m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap_m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])*1e6); // in microns snap_m0 *= snap; snap_m1 *= snap; auto tot_m0 = blitz::sum(snap_m0); @@ -1374,19 +1298,19 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); + arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc(snap); // cloudiness mask //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); // 0-th specific mom of bigrain cloud drops - typename Plotter_t::arr_t bigrain_conc(plotter.h5load_timestep("bigrain_rw_mom0", at * n["outfreq"])); + arr_t bigrain_conc(plotter.h5load_timestep("bigrain_rw_mom0", at * n["outfreq"])); // concentration of bigrain cloud drops at cloud base plotter.tmp_float_hrzntl_slice = plotter.get_value_at_hgt(bigrain_conc, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // we need to multiply by rhod here, because different cloud bases can mean different rhod // 1st specific mom of incloud time of bigrain drops - typename Plotter_t::arr_t bigrain_inclt_mom1(plotter.h5load_timestep("bigrain_incloud_time_mom1", at * n["outfreq"])); + arr_t bigrain_inclt_mom1(plotter.h5load_timestep("bigrain_incloud_time_mom1", at * n["outfreq"])); // 1st mom of incloud time at cloud base plotter.tmp_float_hrzntl_slice2 = plotter.get_value_at_hgt(bigrain_inclt_mom1, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // same as above @@ -1403,19 +1327,19 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); + arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc(snap); // cloudiness mask //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); // 0-th specific mom of bigrain cloud drops - typename Plotter_t::arr_t bigrain_conc(plotter.h5load_timestep("bigrain_rw_mom0", at * n["outfreq"])); + arr_t bigrain_conc(plotter.h5load_timestep("bigrain_rw_mom0", at * n["outfreq"])); // concentration of bigrain cloud drops at cloud base plotter.tmp_float_hrzntl_slice = plotter.get_value_at_hgt(bigrain_conc, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // we need to multiply by rhod here, because different cloud bases can mean different rhod // 1st specific mom of rd of bigrain drops - typename Plotter_t::arr_t bigrain_rd_mom1(plotter.h5load_timestep("bigrain_rd_mom1", at * n["outfreq"])); + arr_t bigrain_rd_mom1(plotter.h5load_timestep("bigrain_rd_mom1", at * n["outfreq"])); // 1st mom of rd at cloud base plotter.tmp_float_hrzntl_slice2 = plotter.get_value_at_hgt(bigrain_rd_mom1, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // same as above @@ -1432,19 +1356,19 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); + arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc(snap); // cloudiness mask //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); // 0-th specific mom of bigrain cloud drops - typename Plotter_t::arr_t bigrain_conc(plotter.h5load_timestep("bigrain_rw_mom0", at * n["outfreq"])); + arr_t bigrain_conc(plotter.h5load_timestep("bigrain_rw_mom0", at * n["outfreq"])); // concentration of bigrain cloud drops at cloud base plotter.tmp_float_hrzntl_slice = plotter.get_value_at_hgt(bigrain_conc, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // we need to multiply by rhod here, because different cloud bases can mean different rhod // 1st specific mom of rd of bigrain drops - typename Plotter_t::arr_t bigrain_kappa_mom1(plotter.h5load_timestep("bigrain_kappa_mom1", at * n["outfreq"])); + arr_t bigrain_kappa_mom1(plotter.h5load_timestep("bigrain_kappa_mom1", at * n["outfreq"])); // 1st mom of rd at cloud base plotter.tmp_float_hrzntl_slice2 = plotter.get_value_at_hgt(bigrain_kappa_mom1, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // same as above @@ -1461,14 +1385,14 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); + arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc(snap); // cloudiness mask //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); // 0-th specific mom of bigrain cloud drops - typename Plotter_t::arr_t bigrain_conc(plotter.h5load_timestep("bigrain_rw_mom0", at * n["outfreq"])); + arr_t bigrain_conc(plotter.h5load_timestep("bigrain_rw_mom0", at * n["outfreq"])); // concentration of bigrain cloud drops at cloud base [1/m^3] plotter.tmp_float_hrzntl_slice = plotter.get_value_at_hgt(bigrain_conc, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // we need to multiply by rhod here, because different cloud bases can mean different rhod @@ -1487,19 +1411,19 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); + arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); snap = iscloudy_rc(snap); // cloudiness mask //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); // 0-th specific mom of bigrain cloud drops - typename Plotter_t::arr_t bigrain_conc(plotter.h5load_timestep("bigrain_rw_mom0", at * n["outfreq"])); + arr_t bigrain_conc(plotter.h5load_timestep("bigrain_rw_mom0", at * n["outfreq"])); // concentration of bigrain cloud drops at cloud base [1/m^3] plotter.tmp_float_hrzntl_slice = plotter.get_value_at_hgt(bigrain_conc, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // we need to multiply by rhod here, because different cloud bases can mean different rhod // 0-th specific mom of bigrain cloud drops formed on gccn - typename Plotter_t::arr_t bigrain_gccn_conc(plotter.h5load_timestep("bigrain_gccn_rw_mom0", at * n["outfreq"])); + arr_t bigrain_gccn_conc(plotter.h5load_timestep("bigrain_gccn_rw_mom0", at * n["outfreq"])); // concentration of bigrain cloud drops at cloud base [1/m^3] plotter.tmp_float_hrzntl_slice2 = plotter.get_value_at_hgt(bigrain_gccn_conc, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // we need to multiply by rhod here, because different cloud bases can mean different rhod @@ -1547,8 +1471,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t lwc(plotter.load_rc_timestep(at * n["outfreq"])); // cloud water, no rain water in pi chamber icmw - //res_series[plt](at) = blitz::mean(typename Plotter_t::arr_t(plotter.nowall(lwc, distance_from_walls))); + arr_t lwc(plotter.load_rc_timestep(at * n["outfreq"])); // cloud water, no rain water in pi chamber icmw + //res_series[plt](at) = blitz::mean(arr_t(plotter.nowall(lwc, distance_from_walls))); res_series[plt](at) = blitz::mean(lwc); } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -1558,7 +1482,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t lwc(plotter.load_rc_timestep(at * n["outfreq"])); // cloud water, no rain water in pi chamber icmw + arr_t lwc(plotter.load_rc_timestep(at * n["outfreq"])); // cloud water, no rain water in pi chamber icmw lwc *= rhod; res_series[plt](at) = blitz::mean(lwc); } @@ -1579,7 +1503,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t nc(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t nc(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); nc *= rhod; // 1/kg -> 1/m^3 res_series[plt](at) = blitz::mean(nc); } @@ -1590,7 +1514,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t na(plotter.h5load_timestep("aerosol_rw_mom0", at * n["outfreq"])); + arr_t na(plotter.h5load_timestep("aerosol_rw_mom0", at * n["outfreq"])); na *= rhod; // 1/kg -> 1/m^3 res_series[plt](at) = blitz::mean(na); } @@ -1601,19 +1525,19 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t u(plotter.h5load_timestep("u", at * n["outfreq"])); + arr_t u(plotter.h5load_timestep("u", at * n["outfreq"])); plotter.subtract_horizontal_mean(u); u = u * u; res_series[plt](at) = blitz::mean(u); - typename Plotter_t::arr_t w(plotter.h5load_timestep("w", at * n["outfreq"])); + arr_t w(plotter.h5load_timestep("w", at * n["outfreq"])); plotter.subtract_horizontal_mean(w); w = w * w; res_series[plt](at) += blitz::mean(w); if (Plotter_t::n_dims > 2) { - typename Plotter_t::arr_t v(plotter.h5load_timestep("v", at * n["outfreq"])); + arr_t v(plotter.h5load_timestep("v", at * n["outfreq"])); plotter.subtract_horizontal_mean(v); v = v * v; res_series[plt](at) += blitz::mean(v); @@ -1627,19 +1551,19 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - typename Plotter_t::arr_t u(plotter.h5load_timestep("u", at * n["outfreq"])); + arr_t u(plotter.h5load_timestep("u", at * n["outfreq"])); plotter.subtract_horizontal_mean(u); u = u * u; res_series[plt](at) = blitz::mean(u); - typename Plotter_t::arr_t w(plotter.h5load_timestep("w", at * n["outfreq"])); + arr_t w(plotter.h5load_timestep("w", at * n["outfreq"])); plotter.subtract_horizontal_mean(w); w = w * w; res_series[plt](at) += blitz::mean(w); if (Plotter_t::n_dims > 2) { - typename Plotter_t::arr_t v(plotter.h5load_timestep("v", at * n["outfreq"])); + arr_t v(plotter.h5load_timestep("v", at * n["outfreq"])); plotter.subtract_horizontal_mean(v); v = v * v; res_series[plt](at) += blitz::mean(v); @@ -1647,8 +1571,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) res_series[plt](at) *= 0.5; // * n["dz"]; - typename Plotter_t::arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); - typename Plotter_t::arr_t snap; + arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); + arr_t snap; snap.reference(tke); res_series[plt](at) += blitz::mean(plotter.horizontal_mean(snap)); @@ -1660,9 +1584,9 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // droplets mean radius away from walls try { - typename Plotter_t::arr_t m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - typename Plotter_t::arr_t m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])); - //auto tot_m0 = blitz::sum(typename Plotter_t::arr_t(plotter.nowall(m0, distance_from_walls))); + arr_t m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])); + //auto tot_m0 = blitz::sum(arr_t(plotter.nowall(m0, distance_from_walls))); auto tot_m0 = blitz::sum(m0); if(tot_m0 > 0) res_series[plt](at) = blitz::sum(m1) / tot_m0; @@ -1676,8 +1600,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // droplets effective radius away from walls try { - typename Plotter_t::arr_t m2(plotter.h5load_timestep("cloud_rw_mom2", at * n["outfreq"])); - typename Plotter_t::arr_t m3(plotter.h5load_timestep("cloud_rw_mom3", at * n["outfreq"])); + arr_t m2(plotter.h5load_timestep("cloud_rw_mom2", at * n["outfreq"])); + arr_t m3(plotter.h5load_timestep("cloud_rw_mom3", at * n["outfreq"])); auto tot_m2 = blitz::sum(m2); if(tot_m2 > 0) res_series[plt](at) = blitz::sum(m3) / tot_m2; @@ -1731,10 +1655,10 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // relative dispersion (std dev / mean) of droplet radius distribution averaged over cells away from walls try { - //typename Plotter_t::arr_t m0(plotter.nowall(typename Plotter_t::arr_t(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])), distance_from_walls)); - typename Plotter_t::arr_t m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - typename Plotter_t::arr_t m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])); - typename Plotter_t::arr_t m2(plotter.h5load_timestep("cloud_rw_mom2", at * n["outfreq"])); + //arr_t m0(plotter.nowall(arr_t(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])), distance_from_walls)); + arr_t m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])); + arr_t m2(plotter.h5load_timestep("cloud_rw_mom2", at * n["outfreq"])); // calculate stddev of radius, store in m2 m2 = where(m0 > 0, m2 / m0 - m1 / m0 * m1 / m0, 0.); @@ -1760,7 +1684,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { const float C_E = 0.845; - typename Plotter_t::arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); + arr_t tke(plotter.h5load_timestep("tke", at * n["outfreq"])); tke = pow(tke, 3./2.); tke /= n_prof["mix_len"](plotter.LastIndex); // divide by SGS mixing length // res_series[plt](at) = blitz::mean(plotter.nowall(tke, distance_from_walls)) * C_E; From 905b34ea9e4868aa5d0bb03a00f008a69bdbb807 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 15 Dec 2022 16:10:53 +0100 Subject: [PATCH 16/51] wip --- drawbicyc/include/gnuplot_series_set_labels.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drawbicyc/include/gnuplot_series_set_labels.hpp b/drawbicyc/include/gnuplot_series_set_labels.hpp index edc4c02..a26d3bc 100644 --- a/drawbicyc/include/gnuplot_series_set_labels.hpp +++ b/drawbicyc/include/gnuplot_series_set_labels.hpp @@ -14,7 +14,7 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) gp << "set ylabel ''\n"; gp << "set title 'autoconersion rate (r>25um) (cloudy) [g/(m3*s}]'\n"; } - if (plt == "cloud_cover_dycoms" || plt == "cloud_cover_rico") + if (plt == "cloud_cover_dycoms" || plt == "cloud_cover") { // res_pos *= 60.; gp << "set xlabel ''\n"; @@ -151,7 +151,7 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) gp << "set title 'average cloud drop conc [1/cm^3]'\n"; else if (plt == "ntot") gp << "set title 'average particle conc [1/cm^3]'\n"; - else if (plt == "cl_nc" || plt == "cl_nc_rico") + else if (plt == "cl_nc") { gp << "set title 'average cloud drop conc [1/cm^3] in cloudy cells'\n"; gp << "set xlabel ''\n"; @@ -163,7 +163,7 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) gp << "set xlabel ''\n"; gp << "set ylabel ''\n"; } - else if (plt == "cl_nr" || plt == "cl_nr_rico") + else if (plt == "cl_nr") { gp << "set title 'average rain drop conc [1/cm^3] in cloudy cells'\n"; gp << "set xlabel ''\n"; @@ -253,7 +253,7 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) gp << "set xlabel ''\n"; gp << "set ylabel ''\n"; } - else if (plt == "min_cloud_base_rico") + else if (plt == "min_cloud_base") { gp << "set title 'lowest cloud base [m]'\n"; gp << "set xlabel ''\n"; From 87ee504bfc3fb6739c7146611f36695697516f7d Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 16 Dec 2022 11:04:18 +0100 Subject: [PATCH 17/51] get rid of iscloudy in series and profs --- drawbicyc/include/cases/RICO11/plots.hpp | 7 +- drawbicyc/include/plot_prof.hpp | 43 ++---- drawbicyc/include/plot_series.hpp | 165 +++++------------------ 3 files changed, 48 insertions(+), 167 deletions(-) diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index 19fe652..3e5b661 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -17,6 +17,9 @@ const std::vector series_rico({ "cl_meanr", //TODO: zmienic maske na rico "sd_conc" +cl_avg_cloud_rad +cloud_avg_std_dev_act_rad + // "clb_bigrain_mean_rd", // "clb_bigrain_mean_kappa", @@ -24,8 +27,8 @@ const std::vector series_rico({ // "clb_bigrain_mean_inclt", //, "clb_bigrain_mean_gccn_fraction" -//"cl_acnv25_rico", -//"cl_accr25_rico", +//"cl_acnv25", +//"cl_accr25", //,"nc" //,"nr" //TODO (po usprawnieniu cloud mask i ujednoliceniu tego: diff --git a/drawbicyc/include/plot_prof.hpp b/drawbicyc/include/plot_prof.hpp index 2e99f17..54a3e91 100644 --- a/drawbicyc/include/plot_prof.hpp +++ b/drawbicyc/include/plot_prof.hpp @@ -132,8 +132,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp = where(res_tmp > 0 , res_tmp / snap, res_tmp); } { - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - res_tmp2 = iscloudy_rc_rico(snap); + res_tmp2 = arr_t(plotter.get_mask(at * n["outfreq"])); res_tmp *= res_tmp2; } // mean only over downdraught cells @@ -149,8 +148,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp = where(res_tmp > 0 , res_tmp / snap, res_tmp); // mean radius } { - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - res_tmp2 = iscloudy_rc_rico(snap); + res_tmp2 = arr_t(plotter.get_mask(at * n["outfreq"])); res_tmp *= res_tmp2; } // mean only over downdraught cells @@ -206,8 +204,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp2 = isdowndraught(snap); } { // cloudy - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - res_tmp = iscloudy_rc_rico(snap); + res_tmp = arr_t(plotter.get_mask(at * n["outfreq"])); res_tmp2 *= res_tmp; } // mean rw @@ -235,8 +232,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp2 = isdowndraught(snap); } { // cloudy - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - res_tmp = iscloudy_rc_rico(snap); + res_tmp = arr_t(plotter.get_mask(at * n["outfreq"])); res_tmp2 *= res_tmp; } // mean rw @@ -264,8 +260,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp2 = isupdraught(snap); } { // cloudy - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - res_tmp = iscloudy_rc_rico(snap); + res_tmp = arr_t(plotter.get_mask(at * n["outfreq"])); res_tmp2 *= res_tmp; } // mean rw @@ -401,8 +396,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp = where(res_tmp > 0 , res_tmp / snap, res_tmp); } { - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - res_tmp2 = iscloudy_rc_rico(snap); + res_tmp2 = arr_t(plotter.get_mask(at * n["outfreq"])); res_tmp *= res_tmp2; } // mean only over downdraught cells @@ -423,8 +417,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp = where(res_tmp > 0 , res_tmp / snap, res_tmp); } { - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - res_tmp2 = iscloudy_rc_rico(snap); + res_tmp2 = arr_t(plotter.get_mask(at * n["outfreq"])); res_tmp *= res_tmp2; } // mean only over downdraught cells @@ -461,10 +454,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool } { - auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - res_tmp = snap; - snap = iscloudy_nc_dycoms(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); res_tmp2 *= snap; // cloudy updrafts only } @@ -675,13 +665,8 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool // cloud droplet (0.5um < r < 25 um) concentration in cloudy grid cells try { - // cloud fraction (cloudy if N_c > 20/cm^3) - auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - typename Plotter_t::arr_t snap2; - snap2.resize(snap.shape()); - snap2=snap; - snap = iscloudy_nc_dycoms(snap); // cloudiness mask + typename Plotter_t::arr_t snap2(plotter.load_nc_timestep(at * n["outfreq"])); + arr_t snap(plotter.get_mask(at * n["outfreq"])); snap2 *= snap; // mean only over cloudy cells @@ -731,9 +716,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool { // cloud fraction (cloudy if N_c > 20/cm^3) { - auto tmp = plotter.load_nc_timestep(at * n["outfreq"]); - typename Plotter_t::arr_t snap(tmp); - snap = iscloudy_nc_dycoms(snap); + arr_t snap(plotter.get_mask(at * n["outfreq"])); res += snap; } res_prof_hlpr = plotter.horizontal_mean(res); // average in x @@ -742,9 +725,7 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool // TODO: 'normalize' messes with this plot { res_prof_hlpr = 0; - // cloudy cells (cloudy if q_c > 0.01 g/kg as in RICO paper. NOTE: also add q_r ?) - typename Plotter_t::arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - snap = iscloudy_rc_rico(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); plotter.k_i = blitz::sum(snap, plotter.LastIndex); // sum in the vertical, assumes that all cloudy cells in a column belong to the same cloud plotter.tmp_int_hrzntl_slice = blitz::first(snap > 0, plotter.LastIndex); // cloud base hgt over dz diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index 2bc7405..033bb3c 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -165,8 +165,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - // r_act averaged over cloudy cells - else if (plt == "ract_avg") + // mixing ratio of acivated droplets averaged over cloudy cells + else if (plt == "cl_ract") { try { @@ -518,18 +518,12 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cloud_base_dycoms") + else if (plt == "cloud_base") { // average cloud base in the domain try { - // cloud fraction (cloudy if N_c > 20/cm^3) - auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); - arr_t snap(tmp); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask - snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux + arr_t snap(plotter.get_mask(at * n["outfreq"])); plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); auto cloudy_column = plotter.k_i.copy(); cloudy_column = blitz::sum(snap, plotter.LastIndex); @@ -542,19 +536,13 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cloud_base_precip_dycoms") + else if (plt == "cloud_base_precip") { // domain-averaged (all columns) precipitation at the average cloud base height [mm/day] try { - // -- average cloud base, almost exactly as in "cloud_base_dycoms"... -- - // cloud fraction (cloudy if N_c > 20/cm^3) - auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); - arr_t snap(tmp); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask - snap(plotter.hrzntl_slice(0)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux + // -- average cloud base, almost exactly as in "cloud_base"... -- + arr_t snap(plotter.get_mask(at * n["outfreq"])); plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); auto cloudy_column = plotter.k_i.copy(); cloudy_column = blitz::sum(snap, plotter.LastIndex); @@ -680,19 +668,15 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cl_acnv25_dycoms") + else if (plt == "cl_acnv25") { - // autconversion rate with rain threshold r=25um (cloudy cells as in Dycoms) [g/(m3*s)] + // autconversion rate with rain threshold r=25um [g/(m3*s)] // rather coarse estimate, sum of acnv accumulated over ALL cells since the last output // is divided by the instantaneous volume of all cloudy cells // TODO: output instantaneous acnv rate in libcloud, not the accumulated one? try { - // cloud fraction (cloudy if N_c > 20/cm^3) - arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); // cloud mask arr_t acc_acnv(plotter.h5load_timestep("acc_acnv25", at * n["outfreq"])); auto tot_acc_acnv = blitz::sum(acc_acnv); @@ -706,67 +690,15 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cl_accr25_dycoms") + else if (plt == "cl_accr25") { - // accretion rate with rain threshold r=25um (cloudy cells as in Dycoms) [g/(m3*s)] + // accretion rate with rain threshold r=25um [g/(m3*s)] // rather coarse estimate, sum of accr accumulated over ALL cells since the last output // is divided by the instantaneous volume of all cloudy cells // TODO: output instantaneous accr rate in libcloud, not the accumulated one? try { - // cloud fraction (cloudy if N_c > 20/cm^3) - arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask - - arr_t acc_accr(plotter.h5load_timestep("acc_accr25", at * n["outfreq"])); - double tot_acc_accr = blitz::sum(acc_accr); - - if(blitz::sum(snap) > 0) - res_series[plt](at) = 4./3. * 3.14166 * 1e6 * (tot_acc_accr - tot_acc_accr_prev) / ((blitz::sum(snap) * plotter.CellVol) * (n["outfreq"] * n["dt"])); - else - res_series[plt](at) = 0; - - tot_acc_accr_prev = tot_acc_accr; - } - catch(...) {if(at==first_timestep) data_found[plt]=0;} - } - else if (plt == "cl_acnv25_rico") - { - // autconversion rate with rain threshold r=25um (cloudy cells as in Rico) [g/(m3*s)] - // rather coarse estimate, sum of acnv accumulated over ALL cells since the last output - // is divided by the instantaneous volume of all cloudy cells - // TODO: output instantaneous acnv rate in libcloud, not the accumulated one? - try - { - // cloud fraction (cloudy if r_c > 1e-5) - arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - snap = iscloudy_rc_rico(snap); - - arr_t acc_acnv(plotter.h5load_timestep("acc_acnv25", at * n["outfreq"])); - auto tot_acc_acnv = blitz::sum(acc_acnv); - - if(blitz::sum(snap) > 0) - res_series[plt](at) = 4./3. * 3.1416 * 1e6 * (tot_acc_acnv - tot_acc_acnv_prev) / ((blitz::sum(snap) * plotter.CellVol) * (n["outfreq"] * n["dt"])); - else - res_series[plt](at) = 0; - - tot_acc_acnv_prev = tot_acc_acnv; - } - catch(...) {if(at==first_timestep) data_found[plt]=0;} - } - else if (plt == "cl_accr25_rico") - { - // accretion rate with rain threshold r=25um (cloudy cells as in Rico) [g/(m3*s)] - // rather coarse estimate, sum of accr accumulated over ALL cells since the last output - // is divided by the instantaneous volume of all cloudy cells - // TODO: output instantaneous accr rate in libcloud, not the accumulated one? - try - { - // cloud fraction (cloudy if r_c > 1e-5) - arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - snap = iscloudy_rc_rico(snap); + arr_t snap(plotter.get_mask(at * n["outfreq"])); // cloud mask arr_t acc_accr(plotter.h5load_timestep("acc_accr25", at * n["outfreq"])); double tot_acc_accr = blitz::sum(acc_accr); @@ -893,7 +825,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "er") + else if (plt == "er_dycoms") { //entrainment rate as in the 2009 Ackerman paper // to store total mixingg ratio @@ -1096,11 +1028,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // gccn (r_d > 2 um) concentration in cloudy grid cells try { - // cloud fraction (cloudy if N_c > 20/cm^3) - arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 @@ -1117,11 +1045,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // gccn (r_d < 2 um) concentration in cloudy grid cells try { - // cloud fraction (cloudy if N_c > 20/cm^3) - arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); arr_t snap2(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 @@ -1137,11 +1061,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - // cloud fraction (cloudy if N_c > 20/cm^3) - arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); arr_t snap2(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); arr_t snap3(plotter.h5load_timestep("non_gccn_rw_mom0", at * n["outfreq"])); @@ -1160,11 +1080,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // gccn (r_d > 2 um) mean radius in cloudy grid cells try { - // cloud fraction (cloudy if N_c > 20/cm^3) - arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); arr_t snap_m0(plotter.h5load_timestep("gccn_rw_mom0", at * n["outfreq"])); arr_t snap_m1(plotter.h5load_timestep("gccn_rw_mom1", at * n["outfreq"]) * 1e6); // in microns snap_m0 *= snap; @@ -1208,11 +1124,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // gccn (r_d >= 0.8 um) concentration in cloudy grid cells try { - // cloud fraction (cloudy if N_c > 20/cm^3) - arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); arr_t snap2(plotter.h5load_timestep("rd_geq_0.8um_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 @@ -1242,11 +1154,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - // cloud fraction (cloudy if N_c > 20/cm^3) - arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); arr_t snap2(plotter.h5load_timestep("rd_lt_0.8um_rw_mom0", at * n["outfreq"])); plotter.multiply_by_rhod(snap2); snap2 /= 1e6; // per cm^3 @@ -1275,11 +1183,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // cloud droplets mean radius in cloudy grid cells try { - // cloud fraction (cloudy if N_c > 20/cm^3) - arr_t snap(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - plotter.multiply_by_rhod(snap); - snap /= 1e6; // per cm^3 - snap = iscloudy_nc_dycoms(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); arr_t snap_m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); arr_t snap_m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])*1e6); // in microns snap_m0 *= snap; @@ -1297,11 +1201,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - // find cloud base (cloudy if q_c > 0.1 g/kg) - arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - snap = iscloudy_rc(snap); // cloudiness mask - //for(int i=0;i<10;++i) - // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux + // find cloud base + arr_t snap(plotter.get_mask(at * n["outfreq"])); plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); // 0-th specific mom of bigrain cloud drops @@ -1327,8 +1228,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - snap = iscloudy_rc(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); @@ -1356,8 +1256,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - snap = iscloudy_rc(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); @@ -1385,8 +1284,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - snap = iscloudy_rc(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); @@ -1411,8 +1309,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { // find cloud base (cloudy if q_c > 0.1 g/kg) - arr_t snap(plotter.load_rc_timestep(at * n["outfreq"])); - snap = iscloudy_rc(snap); // cloudiness mask + arr_t snap(plotter.get_mask(at * n["outfreq"])); //for(int i=0;i<10;++i) // snap(plotter.hrzntl_slice(i)) = 0; // cheat to avoid occasional "cloudy" cell at ground level due to activation from surf flux plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); @@ -1762,7 +1659,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) res_series[plt] /= 1000.; res_pos *= 60.; } - else if (plt == "ract_avg") + else if (plt == "cl_ract") { plot_std_dev = true; res_pos *= 60.; @@ -1869,7 +1766,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { res_series[plt] *= (n["z"] - 1) * n["dz"]; // top and bottom cells are smaller } - else if (plt == "er") + else if (plt == "er_dycoms") { // central difference, in cm Range nofirstlast = Range(1, last_timestep-1); @@ -1954,7 +1851,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) gp << "plot '-' with l"; if(plot_std_dev) gp << ", '-' w l, '-' w l"; - else if(plt == "cl_acnv25_dycoms" || plt == "cl_acnv25_rico" || plt == "cl_accr25_dycoms" || plt == "cl_accr25_rico") + else if(plt == "cl_acnv25" || plt == "cl_accr25" ) gp << ", '-' w l"; gp << " \n"; @@ -1970,7 +1867,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) res_series[plt] = res_series[plt] - 2*res_series_std_dev[plt]; gp.send1d(boost::make_tuple(res_pos, res_series[plt])); } - if(plt == "cl_acnv25_dycoms" || plt == "cl_acnv25_rico" || plt == "cl_accr25_dycoms" || plt == "cl_accr25_rico") + if(plt == "cl_acnv25" || plt == "cl_accr25") { // acnv/accr rate averaged since the start of the simulation int nt = last_timestep - first_timestep + 1; From 71a7ec43b24846812549d2e649ddb3a6eff501a8 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 16 Dec 2022 11:09:26 +0100 Subject: [PATCH 18/51] prof fix --- UWLCM_plotters/include/PlotterMask.hpp | 2 +- drawbicyc/include/plot_prof.hpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index f086a9e..fd4e272 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -19,7 +19,7 @@ class PlotterMask : public PlotterMicro { if(mask_type == mask_type_t::Rico11) { - mask = this->load_ract_timestep(at); + mask = this->load_rc_timestep(at); mask = iscloudy_rc_rico(mask); } else if(mask_type == mask_type_t::Dycoms_rf02) diff --git a/drawbicyc/include/plot_prof.hpp b/drawbicyc/include/plot_prof.hpp index 54a3e91..fae79c6 100644 --- a/drawbicyc/include/plot_prof.hpp +++ b/drawbicyc/include/plot_prof.hpp @@ -458,6 +458,8 @@ void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool res_tmp2 *= snap; // cloudy updrafts only } + res_tmp = typename Plotter_t::arr_t(plotter.load_nc_timestep(at * n["outfreq"])); + // mean only over cloudy updraught cells prof_tmp = plotter.horizontal_sum(res_tmp2); // number of downdraft cells on a given level From 952fbd18e220d79687dd4e5b6ae3c7697d731c3b Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 16 Dec 2022 11:18:09 +0100 Subject: [PATCH 19/51] drawbicyc: cloud mask choice --- UWLCM_plotters/include/PlotterMask.hpp | 2 +- drawbicyc/drawbicyc.cpp | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index fd4e272..461d301 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -1,7 +1,7 @@ #pragma once #include "PlotterMicro.hpp" -enum class mask_type_t{Rico11, Dycoms_rf02}; +enum class mask_type_t{Rico11, Dycoms_rf02, unset}; template class PlotterMask : public PlotterMicro diff --git a/drawbicyc/drawbicyc.cpp b/drawbicyc/drawbicyc.cpp index d987f18..264bbb0 100644 --- a/drawbicyc/drawbicyc.cpp +++ b/drawbicyc/drawbicyc.cpp @@ -56,6 +56,19 @@ int main(int argc, char** argv) H5::DataSet h5d = h5f.openDataSet("G"); H5::DataSpace h5s = h5d.getSpace(); int NDims = h5s.getSimpleExtentNdims(); + + // selecting type of cloud mask + mask_type_t mask_type = mask_type_t::unset; + if(type == "dycoms") + { + std::cout << "Using Dycoms_rf02 cloud mask." << std::endl; + mask_type = mask_type_t::Dycoms_rf02; + } + else + { + std::cout << "Using Rico11 cloud mask." << std::endl; + mask_type = mask_type_t::Rico11; + } // detecting if subgrid model was on bool sgs = true; @@ -80,8 +93,8 @@ int main(int argc, char** argv) } else if(NDims == 3) { - if(flag_series) plot_series(PlotterMask<3>(h5, micro, mask_type_t::Rico11), plots, type); - if(flag_profiles) plot_profiles(PlotterMask<3>(h5, micro, mask_type_t::Rico11), plots, type, normalize_prof); + if(flag_series) plot_series(PlotterMask<3>(h5, micro, mask_type), plots, type); + if(flag_profiles) plot_profiles(PlotterMask<3>(h5, micro, mask_type), plots, type, normalize_prof); // if(flag_fields) plot_fields(PlotterMask<3>(h5, micro), plots, type); // if(flag_qv_qc_2_6_10_min) plot_qv_qc_2_6_10_min(PlotterMask<2>(h5, micro)); // if(flag_lgrngn_spec) { From c08f0f22e319463d4178a5c9506dfef6e7310321 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 16 Dec 2022 11:50:39 +0100 Subject: [PATCH 20/51] wip --- UWLCM_plotters/include/PlotterMask.hpp | 122 ++++++++++++++--------- drawbicyc/include/cases/RICO11/plots.hpp | 7 +- drawbicyc/include/plot_series.hpp | 96 +++++++++--------- 3 files changed, 124 insertions(+), 101 deletions(-) diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index 461d301..8dda6f2 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -58,26 +58,7 @@ class PlotterMask : public PlotterMicro return res; } - public: - - - arr_t get_mask(int at) - { - calc_mask(at); - return mask; - } - // functions for diagnosing statistics - // mean and std dev [g/kg] of the mixing ratio of activated dropelts in cloudy cells (characteristics of the spatial distribution at this timestep) - std::pair cloud_ract_stats_timestep(int at) - { - // read activated droplets mixing ratio - arr_t ract(this->load_ract_timestep(at)); - ract *= 1e3; // turn it into g/kg - return cloud_hlpr(ract, at); - } - - // mean and std_dev of concentration of activated droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) std::pair cloud_conc_stats_timestep_hlpr(int at, std::string lgrngn_prefix, std::string blk_2m_1, std::string blk_2m_2 = "") { arr_t conc; @@ -101,7 +82,55 @@ class PlotterMask : public PlotterMicro return cloud_hlpr(conc, at); } - // mean and std_dev of concentration of activated droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) + std::pair cloud_meanr_stats_timestep_hlpr(int at, std::string lgrngn_prefix) + { + if(this->micro == "blk_1m" || this->micro == "blk_2m") return {0,0}; + // read drop 0th raw moment / mass [1/kg] + arr_t 0th(this->h5load_timestep(lgrngn_prefix+"_mom0", at)); + // read drop 1st raw moment / mass [um/kg] + arr_t 1st(this->h5load_timestep(lgrngn_prefix"_mom1", at) * 1e6); + // calculate mean radius, store in 1st + 1st = where(0th > 0, 1st / 0th, 0.); + return cloud_hlpr(1st, at); + } + + std::pair cloud_stddevr_stats_timestep_hlpr(int at, std::string lgrngn_prefix) + { + if(this->micro == "blk_1m" || this->micro == "blk_2m") return {0,0}; + // read drop 0th raw moment / mass [1/kg] + arr_t 0th(this->h5load_timestep(lgrngn_prefix+"_mom0", at)); + // read drop 1st raw moment / mass [um/kg] + arr_t 1st(this->h5load_timestep(lgrngn_prefix+"_mom1", at)); + // read drop 2nd raw moment / mass [um^2/kg] + arr_t 2nd(this->h5load_timestep(lgrngn_prefix+"_mom2", at)); + // calculate stddev of radius, store in 1st + 1st = where(0th > 0, + 2nd / 0th - 1st / 0th * 1st / 0th, 0.); + // might be slightly negative due to numerical errors + 1st = where(1st < 0, 0, 1st); + 1st = sqrt(1st); + return cloud_hlpr(1st, at); + } + + public: + + arr_t get_mask(int at) + { + calc_mask(at); + return mask; + } + + // functions for diagnosing statistics + // mean and std dev [g/kg] of the mixing ratio of activated dropelts in cloudy cells (characteristics of the spatial distribution at this timestep) + std::pair cloud_ract_stats_timestep(int at) + { + // read activated droplets mixing ratio + arr_t ract(this->load_ract_timestep(at)); + ract *= 1e3; // turn it into g/kg + return cloud_hlpr(ract, at); + } + + // mean and std_dev of concentration of activated/cloud/rain droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) std::pair cloud_actconc_stats_timestep(int at) { return cloud_conc_stats_timestep_hlpr(at, "act_rw", "nc", "nr"); @@ -121,7 +150,7 @@ class PlotterMask : public PlotterMicro // mean and std_dev of number of SDs in cloudy cells (characteristics of the spatial distribution at this timestep) std::pair cloud_sdconc_stats_timestep(int at) { - if(this->micro == "blk_1m") return {0,0}; + if(this->micro == "blk_1m" || this->micro == "blk_2m") return {0,0}; arr_t sdconc(this->h5load_timestep("sd_conc", at)); return cloud_hlpr(sdconc, at); } @@ -129,43 +158,38 @@ class PlotterMask : public PlotterMicro // mean and std_dev of number of activated SDs in cloudy cells (characteristics of the spatial distribution at this timestep) std::pair cloud_sdconc_act_stats_timestep(int at) { - if(this->micro == "blk_1m") return {0,0}; + if(this->micro == "blk_1m" || this->micro == "blk_2m") return {0,0}; arr_t sdconc_act(this->h5load_timestep("sd_conc_act", at)); return cloud_hlpr(sdconc_act, at); } - // mean and std_dev of mean radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) - std::pair cloud_meanr_stats_timestep(int at) + // mean and std_dev of mean radius of activated/cloud/rain droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) + std::pair cloud_actmeanr_stats_timestep(int at) { - if(this->micro == "blk_1m") return {0,0}; - // read act drop 0th raw moment / mass [1/kg] - arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); - // read act drop 1st raw moment / mass [um/kg] - arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); - // calculate mean radius, store in act1st - act1st = where(act0th > 0, act1st / act0th, 0.); - return cloud_hlpr(act1st, at); + return cloud_meanr_stats_timestep_hlpr(at, "act_rw"); } - - // mean and std_dev of std_dev of radius of activated droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) - std::pair cloud_stddevr_stats_timestep(int at) + std::pair cloud_cloudmeanr_stats_timestep(int at) { - if(this->micro == "blk_1m") return {0,0}; - // read act drop 0th raw moment / mass [1/kg] - arr_t act0th(this->h5load_timestep("actrw_rw_mom0", at)); - // read act drop 1st raw moment / mass [um/kg] - arr_t act1st(this->h5load_timestep("actrw_rw_mom1", at) * 1e6); - // read act drop 2nd raw moment / mass [um^2/kg] - arr_t act2nd(this->h5load_timestep("actrw_rw_mom2", at) * 1e12); - // calculate stddev of radius, store in act1st - act1st = where(act0th > 0, - act2nd / act0th - act1st / act0th * act1st / act0th, 0.); - // might be slightly negative due to numerical errors - act1st = where(act1st < 0, 0, act1st); - act1st = sqrt(act1st); - return cloud_hlpr(act1st, at); + return cloud_meanr_stats_timestep_hlpr(at, "cloud_rw"); + } + std::pair cloud_rainmeanr_stats_timestep(int at) + { + return cloud_meanr_stats_timestep_hlpr(at, "rain_rw"); } + // mean and std_dev of std_dev of radius of activated/cloud/rain droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) + std::pair cloud_actstddevr_stats_timestep(int at) + { + return cloud_stddevr_stats_timestep_hlpr(at, "act_rw"); + } + std::pair cloud_cloudstddevr_stats_timestep(int at) + { + return cloud_stddevr_stats_timestep_hlpr(at, "cloud_rw"); + } + std::pair cloud_rainstddevr_stats_timestep(int at) + { + return cloud_stddevr_stats_timestep_hlpr(at, "rain_rw"); + } // height [m] of the center of mass of activated droplets double act_com_z_timestep(int at) diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index 3e5b661..fe9f711 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -12,14 +12,13 @@ const std::vector series_rico({ "acc_precip", "cl_nc", "cl_nr", -"cloud_avg_supersat", +"cl_avg_supersat", +"cl_avg_cloud_meanr", +"cl_avg_cloud_stddevr", "wvarmax", "cl_meanr", //TODO: zmienic maske na rico "sd_conc" -cl_avg_cloud_rad -cloud_avg_std_dev_act_rad - // "clb_bigrain_mean_rd", // "clb_bigrain_mean_kappa", diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index 033bb3c..7c431b3 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -125,7 +125,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) for (auto &plt : plots.series) { std::cerr << plt << std::endl; - if (plt == "cloud_cover_dycoms") + if (plt == "cl_cover_dycoms") { try { @@ -139,7 +139,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cloud_cover") + else if (plt == "cl_cover") { try { @@ -170,14 +170,14 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - auto stats = plotter.cloud_ract_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cl_ract_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } catch(...) {if(at==first_timestep) data_found[plt]=0;} } // cloud top height - else if (plt =="cloud_top_height") + else if (plt =="cl_top_height") { try { @@ -210,7 +210,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - auto stats = plotter.cloud_sdconc_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cl_sdconc_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -221,7 +221,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - auto stats = plotter.cloud_sdconc_act_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cl_sdconc_act_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -240,7 +240,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } */ { - auto tmp = plotter.h5load_timestep("cloud_rw_mom3", at * n["outfreq"]) * 4./3. * 3.1416 * 1e3; + auto tmp = plotter.h5load_timestep("cl_rw_mom3", at * n["outfreq"]) * 4./3. * 3.1416 * 1e3; arr_t snap(tmp); plotter.multiply_by_rhod(snap); res_series[plt](at) += blitz::mean(snap); @@ -451,7 +451,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // cloud droplet (0.5um < r < 25 um) concentration try { - auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); + auto tmp = plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"]); arr_t snap(tmp); snap /= 1e6; // per cm^3 plotter.multiply_by_rhod(snap); @@ -490,7 +490,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // cloud droplet (0.5um < r < 25 um) concentration in cloudy grid cells try { - auto stats = plotter.cloud_cloudconc_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cl_cloudconc_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -501,7 +501,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // rain drop (25um < r) concentration in cloudy grid cells try { - auto stats = plotter.cloud_rainconc_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cl_rainconc_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -518,7 +518,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cloud_base") + else if (plt == "cl_base") { // average cloud base in the domain try @@ -536,36 +536,36 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cloud_base_precip") + else if (plt == "cl_base_precip") { // domain-averaged (all columns) precipitation at the average cloud base height [mm/day] try { - // -- average cloud base, almost exactly as in "cloud_base"... -- + // -- average cloud base, almost exactly as in "cl_base"... -- arr_t snap(plotter.get_mask(at * n["outfreq"])); plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); auto cloudy_column = plotter.k_i.copy(); cloudy_column = blitz::sum(snap, plotter.LastIndex); cloudy_column = where(cloudy_column > 0, 1, 0); plotter.k_i = where(cloudy_column == 0, 0, plotter.k_i); - int cloud_base_idx; + int cl_base_idx; if(blitz::sum(cloudy_column) > 0) - cloud_base_idx = double(blitz::sum(plotter.k_i)) / blitz::sum(cloudy_column) + 0.5; + cl_base_idx = double(blitz::sum(plotter.k_i)) / blitz::sum(cloudy_column) + 0.5; else - cloud_base_idx = 0; + cl_base_idx = 0; - if(cloud_base_idx == 0) + if(cl_base_idx == 0) res_series[plt](at) = 0; else { // -- precipitation at this height averaged over all cells, cloudy or not -- auto prflux = plotter.load_prflux_timestep(at * n["outfreq"]); // prflux in [W/m^2] - res_series[plt](at) = blitz::mean(prflux(plotter.hrzntl_slice(cloud_base_idx))) / 2264.705 * 3.6 * 24; // convert to [mm/day] + res_series[plt](at) = blitz::mean(prflux(plotter.hrzntl_slice(cl_base_idx))) / 2264.705 * 3.6 * 24; // convert to [mm/day] } } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "min_cloud_base") + else if (plt == "min_cl_base") { // lowest cloud base in the domain try @@ -584,18 +584,18 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) catch(...) {if(at==first_timestep) data_found[plt]=0;} } // average concentration of activated droplets in cloudy cells - else if (plt == "cloud_avg_act_conc") + else if (plt == "cl_avg_act_conc") { try { - auto stats = plotter.cloud_actconc_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cl_actconc_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } catch(...) {if(at==first_timestep) data_found[plt]=0;} } // average supersaturation in cells with S>0 - else if (plt == "cloud_avg_supersat") + else if (plt == "cl_avg_supersat") { try { @@ -605,23 +605,23 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - // spatial average of mean radius of activated droplets in cloudy cells - else if (plt == "cl_avg_cloud_rad") + // spatial average of mean radius of cloud droplets in cloudy cells + else if (plt == "cl_avg_cl_meanr") { try { - auto stats = plotter.cloud_meanr_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cl_cloudmeanr_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - // spatial average of standard deviation of the acttivated droplets radius distribution in cloudy cells - else if (plt == "cloud_avg_std_dev_act_rad") + // spatial average of standard deviation of cloud droplet radius distribution in cloudy cells + else if (plt == "cl_avg_cl_stddevr") { try { - auto stats = plotter.cloud_stddevr_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cl_cloudstddevr_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -1008,7 +1008,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { arr_t tot_m0(plotter.h5load_timestep("aerosol_rw_mom0", at * n["outfreq"])); - tot_m0 += arr_t(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + tot_m0 += arr_t(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])); tot_m0 += arr_t(plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"])); arr_t tke(plotter.h5load_timestep("all_up_mom2", at * n["outfreq"])); @@ -1184,8 +1184,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { arr_t snap(plotter.get_mask(at * n["outfreq"])); - arr_t snap_m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - arr_t snap_m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])*1e6); // in microns + arr_t snap_m0(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])); + arr_t snap_m1(plotter.h5load_timestep("cl_rw_mom1", at * n["outfreq"])*1e6); // in microns snap_m0 *= snap; snap_m1 *= snap; auto tot_m0 = blitz::sum(snap_m0); @@ -1211,7 +1211,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) plotter.tmp_float_hrzntl_slice = plotter.get_value_at_hgt(bigrain_conc, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // we need to multiply by rhod here, because different cloud bases can mean different rhod // 1st specific mom of incloud time of bigrain drops - arr_t bigrain_inclt_mom1(plotter.h5load_timestep("bigrain_incloud_time_mom1", at * n["outfreq"])); + arr_t bigrain_inclt_mom1(plotter.h5load_timestep("bigrain_incl_time_mom1", at * n["outfreq"])); // 1st mom of incloud time at cloud base plotter.tmp_float_hrzntl_slice2 = plotter.get_value_at_hgt(bigrain_inclt_mom1, plotter.k_i) * plotter.get_value_at_hgt(rhod, plotter.k_i); // same as above @@ -1400,7 +1400,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - arr_t nc(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t nc(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])); nc *= rhod; // 1/kg -> 1/m^3 res_series[plt](at) = blitz::mean(nc); } @@ -1481,8 +1481,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // droplets mean radius away from walls try { - arr_t m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - arr_t m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])); + arr_t m0(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])); + arr_t m1(plotter.h5load_timestep("cl_rw_mom1", at * n["outfreq"])); //auto tot_m0 = blitz::sum(arr_t(plotter.nowall(m0, distance_from_walls))); auto tot_m0 = blitz::sum(m0); if(tot_m0 > 0) @@ -1497,8 +1497,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // droplets effective radius away from walls try { - arr_t m2(plotter.h5load_timestep("cloud_rw_mom2", at * n["outfreq"])); - arr_t m3(plotter.h5load_timestep("cloud_rw_mom3", at * n["outfreq"])); + arr_t m2(plotter.h5load_timestep("cl_rw_mom2", at * n["outfreq"])); + arr_t m3(plotter.h5load_timestep("cl_rw_mom3", at * n["outfreq"])); auto tot_m2 = blitz::sum(m2); if(tot_m2 > 0) res_series[plt](at) = blitz::sum(m3) / tot_m2; @@ -1552,10 +1552,10 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // relative dispersion (std dev / mean) of droplet radius distribution averaged over cells away from walls try { - //arr_t m0(plotter.nowall(arr_t(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])), distance_from_walls)); - arr_t m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - arr_t m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])); - arr_t m2(plotter.h5load_timestep("cloud_rw_mom2", at * n["outfreq"])); + //arr_t m0(plotter.nowall(arr_t(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])), distance_from_walls)); + arr_t m0(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])); + arr_t m1(plotter.h5load_timestep("cl_rw_mom1", at * n["outfreq"])); + arr_t m2(plotter.h5load_timestep("cl_rw_mom2", at * n["outfreq"])); // calculate stddev of radius, store in m2 m2 = where(m0 > 0, m2 / m0 - m1 / m0 * m1 / m0, 0.); @@ -1668,29 +1668,29 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { res_pos *= 60.; } - else if (plt == "cloud_avg_act_conc") + else if (plt == "cl_avg_act_conc") { plot_std_dev = true; res_pos *= 60.; } - else if (plt == "cloud_std_dev_act_conc") + else if (plt == "cl_std_dev_act_conc") { res_pos *= 60.; } - else if (plt == "cloud_avg_supersat") + else if (plt == "cl_avg_supersat") { plot_std_dev = true; res_pos *= 60.; } - else if (plt == "cloud_std_dev_supersat") + else if (plt == "cl_std_dev_supersat") { res_pos *= 60.; } - else if (plt == "cloud_avg_act_rad") + else if (plt == "cl_avg_cl_meanr") { res_pos *= 60.; } - else if (plt == "cloud_avg_std_dev_act_rad") + else if (plt == "cl_avg_cl_stddevr") { res_pos *= 60.; } @@ -1746,7 +1746,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { res_pos *= 60.; } - else if (plt == "cloud_top_height") + else if (plt == "cl_top_height") { res_pos *= 60.; } From b9c5ff5dacd4725111174a959803e2d45e45f1dd Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 16 Dec 2022 14:06:05 +0100 Subject: [PATCH 21/51] fxes --- UWLCM_plotters/include/PlotterH5.hpp | 1 - UWLCM_plotters/include/PlotterMask.hpp | 24 ++++----- drawbicyc/include/plot_prof.hpp | 1 + drawbicyc/include/plot_series.hpp | 74 +++++++++++++------------- 4 files changed, 50 insertions(+), 50 deletions(-) diff --git a/UWLCM_plotters/include/PlotterH5.hpp b/UWLCM_plotters/include/PlotterH5.hpp index d244731..ed62860 100644 --- a/UWLCM_plotters/include/PlotterH5.hpp +++ b/UWLCM_plotters/include/PlotterH5.hpp @@ -133,7 +133,6 @@ class PlotterH5 catch(...) // for pre-refinement simulations, use rhod as refined rhod { map_prof.emplace("refined rhod", map_prof["rhod"].copy()); - std::cerr << "refined rhod as copy of rhod: " << map_prof["refined rhod"]; } } } diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index 8dda6f2..a14b64e 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -86,30 +86,30 @@ class PlotterMask : public PlotterMicro { if(this->micro == "blk_1m" || this->micro == "blk_2m") return {0,0}; // read drop 0th raw moment / mass [1/kg] - arr_t 0th(this->h5load_timestep(lgrngn_prefix+"_mom0", at)); + arr_t m0th(this->h5load_timestep(lgrngn_prefix+"_mom0", at)); // read drop 1st raw moment / mass [um/kg] - arr_t 1st(this->h5load_timestep(lgrngn_prefix"_mom1", at) * 1e6); + arr_t m1st(this->h5load_timestep(lgrngn_prefix+"_mom1", at) * 1e6); // calculate mean radius, store in 1st - 1st = where(0th > 0, 1st / 0th, 0.); - return cloud_hlpr(1st, at); + m1st = where(m0th > 0, m1st / m0th, 0.); + return cloud_hlpr(m1st, at); } std::pair cloud_stddevr_stats_timestep_hlpr(int at, std::string lgrngn_prefix) { if(this->micro == "blk_1m" || this->micro == "blk_2m") return {0,0}; // read drop 0th raw moment / mass [1/kg] - arr_t 0th(this->h5load_timestep(lgrngn_prefix+"_mom0", at)); + arr_t m0th(this->h5load_timestep(lgrngn_prefix+"_mom0", at)); // read drop 1st raw moment / mass [um/kg] - arr_t 1st(this->h5load_timestep(lgrngn_prefix+"_mom1", at)); + arr_t m1st(this->h5load_timestep(lgrngn_prefix+"_mom1", at)); // read drop 2nd raw moment / mass [um^2/kg] - arr_t 2nd(this->h5load_timestep(lgrngn_prefix+"_mom2", at)); + arr_t m2nd(this->h5load_timestep(lgrngn_prefix+"_mom2", at)); // calculate stddev of radius, store in 1st - 1st = where(0th > 0, - 2nd / 0th - 1st / 0th * 1st / 0th, 0.); + m1st = where(m0th > 0, + m2nd / m0th - m1st / m0th * m1st / m0th, 0.); // might be slightly negative due to numerical errors - 1st = where(1st < 0, 0, 1st); - 1st = sqrt(1st); - return cloud_hlpr(1st, at); + m1st = where(m1st < 0, 0, m1st); + m1st = sqrt(m1st); + return cloud_hlpr(m1st, at); } public: diff --git a/drawbicyc/include/plot_prof.hpp b/drawbicyc/include/plot_prof.hpp index fae79c6..3515190 100644 --- a/drawbicyc/include/plot_prof.hpp +++ b/drawbicyc/include/plot_prof.hpp @@ -8,6 +8,7 @@ template void plot_profiles(Plotter_t plotter, Plots plots, std::string type, const bool normalize) { + using arr_t = typename Plotter_t::arr_t; // read opts po::options_description opts("profile plotting options"); diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index 7c431b3..d1b63b3 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -125,7 +125,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) for (auto &plt : plots.series) { std::cerr << plt << std::endl; - if (plt == "cl_cover_dycoms") + if (plt == "cloud_cover_dycoms") { try { @@ -139,7 +139,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cl_cover") + else if (plt == "cloud_cover") { try { @@ -170,7 +170,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - auto stats = plotter.cl_ract_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cloud_ract_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -210,7 +210,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - auto stats = plotter.cl_sdconc_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cloud_sdconc_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -221,7 +221,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - auto stats = plotter.cl_sdconc_act_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cloud_sdconc_act_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -240,7 +240,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } */ { - auto tmp = plotter.h5load_timestep("cl_rw_mom3", at * n["outfreq"]) * 4./3. * 3.1416 * 1e3; + auto tmp = plotter.h5load_timestep("cloud_rw_mom3", at * n["outfreq"]) * 4./3. * 3.1416 * 1e3; arr_t snap(tmp); plotter.multiply_by_rhod(snap); res_series[plt](at) += blitz::mean(snap); @@ -451,7 +451,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // cloud droplet (0.5um < r < 25 um) concentration try { - auto tmp = plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"]); + auto tmp = plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"]); arr_t snap(tmp); snap /= 1e6; // per cm^3 plotter.multiply_by_rhod(snap); @@ -490,7 +490,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // cloud droplet (0.5um < r < 25 um) concentration in cloudy grid cells try { - auto stats = plotter.cl_cloudconc_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cloud_cloudconc_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -501,7 +501,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // rain drop (25um < r) concentration in cloudy grid cells try { - auto stats = plotter.cl_rainconc_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cloud_rainconc_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -518,7 +518,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cl_base") + else if (plt == "cloud_base") { // average cloud base in the domain try @@ -536,36 +536,36 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "cl_base_precip") + else if (plt == "cloud_base_precip") { // domain-averaged (all columns) precipitation at the average cloud base height [mm/day] try { - // -- average cloud base, almost exactly as in "cl_base"... -- + // -- average cloud base, almost exactly as in "cloud_base"... -- arr_t snap(plotter.get_mask(at * n["outfreq"])); plotter.k_i = blitz::first((snap == 1), plotter.LastIndex); auto cloudy_column = plotter.k_i.copy(); cloudy_column = blitz::sum(snap, plotter.LastIndex); cloudy_column = where(cloudy_column > 0, 1, 0); plotter.k_i = where(cloudy_column == 0, 0, plotter.k_i); - int cl_base_idx; + int cloud_base_idx; if(blitz::sum(cloudy_column) > 0) - cl_base_idx = double(blitz::sum(plotter.k_i)) / blitz::sum(cloudy_column) + 0.5; + cloud_base_idx = double(blitz::sum(plotter.k_i)) / blitz::sum(cloudy_column) + 0.5; else - cl_base_idx = 0; + cloud_base_idx = 0; - if(cl_base_idx == 0) + if(cloud_base_idx == 0) res_series[plt](at) = 0; else { // -- precipitation at this height averaged over all cells, cloudy or not -- auto prflux = plotter.load_prflux_timestep(at * n["outfreq"]); // prflux in [W/m^2] - res_series[plt](at) = blitz::mean(prflux(plotter.hrzntl_slice(cl_base_idx))) / 2264.705 * 3.6 * 24; // convert to [mm/day] + res_series[plt](at) = blitz::mean(prflux(plotter.hrzntl_slice(cloud_base_idx))) / 2264.705 * 3.6 * 24; // convert to [mm/day] } } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - else if (plt == "min_cl_base") + else if (plt == "min_cloud_base") { // lowest cloud base in the domain try @@ -588,7 +588,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - auto stats = plotter.cl_actconc_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cloud_actconc_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -606,22 +606,22 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) catch(...) {if(at==first_timestep) data_found[plt]=0;} } // spatial average of mean radius of cloud droplets in cloudy cells - else if (plt == "cl_avg_cl_meanr") + else if (plt == "cl_avg_cloud_meanr") { try { - auto stats = plotter.cl_cloudmeanr_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cloud_cloudmeanr_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; } catch(...) {if(at==first_timestep) data_found[plt]=0;} } // spatial average of standard deviation of cloud droplet radius distribution in cloudy cells - else if (plt == "cl_avg_cl_stddevr") + else if (plt == "cl_avg_cloud_stddevr") { try { - auto stats = plotter.cl_cloudstddevr_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cloud_cloudstddevr_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; } catch(...) {if(at==first_timestep) data_found[plt]=0;} @@ -1008,7 +1008,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { arr_t tot_m0(plotter.h5load_timestep("aerosol_rw_mom0", at * n["outfreq"])); - tot_m0 += arr_t(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])); + tot_m0 += arr_t(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); tot_m0 += arr_t(plotter.h5load_timestep("rain_rw_mom0", at * n["outfreq"])); arr_t tke(plotter.h5load_timestep("all_up_mom2", at * n["outfreq"])); @@ -1184,8 +1184,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) try { arr_t snap(plotter.get_mask(at * n["outfreq"])); - arr_t snap_m0(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])); - arr_t snap_m1(plotter.h5load_timestep("cl_rw_mom1", at * n["outfreq"])*1e6); // in microns + arr_t snap_m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t snap_m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])*1e6); // in microns snap_m0 *= snap; snap_m1 *= snap; auto tot_m0 = blitz::sum(snap_m0); @@ -1400,7 +1400,7 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { try { - arr_t nc(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])); + arr_t nc(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); nc *= rhod; // 1/kg -> 1/m^3 res_series[plt](at) = blitz::mean(nc); } @@ -1481,8 +1481,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // droplets mean radius away from walls try { - arr_t m0(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])); - arr_t m1(plotter.h5load_timestep("cl_rw_mom1", at * n["outfreq"])); + arr_t m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])); //auto tot_m0 = blitz::sum(arr_t(plotter.nowall(m0, distance_from_walls))); auto tot_m0 = blitz::sum(m0); if(tot_m0 > 0) @@ -1497,8 +1497,8 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // droplets effective radius away from walls try { - arr_t m2(plotter.h5load_timestep("cl_rw_mom2", at * n["outfreq"])); - arr_t m3(plotter.h5load_timestep("cl_rw_mom3", at * n["outfreq"])); + arr_t m2(plotter.h5load_timestep("cloud_rw_mom2", at * n["outfreq"])); + arr_t m3(plotter.h5load_timestep("cloud_rw_mom3", at * n["outfreq"])); auto tot_m2 = blitz::sum(m2); if(tot_m2 > 0) res_series[plt](at) = blitz::sum(m3) / tot_m2; @@ -1552,10 +1552,10 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) // relative dispersion (std dev / mean) of droplet radius distribution averaged over cells away from walls try { - //arr_t m0(plotter.nowall(arr_t(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])), distance_from_walls)); - arr_t m0(plotter.h5load_timestep("cl_rw_mom0", at * n["outfreq"])); - arr_t m1(plotter.h5load_timestep("cl_rw_mom1", at * n["outfreq"])); - arr_t m2(plotter.h5load_timestep("cl_rw_mom2", at * n["outfreq"])); + //arr_t m0(plotter.nowall(arr_t(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])), distance_from_walls)); + arr_t m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); + arr_t m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])); + arr_t m2(plotter.h5load_timestep("cloud_rw_mom2", at * n["outfreq"])); // calculate stddev of radius, store in m2 m2 = where(m0 > 0, m2 / m0 - m1 / m0 * m1 / m0, 0.); @@ -1686,11 +1686,11 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { res_pos *= 60.; } - else if (plt == "cl_avg_cl_meanr") + else if (plt == "cl_avg_cloud_meanr") { res_pos *= 60.; } - else if (plt == "cl_avg_cl_stddevr") + else if (plt == "cl_avg_cloud_stddevr") { res_pos *= 60.; } From d712371dbe5078bc32299935d1c5c3a150a46c8c Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 16 Dec 2022 14:25:37 +0100 Subject: [PATCH 22/51] labels --- drawbicyc/include/gnuplot_series_set_labels.hpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drawbicyc/include/gnuplot_series_set_labels.hpp b/drawbicyc/include/gnuplot_series_set_labels.hpp index a26d3bc..7fcb0bb 100644 --- a/drawbicyc/include/gnuplot_series_set_labels.hpp +++ b/drawbicyc/include/gnuplot_series_set_labels.hpp @@ -63,13 +63,13 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) gp << "set xlabel 'time [min]'\n"; gp << "set title 'relative std dev N_c'\n"; } - else if (plt == "cloud_avg_supersat") + else if (plt == "cl_avg_supersat") { gp << "set ylabel ' [%]'\n"; gp << "set xlabel 'time [min]'\n"; gp << "set title 'avg supersaturation'\n"; } - else if (plt == "cloud_std_dev_supersat") + else if (plt == "cl_std_dev_supersat") { gp << "set ylabel 'sigma(S) / '\n"; gp << "set xlabel 'time [min]'\n"; @@ -87,6 +87,18 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) gp << "set xlabel 'time [min]'\n"; gp << "set title 'average std dev of radius of activated droplets'\n"; } + else if (plt == "cl_avg_cloud_meanr") + { + gp << "set ylabel ' [um]'\n"; + gp << "set xlabel 'time [min]'\n"; + gp << "set title 'mean radius of cloud droplets in cloud'\n"; + } + else if (plt == "cl_avg_cloud_stddevr") + { + gp << "set ylabel ' [um]'\n"; + gp << "set xlabel 'time [min]'\n"; + gp << "set title 'std. dev. of radius of cloud droplets in cloud'\n"; + } else if (plt == "sd_conc") { gp << "set ylabel ''\n"; From 4e29202c86ea587c1e3d490f488a761e3cdc492b Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 16 Dec 2022 15:26:40 +0100 Subject: [PATCH 23/51] std dev fix --- UWLCM_plotters/include/PlotterMask.hpp | 4 ++-- drawbicyc/include/cases/RICO11/plots.hpp | 1 - drawbicyc/include/plot_series.hpp | 19 ------------------- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index a14b64e..1212b1b 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -100,9 +100,9 @@ class PlotterMask : public PlotterMicro // read drop 0th raw moment / mass [1/kg] arr_t m0th(this->h5load_timestep(lgrngn_prefix+"_mom0", at)); // read drop 1st raw moment / mass [um/kg] - arr_t m1st(this->h5load_timestep(lgrngn_prefix+"_mom1", at)); + arr_t m1st(this->h5load_timestep(lgrngn_prefix+"_mom1", at) * 1e6); // read drop 2nd raw moment / mass [um^2/kg] - arr_t m2nd(this->h5load_timestep(lgrngn_prefix+"_mom2", at)); + arr_t m2nd(this->h5load_timestep(lgrngn_prefix+"_mom2", at) * 1e12); // calculate stddev of radius, store in 1st m1st = where(m0th > 0, m2nd / m0th - m1st / m0th * m1st / m0th, 0.); diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index fe9f711..67f1811 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -16,7 +16,6 @@ const std::vector series_rico({ "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", "wvarmax", -"cl_meanr", //TODO: zmienic maske na rico "sd_conc" diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index d1b63b3..20dd055 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -1177,25 +1177,6 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - - else if (plt == "cl_meanr") - { - // cloud droplets mean radius in cloudy grid cells - try - { - arr_t snap(plotter.get_mask(at * n["outfreq"])); - arr_t snap_m0(plotter.h5load_timestep("cloud_rw_mom0", at * n["outfreq"])); - arr_t snap_m1(plotter.h5load_timestep("cloud_rw_mom1", at * n["outfreq"])*1e6); // in microns - snap_m0 *= snap; - snap_m1 *= snap; - auto tot_m0 = blitz::sum(snap_m0); - if(tot_m0 > 0) - res_series[plt](at) = blitz::sum(snap_m1) / tot_m0; - else - res_series[plt](at) = 0; - } - catch(...) {if(at==first_timestep) data_found[plt]=0;} - } // cloud base mean incloud time of bigrain (r>40um) else if (plt == "clb_bigrain_mean_inclt") { From d05b5fa03e3c552e4addf2168161edd9d0943aa4 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Mon, 19 Dec 2022 13:38:42 +0100 Subject: [PATCH 24/51] serie comparison update --- Matplotlib_common/latex_labels.py | 17 +++---- cases/RICO11/Rico_series_comparison.py | 6 +-- cases/RICO11/plot_ranges.py | 68 +++++++++++++------------- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/Matplotlib_common/latex_labels.py b/Matplotlib_common/latex_labels.py index 20c7265..a5a80f7 100644 --- a/Matplotlib_common/latex_labels.py +++ b/Matplotlib_common/latex_labels.py @@ -31,16 +31,14 @@ "surf_precip" : 'Surf. precip. [mm/day]', "acc_precip" : 'Acc. precip. [mm]', "cl_nc" : '$N_c$ [cm$^{-3}$]', - "cl_nc_rico" : '$N_c$ [cm$^{-3}$]', # "cl_nr" : '$N_{r>25\mu m}$ [cm$^{-3}$]', "cl_nr" : '$N_{r}$ [cm$^{-3}$]', - "cl_nr_rico" : '$N_{r}$ [cm$^{-3}$]', "cl_gccn_conc" : '$N_{GCCN}$ [cm$^{-3}$]', "thl" : r'$\theta_l$ [K]', "00rtot" : '$q_{t}$ [g/kg]', "rliq" : '$q_{l}$ [g/kg]', "clfrac" : 'Cloud fraction', - "cloud_cover_rico" : 'Cloud cover', + "cloud_cover" : 'Cloud cover', "cloud_cover_dycoms" : 'Cloud cover', "prflux" : 'Precip. flux [W m$^{-2}$]', "wvar" : r'Var$\left(w\right)$ [m$^2$ s$^{-2}$]', @@ -53,7 +51,7 @@ "er" : 'Entrain. rate [cm s$^{-1}$]', "wvarmax" : 'Max. $w$ var. [m$^{2}$ s$^{-2}$]', "cloud_base_dycoms" : 'Cloud base [m]', - "min_cloud_base_rico" : 'Lowest cloud base [m]', + "min_cloud_base" : 'Lowest cloud base [m]', "inversion_height_rico" : 'Inversion height [m]', "gccn_rw_cl" : '$$ of GCCN droplets [um]', "non_gccn_rw_cl" : '$$ of CCN droplets [um]', @@ -62,12 +60,11 @@ "clb_bigrain_mean_conc" : 'conc. of (r$>$40um) @ clbase [1/cc]', "clb_bigrain_mean_inclt" : 'time since act. of (r$>$40um) @ clbase [s]', "clb_bigrain_mean_gccn_fraction" : 'frac. of (r$>$40um) on gccn @ clbase', - "cl_acnv25_rico" : 'acnv. rate [g m$^{-3}$ d$^{-1}$]', - "cl_accr25_rico" : 'accr. rate [g m$^{-3}$ d$^{-1}$]', - "cl_acnv25_dycoms" : 'acnv. rate [g m$^{-3}$ d$^{-1}$]', - "cl_accr25_dycoms" : 'accr. rate [g m$^{-3}$ d$^{-1}$]', - "cloud_avg_supersat" : '$$ in cloud [\%]', - "cl_meanr" : '$$ in cloud [um]', + "cl_acnv25" : 'acnv. rate [g m$^{-3}$ d$^{-1}$]', + "cl_accr25" : 'accr. rate [g m$^{-3}$ d$^{-1}$]', + "cl_avg_supersat" : '$$ in cloud [\%]', + "cl_avg_cloud_meanr" : '$$ of cloud droplets in cloud [um]', + "cl_avg_cloud_stddevr" : '$\sigma(r)$ of cloud droplets in cloud [um]', "sd_conc" : '$$' } diff --git a/cases/RICO11/Rico_series_comparison.py b/cases/RICO11/Rico_series_comparison.py index 3caf101..3764de5 100644 --- a/cases/RICO11/Rico_series_comparison.py +++ b/cases/RICO11/Rico_series_comparison.py @@ -16,11 +16,11 @@ # activate latex text rendering rc('text', usetex=True) -rico_vars = ["lwp", "rwp", "cloud_cover_rico", "min_cloud_base_rico", "inversion_height_rico", "cl_nc_rico", "cl_nr_rico", "surf_precip", "acc_precip", "RH_max", "cloud_avg_supersat", "wvarmax", "cl_meanr", "sd_conc"]#, "cl_acnv25_rico", "cl_accr25_rico"]#, "surf_flux_latent", "surf_flux_sensible" ] +rico_vars = ["lwp", "rwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc", "cl_nr", "surf_precip", "acc_precip", "RH_max", "cl_avg_supersat", "wvarmax", "sd_conc", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr"]#, "cl_acnv25", "cl_accr25"]#, "surf_flux_latent", "surf_flux_sensible" ] #rico_vars = ["clb_bigrain_mean_rd","clb_bigrain_mean_kappa","clb_bigrain_mean_conc","clb_bigrain_mean_inclt", "cl_nr"] # variables that need rescaling of the yrange to the limited x range of 1-6h -rescale_vars = ["lwp", "cloud_cover_rico", "min_cloud_base_rico", "inversion_height_rico", "cl_nc"]# rico_vars +rescale_vars = ["lwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc"]# rico_vars # init the plot nplotx = 4 @@ -64,7 +64,7 @@ var = rico_vars[x*nploty + y] if var in rescale_vars: autoscale_y(axarr[x,y], margin=0.1) - if(var == "cloud_cover_rico" or var == "cl_nr"): + if(var == "cloud_cover" or var == "cl_nr"): axarr[x,y].yaxis.set_major_formatter(ticker.FormatStrFormatter('%0.2f')) # hide hrzntl tic labels diff --git a/cases/RICO11/plot_ranges.py b/cases/RICO11/plot_ranges.py index 2db01e2..6140095 100644 --- a/cases/RICO11/plot_ranges.py +++ b/cases/RICO11/plot_ranges.py @@ -5,8 +5,6 @@ "prflux" : "linear", "cl_nc" : "linear", "cl_nr" : "linear", - "cl_nc_rico" : "linear", - "cl_nr_rico" : "linear", "clfrac" : "linear", "wvar" : "linear", "w3rd" : "linear", @@ -29,13 +27,15 @@ "clb_bigrain_mean_conc" : "linear", "clb_bigrain_mean_inclt" : "linear", "clb_bigrain_mean_gccn_fraction" : "linear", - "cloud_cover_rico" : "linear", - "min_cloud_base_rico" : "linear", + "cloud_cover" : "linear", + "min_cloud_base" : "linear", "inversion_height_rico" : "linear", - "cl_acnv25_rico" : "linear", - "cl_accr25_rico" : "linear", + "cl_acnv25" : "linear", + "cl_accr25" : "linear", "RH_max" : "linear", - "cloud_avg_supersat" : "linear", + "cl_avg_supersat" : "linear", + "cl_avg_cloud_meanr" : "linear", + "cl_avg_cloud_stddevr" : "linear", "cl_meanr" : "linear", "sd_conc" : "linear", } @@ -47,8 +47,6 @@ "prflux" : "linear", "cl_nc" : "linear", "cl_nr" : "linear", - "cl_nc_rico" : "linear", - "cl_nr_rico" : "linear", "clfrac" : "linear", "wvar" : "linear", "w3rd" : "linear", @@ -71,13 +69,15 @@ "clb_bigrain_mean_conc" : "linear", "clb_bigrain_mean_inclt" : "linear", "clb_bigrain_mean_gccn_fraction" : "linear", - "cloud_cover_rico" : "linear", - "min_cloud_base_rico" : "linear", + "cloud_cover" : "linear", + "min_cloud_base" : "linear", "inversion_height_rico" : "linear", - "cl_acnv25_rico" : "linear", - "cl_accr25_rico" : "linear", + "cl_acnv25" : "linear", + "cl_accr25" : "linear", "RH_max" : "linear", - "cloud_avg_supersat" : "linear", + "cl_avg_supersat" : "linear", + "cl_avg_cloud_meanr" : "linear", + "cl_avg_cloud_stddevr" : "linear", "cl_meanr" : "linear", "sd_conc" : "linear", } @@ -89,8 +89,6 @@ "prflux" : None,#(0,20), "cl_nc" : None,#(0,90), "cl_nr" : None,#(0,90), - "cl_nc_rico" : None,#(0,90), - "cl_nr_rico" : None,#(0,90), "clfrac" : None, "wvar" : None, "w3rd" : None, @@ -101,7 +99,9 @@ "base_prflux_vs_clhght" : None,#(1,10000) "base_prflux_vs_clhght number of occurances" : None,#(1,10000) "RH_max" : None, - "cloud_avg_supersat" : None, + "cl_avg_supersat" : None, + "cl_avg_cloud_meanr" : None, + "cl_avg_cloud_stddevr" : None, "cl_meanr" : None, "sd_conc" : None, } @@ -113,8 +113,6 @@ "prflux" : (0,3000), "cl_nc" : (0,3000), "cl_nr" : (0,3000), - "cl_nc_rico" : (0,3000), - "cl_nr_rico" : (0,3000), "clfrac" : (0,3000), "wvar" : (0,3000), "w3rd" : (0,3000), @@ -125,7 +123,9 @@ "base_prflux_vs_clhght" : (0,2500), "base_prflux_vs_clhght number of occurances" : (0,2500), "RH_max" : (0,3000), - "cloud_avg_supersat" : (0,3000), + "cl_avg_supersat" : (0,3000), + "cl_avg_cloud_meanr" : (0,3000), + "cl_avg_cloud_stddevr" : (0,3000), "cl_meanr" : (0,3000), "sd_conc" : (0,3000), } @@ -134,8 +134,6 @@ "clfrac" : (0,5), "cl_nc" : (0,5), "cl_nr" : (0,5), - "cl_nc_rico" : (0,5), - "cl_nr_rico" : (0,5), "lwp" : (0,5), "rwp" : (0,5), "er" : (0,5), @@ -149,13 +147,15 @@ "clb_bigrain_mean_conc" : (0,5), "clb_bigrain_mean_inclt" : (0,5), "clb_bigrain_mean_gccn_fraction" : (0,5), - "cloud_cover_rico" : (0,5), - "min_cloud_base_rico" : (0,5), + "cloud_cover" : (0,5), + "min_cloud_base" : (0,5), "inversion_height_rico" : (0,5), - "cl_acnv25_rico" : (0,5), - "cl_accr25_rico" : (0,5), + "cl_acnv25" : (0,5), + "cl_accr25" : (0,5), "RH_max" : (0,5), - "cloud_avg_supersat" : (0,5), + "cl_avg_supersat" : (0,5), + "cl_avg_cloud_meanr" : (0,5), + "cl_avg_cloud_stddevr" : (0,5), "cl_meanr" : (0,5), "sd_conc" : (0,5), } @@ -164,8 +164,6 @@ "clfrac" : None, "cl_nc" : None,#(-1,155), "cl_nr" : None,#(-0.02,.55), - "cl_nc_rico" : None,#(-1,155), - "cl_nr_rico" : None,#(-0.02,.55), "lwp" : None,#(-1,45), "rwp" : None,#(-1,15), "er" : None, @@ -179,13 +177,15 @@ "clb_bigrain_mean_conc" : None, "clb_bigrain_mean_inclt" : None, "clb_bigrain_mean_gccn_fraction" : None, - "cloud_cover_rico" : None,#(-0.1,0.6), - "min_cloud_base_rico" : None,#(-1,750), + "cloud_cover" : None,#(-0.1,0.6), + "min_cloud_base" : None,#(-1,750), "inversion_height_rico" : None,#(1000,3000), - "cl_acnv25_rico" : None, - "cl_accr25_rico" : None, + "cl_acnv25" : None, + "cl_accr25" : None, "RH_max" : None, - "cloud_avg_supersat" : None, + "cl_avg_supersat" : None, + "cl_avg_cloud_meanr" : None, + "cl_avg_cloud_stddevr" : None, "cl_meanr" : None, "sd_conc" : None, } From c6be8add4f8e5a5a9408dd326680dcf502c39e77 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Wed, 21 Dec 2022 14:29:14 +0100 Subject: [PATCH 25/51] remove faulty normalizing of tke --- Energy_spectrum/spectrum_refined.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Energy_spectrum/spectrum_refined.py b/Energy_spectrum/spectrum_refined.py index 1f4a774..55dafc8 100644 --- a/Energy_spectrum/spectrum_refined.py +++ b/Energy_spectrum/spectrum_refined.py @@ -75,7 +75,7 @@ for lvl in range(level_start_idx * ref[var], level_end_idx * ref[var] + 1): w2d = w3d[:, :, lvl] #print w2d - + wkx = 1.0 / np.sqrt(nx[var] - 1) * np.fft.rfft(w2d, axis = 0) wky = 1.0 / np.sqrt(ny[var] - 1) * np.fft.rfft(w2d, axis = 1) @@ -105,7 +105,7 @@ #crudely scale #Exy_avg[var] /= Exy_avg[var][len(Exy_avg[var])-1] - Exy_avg[var] /= np.sum(Exy_avg[var]) +# Exy_avg[var] /= np.sum(Exy_avg[var]) #plot plt.loglog(lmbd[var], Exy_avg[var] , linewidth=2, label=lab+"_"+var) From d04e9d62ecd60465b2eab17aec3483677f09390f Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 22 Dec 2022 11:00:21 +0100 Subject: [PATCH 26/51] incloud th rv plots --- UWLCM_plotters/include/PlotterMask.hpp | 38 +++++++++++++++++++ drawbicyc/include/cases/RICO11/plots.hpp | 2 + drawbicyc/include/plot_series.hpp | 48 +++++++++++++++++++++++- 3 files changed, 86 insertions(+), 2 deletions(-) diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index 1212b1b..863b847 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -130,6 +130,44 @@ class PlotterMask : public PlotterMicro return cloud_hlpr(ract, at); } + // same for supersat + std::pair cloud_supersat_stats_timestep(int at) + { + // read activated droplets mixing ratio + arr_t RH(this->load_RH_timestep(at)); + return cloud_hlpr(RH, at); + } + // th + std::pair cloud_theta_stats_timestep(int at) + { + // read activated droplets mixing ratio + try + { + arr_t th(this->h5load_timestep("refined th", at)); + return cloud_hlpr(th, at); + } + catch (...) // should work for simulations without refinement + { + arr_t th(this->h5load_timestep("th", at)); + return cloud_hlpr(th, at); + } + } + // rv + std::pair cloud_rv_stats_timestep(int at) + { + // read activated droplets mixing ratio + try + { + arr_t rv(this->h5load_timestep("refined rv", at)); + return cloud_hlpr(rv, at); + } + catch (...) // should work for simulations without refinement + { + arr_t rv(this->h5load_timestep("rv", at)); + return cloud_hlpr(rv, at); + } + } + // mean and std_dev of concentration of activated/cloud/rain droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) std::pair cloud_actconc_stats_timestep(int at) { diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index 67f1811..4a56023 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -13,6 +13,8 @@ const std::vector series_rico({ "cl_nc", "cl_nr", "cl_avg_supersat", +"cl_avg_th", +"cl_avg_rv", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", "wvarmax", diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index 20dd055..d9474b3 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -594,12 +594,34 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } - // average supersaturation in cells with S>0 + // average supersaturation in cloudy cells else if (plt == "cl_avg_supersat") { try { - auto stats = plotter.positive_supersat_stats_timestep(at * n["outfreq"]); + auto stats = plotter.cloud_supersat_stats_timestep(at * n["outfreq"]); + res_series[plt](at) = stats.first; + res_series_std_dev[plt](at) = stats.second; + } + catch(...) {if(at==first_timestep) data_found[plt]=0;} + } + // average theta in cloudy cells + else if (plt == "cl_avg_th") + { + try + { + auto stats = plotter.cloud_theta_stats_timestep(at * n["outfreq"]); + res_series[plt](at) = stats.first; + res_series_std_dev[plt](at) = stats.second; + } + catch(...) {if(at==first_timestep) data_found[plt]=0;} + } + // average rv in cloudy cells + else if (plt == "cl_avg_rv") + { + try + { + auto stats = plotter.cloud_rv_stats_timestep(at * n["outfreq"]); res_series[plt](at) = stats.first; res_series_std_dev[plt](at) = stats.second; } @@ -1649,6 +1671,16 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { res_pos *= 60.; } + else if (plt == "cl_nr") + { + plot_std_dev = true; + res_pos *= 60.; + } + else if (plt == "cl_nc") + { + plot_std_dev = true; + res_pos *= 60.; + } else if (plt == "cl_avg_act_conc") { plot_std_dev = true; @@ -1663,16 +1695,28 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) plot_std_dev = true; res_pos *= 60.; } + else if (plt == "cl_avg_th") + { + plot_std_dev = true; + res_pos *= 60.; + } + else if (plt == "cl_avg_rv") + { + plot_std_dev = true; + res_pos *= 60.; + } else if (plt == "cl_std_dev_supersat") { res_pos *= 60.; } else if (plt == "cl_avg_cloud_meanr") { + plot_std_dev = true; res_pos *= 60.; } else if (plt == "cl_avg_cloud_stddevr") { + plot_std_dev = true; res_pos *= 60.; } else if (plt == "sd_conc") From e6bc830c16b287b084181a6142d6689367c4856a Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 22 Dec 2022 11:24:30 +0100 Subject: [PATCH 27/51] series average th rv fixes --- UWLCM_plotters/include/PlotterMask.hpp | 2 ++ drawbicyc/include/gnuplot_series_set_labels.hpp | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index 863b847..029e705 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -135,6 +135,8 @@ class PlotterMask : public PlotterMicro { // read activated droplets mixing ratio arr_t RH(this->load_RH_timestep(at)); + RH -= 1.; + RH *= 100; return cloud_hlpr(RH, at); } // th diff --git a/drawbicyc/include/gnuplot_series_set_labels.hpp b/drawbicyc/include/gnuplot_series_set_labels.hpp index 7fcb0bb..20d5bfc 100644 --- a/drawbicyc/include/gnuplot_series_set_labels.hpp +++ b/drawbicyc/include/gnuplot_series_set_labels.hpp @@ -67,7 +67,19 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) { gp << "set ylabel ' [%]'\n"; gp << "set xlabel 'time [min]'\n"; - gp << "set title 'avg supersaturation'\n"; + gp << "set title 'avg supersaturation in cloudy cells'\n"; + } + else if (plt == "cl_avg_th") + { + gp << "set ylabel 'theta [K]'\n"; + gp << "set xlabel 'time [min]'\n"; + gp << "set title 'avg theta in cloudy cells'\n"; + } + else if (plt == "cl_avg_rv") + { + gp << "set ylabel 'r_v [1]'\n"; + gp << "set xlabel 'time [min]'\n"; + gp << "set title 'avg rv in cloudy cells'\n"; } else if (plt == "cl_std_dev_supersat") { From 44316f157c71556e35d98f5f452da162501a2a3e Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 22 Dec 2022 11:45:50 +0100 Subject: [PATCH 28/51] series comparison: empty files --- Matplotlib_common/plot_series.py | 2 ++ Matplotlib_common/read_UWLCM_arrays.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Matplotlib_common/plot_series.py b/Matplotlib_common/plot_series.py index 8194773..c7f70ac 100644 --- a/Matplotlib_common/plot_series.py +++ b/Matplotlib_common/plot_series.py @@ -20,6 +20,8 @@ def plot_series(var_list, plot_iter, nplotx, nploty, axarr, xscaledict, yscaledi series_file = open(file_name, "r") my_times = read_my_var(series_file, "position") my_res = read_my_var(series_file, var) + if len(my_res) == 0: # file does not contain this type of plot + continue # rescale time to hours my_times = my_times / 3600. diff --git a/Matplotlib_common/read_UWLCM_arrays.py b/Matplotlib_common/read_UWLCM_arrays.py index 6060ad1..edb5920 100644 --- a/Matplotlib_common/read_UWLCM_arrays.py +++ b/Matplotlib_common/read_UWLCM_arrays.py @@ -15,6 +15,8 @@ def read_my_var(file_obj, var_name): arr_name = file_obj.readline() if(str(arr_name).strip() == str(var_name).strip()): return read_my_array(file_obj) + elif(len(arr_name)==0): + return np.empty(0) #def plot_my_array(axarr, plot_iter, time, val, nploty, xlabel=None, ylabel=None, varlabel=None , linestyle='--', dashes=(5,2), xlim=None, ylim=None, xscale="linear", yscale="linear"): # x = int(plot_iter / nploty) From c6b016e7fd2870431df9468d4e4c5e8a2fc77a5f Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 22 Dec 2022 12:00:07 +0100 Subject: [PATCH 29/51] rico series comparison update --- Matplotlib_common/latex_labels.py | 2 + cases/RICO11/Rico_series_comparison.py | 6 +-- cases/RICO11/plot_ranges.py | 66 +++++++++++++++----------- 3 files changed, 44 insertions(+), 30 deletions(-) diff --git a/Matplotlib_common/latex_labels.py b/Matplotlib_common/latex_labels.py index a5a80f7..9510a01 100644 --- a/Matplotlib_common/latex_labels.py +++ b/Matplotlib_common/latex_labels.py @@ -63,6 +63,8 @@ "cl_acnv25" : 'acnv. rate [g m$^{-3}$ d$^{-1}$]', "cl_accr25" : 'accr. rate [g m$^{-3}$ d$^{-1}$]', "cl_avg_supersat" : '$$ in cloud [\%]', + "cl_avg_th" : '$<\\theta>$ in cloud [K]', + "cl_avg_rv" : '$$ in cloud [1]', "cl_avg_cloud_meanr" : '$$ of cloud droplets in cloud [um]', "cl_avg_cloud_stddevr" : '$\sigma(r)$ of cloud droplets in cloud [um]', "sd_conc" : '$$' diff --git a/cases/RICO11/Rico_series_comparison.py b/cases/RICO11/Rico_series_comparison.py index 3764de5..c147c28 100644 --- a/cases/RICO11/Rico_series_comparison.py +++ b/cases/RICO11/Rico_series_comparison.py @@ -16,14 +16,14 @@ # activate latex text rendering rc('text', usetex=True) -rico_vars = ["lwp", "rwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc", "cl_nr", "surf_precip", "acc_precip", "RH_max", "cl_avg_supersat", "wvarmax", "sd_conc", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr"]#, "cl_acnv25", "cl_accr25"]#, "surf_flux_latent", "surf_flux_sensible" ] +rico_vars = ["lwp", "rwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc", "cl_nr", "surf_precip", "acc_precip", "RH_max", "cl_avg_supersat", "wvarmax", "sd_conc", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", "cl_avg_th", "cl_avg_rv"]#, "cl_acnv25", "cl_accr25"]#, "surf_flux_latent", "surf_flux_sensible" ] #rico_vars = ["clb_bigrain_mean_rd","clb_bigrain_mean_kappa","clb_bigrain_mean_conc","clb_bigrain_mean_inclt", "cl_nr"] # variables that need rescaling of the yrange to the limited x range of 1-6h rescale_vars = ["lwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc"]# rico_vars # init the plot -nplotx = 4 +nplotx = 5 nploty= 4 fig, axarr = plt.subplots(nplotx,nploty) x_arr = np.arange(nplotx) @@ -78,7 +78,7 @@ lgd = fig.legend(handles, labels, handlelength=4, loc='lower center', bbox_to_anchor=(0.45,0)) #figure size -fig.set_size_inches(7.874, 5. + (len(labels) - 2) * 0.2)# 5.214)#20.75,13.74) +fig.set_size_inches(7.874, 1.5 * nplotx + (len(labels) - 2) * 0.2)# 5.214)#20.75,13.74) #distances between subplots and from bottom of the plot fig.subplots_adjust(bottom=0.18 + (len(labels) - 2) * 0.03, hspace=0.1, wspace=0.4) diff --git a/cases/RICO11/plot_ranges.py b/cases/RICO11/plot_ranges.py index 6140095..d9e0f7a 100644 --- a/cases/RICO11/plot_ranges.py +++ b/cases/RICO11/plot_ranges.py @@ -34,6 +34,8 @@ "cl_accr25" : "linear", "RH_max" : "linear", "cl_avg_supersat" : "linear", + "cl_avg_th" : "linear", + "cl_avg_rv" : "linear", "cl_avg_cloud_meanr" : "linear", "cl_avg_cloud_stddevr" : "linear", "cl_meanr" : "linear", @@ -76,6 +78,8 @@ "cl_accr25" : "linear", "RH_max" : "linear", "cl_avg_supersat" : "linear", + "cl_avg_th" : "linear", + "cl_avg_rv" : "linear", "cl_avg_cloud_meanr" : "linear", "cl_avg_cloud_stddevr" : "linear", "cl_meanr" : "linear", @@ -100,6 +104,8 @@ "base_prflux_vs_clhght number of occurances" : None,#(1,10000) "RH_max" : None, "cl_avg_supersat" : None, + "cl_avg_th" : None, + "cl_avg_rv" : None, "cl_avg_cloud_meanr" : None, "cl_avg_cloud_stddevr" : None, "cl_meanr" : None, @@ -124,6 +130,8 @@ "base_prflux_vs_clhght number of occurances" : (0,2500), "RH_max" : (0,3000), "cl_avg_supersat" : (0,3000), + "cl_avg_th" : (0,3000), + "cl_avg_rv" : (0,3000), "cl_avg_cloud_meanr" : (0,3000), "cl_avg_cloud_stddevr" : (0,3000), "cl_meanr" : (0,3000), @@ -131,33 +139,35 @@ } xlimdict_series = { - "clfrac" : (0,5), - "cl_nc" : (0,5), - "cl_nr" : (0,5), - "lwp" : (0,5), - "rwp" : (0,5), - "er" : (0,5), - "wvarmax" : (0,5), - "surf_precip" : (0,5), - "acc_precip" : (0,5), - "cl_gccn_conc" : (0,5), - "cloud_base" : (0,5), - "clb_bigrain_mean_rd" : (0,5), - "clb_bigrain_mean_kappa" : (0,5), - "clb_bigrain_mean_conc" : (0,5), - "clb_bigrain_mean_inclt" : (0,5), - "clb_bigrain_mean_gccn_fraction" : (0,5), - "cloud_cover" : (0,5), - "min_cloud_base" : (0,5), - "inversion_height_rico" : (0,5), - "cl_acnv25" : (0,5), - "cl_accr25" : (0,5), - "RH_max" : (0,5), - "cl_avg_supersat" : (0,5), - "cl_avg_cloud_meanr" : (0,5), - "cl_avg_cloud_stddevr" : (0,5), - "cl_meanr" : (0,5), - "sd_conc" : (0,5), + "clfrac" : (0,24), + "cl_nc" : (0,24), + "cl_nr" : (0,24), + "lwp" : (0,24), + "rwp" : (0,24), + "er" : (0,24), + "wvarmax" : (0,24), + "surf_precip" : (0,24), + "acc_precip" : (0,24), + "cl_gccn_conc" : (0,24), + "cloud_base" : (0,24), + "clb_bigrain_mean_rd" : (0,24), + "clb_bigrain_mean_kappa" : (0,24), + "clb_bigrain_mean_conc" : (0,24), + "clb_bigrain_mean_inclt" : (0,24), + "clb_bigrain_mean_gccn_fraction" : (0,24), + "cloud_cover" : (0,24), + "min_cloud_base" : (0,24), + "inversion_height_rico" : (0,24), + "cl_acnv25" : (0,24), + "cl_accr25" : (0,24), + "RH_max" : (0,24), + "cl_avg_supersat" : (0,24), + "cl_avg_th" : (0,24), + "cl_avg_rv" : (0,24), + "cl_avg_cloud_meanr" : (0,24), + "cl_avg_cloud_stddevr" : (0,24), + "cl_meanr" : (0,24), + "sd_conc" : (0,24), } ylimdict_series = { @@ -184,6 +194,8 @@ "cl_accr25" : None, "RH_max" : None, "cl_avg_supersat" : None, + "cl_avg_th" : (296,302), + "cl_avg_rv" : (1.2e-2,1.6e-2), "cl_avg_cloud_meanr" : None, "cl_avg_cloud_stddevr" : None, "cl_meanr" : None, From 72241766bfe0ce87b26fadbd3e3aa3781670f73e Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 22 Dec 2022 12:43:58 +0100 Subject: [PATCH 30/51] command line xlim for series plots --- Matplotlib_common/plot_series.py | 25 ++++++++++++++++++++----- cases/RICO11/Rico_series_comparison.py | 16 ++++++++++++---- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Matplotlib_common/plot_series.py b/Matplotlib_common/plot_series.py index c7f70ac..d71e55c 100644 --- a/Matplotlib_common/plot_series.py +++ b/Matplotlib_common/plot_series.py @@ -1,17 +1,32 @@ import numpy as np -from sys import argv from math import floor +#from sys import argv +import argparse from latex_labels import var_labels from read_UWLCM_arrays import * + def plot_series(var_list, plot_iter, nplotx, nploty, axarr, xscaledict, yscaledict, xlimdict, ylimdict, show_bin=False, suffix='', xlabel='', ylabeldict=var_labels, file_names=[], file_labels=[], linewidth=1): + + parser = argparse.ArgumentParser(description='Plot UWLCM series comparison') + parser.add_argument("-ts", "--time_start", type=float, required=False, help="start of the plotted period [s] (override default)") + parser.add_argument("-te", "--time_end", type=float, required=False, help="end of the plotted period [s] (override default)") + parser.add_argument("-d", "--dirs", action="extend", nargs="+", type=str, help="list of directories with the data", required=True) + parser.add_argument("-l", "--labels", action="extend", nargs="+", type=str, help="list of labels of the data (same order as --dirs)", required=True) + args, extra = parser.parse_known_args() + print(args) + print(args.dirs) + + if args.time_start is not None and args.time_end is not None: + xlimdict = {x: (args.time_start, args.time_end) for x in xlimdict} + + # if file names are not defined, read them and labels from command line if len(file_names)==0: - file_no = np.arange(1, len(argv)-1 , 2) - for no in file_no: - file_names.append(argv[no] + suffix) - file_labels.append(argv[no+1]) + for directory, lab in zip(args.dirs, args.labels): + file_names.append(directory + suffix) + file_labels.append(lab) for var in var_list: label_counter=0 diff --git a/cases/RICO11/Rico_series_comparison.py b/cases/RICO11/Rico_series_comparison.py index c147c28..db7b0a8 100644 --- a/cases/RICO11/Rico_series_comparison.py +++ b/cases/RICO11/Rico_series_comparison.py @@ -2,6 +2,8 @@ import matplotlib.pyplot as plt import matplotlib.ticker as ticker from matplotlib.ticker import AutoMinorLocator, MultipleLocator +import argparse + import os import sys @@ -16,12 +18,18 @@ # activate latex text rendering rc('text', usetex=True) -rico_vars = ["lwp", "rwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc", "cl_nr", "surf_precip", "acc_precip", "RH_max", "cl_avg_supersat", "wvarmax", "sd_conc", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", "cl_avg_th", "cl_avg_rv"]#, "cl_acnv25", "cl_accr25"]#, "surf_flux_latent", "surf_flux_sensible" ] +rico_vars = ["lwp", "rwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc", "cl_nr", "surf_precip", "acc_precip", "RH_max", "wvarmax", "sd_conc", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", "cl_avg_supersat", "cl_avg_th", "cl_avg_rv"]#, "cl_acnv25", "cl_accr25"]#, "surf_flux_latent", "surf_flux_sensible" ] #rico_vars = ["clb_bigrain_mean_rd","clb_bigrain_mean_kappa","clb_bigrain_mean_conc","clb_bigrain_mean_inclt", "cl_nr"] # variables that need rescaling of the yrange to the limited x range of 1-6h rescale_vars = ["lwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc"]# rico_vars +# arguments +parser = argparse.ArgumentParser(description='Plot UWLCM series comparison for RICO simulations.') +parser.add_argument("-of", "--outfig", help="output file name", required=True) +args, extra = parser.parse_known_args() + + # init the plot nplotx = 5 nploty= 4 @@ -78,11 +86,11 @@ lgd = fig.legend(handles, labels, handlelength=4, loc='lower center', bbox_to_anchor=(0.45,0)) #figure size -fig.set_size_inches(7.874, 1.5 * nplotx + (len(labels) - 2) * 0.2)# 5.214)#20.75,13.74) +fig.set_size_inches(7.874, 1.5 * nplotx + (len(labels) - 2) * 0.1)# 5.214)#20.75,13.74) #distances between subplots and from bottom of the plot -fig.subplots_adjust(bottom=0.18 + (len(labels) - 2) * 0.03, hspace=0.1, wspace=0.4) +fig.subplots_adjust(bottom=0.18 + (len(labels) - 2) * 0.01, hspace=0.1, wspace=0.4) #fig.tight_layout(pad=0, w_pad=0, h_pad=0) #plt.show() -fig.savefig(argv[len(sys.argv)-1], bbox_inches='tight', dpi=300)#, bbox_extra_artists=(lgd,)) +fig.savefig(args.outfig, bbox_inches='tight', dpi=300)#, bbox_extra_artists=(lgd,)) From 6dd8a0dceeb5bb59e3a877a9823ab0fab4b12c1a Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 22 Dec 2022 13:57:32 +0100 Subject: [PATCH 31/51] advance prop cycle for empty plots --- Matplotlib_common/plot_series.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Matplotlib_common/plot_series.py b/Matplotlib_common/plot_series.py index d71e55c..1f79bbe 100644 --- a/Matplotlib_common/plot_series.py +++ b/Matplotlib_common/plot_series.py @@ -2,6 +2,7 @@ from math import floor #from sys import argv import argparse +import matplotlib.pyplot as plt from latex_labels import var_labels from read_UWLCM_arrays import * @@ -15,8 +16,6 @@ def plot_series(var_list, plot_iter, nplotx, nploty, axarr, xscaledict, yscaledi parser.add_argument("-d", "--dirs", action="extend", nargs="+", type=str, help="list of directories with the data", required=True) parser.add_argument("-l", "--labels", action="extend", nargs="+", type=str, help="list of labels of the data (same order as --dirs)", required=True) args, extra = parser.parse_known_args() - print(args) - print(args.dirs) if args.time_start is not None and args.time_end is not None: xlimdict = {x: (args.time_start, args.time_end) for x in xlimdict} @@ -36,6 +35,9 @@ def plot_series(var_list, plot_iter, nplotx, nploty, axarr, xscaledict, yscaledi my_times = read_my_var(series_file, "position") my_res = read_my_var(series_file, var) if len(my_res) == 0: # file does not contain this type of plot + print("skipping from: " + str(label_counter)) + label_counter+=1 + print("skipping to: " + str(label_counter)) continue # rescale time to hours @@ -49,14 +51,15 @@ def plot_series(var_list, plot_iter, nplotx, nploty, axarr, xscaledict, yscaledi linestyles = ['--', '-.', ':'] dashList = [(3,1),(1,1),(4,1,1,1),(4,2)] - colorList = ['red', 'blue', 'green'] + # colorList = ['red', 'blue', 'green'] + colorList = plt.rcParams['axes.prop_cycle'].by_key()['color'] # default prop cycle colors # x label only on he lowest row xlabel_used = xlabel if plot_iter < nploty: xlabel_used = '' - plot_my_array(axarr, plot_iter, my_times, my_res, nploty, xlabel=xlabel_used, ylabel=ylabeldict[var], varlabel=file_labels[label_counter], dashes = dashList[label_counter % len(dashList)], xscale=xscaledict[var], yscale=yscaledict[var], xlim=xlimdict[var], ylim=ylimdict[var], linewidth=linewidth)#, color = colorList[int(floor(label_counter / len(dashList)))]) + plot_my_array(axarr, plot_iter, my_times, my_res, nploty, xlabel=xlabel_used, ylabel=ylabeldict[var], varlabel=file_labels[label_counter], dashes = dashList[label_counter % len(dashList)], xscale=xscaledict[var], yscale=yscaledict[var], xlim=xlimdict[var], ylim=ylimdict[var], linewidth=linewidth, color = colorList[label_counter % len(colorList)]) label_counter+=1 plot_iter = plot_iter + 1 return plot_iter From 95c6114ad9aea7d0be2b9941343c80c1c638a38d Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Tue, 27 Dec 2022 14:55:02 +0100 Subject: [PATCH 32/51] rico series: surf fluxes --- drawbicyc/include/cases/RICO11/plots.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index 4a56023..fc3e052 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -18,6 +18,8 @@ const std::vector series_rico({ "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", "wvarmax", + "surf_flux_latent", + "surf_flux_sensible" "sd_conc" @@ -43,8 +45,6 @@ const std::vector series_rico({ /* "cloud_base", - "surf_flux_latent", - "surf_flux_sensible" ,"cl_sd_conc" //"mass_dry", ,"cl_gccn_conc", "gccn_conc" From a52a1bf4964560e3448923af0a35628977d834bd Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Wed, 28 Dec 2022 17:27:10 +0100 Subject: [PATCH 33/51] fix typo --- drawbicyc/include/cases/RICO11/plots.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index fc3e052..4e893a8 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -19,7 +19,7 @@ const std::vector series_rico({ "cl_avg_cloud_stddevr", "wvarmax", "surf_flux_latent", - "surf_flux_sensible" + "surf_flux_sensible", "sd_conc" From d9768ea0d093fd3442cabffe908e5bde03c136e1 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Wed, 28 Dec 2022 18:17:07 +0100 Subject: [PATCH 34/51] rico series: surf fluxes --- Matplotlib_common/latex_labels.py | 4 +++- cases/RICO11/Rico_series_comparison.py | 2 +- cases/RICO11/plot_ranges.py | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Matplotlib_common/latex_labels.py b/Matplotlib_common/latex_labels.py index 9510a01..e2981f1 100644 --- a/Matplotlib_common/latex_labels.py +++ b/Matplotlib_common/latex_labels.py @@ -67,7 +67,9 @@ "cl_avg_rv" : '$$ in cloud [1]', "cl_avg_cloud_meanr" : '$$ of cloud droplets in cloud [um]', "cl_avg_cloud_stddevr" : '$\sigma(r)$ of cloud droplets in cloud [um]', - "sd_conc" : '$$' + "sd_conc" : '$$', + "surf_flux_latent" : 'latent surface flux [W/m$^2$]', + "surf_flux_sensible" : 'sensible surface flux [W/m$^2$]', } diff --git a/cases/RICO11/Rico_series_comparison.py b/cases/RICO11/Rico_series_comparison.py index db7b0a8..54d257f 100644 --- a/cases/RICO11/Rico_series_comparison.py +++ b/cases/RICO11/Rico_series_comparison.py @@ -18,7 +18,7 @@ # activate latex text rendering rc('text', usetex=True) -rico_vars = ["lwp", "rwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc", "cl_nr", "surf_precip", "acc_precip", "RH_max", "wvarmax", "sd_conc", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", "cl_avg_supersat", "cl_avg_th", "cl_avg_rv"]#, "cl_acnv25", "cl_accr25"]#, "surf_flux_latent", "surf_flux_sensible" ] +rico_vars = ["lwp", "rwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc", "cl_nr", "surf_precip", "acc_precip", "RH_max", "wvarmax", "sd_conc", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", "cl_avg_supersat", "cl_avg_th", "cl_avg_rv", "surf_flux_latent", "surf_flux_sensible"]#, "cl_acnv25", "cl_accr25"]# ] #rico_vars = ["clb_bigrain_mean_rd","clb_bigrain_mean_kappa","clb_bigrain_mean_conc","clb_bigrain_mean_inclt", "cl_nr"] # variables that need rescaling of the yrange to the limited x range of 1-6h diff --git a/cases/RICO11/plot_ranges.py b/cases/RICO11/plot_ranges.py index d9e0f7a..8115fb0 100644 --- a/cases/RICO11/plot_ranges.py +++ b/cases/RICO11/plot_ranges.py @@ -15,6 +15,8 @@ "er" : "linear", "wvarmax" : "linear", "surf_precip" : "linear", + "surf_flux_latent" : "linear", + "surf_flux_sensible" : "linear", "acc_precip" : "linear", "cloud_base" : "linear", "gccn_rw_cl" : "linear", @@ -59,6 +61,8 @@ "er" : "linear", "wvarmax" : "linear", "surf_precip" : "linear", + "surf_flux_latent" : "linear", + "surf_flux_sensible" : "linear", "acc_precip" : "linear", "cloud_base" : "linear", "gccn_rw_cl" : "linear", @@ -147,6 +151,8 @@ "er" : (0,24), "wvarmax" : (0,24), "surf_precip" : (0,24), + "surf_flux_latent" : (0,24), + "surf_flux_sensible" : (0,24), "acc_precip" : (0,24), "cl_gccn_conc" : (0,24), "cloud_base" : (0,24), @@ -179,6 +185,8 @@ "er" : None, "wvarmax" : None, "surf_precip" : None,# (-0.05,1.2), + "surf_flux_latent" : (120,190), + "surf_flux_sensible" : None, "acc_precip" : None,#(-0.002,0.08), "cl_gccn_conc" : None,#(1e-6, 1), "cloud_base" : None, From b481f609f128fabd2a9b4b265dad7ef2f0a64bbb Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 19 Jan 2023 05:12:52 +0100 Subject: [PATCH 35/51] spectrum refined: als plot -3 --- Energy_spectrum/spectrum_refined.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Energy_spectrum/spectrum_refined.py b/Energy_spectrum/spectrum_refined.py index 55dafc8..de47bca 100644 --- a/Energy_spectrum/spectrum_refined.py +++ b/Energy_spectrum/spectrum_refined.py @@ -97,7 +97,10 @@ # print(K, lmbd) if (t == time_start_idx and lab==args.labels[0]): - plt.loglog(lmbd[var], 2e-6* K**(-5./3.) ) + L = np.array([2e2, 2e3]) + plt.loglog(L, 2e-5 * L**(5./3.), label = "-5/3" , color="black", ls='dotted') + L = np.array([5e1, 3e2]) + plt.loglog(L, 2e-8 * L**(3.), label = "-3" , color="black", ls='dashed') for var in args.vars: Exy_avg[var] /= (time_end_idx - time_start_idx) / outfreq + 1 From 5578c7e8ee9a9f5b588d7f86959b5f3cba45a768 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Tue, 28 Feb 2023 10:46:59 +0100 Subject: [PATCH 36/51] histogram: rename correlations to scatter --- histograms/histogram.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/histograms/histogram.py b/histograms/histogram.py index 430512a..12cda34 100644 --- a/histograms/histogram.py +++ b/histograms/histogram.py @@ -45,7 +45,7 @@ def calc_RH(th, rv, p): parser.add_argument("--outfreq", type=int, required=False, help="output frequency of the simulation [number of time steps], if not specified it will be read from const.h5 (if possible)") parser.add_argument('--normalize', action='store_true', help="normalize the histogram") parser.add_argument('--no_histogram', action='store_true', help="dont save the histogram plot") -parser.add_argument('--no_correlations', action='store_true', help="dont calculate correlations and dot save the scatter plot") +parser.add_argument('--no_scatter', action='store_true', help="dont calculate correlations and dot save the scatter plot") parser.add_argument('--mask_rico', action='store_true', help="compute histogram only within cloud cells (using the rico cloud mask)") parser.set_defaults(normalie=False) args = parser.parse_args() @@ -271,5 +271,5 @@ def calc_RH(th, rv, p): plt.figure(2) plt.legend()#loc = 'lower center') -if(not args.no_correlations): +if(not args.no_scatter): plt.savefig(args.outfig + 'scatter.svg') From d01e32a11de81d53dd9fd97ff9fa1513f5d2df8e Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Tue, 28 Feb 2023 11:26:36 +0100 Subject: [PATCH 37/51] histogram: RH_derived based on libcloudph++ functions --- histograms/histogram.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/histograms/histogram.py b/histograms/histogram.py index 12cda34..3e0f27b 100644 --- a/histograms/histogram.py +++ b/histograms/histogram.py @@ -2,29 +2,37 @@ import argparse import h5py import numpy as np -from sys import argv +from sys import path import matplotlib.pyplot as plt from collections import OrderedDict -c_pd = 1005.7 -R_d = 287. +path.append('/home/piotr/singu_built_libraries/usr/lib/python3/dist-packages/') +from libcloudphxx import common -def exner(p): - return (p / 1e5)**(R_d/c_pd) -v_exner = np.vectorize(exner) +#c_pd = 1005.7 +#R_d = 287. +# +#def exner(p): +# return (p / 1e5)**(R_d/c_pd) +#v_exner = np.vectorize(exner) +# def calc_T(th, p): - return th * v_exner(p) -v_calc_T = np.vectorize(calc_T) - -# Tetens: r_vs=3.8/(p*exp(-17.2693882*(T-273.15)/(T-35.86))-6.109) p in mb, T in Kelvins -def calc_rv_s(th, rv, p): - T = v_calc_T(th, p) - return 3.8 / (p*np.exp(-17.2693882*(T-273.15)/(T-35.86))-6.109) -v_calc_rv_s = np.vectorize(calc_rv_s) + return th * common.exner(p) +#v_calc_T = np.vectorize(calc_T) +# +## Tetens: r_vs=3.8/(p*exp(-17.2693882*(T-273.15)/(T-35.86))-6.109) p in mb, T in Kelvins +#def calc_rv_s(th, rv, p): +# T = v_calc_T(th, p) +# return 3.8 / (p*np.exp(-17.2693882*(T-273.15)/(T-35.86))-6.109) + +def calc_r_vs(th, rv, p): + T = calc_T(th, p) + return common.r_vs(T, p) +v_calc_r_vs = np.vectorize(calc_r_vs) def calc_RH(th, rv, p): - return rv / v_calc_rv_s(th, rv, p) / 100. + return rv / v_calc_r_vs(th, rv, p) v_calc_RH = np.vectorize(calc_RH) #mpl.rcParams['figure.figsize'] = 10, 10 From 8d40feeefd43146937afd2487e3b1cd778ebc099 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Tue, 28 Feb 2023 12:17:03 +0100 Subject: [PATCH 38/51] scatter plot: saturation line --- histograms/histogram.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/histograms/histogram.py b/histograms/histogram.py index 3e0f27b..777e803 100644 --- a/histograms/histogram.py +++ b/histograms/histogram.py @@ -18,21 +18,26 @@ #v_exner = np.vectorize(exner) # def calc_T(th, p): - return th * common.exner(p) + return np.float64(th) * common.exner(np.float64(p)) #v_calc_T = np.vectorize(calc_T) + # ## Tetens: r_vs=3.8/(p*exp(-17.2693882*(T-273.15)/(T-35.86))-6.109) p in mb, T in Kelvins #def calc_rv_s(th, rv, p): # T = v_calc_T(th, p) # return 3.8 / (p*np.exp(-17.2693882*(T-273.15)/(T-35.86))-6.109) -def calc_r_vs(th, rv, p): +def calc_r_vs_T(T, p): + return common.r_vs(np.float64(T), np.float64(p)) +v_calc_r_vs_T = np.vectorize(calc_r_vs_T) + +def calc_r_vs(th, p): T = calc_T(th, p) return common.r_vs(T, p) v_calc_r_vs = np.vectorize(calc_r_vs) def calc_RH(th, rv, p): - return rv / v_calc_r_vs(th, rv, p) + return rv / v_calc_r_vs(th, p) v_calc_RH = np.vectorize(calc_RH) #mpl.rcParams['figure.figsize'] = 10, 10 @@ -55,7 +60,8 @@ def calc_RH(th, rv, p): parser.add_argument('--no_histogram', action='store_true', help="dont save the histogram plot") parser.add_argument('--no_scatter', action='store_true', help="dont calculate correlations and dot save the scatter plot") parser.add_argument('--mask_rico', action='store_true', help="compute histogram only within cloud cells (using the rico cloud mask)") -parser.set_defaults(normalie=False) +parser.add_argument('--scatter_saturation', action='store_true', help="plot saturation line on th vs rv scatter plots") +parser.set_defaults(normalize=False, scatter_saturation=False) args = parser.parse_args() @@ -66,6 +72,8 @@ def calc_RH(th, rv, p): dz = {} ref = {} +scatter_saturation_plotted = False + # directories loop for directory, lab in zip(args.dirs, args.labels): @@ -225,9 +233,21 @@ def calc_RH(th, rv, p): plt.scatter(total_arr[lab_var1].flatten(), total_arr[lab_var2].flatten(), marker='.', s=1, label=lab) plt.xlabel(var1) plt.ylabel(var2) - # plt.clf() - + # add saturation line on a rv vs th plot + # TODO: add this line also to refined rv vs refined th plots + if(args.scatter_saturation and var1 == "th" and var2 == "rv" and args.level_start == args.level_end and not scatter_saturation_plotted): + print("plotting a saturation line on the scatter plot") + press = p_e[level_start_idx] + min_th = total_arr[lab_var1].min() + max_th = total_arr[lab_var1].max() + min_T = calc_T(min_th, press) + max_T = calc_T(max_th, press) + v_th = np.linspace(min_th, max_th, 100) + v_T = np.linspace(min_T, max_T, 100) + v_r_vs = v_calc_r_vs_T(v_T, press) + plt.plot(v_th, v_r_vs, c='black', ls='--', label='r_vs') + scatter_saturation_plotted = True From 7b295e26ed0a9b238064e7d2d32fe89c03addc50 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Tue, 9 May 2023 10:35:34 +0200 Subject: [PATCH 39/51] scatter plot: title --- histograms/histogram.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/histograms/histogram.py b/histograms/histogram.py index 777e803..73f0436 100644 --- a/histograms/histogram.py +++ b/histograms/histogram.py @@ -299,5 +299,8 @@ def calc_RH(th, rv, p): plt.figure(2) plt.legend()#loc = 'lower center') +plt.grid(True, which='both', linestyle='--') +plt.title("z=["+str(args.level_start)+"m, "+str(args.level_end)+"m] @["+str(args.time_start)+"s, "+str(args.time_end)+"s]") + if(not args.no_scatter): plt.savefig(args.outfig + 'scatter.svg') From 44d62615ead087b831a6d95106720743a4dbf763 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Tue, 9 May 2023 10:49:03 +0200 Subject: [PATCH 40/51] comment --- histograms/histogram.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/histograms/histogram.py b/histograms/histogram.py index 73f0436..1070e42 100644 --- a/histograms/histogram.py +++ b/histograms/histogram.py @@ -121,9 +121,6 @@ def calc_RH(th, rv, p): filename = directory + "/timestep" + str(time_start_idx).zfill(10) + ".h5" # special case of RH calculated from th and rv - # NOTE: RH_derived is calculated with r_v / r_vs, where r_vs comes from the Tetens formula - # in UWLCM r_vs comes from clausius-clapeyron. - # RH_derived is shifted to the right with respect to RH from UWLCM - maybe due to this difference? if(var == "RH_derived"): w3d = h5py.File(filename, "r")["th"][:,:,:] elif(can_plot_refined_RH_derived and var == "refined RH_derived"): From 75fc02908aa394537d3c47ab07c61704f4e7f28d Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Wed, 10 May 2023 10:37:41 +0200 Subject: [PATCH 41/51] spectrum plot: allow vars not to exists --- Energy_spectrum/spectrum_refined.py | 31 +++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/Energy_spectrum/spectrum_refined.py b/Energy_spectrum/spectrum_refined.py index aec8c2b..526fa9a 100644 --- a/Energy_spectrum/spectrum_refined.py +++ b/Energy_spectrum/spectrum_refined.py @@ -34,6 +34,7 @@ lmbd = {} level_start_idx = {} level_end_idx = {} + exists = {} # read some constant parameters with h5py.File(directory + "/const.h5", 'r') as consth5: @@ -58,16 +59,21 @@ # initiliaze nx,ny,nz,dx and average energy for each variable for var in args.vars: filename = directory + "/timestep" + str(time_start_idx).zfill(10) + ".h5" - w3d = h5py.File(filename, "r")[var][:,:,:] - nx[var], ny[var], nz[var] = tuple(x for x in w3d.shape) - dx[var] = X / (nx[var] - 1) - dz[var] = Z / (nz[var] - 1) - Exy_avg[var] = np.zeros(int((nx[var]-1)/2 + 1)) - ref[var] = int(dx_adve / dx[var]) - assert(float(args.level_start / dz[var]).is_integer()) - assert(float(args.level_end / dz[var]).is_integer()) - level_start_idx[var] = int(args.level_start / dz[var]) - level_end_idx[var] = int(args.level_end / dz[var]) + 1 + + try: + w3d = h5py.File(filename, "r")[var][:,:,:] + nx[var], ny[var], nz[var] = tuple(x for x in w3d.shape) + dx[var] = X / (nx[var] - 1) + dz[var] = Z / (nz[var] - 1) + Exy_avg[var] = np.zeros(int((nx[var]-1)/2 + 1)) + ref[var] = int(dx_adve / dx[var]) + assert(float(args.level_start / dz[var]).is_integer()) + assert(float(args.level_end / dz[var]).is_integer()) + level_start_idx[var] = int(args.level_start / dz[var]) + level_end_idx[var] = int(args.level_end / dz[var]) + 1 + exists[var] = True + except: + exists[var] = False # time loop @@ -78,6 +84,8 @@ # variables loop for var in args.vars: print(var) + if not exists[var]: + continue print(nx[var],dx[var][0]) w3d = h5py.File(filename, "r")[var][0:nx[var]-1,0:ny[var]-1,:] # * 4. / 3. * 3.1416 * 1e3 @@ -113,6 +121,9 @@ plt.loglog(L, 2e-8 * L**(3.), label = "-3" , color="black", ls='dashed') for var in args.vars: + if not exists[var]: + continue + Exy_avg[var] /= (time_end_idx - time_start_idx) / outfreq + 1 Exy_avg[var] /= level_end_idx[var] - level_start_idx[var] From b5079923ae81e08574c364c51744ef625c517977 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 11 May 2023 17:55:00 +0200 Subject: [PATCH 42/51] histograms: plot r_tot and th_l --- histograms/histogram.py | 52 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/histograms/histogram.py b/histograms/histogram.py index 1070e42..2adf2f3 100644 --- a/histograms/histogram.py +++ b/histograms/histogram.py @@ -40,6 +40,11 @@ def calc_RH(th, rv, p): return rv / v_calc_r_vs(th, p) v_calc_RH = np.vectorize(calc_RH) +def calc_th_l(th, rl, p): + T = calc_T(th, p) + return th - 1. / common.exner(np.float64(p)) * common.l_v(np.float64(T)) / common.c_pd * rl +v_calc_th_l = np.vectorize(calc_th_l) + #mpl.rcParams['figure.figsize'] = 10, 10 plt.rcParams.update({'font.size': 10}) plt.figure(1, figsize=(10,10)) # histogram plot @@ -60,6 +65,7 @@ def calc_RH(th, rv, p): parser.add_argument('--no_histogram', action='store_true', help="dont save the histogram plot") parser.add_argument('--no_scatter', action='store_true', help="dont calculate correlations and dot save the scatter plot") parser.add_argument('--mask_rico', action='store_true', help="compute histogram only within cloud cells (using the rico cloud mask)") +parser.add_argument('--mask_rico_rl', action='store_true', help="compute histogram only within cloud cells (using the rico cloud mask based on the r_l array)") parser.add_argument('--scatter_saturation', action='store_true', help="plot saturation line on th vs rv scatter plots") parser.set_defaults(normalize=False, scatter_saturation=False) args = parser.parse_args() @@ -120,11 +126,21 @@ def calc_RH(th, rv, p): # init variable-specific array parameters based on the first timestep filename = directory + "/timestep" + str(time_start_idx).zfill(10) + ".h5" - # special case of RH calculated from th and rv + # special cases of variables that need processing first if(var == "RH_derived"): w3d = h5py.File(filename, "r")["th"][:,:,:] elif(can_plot_refined_RH_derived and var == "refined RH_derived"): w3d = h5py.File(filename, "r")["refined th"][:,:,:] + elif(var == "r_tot"): # total resolved water mixing ratio + try: + w3d = h5py.File(filename, "r")["rv"][:,:,:] + except: + continue + elif(var == "th_l"): # liquid water potential temperature + try: + w3d = h5py.File(filename, "r")["th"][:,:,:] + except: + continue else: try: w3d = h5py.File(filename, "r")[var][:,:,:] @@ -157,16 +173,28 @@ def calc_RH(th, rv, p): lab_var = lab + '_' + str(var) + assert(not (args.mask_rico and args.mask_rico_rl)) + if(args.mask_rico): try: mask = h5py.File(filename, "r")["cloud_rw_mom3"][:,:,:] if(mask.shape != w3d.shape): - print("Cloud mask shape is different than "+var+" shape. Skipping the plot.") + print("Cloud mask shape: " + str(mask.shape) + " is different than "+var+" shape: " + str(w3d.shape) + ". Skipping the plot.") continue except: print("Can't find cloud_rw_mom3 data, so can't use RICO cloud mask. Skipping the plot.") continue + if(args.mask_rico_rl): + try: + mask = h5py.File(filename, "r")["r_l"][:,:,:] + if(mask.shape != w3d.shape): + print("Cloud mask shape: " + str(mask.shape) + " is different than "+var+" shape: " + str(w3d.shape) + ". Skipping the plot.") + continue + except: + print("Can't find r_l data, so can't use RICO r_l cloud mask. Skipping the plot.") + continue + total_arr[lab_var] = np.zeros(0) plot_labels[lab_var] = lab_var @@ -195,6 +223,18 @@ def calc_RH(th, rv, p): p[i,j] = refined_p_e[level_start_idx:level_end_idx] w3d = v_calc_RH(th, rv, p) + elif(var == "r_tot"): # total resolved water mixing ratio + w3d = h5py.File(filename, "r")["rv"][:,:,level_start_idx:level_end_idx] + h5py.File(filename, "r")["r_l"][:,:,level_start_idx:level_end_idx] + + elif(var == "th_l"): # liquid water potential temp + th = h5py.File(filename, "r")["th"][:,:,level_start_idx:level_end_idx] + rl = h5py.File(filename, "r")["r_l"][:,:,level_start_idx:level_end_idx] + p = np.empty(th.shape) + for i in np.arange(p.shape[0]): + for j in np.arange(p.shape[1]): + p[i,j] = p_e[level_start_idx:level_end_idx] + w3d = v_calc_th_l(th, rl, p) + else: w3d = h5py.File(filename, "r")[var][0:nx-1, 0:ny-1, level_start_idx:level_end_idx] # * 4. / 3. * 3.1416 * 1e3 @@ -204,6 +244,12 @@ def calc_RH(th, rv, p): mask = np.where(mask > 1.e-5, 1., 0.) w3d = w3d[(mask == 1)] + # read and apply cloud mask + if(args.mask_rico_rl): + mask = h5py.File(filename, "r")["r_l"][0:nx, 0:ny, level_start_idx:level_end_idx] + mask = np.where(mask > 1.e-5, 1., 0.) + w3d = w3d[(mask == 1)] + total_arr[lab_var] = np.append(total_arr[lab_var], w3d) @@ -300,4 +346,4 @@ def calc_RH(th, rv, p): plt.title("z=["+str(args.level_start)+"m, "+str(args.level_end)+"m] @["+str(args.time_start)+"s, "+str(args.time_end)+"s]") if(not args.no_scatter): - plt.savefig(args.outfig + 'scatter.svg') + plt.savefig(args.outfig + 'scatter.png') # .svg From 0bead4e24f38172abe7162f721adece91be5a408 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 18 May 2023 15:20:53 +0200 Subject: [PATCH 43/51] series: incloud activated droplet mean and std dev or radius --- UWLCM_plotters/include/PlotterMask.hpp | 6 ++-- drawbicyc/include/cases/RICO11/plots.hpp | 2 ++ .../include/gnuplot_series_set_labels.hpp | 12 +++++++ drawbicyc/include/plot_series.hpp | 31 +++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index 029e705..4029c42 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -173,7 +173,7 @@ class PlotterMask : public PlotterMicro // mean and std_dev of concentration of activated/cloud/rain droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) std::pair cloud_actconc_stats_timestep(int at) { - return cloud_conc_stats_timestep_hlpr(at, "act_rw", "nc", "nr"); + return cloud_conc_stats_timestep_hlpr(at, "actrw_rw", "nc", "nr"); } std::pair cloud_cloudconc_stats_timestep(int at) @@ -206,7 +206,7 @@ class PlotterMask : public PlotterMicro // mean and std_dev of mean radius of activated/cloud/rain droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) std::pair cloud_actmeanr_stats_timestep(int at) { - return cloud_meanr_stats_timestep_hlpr(at, "act_rw"); + return cloud_meanr_stats_timestep_hlpr(at, "actrw_rw"); } std::pair cloud_cloudmeanr_stats_timestep(int at) { @@ -220,7 +220,7 @@ class PlotterMask : public PlotterMicro // mean and std_dev of std_dev of radius of activated/cloud/rain droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) std::pair cloud_actstddevr_stats_timestep(int at) { - return cloud_stddevr_stats_timestep_hlpr(at, "act_rw"); + return cloud_stddevr_stats_timestep_hlpr(at, "actrw_rw"); } std::pair cloud_cloudstddevr_stats_timestep(int at) { diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index 4e893a8..df2aba2 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -17,6 +17,8 @@ const std::vector series_rico({ "cl_avg_rv", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", +"cl_avg_act_meanr", +"cl_avg_act_stddevr", "wvarmax", "surf_flux_latent", "surf_flux_sensible", diff --git a/drawbicyc/include/gnuplot_series_set_labels.hpp b/drawbicyc/include/gnuplot_series_set_labels.hpp index 20d5bfc..a97d79c 100644 --- a/drawbicyc/include/gnuplot_series_set_labels.hpp +++ b/drawbicyc/include/gnuplot_series_set_labels.hpp @@ -99,6 +99,18 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) gp << "set xlabel 'time [min]'\n"; gp << "set title 'average std dev of radius of activated droplets'\n"; } + else if (plt == "cl_avg_act_meanr") + { + gp << "set ylabel ' [um]'\n"; + gp << "set xlabel 'time [min]'\n"; + gp << "set title 'mean radius of activated droplets in cloud'\n"; + } + else if (plt == "cl_avg_act_stddevr") + { + gp << "set ylabel ' [um]'\n"; + gp << "set xlabel 'time [min]'\n"; + gp << "set title 'std. dev. of radius of activated droplets in cloud'\n"; + } else if (plt == "cl_avg_cloud_meanr") { gp << "set ylabel ' [um]'\n"; diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index d9474b3..f01e27c 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -627,6 +627,27 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } + // spatial average of mean radius of activated droplets in cloudy cells + else if (plt == "cl_avg_act_meanr") + { + try + { + auto stats = plotter.cloud_actmeanr_stats_timestep(at * n["outfreq"]); + res_series[plt](at) = stats.first; + } + catch(...) {if(at==first_timestep) data_found[plt]=0;} + } + + // spatial average of standard deviation of activated droplet radius distribution in cloudy cells + else if (plt == "cl_avg_act_stddevr") + { + try + { + auto stats = plotter.cloud_actstddevr_stats_timestep(at * n["outfreq"]); + res_series[plt](at) = stats.first; + } + catch(...) {if(at==first_timestep) data_found[plt]=0;} + } // spatial average of mean radius of cloud droplets in cloudy cells else if (plt == "cl_avg_cloud_meanr") { @@ -1709,6 +1730,16 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { res_pos *= 60.; } + else if (plt == "cl_avg_act_meanr") + { + plot_std_dev = true; + res_pos *= 60.; + } + else if (plt == "cl_avg_act_stddevr") + { + plot_std_dev = true; + res_pos *= 60.; + } else if (plt == "cl_avg_cloud_meanr") { plot_std_dev = true; From 18121db9222eb5456a2b1243cf4d027cbb264192 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Thu, 18 May 2023 15:20:53 +0200 Subject: [PATCH 44/51] series: incloud activated droplet mean and std dev or radius --- Matplotlib_common/latex_labels.py | 8 +++++ UWLCM_plotters/include/PlotterMask.hpp | 6 ++-- cases/RICO11/Rico_series_comparison.py | 4 +-- cases/RICO11/plot_ranges.py | 12 +++++++ drawbicyc/include/cases/RICO11/plots.hpp | 2 ++ .../include/gnuplot_series_set_labels.hpp | 12 +++++++ drawbicyc/include/plot_series.hpp | 31 +++++++++++++++++++ 7 files changed, 70 insertions(+), 5 deletions(-) diff --git a/Matplotlib_common/latex_labels.py b/Matplotlib_common/latex_labels.py index e2981f1..1ee0471 100644 --- a/Matplotlib_common/latex_labels.py +++ b/Matplotlib_common/latex_labels.py @@ -67,6 +67,8 @@ "cl_avg_rv" : '$$ in cloud [1]', "cl_avg_cloud_meanr" : '$$ of cloud droplets in cloud [um]', "cl_avg_cloud_stddevr" : '$\sigma(r)$ of cloud droplets in cloud [um]', + "cl_avg_act_meanr" : '$$ of activated droplets in cloud [um]', + "cl_avg_act_stddevr" : '$\sigma(r)$ of activated droplets in cloud [um]', "sd_conc" : '$$', "surf_flux_latent" : 'latent surface flux [W/m$^2$]', "surf_flux_sensible" : 'sensible surface flux [W/m$^2$]', @@ -94,4 +96,10 @@ 17 : "(r)", 18 : "(s)", 19 : "(t)", + 20 : "(u)", + 21 : "(v)", + 22 : "(w)", + 23 : "(x)", + 24 : "(y)", + 25 : "(z)", } diff --git a/UWLCM_plotters/include/PlotterMask.hpp b/UWLCM_plotters/include/PlotterMask.hpp index 029e705..4029c42 100644 --- a/UWLCM_plotters/include/PlotterMask.hpp +++ b/UWLCM_plotters/include/PlotterMask.hpp @@ -173,7 +173,7 @@ class PlotterMask : public PlotterMicro // mean and std_dev of concentration of activated/cloud/rain droplets in cloudy cells [1/cm^3] (characteristics of the spatial distribution at this timestep) std::pair cloud_actconc_stats_timestep(int at) { - return cloud_conc_stats_timestep_hlpr(at, "act_rw", "nc", "nr"); + return cloud_conc_stats_timestep_hlpr(at, "actrw_rw", "nc", "nr"); } std::pair cloud_cloudconc_stats_timestep(int at) @@ -206,7 +206,7 @@ class PlotterMask : public PlotterMicro // mean and std_dev of mean radius of activated/cloud/rain droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) std::pair cloud_actmeanr_stats_timestep(int at) { - return cloud_meanr_stats_timestep_hlpr(at, "act_rw"); + return cloud_meanr_stats_timestep_hlpr(at, "actrw_rw"); } std::pair cloud_cloudmeanr_stats_timestep(int at) { @@ -220,7 +220,7 @@ class PlotterMask : public PlotterMicro // mean and std_dev of std_dev of radius of activated/cloud/rain droplets in cloudy cells [um] (characteristics of the spatial distribution at this timestep) std::pair cloud_actstddevr_stats_timestep(int at) { - return cloud_stddevr_stats_timestep_hlpr(at, "act_rw"); + return cloud_stddevr_stats_timestep_hlpr(at, "actrw_rw"); } std::pair cloud_cloudstddevr_stats_timestep(int at) { diff --git a/cases/RICO11/Rico_series_comparison.py b/cases/RICO11/Rico_series_comparison.py index 54d257f..a604b01 100644 --- a/cases/RICO11/Rico_series_comparison.py +++ b/cases/RICO11/Rico_series_comparison.py @@ -18,7 +18,7 @@ # activate latex text rendering rc('text', usetex=True) -rico_vars = ["lwp", "rwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc", "cl_nr", "surf_precip", "acc_precip", "RH_max", "wvarmax", "sd_conc", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", "cl_avg_supersat", "cl_avg_th", "cl_avg_rv", "surf_flux_latent", "surf_flux_sensible"]#, "cl_acnv25", "cl_accr25"]# ] +rico_vars = ["lwp", "rwp", "cloud_cover", "min_cloud_base", "inversion_height_rico", "cl_nc", "cl_nr", "surf_precip", "acc_precip", "RH_max", "wvarmax", "sd_conc", "cl_avg_act_meanr", "cl_avg_act_stddevr", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", "cl_avg_supersat", "cl_avg_th", "cl_avg_rv", "surf_flux_latent", "surf_flux_sensible"]#, "cl_acnv25", "cl_accr25"]# ] #rico_vars = ["clb_bigrain_mean_rd","clb_bigrain_mean_kappa","clb_bigrain_mean_conc","clb_bigrain_mean_inclt", "cl_nr"] # variables that need rescaling of the yrange to the limited x range of 1-6h @@ -31,7 +31,7 @@ # init the plot -nplotx = 5 +nplotx = 6 nploty= 4 fig, axarr = plt.subplots(nplotx,nploty) x_arr = np.arange(nplotx) diff --git a/cases/RICO11/plot_ranges.py b/cases/RICO11/plot_ranges.py index 8115fb0..ae530e5 100644 --- a/cases/RICO11/plot_ranges.py +++ b/cases/RICO11/plot_ranges.py @@ -40,6 +40,8 @@ "cl_avg_rv" : "linear", "cl_avg_cloud_meanr" : "linear", "cl_avg_cloud_stddevr" : "linear", + "cl_avg_act_meanr" : "linear", + "cl_avg_act_stddevr" : "linear", "cl_meanr" : "linear", "sd_conc" : "linear", } @@ -86,6 +88,8 @@ "cl_avg_rv" : "linear", "cl_avg_cloud_meanr" : "linear", "cl_avg_cloud_stddevr" : "linear", + "cl_avg_act_meanr" : "linear", + "cl_avg_act_stddevr" : "linear", "cl_meanr" : "linear", "sd_conc" : "linear", } @@ -112,6 +116,8 @@ "cl_avg_rv" : None, "cl_avg_cloud_meanr" : None, "cl_avg_cloud_stddevr" : None, + "cl_avg_act_meanr" : None, + "cl_avg_act_stddevr" : None, "cl_meanr" : None, "sd_conc" : None, } @@ -138,6 +144,8 @@ "cl_avg_rv" : (0,3000), "cl_avg_cloud_meanr" : (0,3000), "cl_avg_cloud_stddevr" : (0,3000), + "cl_avg_act_meanr" : (0,3000), + "cl_avg_act_stddevr" : (0,3000), "cl_meanr" : (0,3000), "sd_conc" : (0,3000), } @@ -172,6 +180,8 @@ "cl_avg_rv" : (0,24), "cl_avg_cloud_meanr" : (0,24), "cl_avg_cloud_stddevr" : (0,24), + "cl_avg_act_meanr" : (0,24), + "cl_avg_act_stddevr" : (0,24), "cl_meanr" : (0,24), "sd_conc" : (0,24), } @@ -206,6 +216,8 @@ "cl_avg_rv" : (1.2e-2,1.6e-2), "cl_avg_cloud_meanr" : None, "cl_avg_cloud_stddevr" : None, + "cl_avg_act_meanr" : None, + "cl_avg_act_stddevr" : None, "cl_meanr" : None, "sd_conc" : None, } diff --git a/drawbicyc/include/cases/RICO11/plots.hpp b/drawbicyc/include/cases/RICO11/plots.hpp index 4e893a8..df2aba2 100644 --- a/drawbicyc/include/cases/RICO11/plots.hpp +++ b/drawbicyc/include/cases/RICO11/plots.hpp @@ -17,6 +17,8 @@ const std::vector series_rico({ "cl_avg_rv", "cl_avg_cloud_meanr", "cl_avg_cloud_stddevr", +"cl_avg_act_meanr", +"cl_avg_act_stddevr", "wvarmax", "surf_flux_latent", "surf_flux_sensible", diff --git a/drawbicyc/include/gnuplot_series_set_labels.hpp b/drawbicyc/include/gnuplot_series_set_labels.hpp index 20d5bfc..a97d79c 100644 --- a/drawbicyc/include/gnuplot_series_set_labels.hpp +++ b/drawbicyc/include/gnuplot_series_set_labels.hpp @@ -99,6 +99,18 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) gp << "set xlabel 'time [min]'\n"; gp << "set title 'average std dev of radius of activated droplets'\n"; } + else if (plt == "cl_avg_act_meanr") + { + gp << "set ylabel ' [um]'\n"; + gp << "set xlabel 'time [min]'\n"; + gp << "set title 'mean radius of activated droplets in cloud'\n"; + } + else if (plt == "cl_avg_act_stddevr") + { + gp << "set ylabel ' [um]'\n"; + gp << "set xlabel 'time [min]'\n"; + gp << "set title 'std. dev. of radius of activated droplets in cloud'\n"; + } else if (plt == "cl_avg_cloud_meanr") { gp << "set ylabel ' [um]'\n"; diff --git a/drawbicyc/include/plot_series.hpp b/drawbicyc/include/plot_series.hpp index d9474b3..f01e27c 100644 --- a/drawbicyc/include/plot_series.hpp +++ b/drawbicyc/include/plot_series.hpp @@ -627,6 +627,27 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) } catch(...) {if(at==first_timestep) data_found[plt]=0;} } + // spatial average of mean radius of activated droplets in cloudy cells + else if (plt == "cl_avg_act_meanr") + { + try + { + auto stats = plotter.cloud_actmeanr_stats_timestep(at * n["outfreq"]); + res_series[plt](at) = stats.first; + } + catch(...) {if(at==first_timestep) data_found[plt]=0;} + } + + // spatial average of standard deviation of activated droplet radius distribution in cloudy cells + else if (plt == "cl_avg_act_stddevr") + { + try + { + auto stats = plotter.cloud_actstddevr_stats_timestep(at * n["outfreq"]); + res_series[plt](at) = stats.first; + } + catch(...) {if(at==first_timestep) data_found[plt]=0;} + } // spatial average of mean radius of cloud droplets in cloudy cells else if (plt == "cl_avg_cloud_meanr") { @@ -1709,6 +1730,16 @@ void plot_series(Plotter_t plotter, Plots plots, std::string type) { res_pos *= 60.; } + else if (plt == "cl_avg_act_meanr") + { + plot_std_dev = true; + res_pos *= 60.; + } + else if (plt == "cl_avg_act_stddevr") + { + plot_std_dev = true; + res_pos *= 60.; + } else if (plt == "cl_avg_cloud_meanr") { plot_std_dev = true; From 0d1e40b483288d7d11a301ea912e936389885174 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 19 May 2023 15:29:14 +0200 Subject: [PATCH 45/51] sgs fixes --- UWLCM_plotters/include/Plotter2d.hpp | 3 ++- drawbicyc/drawbicyc.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/UWLCM_plotters/include/Plotter2d.hpp b/UWLCM_plotters/include/Plotter2d.hpp index 6b92228..f7ed60c 100644 --- a/UWLCM_plotters/include/Plotter2d.hpp +++ b/UWLCM_plotters/include/Plotter2d.hpp @@ -21,7 +21,7 @@ class Plotter_t<2> : public PlotterH5 using parent_t = PlotterH5; hsize_t n[2]; enum {x, z}; - arr_t tmp, tmp_srfc; + arr_t tmp, tmp_srfc, tmp_ref; public: @@ -202,6 +202,7 @@ class Plotter_t<2> : public PlotterH5 // other dataset are of the size x*z, resize tmp tmp.resize(n[0]-1, n[1]-1); tmp_srfc.resize(n[0]-1, 1); + tmp_ref.resize(tmp.shape()); } }; diff --git a/drawbicyc/drawbicyc.cpp b/drawbicyc/drawbicyc.cpp index 264bbb0..1e1b229 100644 --- a/drawbicyc/drawbicyc.cpp +++ b/drawbicyc/drawbicyc.cpp @@ -71,7 +71,9 @@ int main(int argc, char** argv) } // detecting if subgrid model was on - bool sgs = true; +// std::cerr << "checking of sgs model was used... "; + bool sgs = h5f.nameExists("sgs");// true; + /* try { auto h5g = h5f.openGroup("sgs"); @@ -80,14 +82,16 @@ int main(int argc, char** argv) { sgs = false; } + */ + // std::cerr << sgs << std::endl; Plots plots(type, sgs); if(NDims == 2) { -// if(flag_series) plot_series(PlotterMask<2>(h5, micro, mask_type_t::Rico11), plots, type); -// if(flag_profiles) plot_profiles(PlotterMask<2>(h5, micro, mask_type_t::Rico11), plots, type, normalize_prof); + if(flag_series) plot_series(PlotterMask<2>(h5, micro, mask_type_t::Rico11), plots, type); + if(flag_profiles) plot_profiles(PlotterMask<2>(h5, micro, mask_type_t::Rico11), plots, type, normalize_prof); // if(flag_fields) plot_fields(PlotterMask<2>(h5, micro), plots, type); // if(flag_qv_qc_2_6_10_min) plot_qv_qc_2_6_10_min(PlotterMask<2>(h5, micro)); } From 4055fdf69370e2ae0b3367816bba8e25ceae0393 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Tue, 13 Jun 2023 12:24:07 +0200 Subject: [PATCH 46/51] blk_1m precip rate fix --- UWLCM_plotters/include/PlotterMicro.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index acd7e36..0961ba0 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -122,11 +122,15 @@ class PlotterMicro : public PlotterCommon try { res = this->h5load_timestep("precip_rate", at); // precip_rate is the difference between influx and outflux + // uppermost cell + top = this->hrzntl_slice(this->map["z"] - 1); + res(top) *= rhod(top); + // cells below for(int z = this->map["z"] - 2; z>=0; --z) { - res(this->hrzntl_slice(z)) = res(this->hrzntl_slice(z+1)) - res(this->hrzntl_slice(z)); + res(this->hrzntl_slice(z)) = res(this->hrzntl_slice(z+1)) + res(this->hrzntl_slice(z)) * rhod(this->hrzntl_slice(z)); } - res *= rhod * this->map["dz"] * L_evap; + res *= -1 * this->map["dz"] * L_evap; } catch(...) { From dff37e3249b1731785b774c5859c55e162876468 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Tue, 26 Sep 2023 15:14:39 +0200 Subject: [PATCH 47/51] fix pm --- UWLCM_plotters/include/PlotterMicro.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/UWLCM_plotters/include/PlotterMicro.hpp b/UWLCM_plotters/include/PlotterMicro.hpp index 0961ba0..697ceb5 100644 --- a/UWLCM_plotters/include/PlotterMicro.hpp +++ b/UWLCM_plotters/include/PlotterMicro.hpp @@ -123,8 +123,7 @@ class PlotterMicro : public PlotterCommon { res = this->h5load_timestep("precip_rate", at); // precip_rate is the difference between influx and outflux // uppermost cell - top = this->hrzntl_slice(this->map["z"] - 1); - res(top) *= rhod(top); + res(this->hrzntl_slice(this->map["z"] - 1)) *= rhod(this->hrzntl_slice(this->map["z"] - 1)); // cells below for(int z = this->map["z"] - 2; z>=0; --z) { From 9bcfd9dad2ea8c43c196373880178ec64cfec48a Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Wed, 27 Sep 2023 12:41:23 +0200 Subject: [PATCH 48/51] labels + file name w/o micro --- drawbicyc/drawbicyc.cpp | 2 +- drawbicyc/include/cases/Dycoms_RF02/plots.hpp | 7 +++++-- drawbicyc/include/gnuplot_series_set_labels.hpp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drawbicyc/drawbicyc.cpp b/drawbicyc/drawbicyc.cpp index 1e1b229..a814446 100644 --- a/drawbicyc/drawbicyc.cpp +++ b/drawbicyc/drawbicyc.cpp @@ -42,7 +42,7 @@ int main(int argc, char** argv) // parse dir name std::string dir = vm["dir"].as(), - h5 = dir + "out_" + micro; + h5 = dir;// + "out_" + micro; // reading required plot types bool flag_series = vm["series"].as(), diff --git a/drawbicyc/include/cases/Dycoms_RF02/plots.hpp b/drawbicyc/include/cases/Dycoms_RF02/plots.hpp index fae9ce4..33f30bb 100644 --- a/drawbicyc/include/cases/Dycoms_RF02/plots.hpp +++ b/drawbicyc/include/cases/Dycoms_RF02/plots.hpp @@ -4,12 +4,15 @@ const std::vector series_dycoms({ // "cl_nr", //"cl_acnv25_dycoms", //"cl_accr25_dycoms", -//"wvarmax", "cloud_cover_dycoms", +"wvarmax", "cloud_cover_dycoms", "lwp", - "er", + "er_dycoms", "surf_precip", // "acc_precip", "cl_nc" + , "surf_flux_latent" + , "surf_flux_sensible" + , "RH" // "cloud_base_dycoms", // "cloud_base_precip_dycoms" diff --git a/drawbicyc/include/gnuplot_series_set_labels.hpp b/drawbicyc/include/gnuplot_series_set_labels.hpp index a97d79c..8184f25 100644 --- a/drawbicyc/include/gnuplot_series_set_labels.hpp +++ b/drawbicyc/include/gnuplot_series_set_labels.hpp @@ -363,7 +363,7 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) { gp << "set title 'latent surf flux [W/m^2]'\n"; } - else if (plt == "er") + else if (plt == "er dycoms") { gp << "set title 'entrainment rate [cm / s]'\n"; gp << "set xlabel ''\n"; From 3de46b66ddb9262aae015f570758913bc82e2279 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Wed, 27 Sep 2023 12:44:59 +0200 Subject: [PATCH 49/51] er label fix --- drawbicyc/include/gnuplot_series_set_labels.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drawbicyc/include/gnuplot_series_set_labels.hpp b/drawbicyc/include/gnuplot_series_set_labels.hpp index 8184f25..ace1ae0 100644 --- a/drawbicyc/include/gnuplot_series_set_labels.hpp +++ b/drawbicyc/include/gnuplot_series_set_labels.hpp @@ -363,7 +363,7 @@ void gnuplot_series_set_labels(Gnuplot &gp, std::string plt) { gp << "set title 'latent surf flux [W/m^2]'\n"; } - else if (plt == "er dycoms") + else if (plt == "er_dycoms") { gp << "set title 'entrainment rate [cm / s]'\n"; gp << "set xlabel ''\n"; From 535ececa951d831d0d1ce0674e7aa5543c12870a Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 29 Sep 2023 12:42:06 +0200 Subject: [PATCH 50/51] update README --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 5ac1cdd..c43cb26 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,28 @@ # UWLCM_plotting a set of scripts for plotting output of the UWLCM model + +CONTENTS + +plotting: + +- /drawbicyc - C++ program for processing UWLCM output; can calculate and plot series, profiles, variable snapshots and spectra; also has C++ programs for averaging and comparing series or profiles from multiple runs, although this is probably better done in Python + +- /cases - Python scripts for comparing series and profiles calculated using drawbicyc; specific to each LES case + +- /Energy_spectrum - Python scripts for plotting and comparing Fourier spectra of variables; works directly on UWLCM output + +- /histograms - Python scripts for plotting and comparing histograms with spatial and/or temporal distribution of variables; also capable of plotting scatter plots of correlation between two variables; works directly on UWLCM output + +- /NC_vs_AF - Python scripts for plotting scatter plots of number concentration of cloud droplets vs adiabatic fraction, or vs liquid water content; works directly on UWLCM output; NOTE: redundant to scatter plots in /histograms? + +- /papers - Python scripts for making figures used in our papers + +- /Size_spectra - Python scripts for comparing droplet size distributions; works directly on UWLCM output + + +helpers: + +- /Matplotlib_common - Python scripts for reading drawbicyc output; also plotting comparison of series and profiles from drawbicyc + +- /UWLCM_plotters - C++ classes for reading UWLCM output; used in drawbicyc + From 8ada388d01dce07295916e7ba487e1158ae50535 Mon Sep 17 00:00:00 2001 From: Piotr Dziekan Date: Fri, 29 Sep 2023 12:54:07 +0200 Subject: [PATCH 51/51] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c43cb26..2d34b4d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ CONTENTS plotting: -- /drawbicyc - C++ program for processing UWLCM output; can calculate and plot series, profiles, variable snapshots and spectra; also has C++ programs for averaging and comparing series or profiles from multiple runs, although this is probably better done in Python +- /drawbicyc - C++ program for processing UWLCM output; can calculate and plot series, profiles and snapshots for multiple parameters; also has C++ programs for averaging and comparing series or profiles from multiple runs, although this is probably better done in Python (e.g. /cases) - /cases - Python scripts for comparing series and profiles calculated using drawbicyc; specific to each LES case