From a7220a7dcd0051f1c7f92be318f91d56c9c8cbd0 Mon Sep 17 00:00:00 2001 From: Evan Anders Date: Fri, 23 Aug 2024 12:23:46 -0700 Subject: [PATCH] Debugs 2D RBC plotting scripts --- .../d3/ivp_box_2d_rayleigh_benard/README.md | 71 +++++++++++++++++++ .../plot_all_slices.py | 6 +- .../ivp_box_2d_rayleigh_benard/plot_b_pdf.py | 6 +- .../plot_instantaneous_profiles.py | 6 +- .../plot_rolled_profiles.py | 6 +- .../plot_scalar_traces.py | 10 +-- plotpal/profiles.py | 2 +- plotpal/scalars.py | 2 +- 8 files changed, 90 insertions(+), 19 deletions(-) create mode 100644 examples/d3/ivp_box_2d_rayleigh_benard/README.md diff --git a/examples/d3/ivp_box_2d_rayleigh_benard/README.md b/examples/d3/ivp_box_2d_rayleigh_benard/README.md new file mode 100644 index 0000000..69c11e1 --- /dev/null +++ b/examples/d3/ivp_box_2d_rayleigh_benard/README.md @@ -0,0 +1,71 @@ +# 2D Rayleigh Benard Convection + +This example problem is lifted directly from the dedalus repository. The types of plots you can make with plotpal are shown below: + +# 2D slices + +Plotpal can plot movies of 2D slices including multiple frames, using e.g., + +```sh +python3 plot_all_slices.py +``` + +Producing images like this one: + +![Lots of slices](./example_figs/frames_000190.png) + +Plotpal can also just do a movie of a single field if you want something less cluttered: + +```sh +python3 plot_b_slices.py +``` + +Producing images like this one: + +![A buoyancy slice](./example_figs/b_frames_000190.png) + +# 1D Profiles + +Plotpal can plot instantaneous 1D profiles from dedalus simulations: + +```sh +python3 plot_instantaneous_profiles.py +``` + +Producing images like this one: + +![A profile from a single Dedalus output](./example_figs/instantaneous_profiles_000190.png) + +Plotpal can also plot a rolling average of profiles: + +```sh +python3 plot_rolled_profiles.py +``` + +Producing less jittery images like this one: + +![A profile averaged over multiple outputs](./example_figs/rolled_profiles_000190.png) + +# PDFs + +Plotpal can plot the PDFs of 2D flow fields: + +```sh +python3 plot_b_pdf.py +``` + +Producing an image like this one: + +![a PDF of the buoyancy field](./example_figs/b_pdf.png) + +# Scalar Traces + +Plotpal can plot the evolution over time of scalar outputs: + +```sh +python3 plot_scalar_traces.py +``` + +Producing images like the one below: + +![A trace of Nu and Re](./plot_scalar_traces.py) \ No newline at end of file diff --git a/examples/d3/ivp_box_2d_rayleigh_benard/plot_all_slices.py b/examples/d3/ivp_box_2d_rayleigh_benard/plot_all_slices.py index 5245ebe..46a6ac3 100644 --- a/examples/d3/ivp_box_2d_rayleigh_benard/plot_all_slices.py +++ b/examples/d3/ivp_box_2d_rayleigh_benard/plot_all_slices.py @@ -36,11 +36,11 @@ # Create Plotter object, tell it which fields to plot plotter = SlicePlotter( - root_dir, - file_dir=data_dir, + run_dir=root_dir, + sub_dir=data_dir, out_name=out_name, start_file=start_file, - n_files=n_files, + num_files=n_files, ) plotter_kwargs = { "col_inch": float(args["--col_inch"]), diff --git a/examples/d3/ivp_box_2d_rayleigh_benard/plot_b_pdf.py b/examples/d3/ivp_box_2d_rayleigh_benard/plot_b_pdf.py index fa9a35e..a3b1b83 100644 --- a/examples/d3/ivp_box_2d_rayleigh_benard/plot_b_pdf.py +++ b/examples/d3/ivp_box_2d_rayleigh_benard/plot_b_pdf.py @@ -47,11 +47,11 @@ "b", ] plotter = PdfPlotter( - root_dir, - file_dir=data_dir, + run_dir=root_dir, + sub_dir=data_dir, out_name=out_name, start_file=start_file, - n_files=n_files, + num_files=n_files, ) plotter.calculate_pdfs( pdfs_to_plot, bins=bins, threeD=threeD, bases=bases, uneven_basis="z" diff --git a/examples/d3/ivp_box_2d_rayleigh_benard/plot_instantaneous_profiles.py b/examples/d3/ivp_box_2d_rayleigh_benard/plot_instantaneous_profiles.py index 1c5d362..db3a8cb 100644 --- a/examples/d3/ivp_box_2d_rayleigh_benard/plot_instantaneous_profiles.py +++ b/examples/d3/ivp_box_2d_rayleigh_benard/plot_instantaneous_profiles.py @@ -33,11 +33,11 @@ # Create Plotter object, tell it which fields to plot plotter = RolledProfilePlotter( - root_dir, - file_dir=data_dir, + run_dir=root_dir, + sub_dir=data_dir, out_name=subdir_name, start_file=start_file, - n_files=n_files, + num_files=n_files, ) plotter.setup_grid( num_rows=2, diff --git a/examples/d3/ivp_box_2d_rayleigh_benard/plot_rolled_profiles.py b/examples/d3/ivp_box_2d_rayleigh_benard/plot_rolled_profiles.py index f4864ac..03b292f 100644 --- a/examples/d3/ivp_box_2d_rayleigh_benard/plot_rolled_profiles.py +++ b/examples/d3/ivp_box_2d_rayleigh_benard/plot_rolled_profiles.py @@ -37,12 +37,12 @@ # Create Plotter object, tell it which fields to plot plotter = RolledProfilePlotter( - root_dir, - file_dir=data_dir, + run_dir=root_dir, + sub_dir=data_dir, out_name=subdir_name, roll_writes=roll_writes, start_file=start_file, - n_files=n_files, + num_files=n_files, ) plotter.setup_grid( num_rows=2, diff --git a/examples/d3/ivp_box_2d_rayleigh_benard/plot_scalar_traces.py b/examples/d3/ivp_box_2d_rayleigh_benard/plot_scalar_traces.py index ac318f1..3bcdc50 100644 --- a/examples/d3/ivp_box_2d_rayleigh_benard/plot_scalar_traces.py +++ b/examples/d3/ivp_box_2d_rayleigh_benard/plot_scalar_traces.py @@ -36,17 +36,17 @@ # Nu vs time fig1 = ScalarFigure(num_rows=2, num_cols=1, col_inch=6, fig_name="fundamentals") -fig1.add_field(0, "Re", color="orange") -fig1.add_field(1, "Nu", color="indigo") +fig1.add_field(0, "Re", extra_kwargs={"color": "orange"}) +fig1.add_field(1, "Nu", extra_kwargs={"color": "indigo"}) figs.append(fig1) # Load in figures and make plots plotter = ScalarPlotter( - root_dir, - file_dir=data_dir, + run_dir=root_dir, + sub_dir=data_dir, out_name=out_name, start_file=start_file, - n_files=n_files, + num_files=n_files, roll_writes=roll_writes, ) plotter.load_figures(figs) diff --git a/plotpal/profiles.py b/plotpal/profiles.py index c7215d3..7a98556 100644 --- a/plotpal/profiles.py +++ b/plotpal/profiles.py @@ -23,7 +23,7 @@ def save_dim_scale( - dim: h5py._hl.dims.DimensionProxy, + dim: h5py.AttributeManager, scale_group: h5py.Group, task_name: str, scale_name: str, diff --git a/plotpal/scalars.py b/plotpal/scalars.py index 5e96518..9e8583c 100644 --- a/plotpal/scalars.py +++ b/plotpal/scalars.py @@ -214,7 +214,7 @@ def plot_figures(self, dpi: int = 200, fig_name: str = "output") -> None: fig_name : default name of the output figure (if not specified in the ScalarFigure object) """ with self.my_sync: - if self.trace_data is None: + if len(self.trace_data.keys()) == 0: self._read_fields() self._clear_figures() if self.idle: