Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def _build_single_animation(
elif animation_format.lower() == "mp4":
frames = _pad_frames_for_mp4([imageio.imread(p) for p in image_paths])
fps = 1000 / duration_ms if duration_ms > 0 else 2
imageio.mimsave(out_path, frames, fps=fps, ffmpeg_params=["-crf", "18"])
imageio.mimsave(out_path, frames, fps=fps, macro_block_size=8, ffmpeg_params=["-framerate", str(fps), "-loglevel", "error", "-crf", "18"])
else:
raise ValueError(f"Unsupported animation format: {animation_format}. Must be 'gif' or 'mp4'.")

Expand Down
30 changes: 15 additions & 15 deletions packages/evaluate/src/weathergen/evaluate/plotting/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,13 @@ def plot_histogram(
color_tar = "black"
color_pred = "#00897B" # teal / green-blue

# Create figure with two subplots: histogram + ratio
fig, (ax_hist, ax_ratio) = plt.subplots(
2,
1,
sharex=True,
figsize=self.fig_size or (8, 6),
gridspec_kw={"height_ratios": [3, 1], "hspace": 0.05},
)
# Create figure with three rows: histogram, ratio, and stats text
fig = plt.figure(figsize=self.fig_size or (8, 8), constrained_layout=True)
gs = fig.add_gridspec(3, 1, height_ratios=[3, 1, 0.5])
ax_hist = fig.add_subplot(gs[0])
ax_ratio = fig.add_subplot(gs[1], sharex=ax_hist)
ax_text = fig.add_subplot(gs[2])
ax_text.set_axis_off()

# Upper panel: histogram curves
ax_hist.plot(
Expand Down Expand Up @@ -434,14 +433,15 @@ def plot_histogram(
f"Wasserstein distance: {w_dist:.4g}\n{t_s.summary('Target:')}\n{p_s.summary('Pred:')}"
)

fig.text(
ax_text.text(
0.5,
0.5,
-0.02,
stat_text,
ha="center",
va="top",
va="center",
fontsize=7,
family="monospace",
transform=ax_text.transAxes,
bbox=dict(boxstyle="round,pad=0.3", facecolor="wheat", alpha=0.5),
)

Expand Down Expand Up @@ -473,7 +473,7 @@ def plot_histogram(

fname = hist_output_dir / f"{name}.{self.image_format}"
_logger.debug(f"Saving histogram to {fname}")
fig.savefig(fname, bbox_inches="tight")
fig.savefig(fname)
plt.close(fig)

return name
Expand Down Expand Up @@ -994,7 +994,7 @@ def scatter_plot(
# canvas so fine structure is visible; sparse grids use the default.
figsize = self.fig_size
if figsize is None and data.size >= 200_000:
figsize = (15, 7)
figsize = (16,8)

proj = ccrs.PlateCarree()
if regionname:
Expand All @@ -1006,7 +1006,7 @@ def scatter_plot(
# If regionname isn't in the library, fall back to PlateCarree
_logger.warning(f"Region '{regionname}' not found in library, using PlateCarree.")
proj = ccrs.PlateCarree()
fig = plt.figure(figsize=figsize, dpi=self.dpi_val)
fig = plt.figure(figsize=figsize, dpi=self.dpi_val, constrained_layout=True)
ax = fig.add_subplot(1, 1, 1, projection=proj)
try:
ax.coastlines(linewidth=0.3)
Expand Down Expand Up @@ -1096,7 +1096,7 @@ def scatter_plot(
name = self._build_map_filename(varname, regionname, tag, data)
fname = f"{map_output_dir.joinpath(name)}.{self.image_format}"
_logger.debug(f"Saving map to {fname}")
plt.savefig(fname, bbox_inches="tight")
plt.savefig(fname, pad_inches=0)
plt.close()

return name
Expand Down
Loading